Don't count kill assist on build time or player immunity (#795)

* Don't count kill assist on build time or player immunity

* Remove register_can_attack, use can_attack global func
This commit is contained in:
savilli 2021-02-14 01:17:05 +03:00 committed by GitHub
parent 3e95d92359
commit abf1fa2ad5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 42 deletions

View file

@ -9,24 +9,12 @@ local COMBATLOG_SCORE_PENALTY = 10
--- Make suicides and combat logs award last puncher with kill
--
minetest.register_on_punchplayer(function(player, hitter,
ctf.register_on_attack(function(player, hitter,
time_from_last_punch, tool_capabilities, dir, damage)
if player and hitter then
if ctf_respawn_immunity.is_immune(player) or ctf_match.is_in_build_time() then
return
end
local pname = player:get_player_name()
local hname = hitter:get_player_name()
local to = ctf.player(pname)
local from = ctf.player(hname)
if to.team == from.team and to.team ~= "" and
to.team ~= nil and to.name ~= from.name then
return
end
local hp = player:get_hp() - damage
if hp <= 0 then
if potential_cowards[pname] then
@ -39,7 +27,7 @@ minetest.register_on_punchplayer(function(player, hitter,
potential_cowards[hname] = nil
end
return false
return
end
if not potential_cowards[pname] then