Skip to content

Commit

Permalink
Merge pull request #432 from ComfyFactory/fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
Gerkiz authored Nov 5, 2023
2 parents ed27efe + acd054a commit 89fa093
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
11 changes: 10 additions & 1 deletion maps/mountain_fortress_v3/breached_wall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions maps/mountain_fortress_v3/ic/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions maps/mountain_fortress_v3/stateful/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions maps/tank_battles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand All @@ -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})
Expand Down

0 comments on commit 89fa093

Please sign in to comment.