Fix medkits HP leak due to missing check
This commit is contained in:
parent
32c0726995
commit
8b706130aa
1 changed files with 13 additions and 10 deletions
|
@ -21,16 +21,17 @@ end
|
|||
-- Aborts if player is already healing
|
||||
local function start_healing(stack, player)
|
||||
if not player then
|
||||
return stack
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local hp = player:get_hp()
|
||||
|
||||
if players[name] or player:get_hp() >= regen_max then
|
||||
return stack
|
||||
if players[name] or hp >= regen_max then
|
||||
return
|
||||
end
|
||||
|
||||
players[name] = {
|
||||
hp = player:get_hp(),
|
||||
hp = hp,
|
||||
pos = player:get_pos(),
|
||||
hud = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
|
@ -82,15 +83,17 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
|
||||
-- Stop healing if target reached
|
||||
if players[name] then
|
||||
local hp = player:get_hp()
|
||||
if hp < regen_max then
|
||||
player:set_hp(hp + regen_step)
|
||||
player:set_hp(math.min(hp + regen_step, regen_max))
|
||||
else
|
||||
player:set_hp(regen_max)
|
||||
stop_healing(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
regen_timer = 0
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in a new issue