Some more missing arg fixes

This commit is contained in:
cora 2022-11-13 03:16:07 +01:00
parent bc496a8682
commit 7bd0b5a9b1
5 changed files with 11 additions and 10 deletions

View file

@ -303,6 +303,7 @@ end
function mob_class:on_step(dtime) function mob_class:on_step(dtime)
self.lifetimer = self.lifetimer - dtime self.lifetimer = self.lifetimer - dtime
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end
if self:check_despawn(pos) then return true end if self:check_despawn(pos) then return true end
local d = 0.85 local d = 0.85
@ -363,8 +364,8 @@ function mob_class:on_step(dtime)
self:follow_flop() self:follow_flop()
--set animation speed relitive to velocity --set animation speed relitive to velocity
self:set_animation_speed() self:set_animation_speed()
self:check_smooth_rotation() self:check_smooth_rotation(dtime)
self:check_head_swivel() self:check_head_swivel(dtime)
self:do_jump() self:do_jump()
self:set_armor_texture() self:set_armor_texture()

View file

@ -279,10 +279,10 @@ local function dir_to_pitch(dir)
return -math.atan2(-dir.y, xz) return -math.atan2(-dir.y, xz)
end end
function mob_class:check_head_swivel() function mob_class:check_head_swivel(dtime)
if self.head_swivel and type(self.head_swivel) == "string" then if not self.head_swivel or type(self.head_swivel) ~= "string" then return end
local final_rotation = vector.new(0,0,0) local final_rotation = vector.new(0,0,0)
local oldp,oldr = self.object:get_bone_position(self.head_swivel) local pos = self.object:get_pos()
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 10)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 10)) do
if obj:is_player() and not self.attack or obj:get_luaentity() and obj:get_luaentity().name == self.name and self ~= obj:get_luaentity() then if obj:is_player() and not self.attack or obj:get_luaentity() and obj:get_luaentity().name == self.name and self ~= obj:get_luaentity() then

View file

@ -59,6 +59,7 @@ end
function mob_class:check_item_pickup() function mob_class:check_item_pickup()
if self.pick_up and #self.pick_up > 0 or self.wears_armor then if self.pick_up and #self.pick_up > 0 or self.wears_armor then
local p = self.object:get_pos() local p = self.object:get_pos()
if not p then return end
for _,o in pairs(minetest.get_objects_inside_radius(p,2)) do for _,o in pairs(minetest.get_objects_inside_radius(p,2)) do
local l=o:get_luaentity() local l=o:get_luaentity()
if l and l.name == "__builtin:item" then if l and l.name == "__builtin:item" then

View file

@ -1355,7 +1355,7 @@ function mob_class:do_states(dtime)
end end
end end
function mob_class:check_smooth_rotation() function mob_class:check_smooth_rotation(dtime)
-- smooth rotation by ThomasMonroe314 -- smooth rotation by ThomasMonroe314
if self._turn_to then if self._turn_to then
self:set_yaw( self._turn_to, .1) self:set_yaw( self._turn_to, .1)

View file

@ -39,6 +39,7 @@ local function within_limits(pos, radius)
wmin = wmin - radius wmin = wmin - radius
wmax = wmax + radius wmax = wmax + radius
end end
if not pos then return true end
for _,v in pairs(pos) do for _,v in pairs(pos) do
if v < wmin or v > wmax then return false end if v < wmin or v > wmax then return false end
end end
@ -582,6 +583,7 @@ function mob_class:do_env_damage()
end end
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end
self.time_of_day = minetest.get_timeofday() self.time_of_day = minetest.get_timeofday()
@ -592,10 +594,7 @@ function mob_class:do_env_damage()
return true return true
end end
local sunlight = 10 local sunlight = minetest.get_natural_light(pos, self.time_of_day)
if within_limits(pos,0) then
sunlight = minetest.get_natural_light(pos, self.time_of_day)
end
-- bright light harms mob -- bright light harms mob
if self.light_damage ~= 0 and (sunlight or 0) > 12 then if self.light_damage ~= 0 and (sunlight or 0) > 12 then