mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
Mtn v3 - more changes
This commit is contained in:
parent
14751c87c9
commit
7a8e705fe3
@ -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
|
||||
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
|
||||
|
@ -73,52 +73,77 @@ local function equip_players(player_starting_items, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function add_step(this)
|
||||
if this.schedule_step ~= this.schedule_max_step then
|
||||
this.schedule_step = this.schedule_step + 1
|
||||
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 this = Public.get()
|
||||
if not this.initial_tick then
|
||||
local scheduler = Public.get('scheduler')
|
||||
if not scheduler.operation then
|
||||
return
|
||||
end
|
||||
|
||||
if this.initial_tick > game.tick then
|
||||
local tick = game.tick
|
||||
|
||||
if scheduler.start_after > tick then
|
||||
return
|
||||
end
|
||||
local step = this.schedule_step
|
||||
local schedule = this.schedule
|
||||
if schedule[step] then
|
||||
local surface = schedule[step].surface
|
||||
if not surface.valid then
|
||||
schedule[step] = nil
|
||||
add_step(this)
|
||||
|
||||
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
|
||||
if schedule[step].operation == 'player_clearing' then
|
||||
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
|
||||
schedule[step] = nil
|
||||
add_step(this)
|
||||
elseif schedule[step].operation == 'clear' then
|
||||
surface.clear()
|
||||
schedule[step] = nil
|
||||
add_step(this)
|
||||
elseif schedule[step].operation == 'delete' then
|
||||
game.delete_surface(surface)
|
||||
schedule[step] = nil
|
||||
add_step(this)
|
||||
elseif schedule[step].operation == 'done' then
|
||||
game.print(mapkeeper .. ' Done clearing old surface.')
|
||||
schedule[step] = nil
|
||||
add_step(this)
|
||||
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
|
||||
|
||||
@ -174,44 +199,19 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
||||
end
|
||||
|
||||
function Public.add_schedule_to_delete_surface(remove_surface)
|
||||
local this = Public.get()
|
||||
local surface = game.get_surface(this.active_surface_index)
|
||||
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
|
||||
|
||||
game.print(mapkeeper .. ' Preparing to remove old entites and clearing surface - this might lag the server a bit.')
|
||||
local tick = game.tick
|
||||
|
||||
local step = this.schedule_max_step
|
||||
|
||||
if not step then
|
||||
this.schedule_step = 0
|
||||
this.schedule_max_step = 0
|
||||
this.schedule = {}
|
||||
this.initial_tick = 0
|
||||
step = this.schedule_max_step
|
||||
end
|
||||
|
||||
local add = 1
|
||||
local count_scrap = surface.count_entities_filtered {force = 'player'}
|
||||
for _ = 1, count_scrap, 1000 do
|
||||
this.schedule[step + add] = {operation = 'player_clearing', surface = surface}
|
||||
add = add + 1
|
||||
end
|
||||
this.schedule[step + add] = {operation = 'clear', surface = surface}
|
||||
add = add + 1
|
||||
if remove_surface then
|
||||
this.schedule[step + add] = {operation = 'delete', surface = surface}
|
||||
add = add + 1
|
||||
end
|
||||
this.schedule[step + add] = {operation = 'done', surface = surface}
|
||||
this.schedule_max_step = this.schedule_max_step + add
|
||||
if this.schedule_step == step then
|
||||
this.schedule_step = this.schedule_step + 1
|
||||
end
|
||||
if this.initial_tick <= game.tick then
|
||||
this.initial_tick = game.tick + 500
|
||||
end
|
||||
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)
|
||||
|
@ -66,9 +66,6 @@ local spread_particles_token =
|
||||
|
||||
local function notify_won_to_discord()
|
||||
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
||||
if not server_name_matches then
|
||||
return
|
||||
end
|
||||
|
||||
local stateful = Public.get_stateful()
|
||||
|
||||
@ -91,40 +88,39 @@ local function notify_won_to_discord()
|
||||
field1 = {
|
||||
text1 = 'Time played:',
|
||||
text2 = time_played,
|
||||
inline = 'true'
|
||||
inline = 'false'
|
||||
},
|
||||
field2 = {
|
||||
text1 = 'Rounds survived:',
|
||||
text2 = stateful.rounds_survived,
|
||||
inline = 'true'
|
||||
inline = 'false'
|
||||
},
|
||||
field3 = {
|
||||
text1 = 'Total connected players:',
|
||||
text2 = total_players,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
inline = 'false'
|
||||
},
|
||||
field4 = {
|
||||
text1 = 'Threat:',
|
||||
text2 = format_number(threat, true),
|
||||
inline = 'true'
|
||||
inline = 'false'
|
||||
},
|
||||
field5 = {
|
||||
text1 = 'Pickaxe Upgrade:',
|
||||
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
|
||||
inline = 'true'
|
||||
inline = 'false'
|
||||
},
|
||||
field6 = {
|
||||
text1 = 'Connected players:',
|
||||
text2 = total_connected_players,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
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()
|
||||
|
@ -511,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
|
||||
@ -542,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
|
||||
)
|
||||
@ -635,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
|
||||
@ -727,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
|
||||
|
@ -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
|
||||
@ -269,11 +275,6 @@ function Public.reset_main_table()
|
||||
rocks_yield_ore_distance_modifier = 0.020
|
||||
}
|
||||
|
||||
this.schedule_step = 0
|
||||
this.schedule_max_step = 0
|
||||
this.schedule = {}
|
||||
this.initial_tick = 0
|
||||
|
||||
for k, _ in pairs(this.players) do
|
||||
this.players[k] = {}
|
||||
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
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user