mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
Merge pull request #411 from ComfyFactory/mtn_v3_changes
Mtn v3 - fix changes
This commit is contained in:
commit
ea4fa6e3ab
@ -20,18 +20,32 @@ function Public.init_enemy_weapon_damage()
|
||||
}
|
||||
|
||||
local e = game.forces.enemy
|
||||
local a = game.forces.aggressors
|
||||
local af = game.forces.aggressors_frenzy
|
||||
|
||||
e.technologies['refined-flammables-1'].researched = true
|
||||
e.technologies['refined-flammables-2'].researched = true
|
||||
e.technologies['energy-weapons-damage-1'].researched = true
|
||||
|
||||
a.technologies['refined-flammables-1'].researched = true
|
||||
a.technologies['refined-flammables-2'].researched = true
|
||||
a.technologies['energy-weapons-damage-1'].researched = true
|
||||
|
||||
af.technologies['refined-flammables-1'].researched = true
|
||||
af.technologies['refined-flammables-2'].researched = true
|
||||
af.technologies['energy-weapons-damage-1'].researched = true
|
||||
|
||||
for k, v in pairs(data) do
|
||||
e.set_ammo_damage_modifier(k, v)
|
||||
a.set_ammo_damage_modifier(k, v)
|
||||
af.set_ammo_damage_modifier(k, v)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.enemy_weapon_damage()
|
||||
local e = game.forces.enemy
|
||||
local a = game.forces.aggressors
|
||||
local af = game.forces.aggressors_frenzy
|
||||
|
||||
local data = {
|
||||
['artillery-shell'] = 0.05,
|
||||
@ -50,8 +64,12 @@ function Public.enemy_weapon_damage()
|
||||
local new = Difficulty.get().value * v
|
||||
|
||||
local e_old = e.get_ammo_damage_modifier(k)
|
||||
local a_old = a.get_ammo_damage_modifier(k)
|
||||
local af_old = af.get_ammo_damage_modifier(k)
|
||||
|
||||
e.set_ammo_damage_modifier(k, new + e_old)
|
||||
a.set_ammo_damage_modifier(k, new + a_old)
|
||||
af.set_ammo_damage_modifier(k, new + af_old)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1215,6 +1215,7 @@ local function show_mvps(player)
|
||||
end
|
||||
local time_played = Core.format_time(game.ticks_played)
|
||||
local total_players = #game.players
|
||||
local total_connected_players = #game.connected_players
|
||||
local pickaxe_upgrades = Public.pickaxe_upgrades
|
||||
local upgrades = Public.get('upgrades')
|
||||
local pick_tier = pickaxe_upgrades[upgrades.pickaxe_tier]
|
||||
@ -1265,6 +1266,11 @@ local function show_mvps(player)
|
||||
field7 = {
|
||||
text1 = 'Collapse Amount:',
|
||||
text2 = collapse_amount,
|
||||
inline = 'true'
|
||||
},
|
||||
field8 = {
|
||||
text1 = 'Connected players:',
|
||||
text2 = total_connected_players,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
|
@ -1137,9 +1137,14 @@ end
|
||||
function Public.set_spawn_position()
|
||||
local collapse_pos = Collapse.get_position()
|
||||
local locomotive = Public.get('locomotive')
|
||||
local final_battle = Public.get('final_battle')
|
||||
if final_battle then
|
||||
return
|
||||
end
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
--TODO check if final battle
|
||||
local l = locomotive.position
|
||||
|
||||
local retries = 0
|
||||
|
@ -115,6 +115,22 @@ local reconstruct_all_trains =
|
||||
end
|
||||
)
|
||||
|
||||
local remove_non_migrated_doors_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local icw = data.icw
|
||||
for _, unit_data in pairs(icw.wagons) do
|
||||
if not unit_data.migrated then
|
||||
for _, door in pairs(unit_data.doors) do
|
||||
if door and door.valid then
|
||||
door.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function get_tile_name()
|
||||
-- local main_tile_name = 'tutorial-grid'
|
||||
-- local main_tile_name = 'stone-path'
|
||||
@ -703,10 +719,12 @@ function Public.migrate_wagon(icw, source, target)
|
||||
if unit_number == source_wagon then
|
||||
unit_data.surface.name = tostring(target_wagon)
|
||||
unit_data.entity = target
|
||||
unit_data.migrated = true
|
||||
icw.wagons[target_wagon] = deepcopy(unit_data)
|
||||
return icw.wagons[target_wagon]
|
||||
end
|
||||
end
|
||||
|
||||
Task.set_timeout_in_ticks(100, remove_non_migrated_doors_token, {icw = icw})
|
||||
end
|
||||
|
||||
function Public.use_cargo_wagon_door_with_entity(icw, player, door)
|
||||
@ -954,6 +972,11 @@ function Public.construct_train(icw, locomotive, carriages)
|
||||
end
|
||||
|
||||
function Public.reconstruct_all_trains(icw)
|
||||
local final_battle = WPT.get('final_battle')
|
||||
if final_battle then
|
||||
return
|
||||
end
|
||||
|
||||
icw.trains = {}
|
||||
for unit_number, wagon in pairs(icw.wagons) do
|
||||
if not validate_entity(wagon.entity) then
|
||||
|
@ -68,6 +68,22 @@ local function initial_cargo_boxes()
|
||||
}
|
||||
end
|
||||
|
||||
local place_tiles_token =
|
||||
Token.register(
|
||||
function(event)
|
||||
local surface = event.surface
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local position = event.position
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
|
||||
MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12)
|
||||
end
|
||||
)
|
||||
|
||||
local set_loco_tiles =
|
||||
Token.register(
|
||||
function(data)
|
||||
@ -83,6 +99,12 @@ local set_loco_tiles =
|
||||
|
||||
---@diagnostic disable-next-line: count-down-loop
|
||||
for x = position.x - 5, 1, 3 do
|
||||
if x == -1 then
|
||||
x = x - 1
|
||||
end
|
||||
if x == 0 then
|
||||
x = x + 1
|
||||
end
|
||||
for y = 1, position.y + 5, 2 do
|
||||
if random(1, 3) == 1 then
|
||||
p[#p + 1] = {x = x, y = y}
|
||||
@ -90,17 +112,8 @@ local set_loco_tiles =
|
||||
end
|
||||
end
|
||||
|
||||
if random(1, 6) == 1 then
|
||||
MapFunctions.draw_noise_tile_circle(position, 'blue-refined-concrete', surface, 12)
|
||||
elseif random(1, 5) == 1 then
|
||||
MapFunctions.draw_noise_tile_circle(position, 'black-refined-concrete', surface, 12)
|
||||
elseif random(1, 4) == 1 then
|
||||
MapFunctions.draw_noise_tile_circle(position, 'cyan-refined-concrete', surface, 12)
|
||||
elseif random(1, 3) == 1 then
|
||||
MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12)
|
||||
else
|
||||
MapFunctions.draw_noise_tile_circle(position, 'blue-refined-concrete', surface, 12)
|
||||
end
|
||||
MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12)
|
||||
Task.set_timeout_in_ticks(300, place_tiles_token, {surface = surface, position = position})
|
||||
|
||||
for i = 1, #cargo_boxes, 1 do
|
||||
if not p[i] then
|
||||
@ -175,7 +188,7 @@ function Public.locomotive_spawn(surface, position)
|
||||
position = position
|
||||
}
|
||||
|
||||
Task.set_timeout_in_ticks(150, set_loco_tiles, data)
|
||||
Task.set_timeout_in_ticks(50, set_loco_tiles, data)
|
||||
|
||||
for y = -1, 0, 0.05 do
|
||||
local scale = random(50, 100) * 0.01
|
||||
|
@ -8,6 +8,13 @@ Want to host it? Ask Gerkiz#0001 at discord!
|
||||
-- develop setting
|
||||
local _DEV_MODE = false
|
||||
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'maps.mountain_fortress_v3.ic.main'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Public = require 'maps.mountain_fortress_v3.core'
|
||||
local Discord = require 'utils.discord'
|
||||
@ -38,13 +45,6 @@ local JailData = require 'utils.datastore.jail_data'
|
||||
local RPG_Progression = require 'utils.datastore.rpg_data'
|
||||
local OfflinePlayers = require 'modules.clear_vacant_players'
|
||||
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'maps.mountain_fortress_v3.ic.main'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
-- Use these settings for live
|
||||
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
||||
local role_to_mention = Discord.role_mentions.mtn_fortress
|
||||
@ -113,14 +113,13 @@ local announce_new_map =
|
||||
)
|
||||
|
||||
function Public.reset_map()
|
||||
local wave = WD.get_wave()
|
||||
local this = Public.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
Misc.set('creative_are_you_sure', false)
|
||||
Misc.set('creative_enabled', false)
|
||||
|
||||
this.active_surface_index = Public.create_surface()
|
||||
-- this.soft_reset_counter = Public.get_reset_counter()
|
||||
this.old_surface_index = this.active_surface_index
|
||||
|
||||
Public.stateful.clear_all_frames()
|
||||
|
||||
@ -295,7 +294,7 @@ function Public.reset_map()
|
||||
WD.disable_spawning_biters(true)
|
||||
end
|
||||
|
||||
if wave >= 500 then
|
||||
if not this.disable_startup_notification then
|
||||
Task.set_timeout_in_ticks(25, announce_new_map)
|
||||
end
|
||||
end
|
||||
@ -442,6 +441,11 @@ local compare_collapse_and_train = function()
|
||||
end
|
||||
|
||||
local collapse_after_wave_200 = function()
|
||||
local final_battle = Public.get('final_battle')
|
||||
if final_battle then
|
||||
return
|
||||
end
|
||||
|
||||
local collapse_grace = Public.get('collapse_grace')
|
||||
if not collapse_grace then
|
||||
return
|
||||
@ -452,7 +456,7 @@ local collapse_after_wave_200 = function()
|
||||
|
||||
local wave_number = WD.get_wave()
|
||||
|
||||
if wave_number >= 200 then
|
||||
if wave_number >= 200 and not Collapse.get_start_now() then
|
||||
Collapse.start_now(true)
|
||||
local data = {
|
||||
position = Collapse.get_position()
|
||||
|
@ -2,6 +2,7 @@ local Server = require 'utils.server'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Modifers = require 'utils.player_modifiers'
|
||||
local Public = require 'maps.mountain_fortress_v3.table'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
||||
@ -48,7 +49,7 @@ local function teleport_players(surface)
|
||||
end
|
||||
|
||||
local function equip_players(player_starting_items, data)
|
||||
for k, player in pairs(game.players) do
|
||||
for _, player in pairs(game.players) do
|
||||
if player.character and player.character.valid then
|
||||
player.character.destroy()
|
||||
end
|
||||
@ -72,6 +73,80 @@ local function equip_players(player_starting_items, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function clear_scheduler(scheduler)
|
||||
scheduler.operation = nil
|
||||
scheduler.surface = nil
|
||||
scheduler.remove_surface = false
|
||||
scheduler.start_after = 0
|
||||
end
|
||||
|
||||
local function scheduled_surface_clearing()
|
||||
local scheduler = Public.get('scheduler')
|
||||
if not scheduler.operation then
|
||||
return
|
||||
end
|
||||
|
||||
local tick = game.tick
|
||||
|
||||
if scheduler.start_after > tick then
|
||||
return
|
||||
end
|
||||
|
||||
local operation = scheduler.operation
|
||||
|
||||
if operation == 'warn' then
|
||||
game.print(mapkeeper .. ' Preparing to remove old entites and clearing surface - this might lag the server a bit.')
|
||||
scheduler.operation = 'player_clearing'
|
||||
scheduler.start_after = tick + 100
|
||||
elseif operation == 'player_clearing' then
|
||||
local surface = scheduler.surface
|
||||
if not surface or not surface.valid then
|
||||
clear_scheduler(scheduler)
|
||||
return
|
||||
end
|
||||
game.print(mapkeeper .. ' Removing old entities.')
|
||||
|
||||
local ent = surface.find_entities_filtered {force = 'player', limit = 1000}
|
||||
for _, e in pairs(ent) do
|
||||
if e.valid then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
scheduler.operation = 'clear'
|
||||
scheduler.start_after = tick + 100
|
||||
elseif operation == 'clear' then
|
||||
local surface = scheduler.surface
|
||||
if not surface or not surface.valid then
|
||||
clear_scheduler(scheduler)
|
||||
return
|
||||
end
|
||||
|
||||
game.print(mapkeeper .. ' Clearing old surface.')
|
||||
surface.clear()
|
||||
if scheduler.remove_surface then
|
||||
scheduler.operation = 'delete'
|
||||
else
|
||||
scheduler.operation = 'done'
|
||||
end
|
||||
scheduler.start_after = tick + 100
|
||||
elseif operation == 'delete' then
|
||||
local surface = scheduler.surface
|
||||
if not surface or not surface.valid then
|
||||
clear_scheduler(scheduler)
|
||||
return
|
||||
end
|
||||
|
||||
game.print(mapkeeper .. ' Deleting old surface.')
|
||||
|
||||
game.delete_surface(surface)
|
||||
scheduler.operation = 'done'
|
||||
scheduler.start_after = tick + 100
|
||||
elseif operation == 'done' then
|
||||
game.print(mapkeeper .. ' Done clearing old surface.')
|
||||
clear_scheduler(scheduler)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_items)
|
||||
local this = Public.get()
|
||||
|
||||
@ -91,7 +166,7 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
||||
teleport_players(new_surface)
|
||||
equip_players(player_starting_items, this)
|
||||
|
||||
game.delete_surface(old_surface)
|
||||
Public.add_schedule_to_delete_surface(true)
|
||||
|
||||
local radius = 512
|
||||
local area = {{x = -radius, y = -radius}, {x = radius, y = radius}}
|
||||
@ -123,4 +198,22 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
||||
return new_surface
|
||||
end
|
||||
|
||||
function Public.add_schedule_to_delete_surface(remove_surface)
|
||||
local old_surface_index = Public.get('old_surface_index')
|
||||
local surface = game.get_surface(old_surface_index)
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local tick = game.tick
|
||||
|
||||
local scheduler = Public.get('scheduler')
|
||||
scheduler.operation = 'warn'
|
||||
scheduler.surface = surface
|
||||
scheduler.remove_surface = remove_surface or false
|
||||
scheduler.start_after = tick + 500
|
||||
end
|
||||
|
||||
Event.on_nth_tick(10, scheduled_surface_clearing)
|
||||
|
||||
return Public
|
||||
|
@ -33,6 +33,16 @@ function Public.blueprint()
|
||||
return
|
||||
end
|
||||
|
||||
local spawners = surface.find_entities_filtered({type = 'unit-spawner', area = {{position.x - 70, position.y - 70}, {position.x + 70, position.y + 70}}})
|
||||
if #spawners == 0 then
|
||||
return
|
||||
end
|
||||
for _, e in pairs(spawners) do
|
||||
if e and e.valid then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local success = item.stack.import_stack(bp)
|
||||
if success <= 0 then
|
||||
local ghosts = item.stack.build_blueprint {surface = surface, force = 'player', position = position, force_build = true}
|
||||
|
@ -5,6 +5,7 @@ local Token = require 'utils.token'
|
||||
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
||||
|
||||
local ceil = math.ceil
|
||||
local random = math.random
|
||||
local queue_task = Task.queue_task
|
||||
local tiles_per_call = 8
|
||||
local total_calls = ceil(1024 / tiles_per_call)
|
||||
@ -212,10 +213,19 @@ local function do_place_entities(data)
|
||||
if e.direction then
|
||||
entity.direction = e.direction
|
||||
end
|
||||
if e.active ~= nil then
|
||||
if e.active ~= nil and e.random_active == nil then
|
||||
entity.active = e.active
|
||||
end
|
||||
if e.destructible ~= nil then
|
||||
if e.random_active ~= nil then
|
||||
if random(1, 10) == 1 then
|
||||
entity.active = true
|
||||
entity.destructible = true
|
||||
else
|
||||
entity.active = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
if e.destructible ~= nil and e.random_active == nil then
|
||||
entity.destructible = e.destructible
|
||||
end
|
||||
if e.force then
|
||||
|
@ -8,7 +8,10 @@ local Task = require 'utils.task'
|
||||
local Core = require 'utils.core'
|
||||
local Server = require 'utils.server'
|
||||
local LinkedChests = require 'maps.mountain_fortress_v3.icw.linked_chests'
|
||||
local Discord = require 'utils.discord'
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
||||
local main_button_name = Gui.uid_name()
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local boss_frame_name = Gui.uid_name()
|
||||
@ -61,6 +64,65 @@ local spread_particles_token =
|
||||
end
|
||||
)
|
||||
|
||||
local function notify_won_to_discord()
|
||||
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
||||
|
||||
local stateful = Public.get_stateful()
|
||||
|
||||
local wave = WD.get_wave()
|
||||
local date = Server.get_start_time()
|
||||
game.server_save('Complete_Mtn_v3_' .. tostring(date) .. '_wave' .. tostring(wave))
|
||||
|
||||
local threat = WD.get('threat')
|
||||
local time_played = Core.format_time(game.ticks_played)
|
||||
local total_players = #game.players
|
||||
local total_connected_players = #game.connected_players
|
||||
local pickaxe_upgrades = Public.pickaxe_upgrades
|
||||
local upgrades = Public.get('upgrades')
|
||||
local pick_tier = pickaxe_upgrades[upgrades.pickaxe_tier]
|
||||
|
||||
local text = {
|
||||
title = 'Game won!',
|
||||
description = 'Game statistics from the game is below',
|
||||
color = 'success',
|
||||
field1 = {
|
||||
text1 = 'Time played:',
|
||||
text2 = time_played,
|
||||
inline = 'false'
|
||||
},
|
||||
field2 = {
|
||||
text1 = 'Rounds survived:',
|
||||
text2 = stateful.rounds_survived,
|
||||
inline = 'false'
|
||||
},
|
||||
field3 = {
|
||||
text1 = 'Total connected players:',
|
||||
text2 = total_players,
|
||||
inline = 'false'
|
||||
},
|
||||
field4 = {
|
||||
text1 = 'Threat:',
|
||||
text2 = format_number(threat, true),
|
||||
inline = 'false'
|
||||
},
|
||||
field5 = {
|
||||
text1 = 'Pickaxe Upgrade:',
|
||||
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
|
||||
inline = 'false'
|
||||
},
|
||||
field6 = {
|
||||
text1 = 'Connected players:',
|
||||
text2 = total_connected_players,
|
||||
inline = 'false'
|
||||
}
|
||||
}
|
||||
if server_name_matches then
|
||||
Server.to_discord_named_parsed_embed(send_ping_to_channel, text)
|
||||
else
|
||||
Server.to_discord_embed_parsed(text)
|
||||
end
|
||||
end
|
||||
|
||||
local function clear_all_frames()
|
||||
Core.iter_players(
|
||||
function(player)
|
||||
@ -181,7 +243,7 @@ local function objective_frames(stateful, player_frame, objective, data)
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
right_flow.style.horizontally_stretchable = true
|
||||
|
||||
if stateful.objectives_completed.supplies then
|
||||
if stateful.objectives_completed.supplies or stateful.objectives_completed.single_item then
|
||||
data.supply_completed = right_flow.add({type = 'label', caption = ' [img=utility/check_mark_green]', tooltip = {'stateful.tooltip_completed'}})
|
||||
else
|
||||
data.supply_completed = right_flow.add({type = 'label', caption = ' [img=utility/not_available]', tooltip = {'stateful.tooltip_not_completed'}})
|
||||
@ -620,7 +682,8 @@ local function update_data()
|
||||
single_item.total = single_item.count
|
||||
end
|
||||
single_item.count = single_item.total - count
|
||||
if single_item.count == 0 then
|
||||
if single_item.count <= 0 then
|
||||
single_item.count = 0
|
||||
frame.number = nil
|
||||
frame.sprite = 'utility/check_mark_green'
|
||||
else
|
||||
@ -779,7 +842,8 @@ local function update_raw()
|
||||
single_item.total = single_item.count
|
||||
end
|
||||
single_item.count = single_item.total - count
|
||||
if single_item.count == 0 then
|
||||
if single_item.count <= 0 then
|
||||
single_item.count = 0
|
||||
if not stateful.objectives_completed.single_item then
|
||||
stateful.objectives_completed.single_item = true
|
||||
play_achievement_unlocked()
|
||||
@ -799,6 +863,8 @@ local function update_raw()
|
||||
if not collection.nuke_blueprint then
|
||||
collection.nuke_blueprint = true
|
||||
Public.stateful_blueprints.nuke_blueprint()
|
||||
WD.disable_spawning_biters(false)
|
||||
Server.to_discord_embed('Final battle starts now!')
|
||||
refresh_boss_frame()
|
||||
end
|
||||
end
|
||||
@ -832,8 +898,10 @@ local function update_raw()
|
||||
collection.game_won_notified = true
|
||||
refresh_boss_frame()
|
||||
play_game_won()
|
||||
Server.to_discord_embed('Game won!')
|
||||
stateful.rounds_survived = stateful.rounds_survived + 1
|
||||
Public.stateful.save_settings()
|
||||
notify_won_to_discord()
|
||||
local locomotive = Public.get('locomotive')
|
||||
if locomotive and locomotive.valid then
|
||||
locomotive.surface.spill_item_stack(locomotive.position, {name = 'coin', count = 512}, false)
|
||||
@ -871,6 +939,9 @@ local function update_raw()
|
||||
stateful.collection.gather_time = tick + 54000
|
||||
stateful.collection.gather_time_timer = tick + 54000
|
||||
play_achievement_unlocked()
|
||||
WD.disable_spawning_biters(true)
|
||||
Public.stateful_blueprints.blueprint()
|
||||
WD.nuke_wave_gui()
|
||||
|
||||
Core.iter_connected_players(
|
||||
function(player)
|
||||
|
@ -30,7 +30,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.on_nth_tick(
|
||||
200,
|
||||
100,
|
||||
function()
|
||||
local final_battle = Public.get_stateful('final_battle')
|
||||
if not final_battle then
|
||||
|
@ -35,19 +35,22 @@ Global.register(
|
||||
)
|
||||
|
||||
local stateful_spawn_points = {
|
||||
{{x = -186, y = -170}, {x = 177, y = 119}},
|
||||
{{x = -190, y = -200}, {x = 160, y = -160}},
|
||||
{{x = -186, y = -150}, {x = 177, y = 119}},
|
||||
{{x = -190, y = -150}, {x = 160, y = -155}},
|
||||
{{x = -190, y = -0}, {x = 160, y = -0}},
|
||||
{{x = -186, y = -170}, {x = 177, y = 119}},
|
||||
{{x = -160, y = -200}, {x = 160, y = -160}},
|
||||
{{x = 160, y = -200}, {x = 190, y = -160}},
|
||||
{{x = -186, y = -150}, {x = 177, y = 119}},
|
||||
{{x = -160, y = -150}, {x = 160, y = -155}},
|
||||
{{x = 160, y = -150}, {x = 190, y = -155}},
|
||||
{{x = 160, y = 0}, {x = 190, y = 0}},
|
||||
{{x = -186, y = -170}, {x = 177, y = 119}},
|
||||
{{x = 160, y = -160}, {x = 190, y = 160}},
|
||||
{{x = 160, y = 160}, {x = 190, y = 200}},
|
||||
{{x = -160, y = 160}, {x = 160, y = 200}},
|
||||
{{x = -190, y = 160}, {x = -160, y = 200}},
|
||||
{{x = -190, y = -160}, {x = -160, y = 160}}
|
||||
{{x = -186, y = -150}, {x = 177, y = 119}},
|
||||
{{x = 160, y = 0}, {x = -160, y = 0}},
|
||||
{{x = 160, y = -155}, {x = 190, y = 155}},
|
||||
{{x = 160, y = 155}, {x = 190, y = 150}},
|
||||
{{x = -160, y = 0}, {x = 160, y = 0}},
|
||||
{{x = -160, y = 155}, {x = 160, y = 150}},
|
||||
{{x = -190, y = 155}, {x = -160, y = 150}},
|
||||
{{x = -160, y = 0}, {x = 160, y = 0}},
|
||||
{{x = -190, y = -155}, {x = -160, y = 155}}
|
||||
}
|
||||
|
||||
local function get_random_buff()
|
||||
@ -87,6 +90,10 @@ local function get_random_buff()
|
||||
}
|
||||
}
|
||||
|
||||
shuffle(buffs)
|
||||
shuffle(buffs)
|
||||
shuffle(buffs)
|
||||
shuffle(buffs)
|
||||
shuffle(buffs)
|
||||
shuffle(buffs)
|
||||
|
||||
@ -504,8 +511,6 @@ local apply_settings_token =
|
||||
|
||||
settings = apply_startup_settings(settings)
|
||||
|
||||
Public.increase_enemy_damage_and_health()
|
||||
|
||||
this.rounds_survived = settings.rounds_survived
|
||||
this.objectives_completed = {}
|
||||
this.objectives_completed_count = 0
|
||||
@ -535,6 +540,8 @@ local apply_settings_token =
|
||||
this.force_chunk = true
|
||||
this.force_chunk_until = game.tick + 1000
|
||||
|
||||
Public.increase_enemy_damage_and_health()
|
||||
|
||||
Server.set_data(dataset, dataset_key, settings)
|
||||
end
|
||||
)
|
||||
@ -628,6 +635,10 @@ function Public.move_all_players()
|
||||
end
|
||||
|
||||
local surface = market.surface
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_pos = surface.find_non_colliding_position('character', market.position, 3, 0, 5)
|
||||
|
||||
if spawn_pos then
|
||||
@ -663,6 +674,7 @@ function Public.allocate()
|
||||
if stateful_locomotive and not stateful_locomotive_migrated then
|
||||
Task.set_timeout_in_ticks(100, move_all_players_token, {})
|
||||
|
||||
Public.soft_reset.add_schedule_to_delete_surface()
|
||||
Public.set_stateful('stateful_locomotive_migrated', true)
|
||||
local locomotive = Public.get('locomotive')
|
||||
local icw_data = ICW.migrate_wagon(locomotive, stateful_locomotive)
|
||||
@ -696,7 +708,7 @@ function Public.allocate()
|
||||
|
||||
collection.time_until_attack = 54000 + game.tick
|
||||
collection.time_until_attack_timer = 54000 + game.tick
|
||||
collection.survive_for = collection.time_until_attack_timer + scale(random(18000, 54000), 216000)
|
||||
collection.survive_for = collection.time_until_attack_timer + scale(random(54000, 108000), 324000)
|
||||
collection.survive_for_timer = collection.survive_for
|
||||
|
||||
Public.set_target(stateful_locomotive, icw_data)
|
||||
@ -719,10 +731,12 @@ end
|
||||
|
||||
function Public.increase_enemy_damage_and_health()
|
||||
if this.rounds_survived == 1 then
|
||||
Event.raise(WD.events.on_biters_evolved, {})
|
||||
Event.raise(WD.events.on_biters_evolved, {force = game.forces.aggressors})
|
||||
Event.raise(WD.events.on_biters_evolved, {force = game.forces.aggressors_frenzy})
|
||||
else
|
||||
for _ = 1, this.rounds_survived do
|
||||
Event.raise(WD.events.on_biters_evolved, {})
|
||||
Event.raise(WD.events.on_biters_evolved, {force = game.forces.aggressors})
|
||||
Event.raise(WD.events.on_biters_evolved, {force = game.forces.aggressors_frenzy})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -790,12 +804,12 @@ Server.on_data_set_changed(
|
||||
if data.value.test_mode then
|
||||
Public.reset_stateful()
|
||||
Public.stateful.clear_all_frames()
|
||||
game.print('[Stateful] Test round settings received.')
|
||||
log('[Stateful] new settings applied.')
|
||||
this.test_mode = true
|
||||
elseif data.value.test_mode == false then
|
||||
Public.reset_stateful()
|
||||
Public.stateful.clear_all_frames()
|
||||
game.print('[Stateful] Test round settings has been disabled.')
|
||||
log('[Stateful] new settings applied.')
|
||||
this.test_mode = false
|
||||
end
|
||||
end
|
||||
|
@ -152,7 +152,7 @@ local function border_chunk(p, data)
|
||||
name = 'spitter-spawner'
|
||||
end
|
||||
if enemy_spawn_positions(p) then
|
||||
entities[#entities + 1] = {name = name, position = pos, force = 'enemy', collision = true, active = false, destructible = false}
|
||||
entities[#entities + 1] = {name = name, position = pos, force = 'enemy', collision = true, active = false, destructible = false, random_active = true}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,13 @@ local Event = require 'utils.event'
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
traps = {}
|
||||
traps = {},
|
||||
scheduler = {
|
||||
start_after = 0,
|
||||
surface = nil,
|
||||
operation = nil,
|
||||
next_operation = nil
|
||||
}
|
||||
}
|
||||
local Public = {}
|
||||
local random = math.random
|
||||
|
@ -24,7 +24,7 @@ local directions = {
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local width = surface.map_gen_settings.width
|
||||
@ -42,7 +42,7 @@ local directions = {
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local width = surface.map_gen_settings.width
|
||||
@ -60,7 +60,7 @@ local directions = {
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local width = surface.map_gen_settings.height
|
||||
@ -78,7 +78,7 @@ local directions = {
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local width = surface.map_gen_settings.height
|
||||
@ -125,7 +125,7 @@ local function progress()
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
@ -183,7 +183,7 @@ function Public.set_surface_index(surface_index)
|
||||
end
|
||||
|
||||
local surface = game.get_surface(surface_index)
|
||||
if not surface.valid then
|
||||
if not surface or not surface.valid then
|
||||
print_debug(2)
|
||||
return
|
||||
end
|
||||
|
@ -387,7 +387,6 @@ local function on_init()
|
||||
this.settings.frenzy_burst_length = 160
|
||||
this.settings.update_rate = 120
|
||||
this.target_settings = {}
|
||||
|
||||
set_forces()
|
||||
end
|
||||
|
||||
|
@ -564,13 +564,13 @@ local function spawn_biter(surface, position, forceSpawn, is_boss_biter, unit_se
|
||||
return biter
|
||||
end
|
||||
|
||||
local function increase_biter_damage()
|
||||
local function increase_biter_damage(force)
|
||||
local increase_damage_per_wave = Public.get('increase_damage_per_wave')
|
||||
if not increase_damage_per_wave then
|
||||
return
|
||||
end
|
||||
|
||||
local e = game.forces.enemy
|
||||
local e = force or game.forces.enemy
|
||||
local new = Difficulty.get('value') * 0.04
|
||||
local melee = new
|
||||
local bio = new - 0.02
|
||||
@ -1302,8 +1302,12 @@ Event.on_nth_tick(
|
||||
|
||||
Event.add(
|
||||
Public.events.on_biters_evolved,
|
||||
function()
|
||||
increase_biter_damage()
|
||||
function(event)
|
||||
if not event then
|
||||
event = {force = game.forces.enemy}
|
||||
end
|
||||
|
||||
increase_biter_damage(event.force)
|
||||
increase_biters_health()
|
||||
end
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Global = require 'utils.global'
|
||||
local Core = require 'utils.core'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {}
|
||||
@ -427,6 +428,17 @@ function Public.disable_spawning_biters(boolean)
|
||||
this.game_lost = boolean or false
|
||||
end
|
||||
|
||||
---Removes the player wave defense gui
|
||||
function Public.nuke_wave_gui()
|
||||
Core.iter_players(
|
||||
function(player)
|
||||
if player.gui.top.wave_defense and player.gui.top.wave_defense.valid then
|
||||
player.gui.top.wave_defense.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
--- Toggle debug - when you need to troubleshoot.
|
||||
-- @param <null>
|
||||
function Public.toggle_debug()
|
||||
|
@ -3,18 +3,26 @@ local Token = {}
|
||||
local tokens = {}
|
||||
|
||||
local counter = 200
|
||||
local alternative_counter = 20000
|
||||
|
||||
--- Assigns a unquie id for the given var.
|
||||
-- This function cannot be called after on_init() or on_load() has run as that is a desync risk.
|
||||
-- Typically this is used to register functions, so the id can be stored in the global table
|
||||
-- instead of the function. This is becasue closures cannot be safely stored in the global table.
|
||||
-- @param var<any>
|
||||
-- @param sarg<boolean>
|
||||
-- @return number the unique token for the variable.
|
||||
function Token.register(var)
|
||||
function Token.register(var, sarg)
|
||||
if _LIFECYCLE == 8 then
|
||||
error('Calling Token.register after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
if sarg then
|
||||
alternative_counter = alternative_counter + 1
|
||||
tokens[alternative_counter] = var
|
||||
return alternative_counter
|
||||
end
|
||||
|
||||
counter = counter + 1
|
||||
|
||||
tokens[counter] = var
|
||||
|
Loading…
x
Reference in New Issue
Block a user