1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-29 21:47:08 +02:00

Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
danielmartin0 2022-05-23 01:17:05 +01:00
commit a337c2ffcc
22 changed files with 453 additions and 294 deletions

@ -27,6 +27,7 @@ require 'modules.floaty_chat'
require 'modules.show_inventory' require 'modules.show_inventory'
require 'modules.inserter_drops_pickup' require 'modules.inserter_drops_pickup'
require 'modules.autostash' require 'modules.autostash'
require 'modules.blueprint_requesting'
require 'utils.gui' require 'utils.gui'
require 'utils.gui.player_list' require 'utils.gui.player_list'

@ -21,6 +21,10 @@ turret_filler_label_amount=Amount:
turret_filler_ammo_type=Select Ammo: turret_filler_ammo_type=Select Ammo:
turret_filler_ammo_lower=Enable lower tiers? turret_filler_ammo_lower=Enable lower tiers?
blueprint_requesting=Blueprint Requesting
blueprint_requesting_desc=Placing blueprints into [entity=logistic-chest-requester] or [entity=logistic-chest-buffer] will set the chest requests to match the blueprint costs. Happens when chest is closed.
blueprint_requesting_notify=This server has Blueprint Requesting feature enabled. Placing blueprints into [entity=logistic-chest-requester] or [entity=logistic-chest-buffer] will match the requests to the blueprint costs. You can disable this feature for yourself in Comfy menu -> Config.
[modules_towny] [modules_towny]
map_info=__1__\n\n__2__\n\n__3__\n\n__4__\n\n__5__ map_info=__1__\n\n__2__\n\n__3__\n\n__4__\n\n__5__
map_info1=To ally or settle with another town, drop a fish on their market or character. (Default Hotkey Z)\nThey will have to do the same to you to complete the request.\nCoal yields the opposite result, as it will make foes or banish settlers. map_info1=To ally or settle with another town, drop a fish on their market or character. (Default Hotkey Z)\nThey will have to do the same to you to complete the request.\nCoal yields the opposite result, as it will make foes or banish settlers.

@ -192,7 +192,7 @@ function Public.reset_map()
Collapse.set_speed(8) Collapse.set_speed(8)
Collapse.set_amount(1) Collapse.set_amount(1)
Collapse.set_max_line_size(level_depth) Collapse.set_max_line_size(level_depth)
Collapse.set_surface(surface) Collapse.set_surface_index(surface.index)
Collapse.set_position({0, 130}) Collapse.set_position({0, 130})
Collapse.set_direction('north') Collapse.set_direction('north')

@ -1,17 +1,15 @@
local Event = require 'utils.event' local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
local BiterRolls = require 'modules.wave_defense.biter_rolls'
local BiterHealthBooster = require 'modules.biter_health_booster_v2' local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local WD = require 'modules.wave_defense.table' local WD = require 'modules.wave_defense.table'
local WPT = require 'maps.mountain_fortress_v3.table' local WPT = require 'maps.mountain_fortress_v3.table'
local Diff = require 'modules.difficulty_vote_by_amount'
local traps = {} local this = {}
Global.register( Global.register(
traps, this,
function(t) function(t)
traps = t this = t
end end
) )
@ -59,41 +57,10 @@ local function create_particles(data)
end end
end end
local function trigger_health()
local wave_number = WD.get('wave_number')
local d = Diff.get()
local m = 0.0015
if d.difficulty_vote_index then
if not d.strength_modifier then
m = m * 1.05
else
m = m * d.strength_modifier
end
end
local boosted_health = 1.25
if wave_number <= 10 then
wave_number = 10
end
boosted_health = boosted_health * (wave_number * 0.02)
local sum = boosted_health * 5
sum = sum + m
if sum >= 100 then
sum = 100
end
return sum
end
local function spawn_biters(data) local function spawn_biters(data)
local surface = data.surface local surface = data.surface
if not (surface and surface.valid) then if not (surface and surface.valid) then
return return false
end end
local position = data.position local position = data.position
local h = floor(abs(position.y)) local h = floor(abs(position.y))
@ -101,58 +68,66 @@ local function spawn_biters(data)
local max_biters = WPT.get('biters') local max_biters = WPT.get('biters')
if max_biters.amount >= max_biters.limit then if max_biters.amount >= max_biters.limit then
return return false
end end
if not position then if not position then
position = surface.find_non_colliding_position('small-biter', position, 10, 1) position = surface.find_non_colliding_position('small-biter', position, 10, 1)
if not position then if not position then
return return false
end end
end end
BiterRolls.wave_defense_set_unit_raffle(h * 0.20) local unit_to_create
local unit
if random(1, 3) == 1 then if random(1, 3) == 1 then
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = position}) unit_to_create = WD.wave_defense_roll_spitter_name()
max_biters.amount = max_biters.amount + 1
else else
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position}) unit_to_create = WD.wave_defense_roll_biter_name()
max_biters.amount = max_biters.amount + 1
end end
if random(1, 45) == 1 then local modified_unit_health = WD.get('modified_unit_health')
local sum = trigger_health() local modified_boss_unit_health = WD.get('modified_boss_unit_health')
BiterHealthBooster.add_unit(unit, sum)
elseif random(1, 64) == 1 then WD.wave_defense_set_unit_raffle(h * 0.20)
local sum = trigger_health()
BiterHealthBooster.add_boss_unit(unit, sum, 0.38) local unit = surface.create_entity({name = unit_to_create, position = position})
max_biters.amount = max_biters.amount + 1
if random(1, 30) == 1 then
BiterHealthBooster.add_boss_unit(unit, modified_boss_unit_health.current_value, 0.38)
else
BiterHealthBooster.add_unit(unit, modified_unit_health.current_value)
end end
return true
end end
local function spawn_worms(data) local function spawn_worms(data)
local modified_unit_health = WD.get('modified_unit_health')
local modified_boss_unit_health = WD.get('modified_boss_unit_health')
local max_biters = WPT.get('biters') local max_biters = WPT.get('biters')
if max_biters.amount >= max_biters.limit then if max_biters.amount >= max_biters.limit then
return return
end end
local unit_to_create = WD.wave_defense_roll_worm_name()
local surface = data.surface local surface = data.surface
if not (surface and surface.valid) then if not (surface and surface.valid) then
return return
end end
local position = data.position local position = data.position
BiterRolls.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
local unit = surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position}) WD.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
local unit = surface.create_entity({name = unit_to_create, position = position})
max_biters.amount = max_biters.amount + 1 max_biters.amount = max_biters.amount + 1
if random(1, 45) == 1 then if random(1, 30) == 1 then
local sum = trigger_health() BiterHealthBooster.add_boss_unit(unit, modified_boss_unit_health.current_value, 0.38)
BiterHealthBooster.add_unit(unit, sum) else
elseif random(1, 64) == 1 then BiterHealthBooster.add_unit(unit, modified_unit_health.current_value)
local sum = trigger_health()
BiterHealthBooster.add_boss_unit(unit, sum, 0.38)
end end
end end
@ -171,17 +146,17 @@ function Public.buried_biter(surface, position)
end end
for t = 1, 60, 1 do for t = 1, 60, 1 do
if not traps[game.tick + t] then if not this[game.tick + t] then
traps[game.tick + t] = {} this[game.tick + t] = {}
end end
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'create_particles', callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = math.ceil(t * 0.05)} data = {surface = surface, position = {x = position.x, y = position.y}, amount = math.ceil(t * 0.05)}
} }
if t == 60 then if t == 60 then
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'spawn_biters', callback = 'spawn_biters',
data = {surface = surface, position = {x = position.x, y = position.y}} data = {surface = surface, position = {x = position.x, y = position.y}}
} }
@ -204,17 +179,17 @@ function Public.buried_worm(surface, position)
end end
for t = 1, 60, 1 do for t = 1, 60, 1 do
if not traps[game.tick + t] then if not this[game.tick + t] then
traps[game.tick + t] = {} this[game.tick + t] = {}
end end
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'create_particles', callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = math.ceil(t * 0.05)} data = {surface = surface, position = {x = position.x, y = position.y}, amount = math.ceil(t * 0.05)}
} }
if t == 60 then if t == 60 then
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'spawn_worms', callback = 'spawn_worms',
data = {surface = surface, position = {x = position.x, y = position.y}} data = {surface = surface, position = {x = position.x, y = position.y}}
} }
@ -230,10 +205,10 @@ local callbacks = {
local function on_tick() local function on_tick()
local t = game.tick local t = game.tick
if not traps[t] then if not this[t] then
return return
end end
for _, token in pairs(traps[t]) do for _, token in pairs(this[t]) do
local callback = token.callback local callback = token.callback
local data = token.data local data = token.data
local cbl = callbacks[callback] local cbl = callbacks[callback]
@ -241,12 +216,12 @@ local function on_tick()
cbl(data) cbl(data)
end end
end end
traps[t] = nil this[t] = nil
end end
function Public.reset() function Public.reset()
for k, _ in pairs(traps) do for k, _ in pairs(this) do
traps[k] = nil this[k] = nil
end end
end end

@ -351,9 +351,13 @@ end
local function hidden_treasure(player, entity) local function hidden_treasure(player, entity)
local rpg = RPG.get_value_from_player(player.index) local rpg = RPG.get_value_from_player(player.index)
if not rpg then
return
end
local magic = rpg.magicka local magic = rpg.magicka
if magic > 50 then if magic >= 50 then
local msg = rare_treasure_chest_messages[random(1, #rare_treasure_chest_messages)] local msg = rare_treasure_chest_messages[random(1, #rare_treasure_chest_messages)]
Alert.alert_player(player, 5, msg) Alert.alert_player(player, 5, msg)
Loot.add_rare(entity.surface, entity.position, 'wooden-chest', magic) Loot.add_rare(entity.surface, entity.position, 'wooden-chest', magic)

@ -8,6 +8,7 @@ local Global = require 'utils.global'
local Alert = require 'utils.alert' local Alert = require 'utils.alert'
local WPT = require 'maps.mountain_fortress_v3.table' local WPT = require 'maps.mountain_fortress_v3.table'
local WD = require 'modules.wave_defense.table' local WD = require 'modules.wave_defense.table'
local RPG = require 'modules.rpg.main'
local Collapse = require 'modules.collapse' local Collapse = require 'modules.collapse'
local Difficulty = require 'modules.difficulty_vote_by_amount' local Difficulty = require 'modules.difficulty_vote_by_amount'
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions' local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
@ -818,6 +819,8 @@ local retry_final_boost_movement_speed_on_respawn =
end end
player.character.character_running_speed_modifier = old_speed player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info) player.print('Movement speed bonus removed!', Color.info)
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = nil
end end
) )
@ -835,6 +838,8 @@ local retry_boost_movement_speed_on_respawn =
end end
player.character.character_running_speed_modifier = old_speed player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info) player.print('Movement speed bonus removed!', Color.info)
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = nil
end end
) )
@ -852,6 +857,8 @@ local remove_boost_movement_speed_on_respawn =
end end
player.character.character_running_speed_modifier = old_speed player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info) player.print('Movement speed bonus removed!', Color.info)
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = nil
end end
) )
@ -866,6 +873,9 @@ local boost_movement_speed_on_respawn =
return return
end end
local rpg_t = RPG.get_value_from_player(player.index)
rpg_t.has_custom_spell_active = true
local old_speed = player.character_running_speed_modifier local old_speed = player.character_running_speed_modifier
local new_speed = player.character_running_speed_modifier + 1 local new_speed = player.character_running_speed_modifier + 1

@ -27,6 +27,12 @@ local clear_items_upon_surface_entry = {
['substation'] = true ['substation'] = true
} }
local valid_armors = {
['modular-armor'] = true,
['power-armor'] = true,
['power-armor-mk2'] = true
}
local function add_random_loot_to_main_market(rarity) local function add_random_loot_to_main_market(rarity)
local main_market_items = WPT.get('main_market_items') local main_market_items = WPT.get('main_market_items')
local items = Market.get_random_item(rarity, true, false) local items = Market.get_random_item(rarity, true, false)
@ -247,6 +253,34 @@ local function set_carriages()
WPT.set('carriages', locomotive.train.carriages) WPT.set('carriages', locomotive.train.carriages)
end end
local function get_driver_action(entity)
if not entity or not entity.valid then
return
end
local driver = entity.get_driver()
if not driver or not driver.valid then
return
end
local player = driver.player
if not player or not player.valid then
return
end
if player.cursor_stack and player.cursor_stack.valid_for_read and player.cursor_stack.name == 'raw-fish' then
player.print('[color=blue][Locomotive][/color] Unequip your fishy if you want to drive.')
driver.driving = false
return
end
local armor = driver.get_inventory(defines.inventory.character_armor)
if armor and armor[1] and armor[1].valid_for_read and valid_armors[armor[1].name] then
player.print('[color=blue][Locomotive][/color] Unequip your armor if you want to drive.')
driver.driving = false
end
end
local function set_locomotive_health() local function set_locomotive_health()
local locomotive_health = WPT.get('locomotive_health') local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health') local locomotive_max_health = WPT.get('locomotive_max_health')
@ -265,6 +299,7 @@ local function set_locomotive_health()
if not (entity and entity.valid) then if not (entity and entity.valid) then
return return
end end
get_driver_action(entity)
local cargo_health = 600 local cargo_health = 600
if entity.type == 'locomotive' then if entity.type == 'locomotive' then
entity.health = 1000 * m entity.health = 1000 * m

@ -82,7 +82,7 @@ local collapse_kill = {
['flamethrower-turret'] = true, ['flamethrower-turret'] = true,
['gun-turret'] = true, ['gun-turret'] = true,
['artillery-turret'] = true, ['artillery-turret'] = true,
['landmine'] = true, ['land-mine'] = true,
['locomotive'] = true, ['locomotive'] = true,
['cargo-wagon'] = true, ['cargo-wagon'] = true,
['character'] = true, ['character'] = true,
@ -253,7 +253,7 @@ function Public.reset_map()
Collapse.set_amount(1) Collapse.set_amount(1)
-- Collapse.set_max_line_size(zone_settings.zone_width) -- Collapse.set_max_line_size(zone_settings.zone_width)
Collapse.set_max_line_size(540) Collapse.set_max_line_size(540)
Collapse.set_surface(surface) Collapse.set_surface_index(surface.index)
Collapse.set_position({0, 130}) Collapse.set_position({0, 130})
Collapse.set_direction('north') Collapse.set_direction('north')
Collapse.start_now(false) Collapse.start_now(false)

@ -14,6 +14,15 @@ local ceil = math.ceil
local zone_settings = WPT.zone_settings local zone_settings = WPT.zone_settings
local worm_level_modifier = 0.19 local worm_level_modifier = 0.19
local start_ground_tiles = {
'sand-1',
'dirt-1',
'dirt-2',
'sand-2',
'dirt-3',
'sand-3'
}
local wagon_raffle = { local wagon_raffle = {
'cargo-wagon', 'cargo-wagon',
'cargo-wagon', 'cargo-wagon',
@ -2624,7 +2633,7 @@ end
local function border_chunk(p, data) local function border_chunk(p, data)
local entities = data.entities local entities = data.entities
local decoratives = data.decoratives local decoratives = data.decoratives
-- local tiles = data.tiles local tiles = data.tiles
local pos = p local pos = p
@ -2632,9 +2641,9 @@ local function border_chunk(p, data)
entities[#entities + 1] = {name = trees[random(1, #trees)], position = pos} entities[#entities + 1] = {name = trees[random(1, #trees)], position = pos}
end end
-- local noise = get_perlin('dungeons', pos, data.seed) local noise = get_perlin('dungeons', pos, data.seed)
-- local index = floor(noise * 32) % 4 + 1 local index = floor(noise * 32) % 4 + 1
-- tiles[#tiles + 1] = {name = start_ground_tiles[index], position = pos} tiles[#tiles + 1] = {name = start_ground_tiles[index], position = pos}
local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities() local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities()

@ -136,9 +136,10 @@ local function init(mountain_race)
Collapse.set_speed(8) Collapse.set_speed(8)
Collapse.set_amount(0) Collapse.set_amount(0)
Collapse.set_max_line_size(mountain_race.border_width + mountain_race.playfield_height * 2) Collapse.set_max_line_size(mountain_race.border_width + mountain_race.playfield_height * 2)
Collapse.set_surface(surface) Collapse.set_surface_index(surface.index)
Collapse.set_position({0, 0}) Collapse.set_position({0, 0})
Collapse.set_direction('east') Collapse.set_direction('east')
Collapse.start_now(true)
game.reset_time_played() game.reset_time_played()

@ -157,7 +157,7 @@ local function create_entity_radius(surface, name, source, target)
local position = {source.x, source.y} local position = {source.x, source.y}
for i = 1, distance * 1.5, 1 do for _ = 1, distance * 1.5, 1 do
if random(1, 2) ~= 1 then if random(1, 2) ~= 1 then
surface.create_entity( surface.create_entity(
{ {
@ -401,7 +401,7 @@ local function on_entity_died(event)
end end
--- Use this function to retrieve a key from the global table. --- Use this function to retrieve a key from the global table.
---@param key <string> ---@param key string
function Public.get(key) function Public.get(key)
if key then if key then
return this[key] return this[key]
@ -411,8 +411,8 @@ function Public.get(key)
end end
--- Using this function can set a new value to an exist key or create a new key with value --- Using this function can set a new value to an exist key or create a new key with value
---@param key <string> ---@param key string
---@param value <string/boolean> ---@param value any
function Public.set(key, value) function Public.set(key, value)
if key and (value or value == false) then if key and (value or value == false) then
this[key] = value this[key] = value
@ -442,8 +442,8 @@ function Public.reset_table()
end end
--- Use this function to add a new unit that has extra health --- Use this function to add a new unit that has extra health
---@param unit <LuaEntity> ---@param unit userdata
---@param health_multiplier <number> ---@param health_multiplier number
function Public.add_unit(unit, health_multiplier) function Public.add_unit(unit, health_multiplier)
if not health_multiplier then if not health_multiplier then
health_multiplier = this.biter_health_boost health_multiplier = this.biter_health_boost
@ -460,9 +460,9 @@ function Public.add_unit(unit, health_multiplier)
end end
--- Use this function to add a new boss unit (with healthbar) --- Use this function to add a new boss unit (with healthbar)
---@param unit <LuaEntity> ---@param unit userdata
---@param health_multiplier <number> ---@param health_multiplier number
---@param health_bar_size <number> ---@param health_bar_size number
function Public.add_boss_unit(unit, health_multiplier, health_bar_size) function Public.add_boss_unit(unit, health_multiplier, health_bar_size)
if not health_multiplier then if not health_multiplier then
health_multiplier = this.biter_health_boost health_multiplier = this.biter_health_boost
@ -483,7 +483,7 @@ end
--- This sets the active surface that we check and have the script active. --- This sets the active surface that we check and have the script active.
--- This deletes the list of surfaces if we use multiple, so use it only before setting more of them. --- This deletes the list of surfaces if we use multiple, so use it only before setting more of them.
---@param string ---@param str string
function Public.set_active_surface(str) function Public.set_active_surface(str)
if str and type(str) == 'string' then if str and type(str) == 'string' then
this.active_surfaces = {} this.active_surfaces = {}
@ -493,7 +493,8 @@ function Public.set_active_surface(str)
end end
--- This sets if this surface is active, when we using multiple surfaces. The default active surface does not need to be added again --- This sets if this surface is active, when we using multiple surfaces. The default active surface does not need to be added again
---@param string, boolean ---@param name string
---@param value boolean
function Public.set_surface_activity(name, value) function Public.set_surface_activity(name, value)
if name and type(name) == 'string' and type(value) == 'boolean' then if name and type(name) == 'string' and type(value) == 'boolean' then
this.active_surfaces[name] = value this.active_surfaces[name] = value

@ -0,0 +1,63 @@
--module by Hanakocz
local Event = require 'utils.event'
local Global = require 'utils.global'
local Public = {}
local this = {}
Global.register(
this,
function(tbl)
this = tbl
end
)
local function on_gui_closed(event)
local player_index = event.player_index
if this[player_index] and this[player_index].disabled then return end -- player disabled usage of this module in config tab for his actions
local entity = event.entity
if not entity or not entity.valid then return end
if entity.name == 'logistic-chest-requester' or entity.name == 'logistic-chest-buffer' then
if not this[player_index] or not this[player_index].notified then
local player = game.get_player(player_index)
player.print({'modules.blueprint_requesting_notify'}, {r= 0.88, g = 0.66, b = 0.02})
this[player_index] = this[player_index] or {}
this[player_index].notified = true
end
local inventory = entity.get_inventory(defines.inventory.chest)
if not inventory or not inventory.valid then return end
if inventory.get_item_count('blueprint') > 0 then
local items = {}
for i = 1, #inventory, 1 do
if inventory[i].valid_for_read and inventory[i].is_blueprint then
local cost = inventory[i].cost_to_build
for name, amount in pairs(cost) do
items[name] = (items[name] or 0) + amount
end
end
end
if entity.request_slot_count > 0 then
for slot = 1, entity.request_slot_count, 1 do
entity.clear_request_slot(slot)
end
end
local slot_index = 1
for item, amount in pairs(items) do
entity.set_request_slot({name = item, count = amount}, slot_index)
slot_index = slot_index + 1
end
end
end
end
function Public.get(key)
if key then
return this[key]
else
return this
end
end
Event.add(defines.events.on_gui_closed, on_gui_closed)
return Public

@ -1,60 +1,97 @@
local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
local Public = {} local Public = {}
local math_floor = math.floor local math_floor = math.floor
local table_shuffle_table = table.shuffle_table local table_shuffle_table = table.shuffle_table
local collapse = { local this = {
debug = false debug = false
} }
Global.register( Global.register(
collapse, this,
function(tbl) function(tbl)
collapse = tbl this = tbl
end end
) )
local directions = { local directions = {
['north'] = function(position) ['north'] = function(position)
local width = collapse.surface.map_gen_settings.width local surface_index = this.surface_index
if width > collapse.max_line_size then if not surface_index then
width = collapse.max_line_size return
end
local surface = game.get_surface(surface_index)
if not surface.valid then
return
end
local width = surface.map_gen_settings.width
if width > this.max_line_size then
width = this.max_line_size
end end
local a = width * 0.5 + 1 local a = width * 0.5 + 1
collapse.vector = {0, -1} this.vector = {0, -1}
collapse.area = {{position.x - a, position.y - 1}, {position.x + a, position.y}} this.area = {{position.x - a, position.y - 1}, {position.x + a, position.y}}
end, end,
['south'] = function(position) ['south'] = function(position)
local width = collapse.surface.map_gen_settings.width local surface_index = this.surface_index
if width > collapse.max_line_size then if not surface_index then
width = collapse.max_line_size return
end
local surface = game.get_surface(surface_index)
if not surface.valid then
return
end
local width = surface.map_gen_settings.width
if width > this.max_line_size then
width = this.max_line_size
end end
local a = width * 0.5 + 1 local a = width * 0.5 + 1
collapse.vector = {0, 1} this.vector = {0, 1}
collapse.area = {{position.x - a, position.y}, {position.x + a, position.y + 1}} this.area = {{position.x - a, position.y}, {position.x + a, position.y + 1}}
end, end,
['west'] = function(position) ['west'] = function(position)
local width = collapse.surface.map_gen_settings.height local surface_index = this.surface_index
if width > collapse.max_line_size then if not surface_index then
width = collapse.max_line_size return
end
local surface = game.get_surface(surface_index)
if not surface.valid then
return
end
local width = surface.map_gen_settings.height
if width > this.max_line_size then
width = this.max_line_size
end end
local a = width * 0.5 + 1 local a = width * 0.5 + 1
collapse.vector = {-1, 0} this.vector = {-1, 0}
collapse.area = {{position.x - 1, position.y - a}, {position.x, position.y + a}} this.area = {{position.x - 1, position.y - a}, {position.x, position.y + a}}
end, end,
['east'] = function(position) ['east'] = function(position)
local width = collapse.surface.map_gen_settings.height local surface_index = this.surface_index
if width > collapse.max_line_size then if not surface_index then
width = collapse.max_line_size return
end
local surface = game.get_surface(surface_index)
if not surface.valid then
return
end
local width = surface.map_gen_settings.height
if width > this.max_line_size then
width = this.max_line_size
end end
local a = width * 0.5 + 1 local a = width * 0.5 + 1
collapse.vector = {1, 0} this.vector = {1, 0}
collapse.area = {{position.x, position.y - a}, {position.x + 1, position.y + a}} this.area = {{position.x, position.y - a}, {position.x + 1, position.y + a}}
end end
} }
local function print_debug(a) local function print_debug(a)
if not collapse.debug then if not this.debug then
return return
end end
print('Collapse error #' .. a) print('Collapse error #' .. a)
@ -64,52 +101,60 @@ local function set_collapse_tiles(surface)
if not surface or surface.valid then if not surface or surface.valid then
print_debug(45) print_debug(45)
end end
game.forces.player.chart(surface, collapse.area) game.forces.player.chart(surface, this.area)
collapse.tiles = surface.find_tiles_filtered({area = collapse.area}) this.tiles = surface.find_tiles_filtered({area = this.area})
if not collapse.tiles then if not this.tiles then
return return
end end
collapse.size_of_tiles = #collapse.tiles this.size_of_tiles = #this.tiles
if collapse.size_of_tiles > 0 then if this.size_of_tiles > 0 then
table_shuffle_table(collapse.tiles) table_shuffle_table(this.tiles)
end end
collapse.position = {x = collapse.position.x + collapse.vector[1], y = collapse.position.y + collapse.vector[2]} this.position = {x = this.position.x + this.vector[1], y = this.position.y + this.vector[2]}
local v = collapse.vector local v = this.vector
local area = collapse.area local area = this.area
collapse.area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}} this.area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}}
game.forces.player.chart(surface, collapse.area) game.forces.player.chart(surface, this.area)
end end
local function progress() local function progress()
local surface = collapse.surface local surface_index = this.surface_index
if not surface_index then
if not collapse.start_now then
collapse.tiles = nil
return return
end end
local tiles = collapse.tiles local surface = game.get_surface(surface_index)
if not surface.valid then
return
end
if not this.start_now then
this.tiles = nil
return
end
local tiles = this.tiles
if not tiles then if not tiles then
set_collapse_tiles(surface) set_collapse_tiles(surface)
tiles = collapse.tiles tiles = this.tiles
end end
if not tiles then if not tiles then
return return
end end
for _ = 1, collapse.amount, 1 do for _ = 1, this.amount, 1 do
local tile = tiles[collapse.size_of_tiles] local tile = tiles[this.size_of_tiles]
if not tile then if not tile then
collapse.tiles = nil this.tiles = nil
return return
end end
collapse.size_of_tiles = collapse.size_of_tiles - 1 this.size_of_tiles = this.size_of_tiles - 1
if not tile.valid then if not tile.valid then
return return
end end
if collapse.specific_entities.enabled then if this.specific_entities.enabled then
local position = {tile.position.x + 0.5, tile.position.y + 0.5} local position = {tile.position.x + 0.5, tile.position.y + 0.5}
local entities = collapse.specific_entities.entities local entities = this.specific_entities.entities
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do
if entities[e.name] and e.valid and e.health then if entities[e.name] and e.valid and e.health then
e.die() e.die()
@ -118,7 +163,7 @@ local function progress()
end end
end end
end end
if collapse.kill then if this.kill then
local position = {tile.position.x + 0.5, tile.position.y + 0.5} local position = {tile.position.x + 0.5, tile.position.y + 0.5}
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do
if e.valid and e.health then if e.valid and e.health then
@ -130,20 +175,19 @@ local function progress()
end end
end end
function Public.set_surface(surface) function Public.set_surface_index(surface_index)
if not surface then if not surface_index then
print_debug(1) print_debug(1)
return return
end end
local surface = game.get_surface(surface_index)
if not surface.valid then if not surface.valid then
print_debug(2) print_debug(2)
return return
end end
if not game.surfaces[surface.index] then
print_debug(3) this.surface_index = surface_index
return
end
collapse.surface = surface
end end
function Public.set_direction(direction) function Public.set_direction(direction)
@ -151,7 +195,7 @@ function Public.set_direction(direction)
print_debug(11) print_debug(11)
return return
end end
directions[direction](collapse.position) directions[direction](this.position)
end end
function Public.set_speed(speed) function Public.set_speed(speed)
@ -163,7 +207,7 @@ function Public.set_speed(speed)
if speed < 1 then if speed < 1 then
speed = 1 speed = 1
end end
collapse.speed = speed this.speed = speed
end end
function Public.set_amount(amount) function Public.set_amount(amount)
@ -175,7 +219,7 @@ function Public.set_amount(amount)
if amount < 0 then if amount < 0 then
amount = 0 amount = 0
end end
collapse.amount = amount this.amount = amount
end end
function Public.set_position(position) function Public.set_position(position)
@ -205,28 +249,28 @@ function Public.set_position(position)
if position.y then if position.y then
y = position.y y = position.y
end end
collapse.position = {x = x, y = y} this.position = {x = x, y = y}
end end
function Public.get_position() function Public.get_position()
return collapse.position return this.position
end end
function Public.get_amount() function Public.get_amount()
return collapse.amount return this.amount
end end
function Public.get_speed() function Public.get_speed()
return collapse.speed return this.speed
end end
function Public.start_now(status) function Public.start_now(status)
if status == true then if status == true then
collapse.start_now = true this.start_now = true
elseif status == false then elseif status == false then
collapse.start_now = false this.start_now = false
end end
return collapse.start_now return this.start_now
end end
function Public.set_max_line_size(size) function Public.set_max_line_size(size)
@ -239,44 +283,45 @@ function Public.set_max_line_size(size)
print_debug(21) print_debug(21)
return return
end end
collapse.max_line_size = size this.max_line_size = size
end end
function Public.set_kill_entities(a) function Public.set_kill_entities(a)
collapse.kill = a this.kill = a
end end
function Public.set_kill_specific_entities(tbl) function Public.set_kill_specific_entities(tbl)
if tbl then if tbl then
collapse.specific_entities = tbl this.specific_entities = tbl
else else
collapse.specific_entities = { this.specific_entities = {
enabled = false enabled = false
} }
end end
end end
local function on_init() local function on_init()
Public.set_surface(game.surfaces.nauvis) Public.set_surface_index(game.surfaces.nauvis.index)
Public.set_position({0, 32}) Public.set_position({0, 32})
Public.set_max_line_size(256) Public.set_max_line_size(256)
Public.set_direction('north') Public.set_direction('north')
Public.set_kill_entities(true) Public.set_kill_entities(true)
Public.set_kill_specific_entities() Public.set_kill_specific_entities()
collapse.tiles = nil this.tiles = nil
collapse.speed = 1 this.speed = 1
collapse.amount = 8 this.amount = 8
collapse.start_now = true this.start_now = false
end end
local function on_tick() local function on_tick()
if game.tick % collapse.speed ~= 0 then local tick = game.tick
if tick % this.speed ~= 0 then
return return
end end
progress() progress()
end end
local Event = require 'utils.event'
Event.on_init(on_init) Event.on_init(on_init)
Event.add(defines.events.on_tick, on_tick) Event.add(defines.events.on_tick, on_tick)

@ -29,7 +29,7 @@ local function on_gui_click(event)
if not event then if not event then
return return
end end
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not (player and player.valid) then if not (player and player.valid) then
return return
end end
@ -369,6 +369,9 @@ local function regen_mana_player(players)
local mana_per_tick = Public.get_mana_modifier(player) local mana_per_tick = Public.get_mana_modifier(player)
local rpg_extra = Public.get('rpg_extra') local rpg_extra = Public.get('rpg_extra')
local rpg_t = Public.get_value_from_player(player.index) local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then
return
end
if mana_per_tick <= 0.1 then if mana_per_tick <= 0.1 then
mana_per_tick = rpg_extra.mana_per_tick mana_per_tick = rpg_extra.mana_per_tick
end end
@ -568,7 +571,7 @@ local function on_player_repaired_entity(event)
return return
end end
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid or not player.character then if not player or not player.valid or not player.character then
return return
@ -585,7 +588,7 @@ local function on_player_repaired_entity(event)
end end
local function on_player_rotated_entity(event) local function on_player_rotated_entity(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
@ -603,7 +606,7 @@ local function on_player_rotated_entity(event)
end end
local function on_player_changed_position(event) local function on_player_changed_position(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
end end
@ -627,7 +630,7 @@ local building_and_mining_blacklist = {
} }
local function on_player_died(event) local function on_player_died(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
@ -637,7 +640,7 @@ local function on_player_died(event)
end end
local function on_pre_player_left_game(event) local function on_pre_player_left_game(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
@ -657,7 +660,7 @@ local function on_pre_player_mined_item(event)
if entity.force.index ~= 3 then if entity.force.index ~= 3 then
return return
end end
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
@ -702,7 +705,7 @@ local function on_player_crafted_item(event)
if not event.recipe.energy then if not event.recipe.energy then
return return
end end
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
end end
@ -735,7 +738,7 @@ local function on_player_crafted_item(event)
end end
local function on_player_respawned(event) local function on_player_respawned(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
local rpg_t = Public.get_value_from_player(player.index) local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then if not rpg_t then
Public.rpg_reset_player(player) Public.rpg_reset_player(player)
@ -748,7 +751,7 @@ local function on_player_respawned(event)
end end
local function on_player_joined_game(event) local function on_player_joined_game(event)
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
local rpg_t = Public.get_value_from_player(player.index) local rpg_t = Public.get_value_from_player(player.index)
local rpg_extra = Public.get('rpg_extra') local rpg_extra = Public.get('rpg_extra')
if not rpg_t then if not rpg_t then
@ -851,7 +854,7 @@ local function on_player_used_capsule(event)
local conjure_items = Public.all_spells local conjure_items = Public.all_spells
local projectile_types = Public.get_projectiles local projectile_types = Public.get_projectiles
local player = game.players[event.player_index] local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
end end

@ -98,6 +98,10 @@ local restore_movement_speed_token =
return return
end end
if not player.character or not player.character.valid then
return
end
player.character.character_running_speed_modifier = old_speed player.character.character_running_speed_modifier = old_speed
end end
) )

@ -3,7 +3,7 @@ local Public = require 'modules.wave_defense.table'
function Public.wave_defense_roll_biter_name() function Public.wave_defense_roll_biter_name()
local biter_raffle = Public.get('biter_raffle') local biter_raffle = Public.get('biter_raffle')
local max_chance = 0 local max_chance = 0
for k, v in pairs(biter_raffle) do for _, v in pairs(biter_raffle) do
max_chance = max_chance + v max_chance = max_chance + v
end end
local r = math.random(0, math.floor(max_chance)) local r = math.random(0, math.floor(max_chance))
@ -19,7 +19,7 @@ end
function Public.wave_defense_roll_spitter_name() function Public.wave_defense_roll_spitter_name()
local spitter_raffle = Public.get('spitter_raffle') local spitter_raffle = Public.get('spitter_raffle')
local max_chance = 0 local max_chance = 0
for k, v in pairs(spitter_raffle) do for _, v in pairs(spitter_raffle) do
max_chance = max_chance + v max_chance = max_chance + v
end end
local r = math.random(0, math.floor(max_chance)) local r = math.random(0, math.floor(max_chance))
@ -80,7 +80,7 @@ end
function Public.wave_defense_roll_worm_name() function Public.wave_defense_roll_worm_name()
local worm_raffle = Public.get('worm_raffle') local worm_raffle = Public.get('worm_raffle')
local max_chance = 0 local max_chance = 0
for k, v in pairs(worm_raffle) do for _, v in pairs(worm_raffle) do
max_chance = max_chance + v max_chance = max_chance + v
end end
local r = math.random(0, math.floor(max_chance)) local r = math.random(0, math.floor(max_chance))

@ -2,14 +2,13 @@ local Public = require 'modules.wave_defense.table'
local Event = require 'utils.event' local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
local BiterHealthBooster = require 'modules.biter_health_booster_v2' local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Diff = require 'modules.difficulty_vote_by_amount'
local traps = {} local this = {}
Global.register( Global.register(
traps, this,
function(t) function(t)
traps = t this = t
end end
) )
@ -29,7 +28,7 @@ local random_particles = {
'coal-particle' 'coal-particle'
} }
local s_random_particles = #random_particles local size_random_particles = #random_particles
local function create_particles(data) local function create_particles(data)
local surface = data.surface local surface = data.surface
@ -39,13 +38,13 @@ local function create_particles(data)
if not surface or not surface.valid then if not surface or not surface.valid then
return return
end end
for i = 1, amount, 1 do for _ = 1, amount, 1 do
local m = random(6, 12) local m = random(6, 12)
local m2 = m * 0.005 local m2 = m * 0.005
surface.create_particle( surface.create_particle(
{ {
name = random_particles[random(1, s_random_particles)], name = random_particles[random(1, size_random_particles)],
position = position, position = position,
frame_speed = 0.1, frame_speed = 0.1,
vertical_speed = 0.1, vertical_speed = 0.1,
@ -60,8 +59,6 @@ local function spawn_biters(data)
local surface = data.surface local surface = data.surface
local position = data.position local position = data.position
local h = floor(abs(position.y)) local h = floor(abs(position.y))
local wave_number = Public.get('wave_number')
local d = Diff.get()
if not position then if not position then
position = surface.find_non_colliding_position('small-biter', position, 10, 1) position = surface.find_non_colliding_position('small-biter', position, 10, 1)
@ -70,64 +67,44 @@ local function spawn_biters(data)
end end
end end
local m = 0.0015 local unit_to_create
if d.difficulty_vote_index then
if not d.strength_modifier then if random(1, 3) == 1 then
m = m * 1.05 unit_to_create = Public.wave_defense_roll_spitter_name()
else else
m = m * d.strength_modifier unit_to_create = Public.wave_defense_roll_biter_name()
end
end end
local boosted_health = 1 + (wave_number * (m * 2)) local modified_unit_health = Public.get('modified_unit_health')
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
if wave_number >= 100 then
boosted_health = boosted_health * 2
end
Public.wave_defense_set_unit_raffle(h * 0.20) Public.wave_defense_set_unit_raffle(h * 0.20)
local unit local unit = surface.create_entity({name = unit_to_create, position = position})
if random(1, 3) == 1 then
unit = surface.create_entity({name = Public.wave_defense_roll_spitter_name(), position = position})
else
unit = surface.create_entity({name = Public.wave_defense_roll_biter_name(), position = position})
end
if random(1, 45) == 1 then if random(1, 30) == 1 then
BiterHealthBooster.add_unit(unit, boosted_health) BiterHealthBooster.add_boss_unit(unit, modified_boss_unit_health.current_value, 0.38)
elseif random(1, 64) == 1 then else
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38) BiterHealthBooster.add_unit(unit, modified_unit_health.current_value * 2)
end end
end end
local function spawn_worms(data) local function spawn_worms(data)
local wave_number = Public.get('wave_number') local modified_unit_health = Public.get('modified_unit_health')
local d = Diff.get() local modified_boss_unit_health = Public.get('modified_boss_unit_health')
local m = 0.0015
if d.difficulty_vote_index then
if not d.strength_modifier then
m = m * 1.05
else
m = m * d.strength_modifier
end
end
local boosted_health = 1 + (wave_number * (m * 2))
if wave_number >= 100 then
boosted_health = boosted_health * 2
end
local surface = data.surface local surface = data.surface
local position = data.position local position = data.position
Public.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20) Public.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
local unit = surface.create_entity({name = Public.wave_defense_roll_worm_name(), position = position})
if random(1, 45) == 1 then local unit_to_create = Public.wave_defense_roll_worm_name(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
BiterHealthBooster.add_unit(unit, boosted_health)
elseif random(1, 64) == 1 then local unit = surface.create_entity({name = unit_to_create, position = position})
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38)
if random(1, 30) == 1 then
BiterHealthBooster.add_boss_unit(unit, modified_boss_unit_health.current_value, 0.38)
else
BiterHealthBooster.add_unit(unit, modified_unit_health.current_value * 2)
end end
end end
@ -155,11 +132,11 @@ function Public.buried_biter(surface, position, max)
local ticks = amount * 30 local ticks = amount * 30
ticks = ticks + 90 ticks = ticks + 90
for t = 1, ticks, 1 do for t = 1, ticks, 1 do
if not traps[game.tick + t] then if not this[game.tick + t] then
traps[game.tick + t] = {} this[game.tick + t] = {}
end end
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'create_particles', callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4} data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
} }
@ -167,7 +144,7 @@ function Public.buried_biter(surface, position, max)
if t > 90 then if t > 90 then
if t % 30 == 29 then if t % 30 == 29 then
a = a + 1 a = a + 1
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'spawn_biters', callback = 'spawn_biters',
data = {surface = surface, position = {x = position.x, y = position.y}} data = {surface = surface, position = {x = position.x, y = position.y}}
} }
@ -202,17 +179,17 @@ function Public.buried_worm(surface, position)
ticks = ticks + 90 ticks = ticks + 90
local a = false local a = false
for t = 1, ticks, 1 do for t = 1, ticks, 1 do
if not traps[game.tick + t] then if not this[game.tick + t] then
traps[game.tick + t] = {} this[game.tick + t] = {}
end end
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'create_particles', callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4} data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
} }
if not a then if not a then
traps[game.tick + t][#traps[game.tick + t] + 1] = { this[game.tick + t][#this[game.tick + t] + 1] = {
callback = 'spawn_worms', callback = 'spawn_worms',
data = {surface = surface, position = {x = position.x, y = position.y}} data = {surface = surface, position = {x = position.x, y = position.y}}
} }
@ -229,10 +206,10 @@ local callbacks = {
local function on_tick() local function on_tick()
local t = game.tick local t = game.tick
if not traps[t] then if not this[t] then
return return
end end
for _, token in pairs(traps[t]) do for _, token in pairs(this[t]) do
local callback = token.callback local callback = token.callback
local data = token.data local data = token.data
local cbl = callbacks[callback] local cbl = callbacks[callback]
@ -240,7 +217,7 @@ local function on_tick()
cbl(data) cbl(data)
end end
end end
traps[t] = nil this[t] = nil
end end
Event.add(defines.events.on_tick, on_tick) Event.add(defines.events.on_tick, on_tick)

@ -1,44 +1,49 @@
local Public = require 'modules.wave_defense.table' local Public = require 'modules.wave_defense.table'
if _DEBUG then commands.add_command(
commands.add_command( 'wd_debug_module',
'wd_debug_module', '',
'', function(cmd)
function(cmd) local player = game.player
local player = game.player local param = tostring(cmd.parameter)
local param = tostring(cmd.parameter) if param == nil then
if param == nil then return
return
end
if not (player and player.valid) then
return
end
if not player.admin then
return
end
if param == 'spawn_wave' then
return Public.spawn_unit_group(true, true)
end
if param == 'log_all' then
return Public.toggle_debug()
end
if param == 'debug_health' then
local this = Public.get()
Public.toggle_debug_health()
this.next_wave = 1000
this.wave_interval = 200
this.wave_enforced = true
this.debug_only_on_wave_500 = true
end
end end
)
end if not (player and player.valid) then
return
end
if not player.admin then
return
end
if param == 'spawn_wave' then
return Public.spawn_unit_group(true, true)
end
if param == 'set_next_wave' then
for _ = 1, 100 do
Public.set_next_wave()
end
return Public.spawn_unit_group(true, true)
end
if param == 'log_all' then
return Public.toggle_debug()
end
if param == 'debug_health' then
local this = Public.get()
Public.toggle_debug_health()
this.next_wave = 1000
this.wave_interval = 200
this.wave_enforced = true
this.debug_only_on_wave_500 = true
end
end
)
return Public return Public

@ -118,7 +118,7 @@ local function remove_trees(entity)
local area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}} local area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}
local trees = surface.find_entities_filtered {area = area, type = 'tree'} local trees = surface.find_entities_filtered {area = area, type = 'tree'}
if #trees > 0 then if #trees > 0 then
for i, tree in pairs(trees) do for _, tree in pairs(trees) do
if tree and tree.valid then if tree and tree.valid then
tree.destroy() tree.destroy()
end end
@ -136,7 +136,7 @@ local function remove_rocks(entity)
local area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}} local area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}
local rocks = surface.find_entities_filtered {area = area, type = 'simple-entity'} local rocks = surface.find_entities_filtered {area = area, type = 'simple-entity'}
if #rocks > 0 then if #rocks > 0 then
for i, rock in pairs(rocks) do for _, rock in pairs(rocks) do
if rock and rock.valid then if rock and rock.valid then
rock.destroy() rock.destroy()
end end
@ -1113,10 +1113,10 @@ Event.on_nth_tick(
local t2 = tick % 18000 local t2 = tick % 18000
if tick_tasks[t] then if tick_tasks[t] then
tick_tasks[t](true) tick_tasks[t]()
end end
if tick_tasks[t2] then if tick_tasks[t2] then
tick_tasks[t2](true) tick_tasks[t2]()
end end
local resolve_pathing = Public.get('resolve_pathing') local resolve_pathing = Public.get('resolve_pathing')
@ -1163,4 +1163,6 @@ Event.on_nth_tick(
end end
) )
Public.set_next_wave = set_next_wave
return Public return Public

@ -109,7 +109,7 @@ local function place_nest_near_unit_group()
Task.set_timeout_in_ticks(200, immunity_spawner, {entity = spawner}) Task.set_timeout_in_ticks(200, immunity_spawner, {entity = spawner})
if boss then if boss then
BiterHealthBooster.add_boss_unit(spawner, modified_boss_unit_health.current_value) BiterHealthBooster.add_boss_unit(spawner, modified_boss_unit_health.current_value, 0.5)
else else
BiterHealthBooster.add_unit(spawner, modified_unit_health.current_value) BiterHealthBooster.add_unit(spawner, modified_unit_health.current_value)
end end
@ -206,7 +206,7 @@ function Public.build_worm()
local modified_boss_unit_health = Public.get('modified_boss_unit_health') local modified_boss_unit_health = Public.get('modified_boss_unit_health')
if boss then if boss then
BiterHealthBooster.add_boss_unit(u, modified_boss_unit_health.current_value) BiterHealthBooster.add_boss_unit(u, modified_boss_unit_health.current_value, 0.5)
else else
local final_health = round(modified_unit_health.current_value * worm_unit_settings.scale_units_by_health[worm], 3) local final_health = round(modified_unit_health.current_value * worm_unit_settings.scale_units_by_health[worm], 3)
if final_health < 1 then if final_health < 1 then

@ -239,10 +239,7 @@ commands.add_command(
end end
if not this.creative_are_you_sure then if not this.creative_are_you_sure then
this.creative_are_you_sure = true this.creative_are_you_sure = true
player.print( player.print('[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!', Color.yellow)
'[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!',
Color.yellow
)
return return
end end
if this.creative_enabled then if this.creative_enabled then

@ -126,6 +126,18 @@ local functions = {
game.get_player(event.player_index).spectator = false game.get_player(event.player_index).spectator = false
end end
end, end,
['blueprint_requesting'] = function(event)
local BPRequests = is_loaded('modules.blueprint_requesting')
local Module = BPRequests.get()
if not Module[event.player_index] then
Module[event.player_index] = {}
end
if event.element.switch_state == 'left' then
Module[event.player_index].disabled = false
else
Module[event.player_index].disabled = true
end
end,
['bottom_location'] = function(event) ['bottom_location'] = function(event)
local player = game.get_player(event.player_index) local player = game.get_player(event.player_index)
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
@ -448,6 +460,17 @@ local function build_config_gui(data)
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
end end
local BPRequests = is_loaded('modules.blueprint_requesting')
if BPRequests then
local Module = BPRequests.get()
switch_state = 'left'
if Module[player.index] and Module[player.index].disabled then
switch_state = 'right'
end
add_switch(scroll_pane, switch_state, 'blueprint_requesting', {'modules.blueprint_requesting'}, {'modules.blueprint_requesting_desc'})
scroll_pane.add({type = 'line'})
end
if BottomFrame.is_custom_buttons_enabled() then if BottomFrame.is_custom_buttons_enabled() then
label = scroll_pane.add({type = 'label', caption = 'Bottom Buttons Settings'}) label = scroll_pane.add({type = 'label', caption = 'Bottom Buttons Settings'})
label.style.font = 'default-bold' label.style.font = 'default-bold'