forked from VoxeLibre/VoxeLibre
Add some mob object checks to avoid crashing
This commit is contained in:
parent
9a276489d1
commit
2cd6629ae1
|
@ -186,11 +186,13 @@ function mob_class:slow_mob()
|
||||||
local d = 0.85
|
local d = 0.85
|
||||||
if self:check_dying() then d = 0.92 end
|
if self:check_dying() then d = 0.92 end
|
||||||
|
|
||||||
|
if self.object then
|
||||||
local v = self.object:get_velocity()
|
local v = self.object:get_velocity()
|
||||||
if v then
|
if v then
|
||||||
--diffuse object velocity
|
--diffuse object velocity
|
||||||
self.object:set_velocity({x = v.x*d, y = v.y, z = v.z*d})
|
self.object:set_velocity({x = v.x*d, y = v.y, z = v.z*d})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- move mob in facing direction
|
-- move mob in facing direction
|
||||||
|
@ -518,9 +520,11 @@ function mob_class:check_for_death(cause, cmi_cause)
|
||||||
})
|
})
|
||||||
|
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
|
if self.object then
|
||||||
local acc = self.object:get_acceleration()
|
local acc = self.object:get_acceleration()
|
||||||
acc.x, acc.y, acc.z = 0, DEFAULT_FALL_SPEED, 0
|
acc.x, acc.y, acc.z = 0, DEFAULT_FALL_SPEED, 0
|
||||||
self.object:set_acceleration(acc)
|
self.object:set_acceleration(acc)
|
||||||
|
end
|
||||||
|
|
||||||
local length
|
local length
|
||||||
-- default death function and die animation (if defined)
|
-- default death function and die animation (if defined)
|
||||||
|
@ -980,9 +984,11 @@ end
|
||||||
|
|
||||||
function mob_class:check_dying()
|
function mob_class:check_dying()
|
||||||
if ((self.state and self.state=="die") or self:check_for_death()) and not self.animation.die_end then
|
if ((self.state and self.state=="die") or self:check_for_death()) and not self.animation.die_end then
|
||||||
|
if self.object then
|
||||||
local rot = self.object:get_rotation()
|
local rot = self.object:get_rotation()
|
||||||
rot.z = ((math.pi/2-rot.z)*.2)+rot.z
|
rot.z = ((math.pi/2-rot.z)*.2)+rot.z
|
||||||
self.object:set_rotation(rot)
|
self.object:set_rotation(rot)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue