forked from MineClone5/MineClone5
fix crash on creeper explosion ( #1755 )
This commit is contained in:
parent
b6dd8d5c44
commit
66f132a645
|
@ -22,7 +22,7 @@ local DEFAULT_CLIMB_SPEED = 3
|
||||||
|
|
||||||
mobs.stick_in_cobweb = function(self)
|
mobs.stick_in_cobweb = function(self)
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = vector_multiply(vector_normalize(current_velocity), 0.4)
|
local goal_velocity = vector_multiply(vector_normalize(current_velocity), 0.4)
|
||||||
|
|
||||||
goal_velocity.y = -0.5
|
goal_velocity.y = -0.5
|
||||||
|
@ -38,8 +38,11 @@ end
|
||||||
--this is a generic float function
|
--this is a generic float function
|
||||||
mobs.float = function(self)
|
mobs.float = function(self)
|
||||||
|
|
||||||
if self.object:get_acceleration().y ~= 0 then
|
local acceleration = self.object:get_acceleration()
|
||||||
|
if acceleration and acceleration.y ~= 0 then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector_new(0,0,0))
|
||||||
|
else
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
@ -86,10 +89,10 @@ end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
_ _
|
_ _
|
||||||
| | | |
|
| | | |
|
||||||
| | __ _ _ __ __| |
|
| | __ _ _ __ __| |
|
||||||
| | / _` | '_ \ / _` |
|
| | / _` | '_ \ / _` |
|
||||||
| |___| (_| | | | | (_| |
|
| |___| (_| | | | | (_| |
|
||||||
\_____/\__,_|_| |_|\__,_|
|
\_____/\__,_|_| |_|\__,_|
|
||||||
]]
|
]]
|
||||||
|
@ -100,7 +103,7 @@ end
|
||||||
--internal = lua (self.yaw)
|
--internal = lua (self.yaw)
|
||||||
--engine = c++ (self.object:get_yaw())
|
--engine = c++ (self.object:get_yaw())
|
||||||
mobs.set_velocity = function(self, v)
|
mobs.set_velocity = function(self, v)
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
local yaw = (self.yaw or 0)
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
@ -152,7 +155,7 @@ mobs.jump = function(self, velocity)
|
||||||
--fallback velocity to allow modularity
|
--fallback velocity to allow modularity
|
||||||
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
||||||
|
|
||||||
self.object:add_velocity(vector_new(0,velocity,0))
|
self.object:add_velocity(vector_new(0,velocity,0))
|
||||||
end
|
end
|
||||||
|
|
||||||
--make mobs fall slowly
|
--make mobs fall slowly
|
||||||
|
@ -188,10 +191,10 @@ end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
_____ _
|
_____ _
|
||||||
/ ___| (_)
|
/ ___| (_)
|
||||||
\ `--.__ ___ _ __ ___
|
\ `--.__ ___ _ __ ___
|
||||||
`--. \ \ /\ / / | '_ ` _ \
|
`--. \ \ /\ / / | '_ ` _ \
|
||||||
/\__/ /\ V V /| | | | | | |
|
/\__/ /\ V V /| | | | | | |
|
||||||
\____/ \_/\_/ |_|_| |_| |_|
|
\____/ \_/\_/ |_|_| |_| |_|
|
||||||
]]--
|
]]--
|
||||||
|
@ -221,7 +224,7 @@ mobs.flop = function(self, velocity)
|
||||||
local final_additional_force = vector_multiply(minetest_yaw_to_dir(dir), force)
|
local final_additional_force = vector_multiply(minetest_yaw_to_dir(dir), force)
|
||||||
|
|
||||||
--place in the "flop" velocity to make the mob flop
|
--place in the "flop" velocity to make the mob flop
|
||||||
final_additional_force.y = velocity
|
final_additional_force.y = velocity
|
||||||
|
|
||||||
self.object:add_velocity(final_additional_force)
|
self.object:add_velocity(final_additional_force)
|
||||||
|
|
||||||
|
@ -235,7 +238,7 @@ end
|
||||||
--internal = lua (self.yaw)
|
--internal = lua (self.yaw)
|
||||||
--engine = c++ (self.object:get_yaw())
|
--engine = c++ (self.object:get_yaw())
|
||||||
mobs.set_swim_velocity = function(self, v)
|
mobs.set_swim_velocity = function(self, v)
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
local yaw = (self.yaw or 0)
|
||||||
local pitch = (self.pitch or 0)
|
local pitch = (self.pitch or 0)
|
||||||
|
|
||||||
|
@ -265,14 +268,14 @@ mobs.set_swim_velocity = function(self, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
______ _
|
______ _
|
||||||
| ___| |
|
| ___| |
|
||||||
| |_ | |_ _
|
| |_ | |_ _
|
||||||
| _| | | | | |
|
| _| | | | | |
|
||||||
| | | | |_| |
|
| | | | |_| |
|
||||||
\_| |_|\__, |
|
\_| |_|\__, |
|
||||||
__/ |
|
__/ |
|
||||||
|___/
|
|___/
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- move mob in facing direction
|
-- move mob in facing direction
|
||||||
|
@ -280,7 +283,7 @@ ______ _
|
||||||
--internal = lua (self.yaw)
|
--internal = lua (self.yaw)
|
||||||
--engine = c++ (self.object:get_yaw())
|
--engine = c++ (self.object:get_yaw())
|
||||||
mobs.set_fly_velocity = function(self, v)
|
mobs.set_fly_velocity = function(self, v)
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
local yaw = (self.yaw or 0)
|
||||||
local pitch = (self.pitch or 0)
|
local pitch = (self.pitch or 0)
|
||||||
|
|
||||||
|
@ -332,14 +335,14 @@ end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
___
|
___
|
||||||
|_ |
|
|_ |
|
||||||
| |_ _ _ __ ___ _ __
|
| |_ _ _ __ ___ _ __
|
||||||
| | | | | '_ ` _ \| '_ \
|
| | | | | '_ ` _ \| '_ \
|
||||||
/\__/ / |_| | | | | | | |_) |
|
/\__/ / |_| | | | | | | |_) |
|
||||||
\____/ \__,_|_| |_| |_| .__/
|
\____/ \__,_|_| |_| |_| .__/
|
||||||
| |
|
| |
|
||||||
|_|
|
|_|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
--special mob jump movement
|
--special mob jump movement
|
||||||
|
@ -388,4 +391,4 @@ mobs.swap_auto_step_height_adjust = function(self)
|
||||||
elseif y_vel ~= 0 and self.stepheight ~= 0 then
|
elseif y_vel ~= 0 and self.stepheight ~= 0 then
|
||||||
self.stepheight = 0
|
self.stepheight = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue