mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-28 23:06:38 +02:00
mtn v3 - don't let players explore too much
Exploring too much causes the map to become laggy and players with slower PCs can't play.
This commit is contained in:
parent
793dea005f
commit
c732517276
@ -10,6 +10,8 @@ wall_breached=[color=blue]Mapkeeper:[/color]\nSurvivor! Well done. You have comp
|
||||
first_to_reach=[color=blue]Mapkeeper:[/color]\n__1__ was the first to reach zone __2__.
|
||||
artillery_warning=[color=blue]Mapkeeper:[/color]\nWarning, Artillery have been spotted north!
|
||||
cheating_through=__1__ tried to cheat their way north with their spidertron!
|
||||
hinder=You are too far away from the main locomotive. You cannot go beyond this point.
|
||||
|
||||
|
||||
[entity]
|
||||
treasure_1=You notice an old crate within the rubble. It's filled with treasure!
|
||||
|
@ -7,6 +7,7 @@ local Alert = require 'utils.alert'
|
||||
local Event = require 'utils.event'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local raise_event = script.raise_event
|
||||
local floor = math.floor
|
||||
@ -80,6 +81,39 @@ local spidertron_too_far =
|
||||
end
|
||||
)
|
||||
|
||||
local check_distance_between_player_and_locomotive = function(player)
|
||||
local surface = player.surface
|
||||
local position = player.position
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local gap_between_locomotive = WPT.get('gap_between_locomotive')
|
||||
|
||||
if not gap_between_locomotive.highest_pos then
|
||||
gap_between_locomotive.highest_pos = locomotive.position
|
||||
end
|
||||
|
||||
gap_between_locomotive.highest_pos = locomotive.position
|
||||
gap_between_locomotive = WPT.get('gap_between_locomotive')
|
||||
|
||||
local c_y = position.y
|
||||
local t_y = gap_between_locomotive.highest_pos.y
|
||||
|
||||
if c_y - t_y <= gap_between_locomotive.neg_gap then
|
||||
player.teleport({position.x, locomotive.position.y + gap_between_locomotive.neg_gap}, surface)
|
||||
player.print(({'breached_wall.hinder'}), Color.warning)
|
||||
if player.character then
|
||||
player.character.health = player.character.health - 5
|
||||
player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local compare_player_pos = function(player)
|
||||
local p = player.position
|
||||
local index = player.index
|
||||
@ -227,17 +261,19 @@ local function on_player_changed_position(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local surface_name = player.surface.name
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
if random(1, 3) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if sub(surface_name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
check_distance_between_player_and_locomotive(player)
|
||||
|
||||
if random(1, 3) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
distance(player)
|
||||
end
|
||||
|
||||
local function on_player_driving_changed_state(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not (player and player.valid) then
|
||||
|
@ -102,6 +102,12 @@ function Public.reset_table()
|
||||
neg_gap = -500,
|
||||
highest_pos = 0
|
||||
}
|
||||
this.gap_between_locomotive = {
|
||||
hinders = {},
|
||||
gap = 900,
|
||||
neg_gap = -2112,
|
||||
highest_pos = nil
|
||||
}
|
||||
this.force_chunk = false
|
||||
this.allow_decon = true
|
||||
this.train_upgrades = 0
|
||||
|
Loading…
Reference in New Issue
Block a user