1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00

more tweaks

This commit is contained in:
Gerkiz 2020-07-08 22:57:43 +02:00
parent 6f368def27
commit df097d7520
15 changed files with 356 additions and 165 deletions

View File

@ -158,14 +158,13 @@ commands.add_command(
local function process_bot_answers(event)
local player = game.players[event.player_index]
-- if player.admin == true then
-- return
-- end
if player.admin == true then
return
end
local message = event.message
message = string.lower(message)
for word in string.gmatch(message, '%g+') do
if links[word] then
local player = game.players[event.player_index]
for _, bot_answer in pairs(links[word]) do
player.print('[font=' .. font .. ']' .. bot_answer .. '[/font]', font_color)
end

View File

@ -279,10 +279,19 @@ local function get_rank(player)
'item/beacon',
'item/steam-turbine',
'item/centrifuge',
'item/nuclear-reactor'
'item/nuclear-reactor',
'item/cannon-shell',
'item/rocket',
'item/explosive-cannon-shell',
'item/explosive-rocket',
'item/uranium-cannon-shell',
'item/explosive-uranium-cannon-shell',
'item/atomic-bomb',
'achievement/so-long-and-thanks-for-all-the-fish',
'achievement/golem'
}
--52 ranks
--60? ranks
local time_needed = 240 -- in minutes between rank upgrades
m = m / time_needed
@ -363,7 +372,7 @@ local function player_list_show(player, frame, sort_by)
-- Header management
local t = frame.add {type = 'table', name = 'player_list_panel_header_table', column_count = 5}
local column_widths = {tonumber(40), tonumber(250), tonumber(250), tonumber(150), tonumber(100)}
local column_widths = {tonumber(40), tonumber(240), tonumber(240), tonumber(150), tonumber(100)}
for _, w in ipairs(column_widths) do
local label = t.add {type = 'label', caption = ''}
label.style.minimal_width = w
@ -456,8 +465,9 @@ local function player_list_show(player, frame, sort_by)
name = 'player_rank_sprite_' .. i,
sprite = player_list[i].rank
}
sprite.style.minimal_width = column_widths[1]
sprite.style.maximal_width = column_widths[1]
sprite.style.height = 32
sprite.style.width = 32
sprite.style.stretch_image_to_widget_size = true
-- Name
local label =

View File

@ -19,19 +19,20 @@ commands.add_command(
end
end
local this = FDT.get()
local reset_map = require 'maps.fish_defender.main'.on_init
local param = cmd.parameter
if param == 'reset' or param == 'restartnow' then
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
goto continue
else
p('[ERROR] Arguments are:\nreset\nrestartnow')
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
return
end
::continue::
local this = FDT.get()
local reset_map = require 'maps.fish_defender.main'.on_init
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
p(
@ -40,11 +41,45 @@ commands.add_command(
return
end
if param == 'restartnow' then
if param == 'restart' then
if this.restart then
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
end
p('[WARNING] Soft-reset is disabled! Server will restart from scenario.')
return
end
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
p(player.name .. ' has restarted the game.')
Server.start_scenario('Fish_defense')
Server.start_scenario('Fish_Defender')
return
elseif param == 'shutdown' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.shutdown = true
this.soft_reset = false
if this.restart then
this.restart = false
end
p('[WARNING] Soft-reset is disabled! Server will shutdown.')
return
end
elseif param == 'reset' then
this.reset_are_you_sure = nil
if player and player.valid then

View File

@ -32,35 +32,15 @@ local sub = string.sub
local Public = {}
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['raw-fish'] = 3, ['iron-plate'] = 32}
local starting_items = {
['pistol'] = 1,
['firearm-magazine'] = 16,
['raw-fish'] = 3,
['iron-plate'] = 32,
['stone'] = 12
}
local biter_count_limit = 1024 --maximum biters on the east side of the map, next wave will be delayed if the maximum has been reached
local boss_waves = {
[50] = {{name = 'big-biter', count = 3}},
[100] = {{name = 'behemoth-biter', count = 1}},
[150] = {{name = 'behemoth-spitter', count = 4}, {name = 'big-spitter', count = 16}},
[200] = {
{name = 'behemoth-biter', count = 4},
{name = 'behemoth-spitter', count = 2},
{name = 'big-biter', count = 32}
},
[250] = {
{name = 'behemoth-biter', count = 8},
{name = 'behemoth-spitter', count = 4},
{name = 'big-spitter', count = 32}
},
[300] = {{name = 'behemoth-biter', count = 16}, {name = 'behemoth-spitter', count = 8}}
}
local difficulties_votes = {
[1] = {wave_interval = 4500, amount_modifier = 0.52, strength_modifier = 0.40, boss_modifier = 3.0},
[2] = {wave_interval = 4100, amount_modifier = 0.76, strength_modifier = 0.65, boss_modifier = 4.0},
[3] = {wave_interval = 3800, amount_modifier = 0.92, strength_modifier = 0.85, boss_modifier = 5.0},
[4] = {wave_interval = 3600, amount_modifier = 1.00, strength_modifier = 1.00, boss_modifier = 6.0},
[5] = {wave_interval = 3400, amount_modifier = 1.08, strength_modifier = 1.25, boss_modifier = 7.0},
[6] = {wave_interval = 3100, amount_modifier = 1.24, strength_modifier = 1.75, boss_modifier = 8.0},
[7] = {wave_interval = 2700, amount_modifier = 1.48, strength_modifier = 2.50, boss_modifier = 9.0}
}
local function shuffle(tbl)
local size = #tbl
@ -152,10 +132,10 @@ local function show_fd_stats(player)
local placed = v.placed
local limit = v.limit
local entry = {name, placed .. '/' .. limit}
for k, v in pairs(entry) do
for _, value_entry in pairs(entry) do
table.add {
type = 'label',
caption = v
caption = value_entry
}
end
end
@ -174,8 +154,8 @@ local function add_fd_stats_button(player)
if player.gui.top[button_id] then
player.gui.top[button_id].destroy()
end
local button =
player.gui.top.add {
player.gui.top.add {
type = 'sprite-button',
name = button_id,
sprite = 'item/submachine-gun'
@ -350,7 +330,7 @@ local function get_biter_pool()
local biter_pool = get_biter_initial_pool()
local biter_raffle = {}
for _, biter_type in pairs(biter_pool) do
for x = 1, biter_type.weight, 1 do
for _ = 1, biter_type.weight, 1 do
insert(biter_raffle, {name = biter_type.name, threat = biter_type.threat})
end
end
@ -472,26 +452,26 @@ local function spawn_boss_units(surface)
game.print({'fish_defender.boss_message', this.wave_count}, {r = 0.8, g = 0.1, b = 0.1})
end
if not boss_waves[this.wave_count] then
if not this.boss_waves[this.wave_count] then
local amount = this.wave_count
if amount > 1000 then
amount = 1000
end
boss_waves[this.wave_count] = {
this.boss_waves[this.wave_count] = {
{name = 'behemoth-biter', count = math.floor(amount / 20)},
{name = 'behemoth-spitter', count = math.floor(amount / 40)}
}
end
local health_factor = difficulties_votes[Diff.difficulty_vote_index].boss_modifier
local health_factor = this.difficulties_votes[Diff.difficulty_vote_index].boss_modifier
if this.wave_count == 100 then
health_factor = health_factor * 2
end
local position = {x = 216, y = 0}
local biter_group = surface.create_unit_group({position = position})
for _, entry in pairs(boss_waves[this.wave_count]) do
for x = 1, entry.count, 1 do
for _, entry in pairs(this.boss_waves[this.wave_count]) do
for _ = 1, entry.count, 1 do
local pos = surface.find_non_colliding_position(entry.name, position, 64, 3)
if pos then
local biter = surface.create_entity({name = entry.name, position = pos})
@ -617,15 +597,15 @@ local function biter_attack_wave()
local m = 0.0015
if Diff.difficulty_vote_index then
m = m * difficulties_votes[Diff.difficulty_vote_index].strength_modifier
m = m * this.difficulties_votes[Diff.difficulty_vote_index].strength_modifier
end
game.forces.enemy.set_ammo_damage_modifier('melee', this.wave_count * m)
game.forces.enemy.set_ammo_damage_modifier('biological', this.wave_count * m)
this.biter_health_boost = 1 + (this.wave_count * (m * 2))
local m = 4
m = 4
if Diff.difficulty_vote_index then
m = m * difficulties_votes[Diff.difficulty_vote_index].amount_modifier
m = m * this.difficulties_votes[Diff.difficulty_vote_index].amount_modifier
end
if this.wave_count % 50 == 0 then
@ -701,7 +681,7 @@ local function biter_attack_wave()
end
local function get_sorted_list(column_name, score_list)
for x = 1, #score_list, 1 do
for _ = 1, #score_list, 1 do
for y = 1, #score_list, 1 do
if not score_list[y + 1] then
break
@ -768,6 +748,7 @@ local function is_game_lost()
end
local this = FDT.get()
local l
for _, player in pairs(game.connected_players) do
if player.gui.left['fish_defense_game_lost'] then
@ -785,12 +766,12 @@ local function is_game_lost()
f.style.font_color = {r = 0.65, g = 0.1, b = 0.99}
local t = f.add({type = 'table', column_count = 2})
local l = t.add({type = 'label', caption = 'Survival Time >> '})
l = t.add({type = 'label', caption = 'Survival Time >> '})
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
if this.market_age >= 216000 then
local l =
l =
t.add(
{
type = 'label',
@ -801,25 +782,24 @@ local function is_game_lost()
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
else
local l = t.add({type = 'label', caption = math.ceil((this.market_age % 216000 / 60) / 60) .. ' minutes'})
l = t.add({type = 'label', caption = math.ceil((this.market_age % 216000 / 60) / 60) .. ' minutes'})
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
end
local mvp = get_mvps()
if mvp then
local l = t.add({type = 'label', caption = 'MVP Defender >> '})
l = t.add({type = 'label', caption = 'MVP Defender >> '})
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local l =
t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
l = t.add({type = 'label', caption = mvp.killscore.name .. ' with a score of ' .. mvp.killscore.score})
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local l = t.add({type = 'label', caption = 'MVP Builder >> '})
l = t.add({type = 'label', caption = 'MVP Builder >> '})
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local l =
l =
t.add(
{
type = 'label',
@ -829,10 +809,10 @@ local function is_game_lost()
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local l = t.add({type = 'label', caption = 'MVP Deaths >> '})
l = t.add({type = 'label', caption = 'MVP Deaths >> '})
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local l = t.add({type = 'label', caption = mvp.deaths.name .. ' died ' .. mvp.deaths.score .. ' times'})
l = t.add({type = 'label', caption = mvp.deaths.name .. ' died ' .. mvp.deaths.score .. ' times'})
l.style.font = 'default-bold'
l.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
@ -852,9 +832,7 @@ local function is_game_lost()
end
end
for _, player in pairs(game.connected_players) do
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.75}
end
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.75}
end
game.map_settings.enemy_expansion.enabled = true
@ -1043,18 +1021,22 @@ local function on_player_joined_game(event)
end
if player.online_time == 0 then
player.insert({name = 'pistol', count = 1})
player.insert({name = 'raw-fish', count = 4})
player.insert({name = 'firearm-magazine', count = 16})
player.insert({name = 'iron-plate', count = 32})
player.insert({name = 'stone', count = 16})
for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount})
end
if global.show_floating_killscore then
global.show_floating_killscore[player.name] = false
end
end
if player.online_time < 2 or player.surface.index ~= active_surface_index then
player.teleport(game.forces['player'].get_spawn_position(surface), surface.name)
local spawn = player.force.get_spawn_position(surface)
local pos = surface.find_non_colliding_position('character', spawn, 3, 0.5)
if not pos and player.online_time < 2 then
player.teleport(game.forces['player'].get_spawn_position(surface), surface)
elseif player.online_time < 2 or player.surface.index ~= active_surface_index then
player.teleport(pos, surface)
end
create_wave_gui(player)
@ -1301,6 +1283,80 @@ local function on_player_repaired_entity(event)
end
end
local function set_market_health()
local this = FDT.get()
if not this.market then
return
end
if not this.market.valid then
return
end
local market_health = FDT.get('market_health')
local market_max_health = FDT.get('market_max_health')
local m = market_health / market_max_health
this.market.health = 150 * m
rendering.set_text(this.health_text, 'HP: ' .. market_health .. ' / ' .. market_max_health)
end
local function has_the_game_ended()
local this = FDT.get()
if this.market_age then
if not this.game_restart_timer then
this.game_restart_timer = 5400
else
if this.game_restart_timer < 0 then
return
end
this.game_restart_timer = this.game_restart_timer - 30
end
local cause_msg
if this.restart then
cause_msg = 'restart'
elseif this.shutdown then
cause_msg = 'shutdown'
elseif this.soft_reset then
cause_msg = 'soft-reset'
end
if this.game_restart_timer % 1800 == 0 then
if this.game_restart_timer > 0 then
this.game_reset = true
this.game_has_ended = true
game.print(
'Game will ' .. cause_msg .. ' in ' .. this.game_restart_timer / 60 .. ' seconds!',
{r = 0.22, g = 0.88, b = 0.22}
)
end
if this.soft_reset and this.game_restart_timer == 0 then
this.game_reset_tick = nil
Public.on_init()
return
end
if this.restart and this.game_restart_timer == 0 then
if not this.announced_message then
game.print('Soft-reset is disabled. Server will restart!', {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled. Server will restart!'
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})
Server.start_scenario('Fish_Defender')
this.announced_message = true
return
end
end
if this.shutdown and this.game_restart_timer == 0 then
if not this.announced_message then
game.print('Soft-reset is disabled. Server is shutting down!', {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled. Server is shutting down!'
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})
Server.stop_scenario()
this.announced_message = true
return
end
end
end
end
end
function Public.on_init()
FDT.reset_table()
Poll.reset()
@ -1342,6 +1398,8 @@ function Public.on_init()
surface.peaceful_mode = false
global.chunk_queue = {}
game.map_settings.enemy_expansion.enabled = false
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
@ -1370,8 +1428,8 @@ function Public.on_init()
game.reset_time_played()
end
this.market_health = 1000
this.market_max_health = 1000
this.market_health = 500
this.market_max_health = 500
local T = Map.Pop_info()
T.localised_category = 'fish_defender'
@ -1397,7 +1455,9 @@ local function on_tick()
local surface = game.surfaces[active_surface_index]
local this = FDT.get()
if game.tick % 30 == 0 then
has_the_game_ended()
if this.market then
set_market_health()
for _, player in pairs(game.connected_players) do
if surface.peaceful_mode == false then
create_wave_gui(player)
@ -1408,31 +1468,7 @@ local function on_tick()
if surface then
game.forces.player.chart(surface, {{-160, -128}, {192, 128}})
if Diff.difficulty_vote_index then
this.wave_interval = difficulties_votes[Diff.difficulty_vote_index].wave_interval
end
end
end
if this.market_age then
if not this.game_restart_timer then
this.game_restart_timer = 5400
else
if this.game_restart_timer < 0 then
return
end
this.game_restart_timer = this.game_restart_timer - 30
end
if this.game_restart_timer % 1800 == 0 then
if this.game_restart_timer > 0 then
this.game_reset = true
this.game_has_ended = true
game.print(
'Game will soft-reset in ' .. this.game_restart_timer / 60 .. ' seconds!',
{r = 0.22, g = 0.88, b = 0.22}
)
end
if this.game_restart_timer == 0 then
Public.on_init()()
this.wave_interval = this.difficulties_votes[Diff.difficulty_vote_index].wave_interval
end
end
end

View File

@ -13,7 +13,13 @@ Global.register(
)
function Public.reset_table()
this.chunk_queue = {}
-- @start
-- these 3 are in case of stop/start/reloading the instance.
this.soft_reset = true
this.restart = false
this.shutdown = false
this.announced_message = false
-- @end
this.game_has_ended = false
this.game_reset = false
this.spawn_area_generated = false
@ -40,7 +46,32 @@ function Public.reset_table()
['laser-turret'] = {placed = 0, limit = 1, str = 'laser turret', slot_price = 300},
['artillery-turret'] = {placed = 0, limit = 1, str = 'artillery turret', slot_price = 500},
['flamethrower-turret'] = {placed = 0, limit = 0, str = 'flamethrower turret', slot_price = 50000},
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 1}
['land-mine'] = {placed = 0, limit = 1, str = 'mine', slot_price = 6}
}
this.difficulties_votes = {
[1] = {wave_interval = 4500, amount_modifier = 0.52, strength_modifier = 0.40, boss_modifier = 3.0},
[2] = {wave_interval = 4100, amount_modifier = 0.76, strength_modifier = 0.65, boss_modifier = 4.0},
[3] = {wave_interval = 3800, amount_modifier = 0.92, strength_modifier = 0.85, boss_modifier = 5.0},
[4] = {wave_interval = 3600, amount_modifier = 1.00, strength_modifier = 1.00, boss_modifier = 6.0},
[5] = {wave_interval = 3400, amount_modifier = 1.08, strength_modifier = 1.25, boss_modifier = 7.0},
[6] = {wave_interval = 3100, amount_modifier = 1.24, strength_modifier = 1.75, boss_modifier = 8.0},
[7] = {wave_interval = 2700, amount_modifier = 1.48, strength_modifier = 2.50, boss_modifier = 9.0}
}
this.boss_waves = {
[50] = {{name = 'big-biter', count = 3}},
[100] = {{name = 'behemoth-biter', count = 1}},
[150] = {{name = 'behemoth-spitter', count = 4}, {name = 'big-spitter', count = 16}},
[200] = {
{name = 'behemoth-biter', count = 4},
{name = 'behemoth-spitter', count = 2},
{name = 'big-biter', count = 32}
},
[250] = {
{name = 'behemoth-biter', count = 8},
{name = 'behemoth-spitter', count = 4},
{name = 'big-spitter', count = 32}
},
[300] = {{name = 'behemoth-biter', count = 16}, {name = 'behemoth-spitter', count = 8}}
}
this.comfylatron_habitat = {
left_top = {x = -1500, y = -1500},

View File

@ -334,10 +334,9 @@ local function process_chunk(left_top)
end
local function process_chunk_queue()
local chunk_queue = FDT.get('chunk_queue')
for k, left_top in pairs(chunk_queue) do
for k, left_top in pairs(global.chunk_queue) do
process_chunk(left_top)
FDT.get().chunk_queue[k] = nil
global.chunk_queue[k] = nil
return
end
end
@ -351,7 +350,6 @@ local function on_chunk_generated(event)
local left_top = event.area.left_top
local game_reset = FDT.get('game_reset')
local game_has_ended = FDT.get('game_has_ended')
local this = FDT.get()
if game.tick == 0 or game_reset then
process_chunk(left_top)
@ -359,7 +357,7 @@ local function on_chunk_generated(event)
if game_has_ended then
return
end
this.chunk_queue[#this.chunk_queue + 1] = {x = left_top.x, y = left_top.y}
global.chunk_queue[#global.chunk_queue + 1] = {x = left_top.x, y = left_top.y}
end
end

View File

@ -725,7 +725,7 @@ function Public.loco_died()
)
surface.spill_item_stack(this.locomotive.position, {name = 'coin', count = 512}, false)
this.game_reset_tick = game.tick + 1000
this.game_reset_tick = 5400
for _, player in pairs(game.connected_players) do
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.75}
end

View File

@ -1,17 +0,0 @@
local Public = {}
Public.wagon_types = {
["cargo-wagon"] = true,
["artillery-wagon"] = true,
["fluid-wagon"] = true,
["locomotive"] = true,
}
Public.wagon_areas = {
["cargo-wagon"] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
["artillery-wagon"] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
["fluid-wagon"] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
["locomotive"] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
}
return Public

View File

@ -1,6 +1,5 @@
local Public = {}
local Constants = require 'maps.mountain_fortress_v3.icw.constants'
local ICW = require 'maps.mountain_fortress_v3.icw.table'
function Public.request_reconstruction(icw)
@ -293,7 +292,9 @@ function Public.kill_wagon(icw, entity)
return
end
if not Constants.wagon_types[entity.type] then
local wagon_types = ICW.get('wagon_types')
if not wagon_types[entity.type] then
return
end
local wagon = icw.wagons[entity.unit_number]
@ -422,12 +423,21 @@ function Public.create_wagon_room(icw, wagon)
return
end
-- this.wagon_areas = {
-- ['cargo-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
-- ['artillery-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
-- ['fluid-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
-- ['locomotive'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}}
-- }
if wagon.entity.type == 'cargo-wagon' then
local multiple_chests = ICW.get('multiple_chests')
local position1 = {-12, 1}
local position2 = {12, 1}
local position3 = {-12, 58}
local position4 = {12, 58}
local wagon_areas = ICW.get('wagon_areas')
local cargo_wagon = wagon_areas['cargo-wagon']
local position1 = {cargo_wagon.left_top.x + 7, cargo_wagon.left_top.y + 1}
local position2 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.left_top.y + 1}
local position3 = {cargo_wagon.left_top.x + 7, cargo_wagon.right_bottom.y - 2}
local position4 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.right_bottom.y - 2}
if multiple_chests then
local e1 =
@ -565,16 +575,19 @@ function Public.create_wagon(icw, created_entity, delay_surface)
return
end
local wagon_types = ICW.get('wagon_types')
local wagon_areas = ICW.get('wagon_areas')
if not created_entity.unit_number then
return
end
if icw.trains[tonumber(created_entity.surface.name)] or icw.wagons[tonumber(created_entity.surface.name)] then
return
end
if not Constants.wagon_types[created_entity.type] then
if not wagon_types[created_entity.type] then
return
end
local wagon_area = Constants.wagon_areas[created_entity.type]
local wagon_area = wagon_areas[created_entity.type]
icw.wagons[created_entity.unit_number] = {
entity = created_entity,

View File

@ -1,6 +1,5 @@
local Event = require 'utils.event'
local Functions = require 'maps.mountain_fortress_v3.icw.functions'
local Constants = require 'maps.mountain_fortress_v3.icw.constants'
local ICW = require 'maps.mountain_fortress_v3.icw.table'
local Public = {}
@ -12,7 +11,9 @@ local function on_entity_died(event)
if not entity and not entity.valid then
return
end
if not Constants.wagon_types[entity.type] then
local wagon_types = ICW.get('wagon_types')
if not wagon_types[entity.type] then
return
end
local icw = ICW.get()

View File

@ -1,40 +1,62 @@
local Global = require 'utils.global'
local icw = {}
local this = {}
Global.register(
icw,
this,
function(tbl)
icw = tbl
this = tbl
end
)
local Public = {}
function Public.reset()
if icw.surfaces then
for k, surface in pairs(icw.surfaces) do
if this.surfaces then
for k, surface in pairs(this.surfaces) do
if surface and surface.valid then
game.delete_surface(surface)
end
end
end
for k, _ in pairs(icw) do
icw[k] = nil
for k, _ in pairs(this) do
this[k] = nil
end
icw.doors = {}
icw.wagons = {}
icw.trains = {}
icw.players = {}
icw.surfaces = {}
icw.multiple_chests = true
this.doors = {}
this.wagons = {}
this.trains = {}
this.players = {}
this.surfaces = {}
this.multiple_chests = true
this.wagon_types = {
['cargo-wagon'] = true,
['artillery-wagon'] = true,
['fluid-wagon'] = true,
['locomotive'] = true
}
this.wagon_areas = {
['cargo-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
['artillery-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
['fluid-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
['locomotive'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}}
}
end
function Public.get(key)
if key then
return icw[key]
return this[key]
else
return icw
return this
end
end
function Public.set_wagon_area(tbl)
local arg = tbl
if not arg then
return
end
this.wagon_areas = arg
end
return Public

View File

@ -21,6 +21,7 @@ local Entities = require 'maps.mountain_fortress_v3.entities'
local Gui_mf = require 'maps.mountain_fortress_v3.gui'
local ICW = require 'maps.mountain_fortress_v3.icw.main'
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
local ICT = require 'maps.mountain_fortress_v3.icw.table'
local WD = require 'modules.wave_defense.table'
local Map = require 'modules.map_info'
local RPG = require 'maps.mountain_fortress_v3.rpg'
@ -38,6 +39,7 @@ local AntiGrief = require 'antigrief'
--local HD = require 'modules.hidden_dimension.main'
local Public = {}
local rng = math.random
-- local raise_event = script.raise_event
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
@ -83,18 +85,26 @@ local set_difficulty = function()
Diff.difficulty_vote_value = 0.1
end
wave_defense_table.max_active_biters = 768 + player_count * (90 * Diff.difficulty_vote_value)
wave_defense_table.max_active_biters = 888 + player_count * (90 * Diff.difficulty_vote_value)
-- threat gain / wave
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.difficulty_vote_value * 0.1
local amount = player_count * 0.25 + 2
amount = math.floor(amount)
if amount > 6 then
amount = 6
if amount > 8 then
amount = 8
end
Collapse.set_amount(amount)
if player_count >= 8 and player_count <= 12 then
Collapse.set_speed(8)
elseif player_count >= 20 then
Collapse.set_speed(6)
elseif player_count >= 35 then
Collapse.set_speed(5)
end
wave_defense_table.wave_interval = 3600 - player_count * 60
if wave_defense_table.wave_interval < 1800 then
wave_defense_table.wave_interval = 1800
@ -248,6 +258,18 @@ function Public.reset_map()
Collapse.set_direction('north')
Collapse.start_now(false)
local x_value = rng(15, 25)
local y_value = rng(50, 60)
local data = {
['cargo-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}},
['artillery-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}},
['fluid-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}},
['locomotive'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}}
}
ICT.set_wagon_area(data)
this.locomotive_health = 10000
this.locomotive_max_health = 10000
@ -474,7 +496,11 @@ local on_research_finished = function(event)
if research.force.technologies['steel-axe'].researched then
mining_speed_bonus = mining_speed_bonus + 0.5
end -- +50% speed for steel-axe research
research.force.manual_mining_speed_modifier = mining_speed_bonus
if this.breached_wall <= 2 then
research.force.manual_mining_speed_modifier = this.force_mining_speed.speed + mining_speed_bonus
else
research.force.manual_mining_speed_modifier = mining_speed_bonus
end
local force_name = research.force.name
if not force_name then
@ -503,23 +529,45 @@ end
local has_the_game_ended = function()
local this = WPT.get()
if this.game_reset_tick then
if this.game_reset_tick < game.tick then
if this.soft_reset then
if this.game_reset_tick < 0 then
return
end
this.game_reset_tick = this.game_reset_tick - 30
if this.game_reset_tick % 1800 == 0 then
if this.game_reset_tick > 0 then
local cause_msg
if this.restart then
cause_msg = 'restart'
elseif this.shutdown then
cause_msg = 'shutdown'
elseif this.soft_reset then
cause_msg = 'soft-reset'
end
this.game_reset = true
this.game_has_ended = true
game.print(
'Game will ' .. cause_msg .. ' in ' .. this.game_reset_tick / 60 .. ' seconds!',
{r = 0.22, g = 0.88, b = 0.22}
)
end
if this.soft_reset and this.game_reset_tick == 0 then
this.game_reset_tick = nil
Public.reset_map()
return
end
if this.restart then
if this.restart and this.game_reset_tick == 0 then
if not this.announced_message then
game.print('Soft-reset is disabled. Server will restart!', {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled. Server will restart!'
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})
Server.start_scenario('Mountain_Fortress_v3')
Server.start_scenario('Fish_Defender')
this.announced_message = true
return
end
end
if this.shutdown then
if this.shutdown and this.game_reset_tick == 0 then
if not this.announced_message then
game.print('Soft-reset is disabled. Server is shutting down!', {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled. Server is shutting down!'
@ -530,12 +578,12 @@ local has_the_game_ended = function()
end
end
end
return
end
end
local boost_difficulty = function()
local difficulty_set = WPT.get('difficulty_set')
local force_mining_speed = WPT.get('force_mining_speed')
if difficulty_set then
return
end
@ -561,6 +609,7 @@ local boost_difficulty = function()
if name == 'Easy' then
rpg_extra.difficulty = 1
game.forces.player.manual_mining_speed_modifier = 1.5
force_mining_speed.speed = game.forces.player.manual_mining_speed_modifier
game.forces.player.character_running_speed_modifier = 0.2
game.forces.player.manual_crafting_speed_modifier = 0.4
WPT.get().coin_amount = 2
@ -573,6 +622,7 @@ local boost_difficulty = function()
elseif name == 'Normal' then
rpg_extra.difficulty = 0.5
game.forces.player.manual_mining_speed_modifier = 1
force_mining_speed.speed = game.forces.player.manual_mining_speed_modifier
game.forces.player.character_running_speed_modifier = 0.1
game.forces.player.manual_crafting_speed_modifier = 0.2
WPT.get().coin_amount = 1
@ -585,6 +635,7 @@ local boost_difficulty = function()
elseif name == 'Hard' then
rpg_extra.difficulty = 0
game.forces.player.manual_mining_speed_modifier = 0
force_mining_speed.speed = game.forces.player.manual_mining_speed_modifier
game.forces.player.character_running_speed_modifier = 0
game.forces.player.manual_crafting_speed_modifier = 0
WPT.get().coin_amount = 1

View File

@ -87,14 +87,14 @@ local resource_loot = {
recipe = 'stone-wall',
output = {item = 'stone-wall', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
},
weight = 1
weight = 2
},
{
stack = {
recipe = 'iron-gear-wheel',
output = {item = 'iron-gear-wheel', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 4
weight = 3
}
}

View File

@ -92,6 +92,9 @@ function Public.reset_table()
this.outside_chests = {}
this.chests_linked_to = {}
this.chest_limit_outside_upgrades = 1
this.force_mining_speed = {
speed = 0
}
end
function Public.get(key)

View File

@ -238,6 +238,7 @@ Event.add(
defines.events.on_console_command,
function(event)
local trusted = Session.get_trusted_table()
local tracker = Session.get_session_table()
local p
local cmd = event.command
@ -258,6 +259,14 @@ Event.add(
local player = game.players[event.player_index]
p = player.print
local playtime = player.online_time
if tracker[player.name] then
playtime = player.online_time + tracker[player.name]
end
if playtime < 25920000 then -- 5 days
return p('You are not trusted enough to run this command.', {r = 1, g = 0.5, b = 0.1})
end
if jailed[player.name] and not player.admin then
return p('You are jailed, there is nothing to be done.', {r = 1, g = 0.5, b = 0.1})
end