You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2026-06-20 16:32:28 +02:00
biter health booster - xp reward fix
This commit is contained in:
@@ -8,12 +8,14 @@ local Event = require 'utils.event'
|
||||
local LootDrop = require 'modules.mobs_drop_loot'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Global = require 'utils.global'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local floor = math.floor
|
||||
local insert = table.insert
|
||||
local round = math.round
|
||||
local random = math.random
|
||||
local sqrt = math.sqrt
|
||||
local ceil = math.ceil
|
||||
local Public = {}
|
||||
|
||||
local this = {
|
||||
@@ -72,6 +74,15 @@ local entity_types = {
|
||||
['unit-spawner'] = true
|
||||
}
|
||||
|
||||
local removeUnit =
|
||||
Token.register(
|
||||
function(data)
|
||||
local biter_health_boost_units = data.biter_health_boost_units
|
||||
local unit_number = data.unit_number
|
||||
biter_health_boost_units[unit_number] = nil
|
||||
end
|
||||
)
|
||||
|
||||
if is_loaded('maps.biter_hatchery.terrain') then
|
||||
entity_types['unit-spawner'] = nil
|
||||
end
|
||||
@@ -293,28 +304,29 @@ local function on_entity_died(event)
|
||||
local biter_health_boost_units = this.biter_health_boost_units
|
||||
|
||||
local unit_number = biter.unit_number
|
||||
|
||||
local health_pool = biter_health_boost_units[unit_number]
|
||||
local wave_count = WD.get_wave()
|
||||
|
||||
local health_pool = biter_health_boost_units[unit_number]
|
||||
if health_pool and health_pool[3] then
|
||||
if this.enable_boss_loot then
|
||||
if random(1, 128) == 1 then
|
||||
LootDrop.drop_loot(biter, wave_count)
|
||||
if health_pool then
|
||||
Task.set_timeout_in_ticks(30, removeUnit, {unit_number = unit_number, biter_health_boost_units = biter_health_boost_units})
|
||||
if health_pool[3] then
|
||||
if this.enable_boss_loot then
|
||||
if random(1, 128) == 1 then
|
||||
LootDrop.drop_loot(biter, wave_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
if this.boss_spawns_projectiles then
|
||||
if random(1, 96) == 1 then
|
||||
loaded_biters(event)
|
||||
if this.boss_spawns_projectiles then
|
||||
if random(1, 96) == 1 then
|
||||
loaded_biters(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
biter_health_boost_units[unit_number] = nil
|
||||
if this.acid_nova then
|
||||
if acid_splashes[biter.name] then
|
||||
acid_nova(event)
|
||||
end
|
||||
if this.acid_lines_delay[biter.unit_number] then
|
||||
this.acid_lines_delay[biter.unit_number] = nil
|
||||
if this.acid_nova then
|
||||
if acid_splashes[biter.name] then
|
||||
acid_nova(event)
|
||||
end
|
||||
if this.acid_lines_delay[biter.unit_number] then
|
||||
this.acid_lines_delay[biter.unit_number] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -367,7 +379,7 @@ function Public.add_unit(unit, health_multiplier)
|
||||
end
|
||||
this.biter_health_boost_units[unit.unit_number] = {
|
||||
floor(unit.prototype.max_health * health_multiplier),
|
||||
round(1 / health_multiplier, 5)
|
||||
ceil(sqrt(health_multiplier))
|
||||
}
|
||||
end
|
||||
|
||||
@@ -385,7 +397,7 @@ function Public.add_boss_unit(unit, health_multiplier, health_bar_size)
|
||||
local health = floor(unit.prototype.max_health * health_multiplier)
|
||||
this.biter_health_boost_units[unit.unit_number] = {
|
||||
health,
|
||||
round(1 / health_multiplier, 5),
|
||||
ceil(sqrt(health_multiplier)),
|
||||
{max_health = health, healthbar_id = create_boss_healthbar(unit, health_bar_size), last_update = game.tick}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -239,7 +239,7 @@ local function on_entity_died(event)
|
||||
if biter_health_boost then
|
||||
local health_pool = biter_health_boost_units[event.entity.unit_number]
|
||||
if health_pool then
|
||||
amount = amount * (1 / health_pool[2])
|
||||
amount = amount * (health_pool[2] * 0.5 / 2)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -278,7 +278,7 @@ local function on_entity_died(event)
|
||||
if health_pool then
|
||||
for _, player in pairs(players) do
|
||||
if rpg_extra.rpg_xp_yield[event.entity.name] then
|
||||
local amount = rpg_extra.rpg_xp_yield[event.entity.name] * (1 / health_pool[2])
|
||||
local amount = rpg_extra.rpg_xp_yield[event.entity.name] * (health_pool[2] * 0.5 / 2)
|
||||
if rpg_extra.turret_kills_to_global_pool then
|
||||
local inserted = Functions.add_to_global_pool(amount, true)
|
||||
Functions.gain_xp(player, inserted, true)
|
||||
@@ -286,7 +286,7 @@ local function on_entity_died(event)
|
||||
Functions.gain_xp(player, amount)
|
||||
end
|
||||
else
|
||||
Functions.gain_xp(player, 0.5 * (1 / health_pool[2]))
|
||||
Functions.gain_xp(player, 0.5 * (health_pool[2] * 0.5 / 2))
|
||||
end
|
||||
end
|
||||
return
|
||||
|
||||
@@ -540,8 +540,8 @@ local function increase_biters_health()
|
||||
boosted_health = boosted_health * (wave_number * 0.03)
|
||||
local sum = boosted_health * 4
|
||||
debug_print('[HEALTHBOOSTER] > Boss Health Boosted: ' .. sum)
|
||||
if sum >= 100 then
|
||||
sum = 100
|
||||
if sum >= 300 then
|
||||
sum = 300
|
||||
end
|
||||
|
||||
WD.set('modified_boss_unit_health', sum)
|
||||
|
||||
Reference in New Issue
Block a user