diff --git a/portal.lua b/portal.lua index 2095253..4800ee6 100644 --- a/portal.lua +++ b/portal.lua @@ -50,7 +50,7 @@ end -- where the player appears after dying local function get_player_died_target(player) 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) return target end @@ -61,10 +61,9 @@ local function obsidian_teleport(player, pname, target) players_in_hell[pname] = true save_hell_players() update_background(player, true) + player:set_hp(0) if target then player:set_pos(target) - else - player:set_hp(0) end end @@ -336,7 +335,10 @@ local function hell_port(player, pos) set_portal(known_portals_d, pos.z,pos.x, pos.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 ~= my then meta:set_string("y", y) @@ -344,14 +346,17 @@ local function hell_port(player, pos) else y = my or 100 end - pos.y = y - 0.3 + destination_pos.y = y - 0.3 - player_from_hell(player, pos) + player_from_hell(player, destination_pos) else set_portal(known_portals_u, pos.z,pos.x, pos.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 ~= my then meta:set_string("y", y) @@ -359,9 +364,9 @@ local function hell_port(player, pos) else y = my or portal_target+math.random(4) end - pos.y = y - 0.3 + destination_pos.y = y - 0.3 - player_to_hell(player, pos) + player_to_hell(player, destination_pos) end minetest.sound_play("hell_teleporter", {pos=pos}) return true @@ -487,7 +492,7 @@ if hell.HELL_REALM_ENABLED then return end - obsidian_teleport(player, pname) + obsidian_teleport(player, pname, new_playerPos) minetest.sound_play("hell_portal_usual", {to_player=pname, gain=1}) end, })