1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2024-09-27 23:10:35 +02:00

don't trigger armor:punch when max_hp decreases

This commit is contained in:
flux 2023-04-19 14:02:29 -07:00
parent dc7fbce09a
commit 320add2e84
No known key found for this signature in database
GPG Key ID: 9333B27816848A15

View File

@ -414,10 +414,18 @@ if armor.config.punch_damage == true then
end end
minetest.register_on_player_hpchange(function(player, hp_change, reason) minetest.register_on_player_hpchange(function(player, hp_change, reason)
if player and reason.type ~= "drown" and reason.hunger == nil if not minetest.is_player(player) then
and hp_change < 0 then return hp_change
end
if reason.type == "drown" or reason.hunger or hp_change >= 0 then
return hp_change
end
local name = player:get_player_name() local name = player:get_player_name()
if name then local properties = player:get_properties()
local hp = player:get_hp()
if hp + hp_change < properties.hp_max then
local heal = armor.def[name].heal local heal = armor.def[name].heal
if heal >= math.random(100) then if heal >= math.random(100) then
hp_change = 0 hp_change = 0
@ -428,7 +436,7 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
armor:punch(player) armor:punch(player)
end end
end end
end
return hp_change return hp_change
end, true) end, true)