0
0
Fork 0

Implement framework for mob death

This commit is contained in:
jordan4ibanez 2021-04-22 20:25:58 -04:00
parent 8530e6ee36
commit b73ab976a1
2 changed files with 14 additions and 1 deletions

View File

@ -610,6 +610,11 @@ mobs.mob_step = function(self, dtime)
return false
end
if self.health <= 0 then
print("I'm DEAD :(")
return
end
local attacking = nil
--scan for players within eyesight

View File

@ -43,6 +43,10 @@ end
-- I have no idea what this does
mobs.create_mob_on_rightclick = function(on_rightclick)
return function(self, clicker)
--don't allow rightclicking dead mobs
if self.health <= 0 then
return
end
local stop = on_rightclick_prefix(self, clicker)
if (not stop) and (on_rightclick) then
on_rightclick(self, clicker)
@ -54,6 +58,11 @@ end
-- deal damage and effects when mob punched
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
--don't do anything if the mob is already dead
if self.health <= 0 then
return
end
--neutral passive mobs switch to neutral hostile
if self.neutral then
@ -82,7 +91,6 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
--don't do damage until pause timer resets
if self.pause_timer > 0 then
print(self.pause_timer)
return
end