properly set hp when poly player dies

This commit is contained in:
bgkillas 2024-10-29 11:55:44 -04:00
parent 28369b17a9
commit 9509277e10

View file

@ -376,6 +376,13 @@ ctx.cap.health = {
reduce_hp()
else
polymorph.switch_entity(end_poly_effect(ctx.my_player.entity))
local _, max_hp_new, has_hp = util.get_ent_health(ctx.my_player.entity)
if not ctx.my_player.currently_polymorphed and has_hp then
-- Restore the player back to small amount of hp.
local new_hp = 3 * max_hp_new / 20
local final_hp = math.max(new_hp, math.min(2/5, max_hp_new))
util.set_ent_health(ctx.my_player.entity, {final_hp, max_hp_new})
end
async(function()
wait(1)
player_died()