mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-07 13:31:40 +02:00
new module
This commit is contained in:
parent
1ee43e9d7d
commit
aba388c40f
@ -2,7 +2,7 @@
|
||||
|
||||
--require "modules.flashlight_toggle_button"
|
||||
--require "modules.biter_noms_you"
|
||||
require "modules.biter_evasion_hp_increaser"
|
||||
require "modules.biter_health_booster"
|
||||
require "modules.wave_defense.main"
|
||||
require "functions.soft_reset"
|
||||
require "functions.basic_markets"
|
||||
@ -197,7 +197,7 @@ local function on_entity_died(event)
|
||||
if event.entity == global.locomotive_cargo then
|
||||
game.print("The cargo was destroyed!")
|
||||
global.wave_defense.game_lost = true
|
||||
global.game_reset_tick = game.tick + 900
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
|
||||
end
|
||||
|
73
modules/biter_health_booster.lua
Normal file
73
modules/biter_health_booster.lua
Normal file
@ -0,0 +1,73 @@
|
||||
-- Biters and Spitters gain additional health / resistance -- mewmew
|
||||
-- Use global.biter_health_boost to modify their health.
|
||||
-- 1 = vanilla health, 2 = 200% vanilla health
|
||||
-- do not use values below 1
|
||||
|
||||
local function clean_table()
|
||||
local units_to_delete = {}
|
||||
|
||||
--Mark all health boost entries for deletion
|
||||
for key, health in pairs(global.biter_health_boost_units) do
|
||||
units_to_delete[key] = true
|
||||
end
|
||||
|
||||
--Remove valid health boost entries from deletion
|
||||
for _, surface in pairs(game.surfaces) do
|
||||
for _, unit in pairs(surface.find_entities_filtered({type = "unit"})) do
|
||||
units_to_delete[unit.unit_number] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--Remove abandoned health boost entries
|
||||
for key, _ in pairs(units_to_delete) do
|
||||
global.biter_health_boost_units[key] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.force.index ~= 2 then return end
|
||||
if event.entity.type ~= "unit" then return end
|
||||
|
||||
--Create new health pool
|
||||
if not global.biter_health_boost_units[event.entity.unit_number] then
|
||||
global.biter_health_boost_units[event.entity.unit_number] = {
|
||||
math.floor(event.entity.prototype.max_health * global.biter_health_boost),
|
||||
math.round(1 / global.biter_health_boost, 5),
|
||||
}
|
||||
|
||||
--Perform a table cleanup every 5000 boosts
|
||||
global.biter_health_boost_count = global.biter_health_boost_count + 1
|
||||
if global.biter_health_boost_count % 5000 == 0 then clean_table() end
|
||||
end
|
||||
|
||||
--Reduce health pool
|
||||
global.biter_health_boost_units[event.entity.unit_number][1] = global.biter_health_boost_units[event.entity.unit_number][1] - event.final_damage_amount
|
||||
|
||||
--Set entity health relative to health pool
|
||||
event.entity.health = global.biter_health_boost_units[event.entity.unit_number][1] * global.biter_health_boost_units[event.entity.unit_number][2]
|
||||
|
||||
--Proceed to kill entity if health is 0
|
||||
if event.entity.health > 0 then return end
|
||||
|
||||
--Remove health pool
|
||||
global.biter_health_boost_units[event.entity.unit_number] = nil
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
event.entity.die(event.entity.force, event.cause)
|
||||
return
|
||||
end
|
||||
end
|
||||
event.entity.die(event.entity.force)
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.biter_health_boost = 1
|
||||
global.biter_health_boost_units = {}
|
||||
global.biter_health_boost_count = 0
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
@ -113,27 +113,28 @@ end
|
||||
|
||||
local function set_enemy_evolution()
|
||||
local evolution_factor = global.wave_defense.wave_number * 0.001
|
||||
local evasion_factor = 1
|
||||
local biter_health_boost = 1
|
||||
local damage_increase = 0
|
||||
|
||||
if evolution_factor > 1 then
|
||||
evasion_factor = evasion_factor + (evolution_factor - 1) * 2
|
||||
damage_increase = damage_increase + (evolution_factor - 1)
|
||||
biter_health_boost = biter_health_boost + (evolution_factor - 1)
|
||||
evolution_factor = 1
|
||||
end
|
||||
|
||||
|
||||
if global.wave_defense.threat > 0 then
|
||||
local m = math.round(global.wave_defense.threat / 50000, 3)
|
||||
evasion_factor = evasion_factor + m
|
||||
damage_increase = damage_increase + m * 0.5
|
||||
local m = math.round(global.wave_defense.threat / 100000, 3)
|
||||
biter_health_boost = biter_health_boost + m
|
||||
damage_increase = damage_increase + m * 0.25
|
||||
end
|
||||
|
||||
global.biter_evasion_health_increase_factor = evasion_factor
|
||||
global.biter_health_boost = biter_health_boost
|
||||
game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase)
|
||||
game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase)
|
||||
game.forces.enemy.evolution_factor = evolution_factor
|
||||
|
||||
debug_print("evolution_factor: " .. evolution_factor)
|
||||
debug_print("evasion_factor: " .. global.biter_evasion_health_increase_factor)
|
||||
debug_print("biter_health_boost: " .. global.biter_health_boost)
|
||||
debug_print("damage_increase: " .. game.forces.enemy.get_ammo_damage_modifier("melee"))
|
||||
end
|
||||
|
||||
@ -209,7 +210,7 @@ local function set_next_wave()
|
||||
global.wave_defense.wave_number = global.wave_defense.wave_number + 1
|
||||
global.wave_defense.group_size = global.wave_defense.wave_number * 2
|
||||
if global.wave_defense.group_size > global.wave_defense.max_group_size then global.wave_defense.group_size = global.wave_defense.max_group_size end
|
||||
global.wave_defense.threat = global.wave_defense.threat + global.wave_defense.wave_number * 2
|
||||
global.wave_defense.threat = global.wave_defense.threat + math.floor(global.wave_defense.wave_number * 1.5)
|
||||
global.wave_defense.last_wave = global.wave_defense.next_wave
|
||||
global.wave_defense.next_wave = game.tick + global.wave_defense.wave_interval
|
||||
end
|
||||
@ -382,7 +383,7 @@ function reset_wave_defense()
|
||||
game_lost = false,
|
||||
threat = 0,
|
||||
simple_entity_shredding_count_modifier = 0.0003,
|
||||
simple_entity_shredding_cost_modifier = 0.007, --threat cost for one health
|
||||
simple_entity_shredding_cost_modifier = 0.01, --threat cost for one health
|
||||
nest_building_density = 64, --lower values = more dense building
|
||||
nest_building_chance = 4, --high value = less chance
|
||||
worm_building_density = 8, --lower values = more dense building
|
||||
|
@ -18,7 +18,7 @@ function build_nest()
|
||||
if not group.members[1] then return end
|
||||
local unit = group.members[math_random(1, #group.members)]
|
||||
if not unit.valid then return end
|
||||
local position = unit.surface.find_non_colliding_position("biter-spawner", unit.position, 8, 1)
|
||||
local position = unit.surface.find_non_colliding_position("rocket-silo", unit.position, 9, 1)
|
||||
if not position then return end
|
||||
local r = global.wave_defense.nest_building_density
|
||||
if unit.surface.count_entities_filtered({type = "unit-spawner", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
@ -43,7 +43,7 @@ function build_worm()
|
||||
if not unit.valid then return end
|
||||
wave_defense_set_worm_raffle(global.wave_defense.wave_number)
|
||||
local worm = wave_defense_roll_worm_name()
|
||||
local position = unit.surface.find_non_colliding_position(worm, unit.position, 8, 1)
|
||||
local position = unit.surface.find_non_colliding_position("biter-spawner", unit.position, 9, 1)
|
||||
if not position then return end
|
||||
local r = global.wave_defense.worm_building_density
|
||||
if unit.surface.count_entities_filtered({type = "turret", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
|
Loading…
x
Reference in New Issue
Block a user