Add a shim for object:getyaw returning nan, this should be fixed correctly eventually
This commit is contained in:
parent
69fc1cbb64
commit
dffc4b97db
@ -150,13 +150,24 @@ function mobs:register_mob(name, def)
|
|||||||
end,
|
end,
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
v = (v or 0)
|
v = (v or 0)
|
||||||
|
|
||||||
if def.drawtype
|
if def.drawtype
|
||||||
and def.drawtype == "side" then
|
and def.drawtype == "side" then
|
||||||
self.rotate = math.rad(90)
|
self.rotate = math.rad(90)
|
||||||
end
|
end
|
||||||
local yaw = self.object:getyaw() + self.rotate
|
|
||||||
|
local tmpyaw = self.object:getyaw()
|
||||||
|
local yaw = self.rotate;
|
||||||
|
|
||||||
|
if tmpyaw ~= nan then
|
||||||
|
yaw = yaw + tmpyaw
|
||||||
|
else
|
||||||
|
minetest.log("object:getyaw() nan shim used")
|
||||||
|
end
|
||||||
|
|
||||||
local x = math.sin(yaw) * -v
|
local x = math.sin(yaw) * -v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
|
|
||||||
self.object:setvelocity({x = x, y = self.object:getvelocity().y, z = z})
|
self.object:setvelocity({x = x, y = self.object:getvelocity().y, z = z})
|
||||||
end,
|
end,
|
||||||
get_velocity = function(self)
|
get_velocity = function(self)
|
||||||
@ -402,7 +413,7 @@ function mobs:register_mob(name, def)
|
|||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
pos.y = (pos.y + self.collisionbox[2]) - 0.2
|
pos.y = (pos.y + self.collisionbox[2]) - 0.2
|
||||||
local nod = minetest.get_node(pos)
|
local nod = minetest.get_node(pos)
|
||||||
--print ("standing on:", nod.name, pos.y)
|
--print("standing on:", nod.name, pos.y)
|
||||||
if not nod
|
if not nod
|
||||||
or not minetest.registered_nodes[nod.name]
|
or not minetest.registered_nodes[nod.name]
|
||||||
or minetest.registered_nodes[nod.name].walkable == false then
|
or minetest.registered_nodes[nod.name].walkable == false then
|
||||||
@ -416,7 +427,7 @@ function mobs:register_mob(name, def)
|
|||||||
y = pos.y,
|
y = pos.y,
|
||||||
z = pos.z + self.direction.z
|
z = pos.z + self.direction.z
|
||||||
})
|
})
|
||||||
--print ("in front:", nod.name, pos.y)
|
--print("in front:", nod.name, pos.y)
|
||||||
if nod and nod.name and
|
if nod and nod.name and
|
||||||
(nod.name ~= "air"
|
(nod.name ~= "air"
|
||||||
or self.walk_chance == 0) then
|
or self.walk_chance == 0) then
|
||||||
@ -781,7 +792,7 @@ function mobs:register_mob(name, def)
|
|||||||
|
|
||||||
-- water swimmers cannot move out of water
|
-- water swimmers cannot move out of water
|
||||||
if self.fly and self.fly_in == "default:water_source" and not lp then
|
if self.fly and self.fly_in == "default:water_source" and not lp then
|
||||||
print ("out of water")
|
-- print("out of water")
|
||||||
self.set_velocity(self, 0)
|
self.set_velocity(self, 0)
|
||||||
self.state = "flop" -- change to undefined state so nothing more happens
|
self.state = "flop" -- change to undefined state so nothing more happens
|
||||||
self:set_animation("stand")
|
self:set_animation("stand")
|
||||||
@ -902,10 +913,7 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
-- end of exploding mobs
|
-- end of exploding mobs
|
||||||
|
|
||||||
elseif self.state == "attack"
|
-- print("stop attacking")
|
||||||
and self.attack_type == "dogfight" then
|
|
||||||
if not self.attack.player or not self.attack.player:getpos() then
|
|
||||||
print("stop attacking")
|
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self:set_animation("stand")
|
self:set_animation("stand")
|
||||||
return
|
return
|
||||||
@ -1075,9 +1083,9 @@ function mobs:register_mob(name, def)
|
|||||||
obj:setvelocity(vec)
|
obj:setvelocity(vec)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
|
|
||||||
if self.type == "monster"
|
if self.type == "monster"
|
||||||
and peaceful_only then
|
and peaceful_only then
|
||||||
@ -1162,9 +1170,9 @@ function mobs:register_mob(name, def)
|
|||||||
self:on_spawn()
|
self:on_spawn()
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
|
|
||||||
-- remove mob when out of range unless tamed
|
-- remove mob when out of range unless tamed
|
||||||
if mobs.remove == true and self.remove_ok and not self.tamed then
|
if mobs.remove == true and self.remove_ok and not self.tamed then
|
||||||
@ -1185,9 +1193,9 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
-- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
|
-- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
|
||||||
return minetest.serialize(tmp)
|
return minetest.serialize(tmp)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
-- weapon wear
|
-- weapon wear
|
||||||
local weapon = hitter:get_wielded_item()
|
local weapon = hitter:get_wielded_item()
|
||||||
if weapon:get_definition().tool_capabilities ~= nil then
|
if weapon:get_definition().tool_capabilities ~= nil then
|
||||||
@ -1259,8 +1267,8 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user