mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-22 03:38:48 +02:00
commit
89fa093c9e
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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})
|
||||
|
Loading…
x
Reference in New Issue
Block a user