1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

integration of biter extra lifes

This commit is contained in:
MewMew 2020-01-19 10:26:11 +01:00
parent 806da8159d
commit 02f907f970
5 changed files with 36 additions and 12 deletions

View File

@ -102,7 +102,23 @@ local function is_biter_inactive(biter, unit_number, biter_force_name)
return true
end
Public.destroy_inactive_biters = function()
local function set_active_biters(group)
if not group.valid then return end
local active_biters = global.active_biters[group.force.name]
for _, unit in pairs(group.members) do
if not active_biters[unit.unit_number] then
active_biters[unit.unit_number] = {entity = unit, active_since = game.tick}
end
end
end
Public.destroy_inactive_biters = function()
for _, group in pairs(global.unit_groups) do
if not set_active_biters(group) then
end
end
for _, biter_force_name in pairs({"north_biters", "south_biters"}) do
for unit_number, biter in pairs(global.active_biters[biter_force_name]) do
if is_biter_inactive(biter, unit_number, biter_force_name) then
@ -279,10 +295,10 @@ local function get_unit_group_position(surface, nearest_player_unit, spawner)
end
local function get_active_threat(biter_force_name)
local active_threat = 0
local active_threat = 0
for unit_number, biter in pairs(global.active_biters[biter_force_name]) do
if biter.entity then
if biter.entity.valid then
if biter.entity.valid then
active_threat = active_threat + threat_values[biter.entity.name]
end
end
@ -316,6 +332,8 @@ local function create_attack_group(surface, force_name, biter_force_name)
local unit_group = surface.create_unit_group({position = unit_group_position, force = biter_force_name})
for _, unit in pairs(units) do unit_group.add_member(unit) end
send_group(unit_group, force_name, nearest_player_unit)
global.unit_groups[unit_group.group_number] = unit_group
end
Public.main_attack = function()
@ -387,7 +405,9 @@ function Public.subtract_threat(entity)
if entity.type == "unit" then
global.active_biters[entity.force.name][entity.unit_number] = nil
end
global.bb_threat[entity.force.name] = global.bb_threat[entity.force.name] - threat_values[entity.name]
return true
end

View File

@ -20,7 +20,7 @@ end
local function set_biter_endgame_modifiers(force)
if force.evolution_factor ~= 1 then return end
local damage_mod = global.bb_evolution[force.name] - 1
local health_boost = ((global.bb_evolution[force.name] - 1) * 4) + 1
local extra_lifes = math.round((global.bb_evolution[force.name] - 1) * 4, 4)
force.set_ammo_damage_modifier("melee", damage_mod)
force.set_ammo_damage_modifier("biological", damage_mod)
@ -28,7 +28,7 @@ local function set_biter_endgame_modifiers(force)
force.set_ammo_damage_modifier("flamethrower", damage_mod)
force.set_ammo_damage_modifier("laser-turret", damage_mod)
global.biter_health_boost_forces[force.index] = health_boost
global.biter_reanimator.forces[force.index] = extra_lifes
end
local function get_enemy_team_of(team)

View File

@ -141,6 +141,7 @@ function Public.forces()
global.spy_fish_timeout = {}
global.force_area = {}
global.active_biters = {}
global.unit_groups = {}
global.biter_raffle = {}
global.evo_raise_counter = 1
global.next_attack = "north"

View File

@ -1,7 +1,7 @@
-- Biter Battles v2 -- by MewMew
require "modules.biter_reanimator"
local Ai = require "maps.biter_battles_v2.ai"
local BiterHealthBooster = require "modules.biter_health_booster"
local Biters_landfill = require "maps.biter_battles_v2.biters_landfill"
local Chat = require "maps.biter_battles_v2.chat"
local Combat_balance = require "maps.biter_battles_v2.combat_balance"
@ -146,4 +146,4 @@ Event.add_event_filter(defines.events.on_entity_damaged, { filter = "type", type
require "maps.biter_battles_v2.spec_spy"
require "maps.biter_battles_v2.terrain"
require "maps.biter_battles_v2.difficulty_vote"
require "modules.custom_death_messages"
require "modules.custom_death_messages"

View File

@ -29,10 +29,12 @@ local function reanimate(entity)
end
local revived_entity = entity.clone({position = entity.position, surface = entity.surface, force = entity.force})
revived_entity.health = revived_entity.prototype.max_health
register_unit(revived_entity, extra_lifes - 1, unit_group)
if unit_group then unit_group.add_member(revived_entity) end
global.biter_reanimator.units[entity.unit_number] = nil
entity.destroy()
end
local function on_entity_died(event)
@ -50,11 +52,12 @@ end
local function on_unit_added_to_group(event)
local unit = event.unit
local group = event.group
local extra_lifes = 0
if global.biter_reanimator.forces[unit.force.index] then
extra_lifes = global.biter_reanimator.forces[unit.force.index]
end
register_unit(unit, extra_lifes, group)
local extra_lifes = global.biter_reanimator.forces[unit.force.index]
if extra_lifes then
register_unit(unit, extra_lifes, group)
else
register_unit(unit, 0, group)
end
end
local function on_init()