--- QuestTest.old/qt_mobs/api.lua +++ QuestTest/qt_mobs/api.lua @@ -52,12 +52,19 @@ set_velocity = function(self, v) local yaw = self.object:getyaw() + if yaw ~= yaw or yaw == nil then yaw = 0 end + if v ~= v or v == nil then v = 0 end if self.drawtype == "side" then yaw = yaw+(math.pi/2) end local x = math.sin(yaw) * -v + local y=self.object:getvelocity().y local z = math.cos(yaw) * v - self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z}) + if x ~= x or x == nil then x = 0 end + if y ~= y or y == nil then y = 0 end + if z ~= z or z == nil then z = 0 end + local pos = {x=x,y=y,z=z} + self.object:setvelocity (pos) end, get_velocity = function(self) @@ -569,9 +576,11 @@ return minetest.serialize(tmp) end, - on_punch = function(self, hitter) - if self.object:get_hp() <= 0 then + on_punch = function(self, hitter, tflp, tcap, dir, dmg) + if (self.object:get_hp() - dmg) <= 0 then if hitter and hitter:is_player() and hitter:get_inventory() then + local pos = self.object:getpos() + minetest.env:add_entity (pos, "experience:orb") for _,drop in ipairs(self.drops) do if math.random(1, drop.chance) == 1 then hitter:get_inventory():add_item("main", ItemStack(drop.name.." "..math.random(drop.min, drop.max)))