From de7e2e407db3a8317b076c50a4c184ebd37d89b0 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 5 Nov 2023 16:34:23 +0100 Subject: [PATCH 1/2] Mtn v3 - minor fixes --- maps/mountain_fortress_v3/breached_wall.lua | 11 ++++++++++- maps/mountain_fortress_v3/ic/functions.lua | 9 +++++++++ maps/mountain_fortress_v3/stateful/table.lua | 3 +-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index d688c0279..3988bd13f 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -7,6 +7,7 @@ local Alert = require 'utils.alert' local Task = require 'utils.task' local Token = require 'utils.token' local Color = require 'utils.color_presets' +local ICF = require 'maps.mountain_fortress_v3.ic.functions' local floor = math.floor local abs = math.abs @@ -192,6 +193,8 @@ local compare_player_and_train = function(player, entity) return end + local car = ICF.get_car(entity.unit_number) + local position = player.position local locomotive = Public.get('locomotive') if not locomotive or not locomotive.valid then @@ -220,6 +223,10 @@ local compare_player_and_train = function(player, entity) if c_y - t_y <= gap_between_zones.neg_gap then if entity.health then + if car and car.health_pool and car.health_pool.health then + car.health_pool.health = car.health_pool.health - 500 + end + entity.health = entity.health - 500 if entity.health <= 0 then entity.die('enemy') @@ -375,12 +382,14 @@ local function on_player_driving_changed_state(event) if not (player and player.valid) then return end + local entity = event.entity if not (entity and entity.valid) then return end + local s = Public.get('validate_spider') - if entity.name == 'spidertron' then + if player.driving then if not s[player.index] then s[player.index] = entity end diff --git a/maps/mountain_fortress_v3/ic/functions.lua b/maps/mountain_fortress_v3/ic/functions.lua index 228958d96..e65fccc1b 100644 --- a/maps/mountain_fortress_v3/ic/functions.lua +++ b/maps/mountain_fortress_v3/ic/functions.lua @@ -1372,6 +1372,15 @@ function Public.check_entity_healths() end end +function Public.get_car(unit_number) + local cars = IC.get('cars') + if not next(cars) then + return + end + + return cars[unit_number] or nil +end + function Public.set_damage_health(data) local entity = data.entity local final_damage_amount = data.final_damage_amount diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index de89eb0e7..7094f0d52 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -486,7 +486,6 @@ local function get_random_research_recipe() local research_level_list = { 'energy-weapons-damage-7', 'physical-projectile-damage-7', - 'refined-flammables-7', 'stronger-explosives-7', 'mining-productivity-4', 'worker-robots-speed-6', @@ -782,7 +781,7 @@ function Public.reset_stateful(refresh_gui, clear_buffs) required = random(scale(50000), scale(100000)) }, trees_farmed = random(scale(9500, 400000), scale(10500, 400000)), - rocks_farmed = random(scale(45000, 4000000), scale(55000, 4000000)), + rocks_farmed = random(scale(45000, 450000), scale(55000, 450000)), rockets_launched = random(scale(30, 700), scale(45, 700)) } end From acd054af10d4ba7b3da30e61a4f4109c0aca3bf6 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 5 Nov 2023 16:35:19 +0100 Subject: [PATCH 2/2] Tank battles - minor fixes --- maps/tank_battles.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/maps/tank_battles.lua b/maps/tank_battles.lua index d9759990f..bb8059152 100644 --- a/maps/tank_battles.lua +++ b/maps/tank_battles.lua @@ -197,11 +197,7 @@ local function create_tank_battle_score_gui() ) end -local function get_valid_random_spawn_position(surface) - local chunks = {} - for chunk in surface.get_chunks() do - insert(chunks, {x = chunk.x, y = chunk.y}) - end +local function get_valid_random_spawn_position(surface, chunks) chunks = shuffle(chunks) for _, chunk in pairs(chunks) do @@ -223,6 +219,13 @@ local function get_valid_random_spawn_position(surface) end local function put_players_into_arena() + local surface = game.get_surface('nauvis') + + local chunks = {} + for chunk in surface.get_chunks() do + insert(chunks, {x = chunk.x, y = chunk.y}) + end + Core.iter_connected_players( function(player) local permissions_group = game.permissions.get_group('Default') @@ -239,16 +242,14 @@ local function put_players_into_arena() player.insert({name = 'rocket-launcher', count = 1}) player.insert({name = 'flamethrower', count = 1}) - local surface = game.get_surface('nauvis') - - local pos = get_valid_random_spawn_position(surface) + local pos = get_valid_random_spawn_position(surface, chunks) player.force.chart(surface, {{x = -1 * arena_size, y = -1 * arena_size}, {x = arena_size, y = arena_size}}) if pos then player.teleport(pos, surface) else - pos = get_valid_random_spawn_position(surface) + pos = get_valid_random_spawn_position(surface, chunks) end local tank = surface.create_entity({name = 'tank', force = game.forces[player.name], position = pos}) tank.insert({name = 'coal', count = 24})