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:
parent
3e95d92359
commit
abf1fa2ad5
5 changed files with 41 additions and 42 deletions
|
@ -446,12 +446,16 @@ function ctf.register_on_killedplayer(func)
|
|||
table.insert(ctf.registered_on_killedplayer, func)
|
||||
end
|
||||
|
||||
ctf.registered_on_punchplayer = {}
|
||||
function ctf.register_on_punchplayer(func)
|
||||
function ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities, dir, damage, ...)
|
||||
return true
|
||||
end
|
||||
|
||||
ctf.registered_on_attack = {}
|
||||
function ctf.register_on_attack(func)
|
||||
if ctf._mt_loaded then
|
||||
error("You can't register callbacks at game time!")
|
||||
end
|
||||
table.insert(ctf.registered_on_punchplayer, func)
|
||||
table.insert(ctf.registered_on_attack, func)
|
||||
end
|
||||
|
||||
local dead_players = {}
|
||||
|
@ -482,6 +486,12 @@ minetest.register_on_punchplayer(function(player, hitter,
|
|||
end
|
||||
end
|
||||
|
||||
if ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities,
|
||||
dir, damage, ...) == false
|
||||
then
|
||||
return true
|
||||
end
|
||||
|
||||
local hp = player:get_hp()
|
||||
if hp == 0 then
|
||||
return false
|
||||
|
@ -497,8 +507,8 @@ minetest.register_on_punchplayer(function(player, hitter,
|
|||
return false
|
||||
end
|
||||
|
||||
for i = 1, #ctf.registered_on_punchplayer do
|
||||
ctf.registered_on_punchplayer[i](
|
||||
for i = 1, #ctf.registered_on_attack do
|
||||
ctf.registered_on_attack[i](
|
||||
player, hitter, time_from_last_punch,
|
||||
tool_capabilities, dir, damage, ...
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue