diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index af5f9bd6e..53eb7492b 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -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