forked from VoxeLibre/VoxeLibre
Fix held attack key not hitting mobs bug (this time for sure)
Reverting to old code in the previous PR but with the new optimizations kept
This commit is contained in:
parent
4cd2962a87
commit
00165959af
|
@ -532,11 +532,10 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- invulnerability time
|
local time_now = minetest.get_us_time()
|
||||||
local invul_time = 0.4
|
|
||||||
|
|
||||||
-- check for invulnerability
|
-- check for invulnerability time in microseconds (0.5 second)
|
||||||
if tflp <= invul_time then
|
if time_now - self.last_invul_time <= 500000 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -665,6 +664,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
-- do damage
|
-- do damage
|
||||||
self.health = self.health - damage
|
self.health = self.health - damage
|
||||||
|
|
||||||
|
-- give invulnerability
|
||||||
|
self.last_invul_time = time_now
|
||||||
|
|
||||||
-- skip future functions if dead, except alerting others
|
-- skip future functions if dead, except alerting others
|
||||||
if self:check_for_death( "hit", {type = "punch", puncher = hitter}) then
|
if self:check_for_death( "hit", {type = "punch", puncher = hitter}) then
|
||||||
die = true
|
die = true
|
||||||
|
|
Loading…
Reference in New Issue