1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00

Fixes to scenario and modules

This commit is contained in:
Gerkiz 2023-04-18 22:38:03 +02:00
parent 25728dc278
commit 65944ecc31
8 changed files with 67 additions and 21 deletions

View File

@ -903,6 +903,8 @@ function Public.set_difficulty()
amount = difficulty.highest -- lowered from 20 to 10
end
local wave = WD.get('wave_number')
local threat_check = nil
if check_if_threat_below_zero then
@ -910,26 +912,27 @@ function Public.set_difficulty()
end
if Diff.index == 1 then
if player_count < 10 then
if wave < 1000 then
wave_defense_table.wave_interval = 4500
else
wave_defense_table.wave_interval = 3600 - player_count * 60
end
if wave_defense_table.wave_interval < 2200 or threat_check then
wave_defense_table.wave_interval = 2200
if wave_defense_table.wave_interval < 2000 or threat_check then
wave_defense_table.wave_interval = 2000
end
elseif Diff.index == 2 then
if player_count < 10 then
if wave < 1000 then
wave_defense_table.wave_interval = 3000
else
wave_defense_table.wave_interval = 2600 - player_count * 60
end
if wave_defense_table.wave_interval < 1900 or threat_check then
wave_defense_table.wave_interval = 1900
if wave_defense_table.wave_interval < 1800 or threat_check then
wave_defense_table.wave_interval = 1800
end
elseif Diff.index == 3 then
if player_count < 10 then
wave_defense_table.wave_interval = 2000
if wave < 1000 then
wave_defense_table.wave_interval = 3000
else
wave_defense_table.wave_interval = 1600 - player_count * 60
end

View File

@ -273,6 +273,7 @@ function Public.reset_map()
end
game.forces.player.set_spawn_position({-27, 25}, surface)
game.speed = 1
Task.set_queue_speed(16)

View File

@ -158,12 +158,15 @@ local function is_position_near(area, table_to_check)
end
local function place_wagon(data, adjusted_zones)
local x_min = (-zone_settings.zone_width / 2) + 10
local x_max = (zone_settings.zone_width / 2) - 10
local x_min = -zone_settings.zone_width / 2
local x_max = zone_settings.zone_width / 2
if data.x < x_min then return end
if data.x > x_max then return end
if data.x < x_min then
return
end
if data.x > x_max then
return
end
local placed_trains_in_zone = Public.get('placed_trains_in_zone')
if not placed_trains_in_zone.randomized then

View File

@ -606,6 +606,30 @@ spells[#spells + 1] = {
return create_projectiles(data)
end
}
if _DEBUG then
spells[#spells + 1] = {
name = 'Kewl Nade',
entityName = 'cluster-grenade',
target = true,
amount = 20,
damage = true,
aoe = true,
force = 'player',
level = 1,
type = 'item',
mana_cost = -1,
cooldown = 0,
enabled = true,
log_spell = false,
sprite = 'recipe/cluster-grenade',
tooltip = 'Spawns a cluster nade where the mouse cursor is at',
callback = function(data)
local player = data.player
player.insert({name = 'raw-fish'})
return create_projectiles(data)
end
}
end
spells[#spells + 1] = {
name = {'item-name.cluster-grenade'},
entityName = 'cluster-grenade',

View File

@ -149,8 +149,9 @@ function Public.toggle_pause_wave_without_votes()
end
Public.set('pause_waves', {index = 0})
local pause_wave_in_ticks = Public.get('pause_wave_in_ticks')
pause_waves_state(true)
Task.set_timeout_in_ticks(18000, pause_waves_state_token, false) -- 5 minutes
Task.set_timeout_in_ticks(pause_wave_in_ticks, pause_waves_state_token, false) -- 5 minutes
end
Gui.on_click(

View File

@ -54,6 +54,7 @@ function Public.reset_wave_defense()
this.log_wave_to_discord = true
this.paused = false
this.pause_without_votes = true
this.pause_wave_in_ticks = 18000 -- 5 minutes
this.game_lost = false
this.get_random_close_spawner_attempts = 5
this.group_size = 2
@ -377,6 +378,12 @@ function Public.set_tick_to_spawn_unit_groups(int)
this.tick_to_spawn_unit_groups = int or 200
end
--- Sets the pause length in ticks.
-- @param <int> in ticks
function Public.set_pause_wave_in_ticks(int)
this.pause_wave_in_ticks = int or 18000
end
--- Pauses the wave defense module
-- @param null
function Public.pause(boolean)

View File

@ -200,7 +200,7 @@ local functions = {
['vacant_toggle'] = function(event)
local vacant = is_loaded('modules.clear_vacant_players')
if not vacant then
log("Error: toggle related to clear_vacant_players was activated, but the module does not seem to be loaded.")
log('Error: toggle related to clear_vacant_players was activated, but the module does not seem to be loaded.')
return
end
@ -844,11 +844,11 @@ local function on_gui_switch_state_changed(event)
pirates_functions[event.element.name](event)
return
elseif is_loaded('utils.gui.poll') then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
if is_spamming then
return
end
if poll_function[event.element.name] then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
if is_spamming then
return
end
poll_function[event.element.name](event)
return
end

View File

@ -22,14 +22,14 @@ local function debug_text(str)
if not this.debug_text then
return
end
print(main_text .. str)
log(main_text .. str)
end
local function debug_spam(str)
if not this.debug_spam then
return
end
print(main_text .. str)
log(main_text .. str)
end
function Public.reset_spam_table()
@ -64,6 +64,10 @@ function Public.is_spamming(player, value_to_compare, text)
return false -- game is paused - shoo
end
if this.debug_spam then
log(serpent.block(debug.traceback()))
end
local tick = game.tick
local value = value_to_compare or this.default_tick
if this.prevent_spam[player.index] then
@ -105,6 +109,9 @@ Event.add(
defines.events.on_player_joined_game,
function(event)
local player = game.get_player(event.player_index)
if not player then
return
end
if not this.prevent_spam[player.index] then
this.prevent_spam[player.index] = game.tick