mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 10:20:21 +01:00
add additional death checks
This commit is contained in:
parent
d12576f0c8
commit
bdea826b7c
27
api.lua
27
api.lua
@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20201029",
|
version = "20201115",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -877,7 +877,7 @@ function mob_class:check_for_death(cmi_cause)
|
|||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
-- execute custom death function
|
-- execute custom death function
|
||||||
if self.on_die then
|
if pos and self.on_die then
|
||||||
|
|
||||||
self:on_die(pos)
|
self:on_die(pos)
|
||||||
|
|
||||||
@ -897,7 +897,7 @@ function mob_class:check_for_death(cmi_cause)
|
|||||||
|
|
||||||
local frames = self.animation.die_end - self.animation.die_start
|
local frames = self.animation.die_end - self.animation.die_start
|
||||||
local speed = self.animation.die_speed or 15
|
local speed = self.animation.die_speed or 15
|
||||||
local length = max(frames / speed, 0)
|
local length = max((frames / speed), 0)
|
||||||
|
|
||||||
self.attack = nil
|
self.attack = nil
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
@ -910,23 +910,28 @@ function mob_class:check_for_death(cmi_cause)
|
|||||||
|
|
||||||
minetest.after(length, function(self)
|
minetest.after(length, function(self)
|
||||||
|
|
||||||
if use_cmi and self.object:get_luaentity() then
|
if self.object:get_luaentity() then
|
||||||
cmi.notify_die(self.object, cmi_cause)
|
|
||||||
|
if use_cmi then
|
||||||
|
cmi.notify_die(self.object, cmi_cause)
|
||||||
|
end
|
||||||
|
|
||||||
|
remove_mob(self, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_mob(self, true)
|
|
||||||
|
|
||||||
end, self)
|
end, self)
|
||||||
else
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
elseif pos then -- otherwise remove mod and show particle effect
|
||||||
|
|
||||||
if use_cmi then
|
if use_cmi then
|
||||||
cmi.notify_die(self.object, cmi_cause)
|
cmi.notify_die(self.object, cmi_cause)
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_mob(self, true)
|
remove_mob(self, true)
|
||||||
end
|
|
||||||
|
|
||||||
effect(pos, 20, "tnt_smoke.png")
|
effect(pos, 20, "tnt_smoke.png")
|
||||||
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user