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
|
||||
end
|
||||
|
||||
-- invulnerability time
|
||||
local invul_time = 0.4
|
||||
local time_now = minetest.get_us_time()
|
||||
|
||||
-- check for invulnerability
|
||||
if tflp <= invul_time then
|
||||
-- check for invulnerability time in microseconds (0.5 second)
|
||||
if time_now - self.last_invul_time <= 500000 then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -665,6 +664,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
|||
-- do damage
|
||||
self.health = self.health - damage
|
||||
|
||||
-- give invulnerability
|
||||
self.last_invul_time = time_now
|
||||
|
||||
-- skip future functions if dead, except alerting others
|
||||
if self:check_for_death( "hit", {type = "punch", puncher = hitter}) then
|
||||
die = true
|
||||
|
|
Loading…
Reference in New Issue