Skip to content

Commit

Permalink
add additional death checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tenplus1 committed Nov 15, 2020
1 parent d12576f commit bdea826
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")

mobs = {
mod = "redo",
version = "20201029",
version = "20201115",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
Expand Down Expand Up @@ -877,7 +877,7 @@ function mob_class:check_for_death(cmi_cause)
local pos = self.object:get_pos()

-- execute custom death function
if self.on_die then
if pos and self.on_die then

self:on_die(pos)

Expand All @@ -897,7 +897,7 @@ function mob_class:check_for_death(cmi_cause)

local frames = self.animation.die_end - self.animation.die_start
local speed = self.animation.die_speed or 15
local length = max(frames / speed, 0)
local length = max((frames / speed), 0)

self.attack = nil
self.v_start = false
Expand All @@ -910,23 +910,28 @@ function mob_class:check_for_death(cmi_cause)

minetest.after(length, function(self)

if use_cmi and self.object:get_luaentity() then
cmi.notify_die(self.object, cmi_cause)
end
if self.object:get_luaentity() then

remove_mob(self, true)
if use_cmi then
cmi.notify_die(self.object, cmi_cause)
end

remove_mob(self, true)
end
end, self)
else

return true

elseif pos then -- otherwise remove mod and show particle effect

if use_cmi then
cmi.notify_die(self.object, cmi_cause)
end

remove_mob(self, true)
end

effect(pos, 20, "tnt_smoke.png")
effect(pos, 20, "tnt_smoke.png")
end

return true
end
Expand Down

0 comments on commit bdea826

Please sign in to comment.