mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-28 23:06:38 +02:00
Elite biter hp scaling and boat tp fix
Changes: - Elite biter health now scales additionally with leagues after 1000 leagues. - Fixed an issue where player could get stranded on water when standing in front of ship as it departs.
This commit is contained in:
parent
dda0dedd95
commit
5de6c541f1
@ -1842,6 +1842,7 @@ function Public.get_random_valid_spawner(surface)
|
||||
return spawners[Math.random(#spawners)]
|
||||
end
|
||||
|
||||
-- @TODO move this somewhere else, so that health multiplier formula can be put to balance
|
||||
function Public.try_make_biter_elite(entity)
|
||||
if not (entity and entity.valid) then return end
|
||||
|
||||
@ -1863,6 +1864,14 @@ function Public.try_make_biter_elite(entity)
|
||||
health_multiplier = 10
|
||||
end
|
||||
|
||||
-- 1000 leagues = 1x
|
||||
-- 2000 leagues = 2x
|
||||
-- 3000 leagues = 4x
|
||||
-- etc.
|
||||
if Public.overworldx() > 1000 then
|
||||
health_multiplier = health_multiplier * 2 ^ ((Public.overworldx() - 1000) / 1000)
|
||||
end
|
||||
|
||||
local max_hp = Math.ceil(entity.prototype.max_health * health_multiplier)
|
||||
Public.new_healthbar(false, entity, max_hp, nil, max_hp, 0.4, -1)
|
||||
|
||||
|
@ -599,6 +599,7 @@ function Public.go_from_currentdestination_to_sea()
|
||||
|
||||
local boat = memory.boat
|
||||
|
||||
local old_boatposition = memory.boat.position
|
||||
local new_boatposition = Utils.snap_coordinates_for_rails({x = Boats.get_scope(memory.boat).Data.width / 2, y = 0})
|
||||
|
||||
Boats.teleport_boat(boat, seaname, new_boatposition, CoreData.static_boat_floor, 'water')
|
||||
@ -659,9 +660,24 @@ function Public.go_from_currentdestination_to_sea()
|
||||
|
||||
|
||||
local players_marooned_count = 0
|
||||
for _, player in pairs(game.connected_players) do
|
||||
for _, player in pairs(Common.crew_get_crew_members()) do
|
||||
if (player.surface == oldsurface and player.character and player.character.valid) then
|
||||
players_marooned_count = players_marooned_count + 1
|
||||
|
||||
-- When players are "hanging in front of ship" when boat departs, teleport them inside ship.
|
||||
-- Side effect: if players happen to be on water tile during this tick and not too far from ship, they will be teleported to the boat.
|
||||
-- @TODO: instead of checking 50 radius, check only smaller area around boat
|
||||
if Math.distance(old_boatposition, player.character.position) < 50 then
|
||||
local tile = oldsurface.get_tile(player.character.position.x, player.character.position.y)
|
||||
if tile.valid then
|
||||
if Utils.contains(CoreData.water_tile_names, tile.name) then
|
||||
local newsurface = game.surfaces[seaname]
|
||||
if newsurface and newsurface.valid then
|
||||
player.teleport(newsurface.find_non_colliding_position('character', memory.spawnpoint, 32, 0.5) or memory.spawnpoint, newsurface)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if players_marooned_count == 0 then
|
||||
|
@ -1111,20 +1111,24 @@ local function teleport_handle_wake_tiles(boat, dummyboat, newsurface_name, olds
|
||||
end
|
||||
end
|
||||
|
||||
-- prevent instant death when players stand in front of ship
|
||||
-- Prevent instant death when players stand in front of ship
|
||||
oldsurface.set_tiles(newtiles, true, false, true)
|
||||
|
||||
-- but since players don't die instantly, they can get stuck in water, this prevents this (even though it let's you walk in front of ship while ship is departing)
|
||||
-- NOTE: this will need to be changed, when ship doesn't necessarily arrive from the left
|
||||
-- ..but since players don't die instantly, they can get stuck in water, this prevents this (even though it let's you walk in front of ship while ship is departing)
|
||||
-- NOTE: this will need to be changed, when ship doesn't necessarily arrive from the left.
|
||||
-- Side effect: if players happen to be on water tile during this tick and not too far from ship, they will be teleported to nearest non water tile.
|
||||
if vector.x < 0 then
|
||||
for _, player in pairs(Common.crew_get_crew_members()) do
|
||||
if player.character and player.character.valid and player.surface.name == oldsurface_name then
|
||||
local tile = oldsurface.get_tile(player.character.position.x, player.character.position.y)
|
||||
if tile.valid then
|
||||
if Utils.contains(CoreData.water_tile_names, tile.name) then
|
||||
local new_pos = oldsurface.find_non_colliding_position('character', player.character.position, 20, 0.1, true)
|
||||
if new_pos then
|
||||
player.character.teleport(new_pos)
|
||||
-- @TODO: instead of checking 50 radius, check only smaller area around boat
|
||||
if Math.distance(boat.position, player.character.position) < 50 then
|
||||
local tile = oldsurface.get_tile(player.character.position.x, player.character.position.y)
|
||||
if tile.valid then
|
||||
if Utils.contains(CoreData.water_tile_names, tile.name) then
|
||||
local new_pos = oldsurface.find_non_colliding_position('character', player.character.position, 20, 0.1, true)
|
||||
if new_pos then
|
||||
player.character.teleport(new_pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user