From b7ccdf5a1d04d09453fe8b845a029f104087f505 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Mon, 1 Mar 2021 22:04:55 +0100 Subject: [PATCH] mtn fortress - minor changes --- maps/mountain_fortress_v3/functions.lua | 8 +++++++- maps/mountain_fortress_v3/main.lua | 2 +- modules/biter_health_booster_v2.lua | 13 ++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 9ce200e4..ca9a0693 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -1082,7 +1082,13 @@ function Public.set_spawn_position() local spawn_near_collapse = WPT.get('spawn_near_collapse') if spawn_near_collapse.active then - local collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 32, 2) + local collapse_position = surface.find_non_colliding_position('rocket-silo', collapse_pos, 64, 2) + if not collapse_position then + collapse_position = surface.find_non_colliding_position('solar-panel', collapse_pos, 32, 2) + end + if not collapse_position then + collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 32, 2) + end local sizeof = locomotive_positions.tbl[total_pos - total_pos + 1] if not sizeof then goto continue diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 82a797d5..e81ac572 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -212,7 +212,7 @@ function Public.reset_map() wave_defense_table.target = this.locomotive wave_defense_table.nest_building_density = 32 wave_defense_table.game_lost = false - wave_defense_table.spawn_position = {x = 0, y = 100} + wave_defense_table.spawn_position = {x = 0, y = 84} WD.alert_boss_wave(true) WD.clear_corpses(false) WD.remove_entities(true) diff --git a/modules/biter_health_booster_v2.lua b/modules/biter_health_booster_v2.lua index d217b1d7..51ebf373 100644 --- a/modules/biter_health_booster_v2.lua +++ b/modules/biter_health_booster_v2.lua @@ -16,6 +16,7 @@ local insert = table.insert local random = math.random local sqrt = math.sqrt local ceil = math.ceil +local round = math.round local Public = {} local this = { @@ -279,9 +280,9 @@ local function on_entity_damaged(event) return end - if event.cause then - if event.cause.valid then - event.entity.die(event.cause.force, event.cause) + if cause then + if cause.valid then + event.entity.die(cause.force, cause) return end end @@ -377,9 +378,10 @@ function Public.add_unit(unit, health_multiplier) if not health_multiplier then health_multiplier = this.biter_health_boost end + local xp_modifier = round(1 / health_multiplier, 5) this.biter_health_boost_units[unit.unit_number] = { floor(unit.prototype.max_health * health_multiplier), - ceil(sqrt(health_multiplier)) + xp_modifier } end @@ -394,10 +396,11 @@ function Public.add_boss_unit(unit, health_multiplier, health_bar_size) if not health_bar_size then health_bar_size = 0.5 end + local xp_modifier = round(1 / health_multiplier, 5) local health = floor(unit.prototype.max_health * health_multiplier) this.biter_health_boost_units[unit.unit_number] = { health, - ceil(sqrt(health_multiplier)), + xp_modifier, {max_health = health, healthbar_id = create_boss_healthbar(unit, health_bar_size), last_update = game.tick} } end