Revert "Rework melee damage (#878)" (#925)

This reverts commit 84dc7da461.
This commit is contained in:
LoneWolfHT 2021-09-03 16:20:18 -07:00 committed by GitHub
parent 84dc7da461
commit ea9d9ad2d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 45 deletions

View file

@ -133,21 +133,22 @@ end)
-- If player takes damage while healing,
-- stop regen and revert back to original state
minetest.register_on_player_hpchange(function(player, hp_change, reason)
minetest.register_on_player_hpchange(function(player, hp, reason)
local name = player:get_player_name()
if hp_change < 0 then
if hp < 0 then
if players[name] then
player:hud_remove(players[name].hud)
players[name] = nil -- Don't use stop_healing(), it uses set_hp() and won't allocate deaths or score properly
end
if reason.type == "punch" then
if reason and reason.type == "punch" then
local hitter = reason.object
if hitter and players[hitter:get_player_name()] then
stop_healing(hitter, "attack")
end
end
end
end)
return hp
end, true)
minetest.register_on_leaveplayer(function(player)
players[player:get_player_name()] = nil