forked from VoxeLibre/VoxeLibre
Give mobs invulnerability for 0.4 seconds after getting hit
This commit is contained in:
parent
accb8742dd
commit
b2da2b2f63
|
@ -553,6 +553,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
local weapon = hitter:get_wielded_item()
|
local weapon = hitter:get_wielded_item()
|
||||||
local punch_interval = 1.4
|
local punch_interval = 1.4
|
||||||
|
|
||||||
|
-- invulnerability time
|
||||||
|
local invul_time = 0.4
|
||||||
|
|
||||||
-- exhaust attacker
|
-- exhaust attacker
|
||||||
if is_player then
|
if is_player then
|
||||||
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
||||||
|
@ -635,7 +638,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
|
|
||||||
if damage >= 0 then
|
if damage >= 0 then
|
||||||
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
|
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
|
||||||
if damage >= 0.1 then
|
if damage >= 0.1 and tflp > invul_time then
|
||||||
-- weapon sounds
|
-- weapon sounds
|
||||||
if weapon:get_definition().sounds ~= nil then
|
if weapon:get_definition().sounds ~= nil then
|
||||||
|
|
||||||
|
@ -672,7 +675,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
if not v then return end
|
if not v then return end
|
||||||
local r = 1.4 - math.min(punch_interval, 1.4)
|
local r = 1.4 - math.min(punch_interval, 1.4)
|
||||||
local kb = r * (math.abs(v.x)+math.abs(v.z))
|
local kb = r * (math.abs(v.x)+math.abs(v.z))
|
||||||
local up = 2
|
local up = 2.75
|
||||||
|
|
||||||
if die==true then
|
if die==true then
|
||||||
kb=kb*2
|
kb=kb*2
|
||||||
|
@ -689,7 +692,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
if tool_capabilities.damage_groups["knockback"] then
|
if tool_capabilities.damage_groups["knockback"] then
|
||||||
kb = tool_capabilities.damage_groups["knockback"]
|
kb = tool_capabilities.damage_groups["knockback"]
|
||||||
else
|
else
|
||||||
kb = kb * 1.5
|
kb = kb * 2.5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -699,7 +702,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
if hitter and is_player then
|
if hitter and is_player then
|
||||||
local wielditem = hitter:get_wielded_item()
|
local wielditem = hitter:get_wielded_item()
|
||||||
kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
kb = kb + 10 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
||||||
elseif luaentity and luaentity._knockback then
|
elseif luaentity and luaentity._knockback then
|
||||||
kb = kb + luaentity._knockback
|
kb = kb + luaentity._knockback
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue