Improve knight's damage boost code
This commit is contained in:
parent
ecc6858c15
commit
abb463fbd3
3 changed files with 14 additions and 29 deletions
|
@ -1,28 +1,12 @@
|
|||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||
if reason.type ~= "punch" or not reason.object or not reason.object:is_player() then
|
||||
return hp_change
|
||||
end
|
||||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
if tool_capabilities.damage_groups.nopunch then return end
|
||||
local class = ctf_classes.get(hitter)
|
||||
|
||||
local class = ctf_classes.get(reason.object)
|
||||
|
||||
if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then
|
||||
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
|
||||
if class.properties.melee_bonus and hitter:get_wielded_item():get_name():find("sword") then
|
||||
if time_from_last_punch > 0.75 then
|
||||
time_from_last_punch = 0.75
|
||||
end
|
||||
|
||||
return change
|
||||
player:punch(hitter, 1, {damage_groups = {fleshy = time_from_last_punch*2, nopunch = 1}}, dir)
|
||||
end
|
||||
|
||||
return hp_change
|
||||
end, true)
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue