Respawn preserves corpse momentum #4382

Open
opened 2023-05-02 17:35:05 +00:00 by sixer · 5 comments

When jumping on the haven trampoline (and dying a lot in the process :) ) I discovered a bug in the respawn. If you die while on the trampoline, a respawn dialog is show, but until you actually click the "respawn" button, you corpse continues jumping on the trampoline. If you click respawn a moment before the corpse would drop to ground (and bounce back into air), you get hurt quite a lot after respawn from "falling". If you click respawn right after bouncing off the trampoline, you spawn with significant upward momentum and jump in the air, hitting the arch above spawn.

So when clicking "respawn", you spawn with the movement momentum your corpse had at the moment of clicking the button.

This can cause troubles also in real-life scenarios - wither or another block-demolishing monster blasts you when you stand on edge of a big cliff, you die and your corpse starts falling off that cliff. You press respawn in middle of the fall, die second time at spawn due to preserved momentum ... and I guess opening death portal will just bring you to your bones at spawn, not the ones in nether. That could be quite annoying :)

When jumping on the haven trampoline (and dying a lot in the process :) ) I discovered a bug in the respawn. If you die while on the trampoline, a respawn dialog is show, but until you actually click the "respawn" button, you corpse continues jumping on the trampoline. If you click respawn a moment before the corpse would drop to ground (and bounce back into air), you get hurt quite a lot after respawn from "falling". If you click respawn right after bouncing off the trampoline, you spawn with significant upward momentum and jump in the air, hitting the arch above spawn. So when clicking "respawn", you spawn with the movement momentum your corpse had at the moment of clicking the button. This can cause troubles also in real-life scenarios - wither or another block-demolishing monster blasts you when you stand on edge of a big cliff, you die and your corpse starts falling off that cliff. You press respawn in middle of the fall, die second time at spawn due to preserved momentum ... and I guess opening death portal will just bring you to your bones at spawn, not the ones in nether. That could be quite annoying :)
AliasAlreadyTaken added the
1. kind/bug
3. source/engine
labels 2023-05-02 18:37:30 +00:00

As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after.

As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after.
Author

Ok, then I suggest having 3x3 patch from mushroom pores at spawn location (or similar measure) as a safety workaround.

Ok, then I suggest having 3x3 patch from mushroom pores at spawn location (or similar measure) as a safety workaround.
AliasAlreadyTaken added the
1. kind/enhancement
label 2023-05-02 19:43:04 +00:00
Member

As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after.

can we set speed and gravity to 0 at death?

> As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after. can we set speed and gravity to 0 at death?
Member

As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after.

can we set speed and gravity to 0 at death?

Doing player:add_velocity in register_on_respawnplayer leads to some very strange results...
When you are dead and have "Respawn" window open, if you call player:get_velocity() it seems to keep the value it had before your death (even if your corpse is not moving). And adding speed behaves strange after death.. I think there's some inconsistency about switching from dead to alive state. Could not figure it out, although even looked at some of the cpp code.

What kinda worked is making player invincible for a short time, they still can fly up and die after that, but at least this prevents instant splat when flying down (but this also works kinda inconsistent)... And doing it this way may leave some players with invincible priv in some cases, which is fun :P

-- there's no function for this or I'm blind?
local function set_priv(playername, priv, val)
    local privs = minetest.get_player_privs(playername)
    privs[priv] = val
    minetest.set_player_privs(playername, privs)
end


minetest.register_on_respawnplayer(function(player)
        local playername = player:get_player_name()
        if not minetest.check_player_privs(playername, { invincible = true }) then
            local revoke = function()
                set_priv(playername, 'invincible', nil)
            end

            set_priv(playername, 'invincible', true)

            minetest.after(0.5, revoke)
        end
end)
> > As far as I understand, we are unable due to engine restrictions to assign 0 speed right before spawn and right after. > > can we set speed and gravity to 0 at death? Doing `player:add_velocity` in `register_on_respawnplayer` leads to some very strange results... When you are dead and have "Respawn" window open, if you call `player:get_velocity()` it seems to keep the value it had before your death (even if your corpse is not moving). And adding speed behaves strange after death.. I think there's some inconsistency about switching from dead to alive state. Could not figure it out, although even looked at some of the cpp code. What kinda worked is making player invincible for a short time, they still can fly up and die after that, but at least this prevents instant splat when flying down (but this also works kinda inconsistent)... And doing it this way may leave some players with invincible priv in some cases, which is fun :P ```lua -- there's no function for this or I'm blind? local function set_priv(playername, priv, val) local privs = minetest.get_player_privs(playername) privs[priv] = val minetest.set_player_privs(playername, privs) end minetest.register_on_respawnplayer(function(player) local playername = player:get_player_name() if not minetest.check_player_privs(playername, { invincible = true }) then local revoke = function() set_priv(playername, 'invincible', nil) end set_priv(playername, 'invincible', true) minetest.after(0.5, revoke) end end) ```
Member

we've already got "safe teleport" (hm, i see a race condition in there...), which makes a player immune to the damage from a single fall for up to 4 seconds after they are teleported, perhaps that could be retrofitted to work on respawn as well.

we've already got "[safe teleport](https://gitea.your-land.de/your-land/yl_commons/src/branch/yl_stable/util/safe_teleport.lua)" (hm, i see a race condition in there...), which makes a player immune to the damage from a single fall for up to 4 seconds after they are teleported, perhaps that could be retrofitted to work on respawn as well.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#4382
No description provided.