Fix points not being awarded on death

This commit is contained in:
LoneWolfHT 2020-10-13 20:00:21 -07:00
parent 90d73f0587
commit 973f01b0a9

View file

@ -6,7 +6,22 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
local class = ctf_classes.get(reason.object) local class = ctf_classes.get(reason.object)
if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then
return hp_change - class.properties.melee_bonus local change = hp_change - class.properties.melee_bonus
if player:get_hp() + change <= 0 and player:get_hp() + hp_change > 0 then
local wielded_item = reason.object:get_wielded_item()
for i = 1, #ctf.registered_on_killedplayer do
ctf.registered_on_killedplayer[i](
player:get_player_name(),
reason.object:get_player_name(),
wielded_item,
wielded_item:get_tool_capabilities()
)
end
end
return change
end end
return hp_change return hp_change