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
|
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 =
|
local set_loco_tiles =
|
||||||
Token.register(
|
Token.register(
|
||||||
function(data)
|
function(data)
|
||||||
@ -83,6 +99,12 @@ local set_loco_tiles =
|
|||||||
|
|
||||||
---@diagnostic disable-next-line: count-down-loop
|
---@diagnostic disable-next-line: count-down-loop
|
||||||
for x = position.x - 5, 1, 3 do
|
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
|
for y = 1, position.y + 5, 2 do
|
||||||
if random(1, 3) == 1 then
|
if random(1, 3) == 1 then
|
||||||
p[#p + 1] = {x = x, y = y}
|
p[#p + 1] = {x = x, y = y}
|
||||||
@ -90,17 +112,8 @@ local set_loco_tiles =
|
|||||||
end
|
end
|
||||||
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)
|
MapFunctions.draw_noise_tile_circle(position, 'hazard-concrete-right', surface, 12)
|
||||||
else
|
Task.set_timeout_in_ticks(300, place_tiles_token, {surface = surface, position = position})
|
||||||
MapFunctions.draw_noise_tile_circle(position, 'blue-refined-concrete', surface, 12)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, #cargo_boxes, 1 do
|
for i = 1, #cargo_boxes, 1 do
|
||||||
if not p[i] then
|
if not p[i] then
|
||||||
@ -175,7 +188,7 @@ function Public.locomotive_spawn(surface, position)
|
|||||||
position = 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
|
for y = -1, 0, 0.05 do
|
||||||
local scale = random(50, 100) * 0.01
|
local scale = random(50, 100) * 0.01
|
||||||
|
@ -8,6 +8,13 @@ Want to host it? Ask Gerkiz#0001 at discord!
|
|||||||
-- develop setting
|
-- develop setting
|
||||||
local _DEV_MODE = false
|
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 Event = require 'utils.event'
|
||||||
local Public = require 'maps.mountain_fortress_v3.core'
|
local Public = require 'maps.mountain_fortress_v3.core'
|
||||||
local Discord = require 'utils.discord'
|
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 RPG_Progression = require 'utils.datastore.rpg_data'
|
||||||
local OfflinePlayers = require 'modules.clear_vacant_players'
|
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
|
-- Use these settings for live
|
||||||
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
||||||
local role_to_mention = Discord.role_mentions.mtn_fortress
|
local role_to_mention = Discord.role_mentions.mtn_fortress
|
||||||
@ -113,14 +113,13 @@ local announce_new_map =
|
|||||||
)
|
)
|
||||||
|
|
||||||
function Public.reset_map()
|
function Public.reset_map()
|
||||||
local wave = WD.get_wave()
|
|
||||||
local this = Public.get()
|
local this = Public.get()
|
||||||
local wave_defense_table = WD.get_table()
|
local wave_defense_table = WD.get_table()
|
||||||
Misc.set('creative_are_you_sure', false)
|
Misc.set('creative_are_you_sure', false)
|
||||||
Misc.set('creative_enabled', false)
|
Misc.set('creative_enabled', false)
|
||||||
|
|
||||||
this.active_surface_index = Public.create_surface()
|
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()
|
Public.stateful.clear_all_frames()
|
||||||
|
|
||||||
@ -295,7 +294,7 @@ function Public.reset_map()
|
|||||||
WD.disable_spawning_biters(true)
|
WD.disable_spawning_biters(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if wave >= 500 then
|
if not this.disable_startup_notification then
|
||||||
Task.set_timeout_in_ticks(25, announce_new_map)
|
Task.set_timeout_in_ticks(25, announce_new_map)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -73,52 +73,77 @@ local function equip_players(player_starting_items, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_step(this)
|
local function clear_scheduler(scheduler)
|
||||||
if this.schedule_step ~= this.schedule_max_step then
|
scheduler.operation = nil
|
||||||
this.schedule_step = this.schedule_step + 1
|
scheduler.surface = nil
|
||||||
end
|
scheduler.remove_surface = false
|
||||||
|
scheduler.start_after = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local function scheduled_surface_clearing()
|
local function scheduled_surface_clearing()
|
||||||
local this = Public.get()
|
local scheduler = Public.get('scheduler')
|
||||||
if not this.initial_tick then
|
if not scheduler.operation then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if this.initial_tick > game.tick then
|
local tick = game.tick
|
||||||
|
|
||||||
|
if scheduler.start_after > tick then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local step = this.schedule_step
|
|
||||||
local schedule = this.schedule
|
local operation = scheduler.operation
|
||||||
if schedule[step] then
|
|
||||||
local surface = schedule[step].surface
|
if operation == 'warn' then
|
||||||
if not surface.valid then
|
game.print(mapkeeper .. ' Preparing to remove old entites and clearing surface - this might lag the server a bit.')
|
||||||
schedule[step] = nil
|
scheduler.operation = 'player_clearing'
|
||||||
add_step(this)
|
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
|
return
|
||||||
end
|
end
|
||||||
if schedule[step].operation == 'player_clearing' then
|
game.print(mapkeeper .. ' Removing old entities.')
|
||||||
|
|
||||||
local ent = surface.find_entities_filtered {force = 'player', limit = 1000}
|
local ent = surface.find_entities_filtered {force = 'player', limit = 1000}
|
||||||
for _, e in pairs(ent) do
|
for _, e in pairs(ent) do
|
||||||
if e.valid then
|
if e.valid then
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
schedule[step] = nil
|
scheduler.operation = 'clear'
|
||||||
add_step(this)
|
scheduler.start_after = tick + 100
|
||||||
elseif schedule[step].operation == 'clear' then
|
elseif operation == 'clear' then
|
||||||
surface.clear()
|
local surface = scheduler.surface
|
||||||
schedule[step] = nil
|
if not surface or not surface.valid then
|
||||||
add_step(this)
|
clear_scheduler(scheduler)
|
||||||
elseif schedule[step].operation == 'delete' then
|
return
|
||||||
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)
|
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,44 +199,19 @@ function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_it
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Public.add_schedule_to_delete_surface(remove_surface)
|
function Public.add_schedule_to_delete_surface(remove_surface)
|
||||||
local this = Public.get()
|
local old_surface_index = Public.get('old_surface_index')
|
||||||
local surface = game.get_surface(this.active_surface_index)
|
local surface = game.get_surface(old_surface_index)
|
||||||
if not surface or not surface.valid then
|
if not surface or not surface.valid then
|
||||||
return
|
return
|
||||||
end
|
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
|
local scheduler = Public.get('scheduler')
|
||||||
|
scheduler.operation = 'warn'
|
||||||
if not step then
|
scheduler.surface = surface
|
||||||
this.schedule_step = 0
|
scheduler.remove_surface = remove_surface or false
|
||||||
this.schedule_max_step = 0
|
scheduler.start_after = tick + 500
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.on_nth_tick(10, scheduled_surface_clearing)
|
Event.on_nth_tick(10, scheduled_surface_clearing)
|
||||||
|
@ -66,9 +66,6 @@ local spread_particles_token =
|
|||||||
|
|
||||||
local function notify_won_to_discord()
|
local function notify_won_to_discord()
|
||||||
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
||||||
if not server_name_matches then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local stateful = Public.get_stateful()
|
local stateful = Public.get_stateful()
|
||||||
|
|
||||||
@ -91,40 +88,39 @@ local function notify_won_to_discord()
|
|||||||
field1 = {
|
field1 = {
|
||||||
text1 = 'Time played:',
|
text1 = 'Time played:',
|
||||||
text2 = time_played,
|
text2 = time_played,
|
||||||
inline = 'true'
|
inline = 'false'
|
||||||
},
|
},
|
||||||
field2 = {
|
field2 = {
|
||||||
text1 = 'Rounds survived:',
|
text1 = 'Rounds survived:',
|
||||||
text2 = stateful.rounds_survived,
|
text2 = stateful.rounds_survived,
|
||||||
inline = 'true'
|
inline = 'false'
|
||||||
},
|
},
|
||||||
field3 = {
|
field3 = {
|
||||||
text1 = 'Total connected players:',
|
text1 = 'Total connected players:',
|
||||||
text2 = total_players,
|
text2 = total_players,
|
||||||
inline = 'true',
|
inline = 'false'
|
||||||
emptyField = 'true',
|
|
||||||
emptyInline = 'true'
|
|
||||||
},
|
},
|
||||||
field4 = {
|
field4 = {
|
||||||
text1 = 'Threat:',
|
text1 = 'Threat:',
|
||||||
text2 = format_number(threat, true),
|
text2 = format_number(threat, true),
|
||||||
inline = 'true'
|
inline = 'false'
|
||||||
},
|
},
|
||||||
field5 = {
|
field5 = {
|
||||||
text1 = 'Pickaxe Upgrade:',
|
text1 = 'Pickaxe Upgrade:',
|
||||||
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
|
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
|
||||||
inline = 'true'
|
inline = 'false'
|
||||||
},
|
},
|
||||||
field6 = {
|
field6 = {
|
||||||
text1 = 'Connected players:',
|
text1 = 'Connected players:',
|
||||||
text2 = total_connected_players,
|
text2 = total_connected_players,
|
||||||
inline = 'true',
|
inline = 'false'
|
||||||
emptyField = 'true',
|
|
||||||
emptyInline = 'true'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if server_name_matches then
|
||||||
Server.to_discord_named_parsed_embed(send_ping_to_channel, text)
|
Server.to_discord_named_parsed_embed(send_ping_to_channel, text)
|
||||||
|
else
|
||||||
|
Server.to_discord_embed_parsed(text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function clear_all_frames()
|
local function clear_all_frames()
|
||||||
|
@ -511,8 +511,6 @@ local apply_settings_token =
|
|||||||
|
|
||||||
settings = apply_startup_settings(settings)
|
settings = apply_startup_settings(settings)
|
||||||
|
|
||||||
Public.increase_enemy_damage_and_health()
|
|
||||||
|
|
||||||
this.rounds_survived = settings.rounds_survived
|
this.rounds_survived = settings.rounds_survived
|
||||||
this.objectives_completed = {}
|
this.objectives_completed = {}
|
||||||
this.objectives_completed_count = 0
|
this.objectives_completed_count = 0
|
||||||
@ -542,6 +540,8 @@ local apply_settings_token =
|
|||||||
this.force_chunk = true
|
this.force_chunk = true
|
||||||
this.force_chunk_until = game.tick + 1000
|
this.force_chunk_until = game.tick + 1000
|
||||||
|
|
||||||
|
Public.increase_enemy_damage_and_health()
|
||||||
|
|
||||||
Server.set_data(dataset, dataset_key, settings)
|
Server.set_data(dataset, dataset_key, settings)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -635,6 +635,10 @@ function Public.move_all_players()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local surface = market.surface
|
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)
|
local spawn_pos = surface.find_non_colliding_position('character', market.position, 3, 0, 5)
|
||||||
|
|
||||||
if spawn_pos then
|
if spawn_pos then
|
||||||
@ -727,10 +731,12 @@ end
|
|||||||
|
|
||||||
function Public.increase_enemy_damage_and_health()
|
function Public.increase_enemy_damage_and_health()
|
||||||
if this.rounds_survived == 1 then
|
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
|
else
|
||||||
for _ = 1, this.rounds_survived do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,13 @@ local Event = require 'utils.event'
|
|||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
players = {},
|
players = {},
|
||||||
traps = {}
|
traps = {},
|
||||||
|
scheduler = {
|
||||||
|
start_after = 0,
|
||||||
|
surface = nil,
|
||||||
|
operation = nil,
|
||||||
|
next_operation = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
local Public = {}
|
local Public = {}
|
||||||
local random = math.random
|
local random = math.random
|
||||||
@ -269,11 +275,6 @@ function Public.reset_main_table()
|
|||||||
rocks_yield_ore_distance_modifier = 0.020
|
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
|
for k, _ in pairs(this.players) do
|
||||||
this.players[k] = {}
|
this.players[k] = {}
|
||||||
end
|
end
|
||||||
|
@ -387,7 +387,6 @@ local function on_init()
|
|||||||
this.settings.frenzy_burst_length = 160
|
this.settings.frenzy_burst_length = 160
|
||||||
this.settings.update_rate = 120
|
this.settings.update_rate = 120
|
||||||
this.target_settings = {}
|
this.target_settings = {}
|
||||||
|
|
||||||
set_forces()
|
set_forces()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -564,13 +564,13 @@ local function spawn_biter(surface, position, forceSpawn, is_boss_biter, unit_se
|
|||||||
return biter
|
return biter
|
||||||
end
|
end
|
||||||
|
|
||||||
local function increase_biter_damage()
|
local function increase_biter_damage(force)
|
||||||
local increase_damage_per_wave = Public.get('increase_damage_per_wave')
|
local increase_damage_per_wave = Public.get('increase_damage_per_wave')
|
||||||
if not increase_damage_per_wave then
|
if not increase_damage_per_wave then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local e = game.forces.enemy
|
local e = force or game.forces.enemy
|
||||||
local new = Difficulty.get('value') * 0.04
|
local new = Difficulty.get('value') * 0.04
|
||||||
local melee = new
|
local melee = new
|
||||||
local bio = new - 0.02
|
local bio = new - 0.02
|
||||||
@ -1302,8 +1302,12 @@ Event.on_nth_tick(
|
|||||||
|
|
||||||
Event.add(
|
Event.add(
|
||||||
Public.events.on_biters_evolved,
|
Public.events.on_biters_evolved,
|
||||||
function()
|
function(event)
|
||||||
increase_biter_damage()
|
if not event then
|
||||||
|
event = {force = game.forces.enemy}
|
||||||
|
end
|
||||||
|
|
||||||
|
increase_biter_damage(event.force)
|
||||||
increase_biters_health()
|
increase_biters_health()
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user