Corrige la portée de téléportation
This commit is contained in:
parent
c66efa6964
commit
5fb7d30dbc
25
portal.lua
25
portal.lua
@ -50,7 +50,7 @@ end
|
|||||||
-- where the player appears after dying
|
-- where the player appears after dying
|
||||||
local function get_player_died_target(player)
|
local function get_player_died_target(player)
|
||||||
local target = vector.add(player:get_pos(),
|
local target = vector.add(player:get_pos(),
|
||||||
{x=math.random(-100,100), y=0, z=math.random(-100,100)})
|
{x=math.random(-5,5), y=0, z=math.random(-5,5)})
|
||||||
target.y = portal_target + math.random(4)
|
target.y = portal_target + math.random(4)
|
||||||
return target
|
return target
|
||||||
end
|
end
|
||||||
@ -61,10 +61,9 @@ local function obsidian_teleport(player, pname, target)
|
|||||||
players_in_hell[pname] = true
|
players_in_hell[pname] = true
|
||||||
save_hell_players()
|
save_hell_players()
|
||||||
update_background(player, true)
|
update_background(player, true)
|
||||||
|
player:set_hp(0)
|
||||||
if target then
|
if target then
|
||||||
player:set_pos(target)
|
player:set_pos(target)
|
||||||
else
|
|
||||||
player:set_hp(0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -336,7 +335,10 @@ local function hell_port(player, pos)
|
|||||||
set_portal(known_portals_d, pos.z,pos.x, pos.y)
|
set_portal(known_portals_d, pos.z,pos.x, pos.y)
|
||||||
|
|
||||||
local my = tonumber(meta:get_string("y"))
|
local my = tonumber(meta:get_string("y"))
|
||||||
local y = get_portal(known_portals_u, pos.z,pos.x)
|
local destination_pos = vector.multiply(pos, hell.FASTTRAVEL_FACTOR)
|
||||||
|
destination_pos.x = math.min(30900, math.max(-30900, destination_pos.x)) -- clip to world boundary
|
||||||
|
destination_pos.z = math.min(30900, math.max(-30900, destination_pos.z)) -- clip to world boundary
|
||||||
|
local y = get_portal(known_portals_u, destination_pos.z, destination_pos.x)
|
||||||
if y then
|
if y then
|
||||||
if y ~= my then
|
if y ~= my then
|
||||||
meta:set_string("y", y)
|
meta:set_string("y", y)
|
||||||
@ -344,14 +346,17 @@ local function hell_port(player, pos)
|
|||||||
else
|
else
|
||||||
y = my or 100
|
y = my or 100
|
||||||
end
|
end
|
||||||
pos.y = y - 0.3
|
destination_pos.y = y - 0.3
|
||||||
|
|
||||||
player_from_hell(player, pos)
|
player_from_hell(player, destination_pos)
|
||||||
else
|
else
|
||||||
set_portal(known_portals_u, pos.z,pos.x, pos.y)
|
set_portal(known_portals_u, pos.z,pos.x, pos.y)
|
||||||
|
|
||||||
local my = tonumber(meta:get_string("y"))
|
local my = tonumber(meta:get_string("y"))
|
||||||
local y = get_portal(known_portals_d, pos.z,pos.x)
|
local destination_pos = vector.divide(pos, hell.FASTTRAVEL_FACTOR)
|
||||||
|
destination_pos.x = math.floor(0.5 + destination_pos.x) -- round to int
|
||||||
|
destination_pos.z = math.floor(0.5 + destination_pos.z) -- round to int
|
||||||
|
local y = get_portal(known_portals_d, destination_pos.z, destination_pos.x)
|
||||||
if y then
|
if y then
|
||||||
if y ~= my then
|
if y ~= my then
|
||||||
meta:set_string("y", y)
|
meta:set_string("y", y)
|
||||||
@ -359,9 +364,9 @@ local function hell_port(player, pos)
|
|||||||
else
|
else
|
||||||
y = my or portal_target+math.random(4)
|
y = my or portal_target+math.random(4)
|
||||||
end
|
end
|
||||||
pos.y = y - 0.3
|
destination_pos.y = y - 0.3
|
||||||
|
|
||||||
player_to_hell(player, pos)
|
player_to_hell(player, destination_pos)
|
||||||
end
|
end
|
||||||
minetest.sound_play("hell_teleporter", {pos=pos})
|
minetest.sound_play("hell_teleporter", {pos=pos})
|
||||||
return true
|
return true
|
||||||
@ -487,7 +492,7 @@ if hell.HELL_REALM_ENABLED then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
obsidian_teleport(player, pname)
|
obsidian_teleport(player, pname, new_playerPos)
|
||||||
minetest.sound_play("hell_portal_usual", {to_player=pname, gain=1})
|
minetest.sound_play("hell_portal_usual", {to_player=pname, gain=1})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user