remove death from game

A survival server that was interested in having this game pointed out that death is expensive in survival. So I removed death from the game with a hp_change modifier. If the damage applied while in game would not cause death, then it is applied as normal. If it would cause death, then full health is restored, but the player is eliminated. A benefit of this approach is that the player no longer needs to see the you died message which really is not appropriate for this type of game.
This commit is contained in:
MisterE123 2021-01-28 16:35:34 +00:00
parent 8d3b867495
commit 27f69735ac

View File

@ -63,6 +63,31 @@ arena_lib.on_time_tick('sumo', function(arena)
end)
minetest.register_on_player_hpchange(function(player, hp_change)
local pl_name = player:get_player_name()
if arena_lib.is_player_in_arena(pl_name, 'sumo') then
local arena = arena_lib.get_arena_by_player(pl_name)
local hp = player:get_hp()
if arena.in_celebration then --protect winners from damage
return 0
end
if hp + hp_change <= 0 then --dont ever kill players, but if a damage *would* kill them, then eliminate them, and set their health back to normal
arena_lib.HUD_hide('hotbar', p_name)
arena_lib.remove_player_from_arena(pl_name, 1)
player:set_hp(20)
return 0
else
return hp_change --if it would not kill players then apply damage as normal
end
else
return hp_change
end
end, true)
--if the game times out
arena_lib.on_timeout('sumo', function(arena)