1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00

Mtn v3 fixes

Fixes when in reverse mode collapse could get triggered even though a player didn't cross the lightning line.
Added that non-trusted players will not trigger collapse.
This commit is contained in:
Gerkiz 2024-04-21 18:50:32 +02:00
parent c928e3153b
commit 1a84eaa966

View File

@ -7,6 +7,7 @@ local Alert = require 'utils.alert'
local Task = require 'utils.task_token'
local Color = require 'utils.color_presets'
local ICF = require 'maps.mountain_fortress_v3.ic.functions'
local Session = require 'utils.datastore.session_data'
local floor = math.floor
local abs = math.abs
@ -118,18 +119,23 @@ local artillery_warning =
end
)
local breach_wall_warning_teleport = function(player)
local breach_wall_warning_teleport = function(player, check_trusted)
if not player or not player.valid then
return
end
local wave_number = WD.get('wave_number')
if wave_number >= 200 then
return
return false
end
local message = ({'breached_wall.warning_teleport', player.name})
Alert.alert_all_players(40, message)
if not check_trusted then
local message = ({'breached_wall.warning_teleport', player.name})
Alert.alert_all_players(40, message)
else
local message = ({'breached_wall.warning_not_trusted_teleport', player.name})
Alert.alert_all_players(40, message)
end
local pos = player.surface.find_non_colliding_position('character', player.force.get_spawn_position(player.surface), 3, 0)
if pos then
player.teleport(pos, player.surface)
@ -137,6 +143,7 @@ local breach_wall_warning_teleport = function(player)
pos = game.forces.player.get_spawn_position(player.surface)
player.teleport(pos, player.surface)
end
return true
end
local spidertron_too_far =
@ -156,12 +163,6 @@ local check_distance_between_player_and_locomotive = function(player)
return
end
local breached_wall = Public.get('breached_wall')
if breached_wall < 3 then
return
end
local collapse_position = Collapse.get_position()
local adjusted_zones = Public.get('adjusted_zones')
@ -175,24 +176,20 @@ local check_distance_between_player_and_locomotive = function(player)
local locomotive_distance
local collapse_distance
local source
if adjusted_zones.reversed then
locomotive_distance = p_y - t_y >= gap_between_locomotive.neg_gap
collapse_distance = p_y - c_y >= gap_between_locomotive.neg_gap_collapse
source = {position.x, locomotive.position.y + gap_between_locomotive.neg_gap - 4}
else
locomotive_distance = p_y - t_y <= gap_between_locomotive.neg_gap
collapse_distance = p_y - c_y <= gap_between_locomotive.neg_gap_collapse
source = {position.x, locomotive.position.y + gap_between_locomotive.neg_gap + 4}
end
if locomotive_distance then
local source = {position.x, locomotive.position.y + gap_between_locomotive.neg_gap + 4}
local source_position = surface.find_non_colliding_position('character', source, 32, 1)
if source_position then
player.teleport(source_position, surface)
else
player.teleport(source, surface)
end
player.teleport(source, surface)
player.print(({'breached_wall.hinder'}), Color.warning)
if player.driving then
player.driving = false
@ -208,12 +205,7 @@ local check_distance_between_player_and_locomotive = function(player)
if collapse_distance then
local source = {position.x, c_y + gap_between_locomotive.neg_gap_collapse + 4}
local source_position = surface.find_non_colliding_position('character', source, 32, 1)
if source_position then
player.teleport(source_position, surface)
else
player.teleport(source, surface)
end
player.teleport(source, surface)
player.print(({'breached_wall.hinder_collapse'}), Color.warning)
if player.driving then
@ -350,14 +342,13 @@ local function distance(player)
compare_player_pos(player)
local distance_to_center = floor(sqrt(p.y ^ 2))
local location = distance_to_center
local adjusted_zones = Public.get('adjusted_zones')
if adjusted_zones.reversed then
if location < zone_settings.zone_depth * bonus + 30 then
if distance_to_center < zone_settings.zone_depth * bonus + 32 then
return
end
else
if location < zone_settings.zone_depth * bonus - 10 then
if distance_to_center < zone_settings.zone_depth * bonus - 10 then
return
end
end
@ -366,9 +357,14 @@ local function distance(player)
local max = zone_settings.zone_depth * bonus
local breach_max = zone_settings.zone_depth * breached_wall
local breach_max_times = location >= breach_max
local max_times = location >= max
local breach_max_times = distance_to_center >= breach_max
local max_times = distance_to_center >= max
if max_times then
if not Session.get_trusted_player(player) then
if breach_wall_warning_teleport(player, true) then
return
end
end
if not breach_wall_warning then
Public.set('breach_wall_warning', true)
breach_wall_warning_teleport(player)