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
|
-- Aborts if player is already healing
|
||||||
local function start_healing(stack, player)
|
local function start_healing(stack, player)
|
||||||
if not player then
|
if not player then
|
||||||
return stack
|
return
|
||||||
end
|
end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local hp = player:get_hp()
|
||||||
|
|
||||||
if players[name] or player:get_hp() >= regen_max then
|
if players[name] or hp >= regen_max then
|
||||||
return stack
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
players[name] = {
|
players[name] = {
|
||||||
hp = player:get_hp(),
|
hp = hp,
|
||||||
pos = player:get_pos(),
|
pos = player:get_pos(),
|
||||||
hud = player:hud_add({
|
hud = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
|
@ -82,12 +83,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop healing if target reached
|
-- Stop healing if target reached
|
||||||
local hp = player:get_hp()
|
if players[name] then
|
||||||
if hp < regen_max then
|
local hp = player:get_hp()
|
||||||
player:set_hp(hp + regen_step)
|
if hp < regen_max then
|
||||||
else
|
player:set_hp(math.min(hp + regen_step, regen_max))
|
||||||
player:set_hp(regen_max)
|
else
|
||||||
stop_healing(player)
|
player:set_hp(regen_max)
|
||||||
|
stop_healing(player)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue