1
0
Fork 0

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:
Eliy21 2023-11-12 12:51:31 +00:00
parent 4cd2962a87
commit 00165959af
1 changed files with 6 additions and 4 deletions

View File

@ -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