remove some empty lines (after if/else/function, before end)

This commit is contained in:
nixnoxus 2024-05-04 16:04:36 +02:00
parent ecd62dbba1
commit ba2ee39a86
9 changed files with 2 additions and 169 deletions

View File

@ -97,7 +97,6 @@ function mob_class:get_staticdata()
local tmp = {} local tmp = {}
for _,stat in pairs(self) do for _,stat in pairs(self) do
local t = type(stat) local t = type(stat)
if t ~= "function" if t ~= "function"
@ -149,7 +148,6 @@ function mob_class:mob_activate(staticdata, def, dtime)
--If textures in definition change, reload textures --If textures in definition change, reload textures
if not valid_texture(self, def.textures) then if not valid_texture(self, def.textures) then
-- compatiblity with old simple mobs textures -- compatiblity with old simple mobs textures
if type(def.textures[1]) == "string" then if type(def.textures[1]) == "string" then
def.textures = {def.textures} def.textures = {def.textures}
@ -189,7 +187,6 @@ function mob_class:mob_activate(staticdata, def, dtime)
end end
if self.child == true then if self.child == true then
vis_size = { vis_size = {
x = self.base_size.x * .5, x = self.base_size.x * .5,
y = self.base_size.y * .5, y = self.base_size.y * .5,
@ -289,7 +286,6 @@ function mob_class:mob_activate(staticdata, def, dtime)
return return
end end
if self.on_spawn and not self.on_spawn_run then if self.on_spawn and not self.on_spawn_run then
if self.on_spawn(self) then if self.on_spawn(self) then
self.on_spawn_run = true self.on_spawn_run = true
@ -306,9 +302,6 @@ function mob_class:mob_activate(staticdata, def, dtime)
self._run_armor_init = true self._run_armor_init = true
end end
if def.after_activate then if def.after_activate then
def.after_activate(self, staticdata, def, dtime) def.after_activate(self, staticdata, def, dtime)
end end
@ -426,7 +419,6 @@ local function on_step_work (self, dtime)
end end
if mcl_util.check_dtime_timer(self, dtime, "onstep_occassional", 1) then if mcl_util.check_dtime_timer(self, dtime, "onstep_occassional", 1) then
if player_in_active_range then if player_in_active_range then
self:check_item_pickup() self:check_item_pickup()
self:set_armor_texture() self:set_armor_texture()

View File

@ -40,7 +40,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
local consume_food = false local consume_food = false
-- tame if not still a baby -- tame if not still a baby
if tame and not self.child then if tame and not self.child then
if not self.owner or self.owner == "" then if not self.owner or self.owner == "" then
self.tamed = true self.tamed = true
@ -50,7 +49,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
end end
-- increase health -- increase health
if self.health < self.hp_max and not consume_food then if self.health < self.hp_max and not consume_food then
consume_food = true consume_food = true
self.health = math.min(self.health + 4, self.hp_max) self.health = math.min(self.health + 4, self.hp_max)
@ -62,7 +60,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
end end
-- make children grow quicker -- make children grow quicker
if not consume_food and self.child == true then if not consume_food and self.child == true then
consume_food = true consume_food = true
-- deduct 10% of the time to adulthood -- deduct 10% of the time to adulthood
@ -70,7 +67,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
end end
-- breed animals -- breed animals
if breed and not consume_food and self.hornytimer == 0 and not self.horny then if breed and not consume_food and self.hornytimer == 0 and not self.horny then
self.food = (self.food or 0) + 1 self.food = (self.food or 0) + 1
consume_food = true consume_food = true
@ -158,12 +154,10 @@ function mob_class:check_breeding()
--mcl_log("In breed function") --mcl_log("In breed function")
-- child takes a long time before growing into adult -- child takes a long time before growing into adult
if self.child == true then if self.child == true then
-- When a child, hornytimer is used to count age until adulthood -- When a child, hornytimer is used to count age until adulthood
self.hornytimer = self.hornytimer + 1 self.hornytimer = self.hornytimer + 1
if self.hornytimer >= CHILD_GROW_TIME then if self.hornytimer >= CHILD_GROW_TIME then
self.child = false self.child = false
self.hornytimer = 0 self.hornytimer = 0
@ -210,7 +204,6 @@ function mob_class:check_breeding()
-- find another same animal who is also horny and mate if nearby -- find another same animal who is also horny and mate if nearby
if self.horny == true if self.horny == true
and self.hornytimer <= HORNY_TIME then and self.hornytimer <= HORNY_TIME then
mcl_log("In breed function. All good. Do the magic.") mcl_log("In breed function. All good. Do the magic.")
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -222,14 +215,12 @@ function mob_class:check_breeding()
local ent = nil local ent = nil
for n = 1, #objs do for n = 1, #objs do
ent = objs[n]:get_luaentity() ent = objs[n]:get_luaentity()
-- check for same animal with different colour -- check for same animal with different colour
local canmate = false local canmate = false
if ent then if ent then
if ent.name == self.name then if ent.name == self.name then
canmate = true canmate = true
else else
@ -258,13 +249,10 @@ function mob_class:check_breeding()
-- found your mate? then have a baby -- found your mate? then have a baby
if num > 1 then if num > 1 then
self.hornytimer = HORNY_TIME + 1 self.hornytimer = HORNY_TIME + 1
ent.hornytimer = HORNY_TIME + 1 ent.hornytimer = HORNY_TIME + 1
-- spawn baby -- spawn baby
minetest.after(5, function(parent1, parent2, pos) minetest.after(5, function(parent1, parent2, pos)
if not parent1.object:get_luaentity() then if not parent1.object:get_luaentity() then
return return
@ -284,10 +272,8 @@ function mob_class:check_breeding()
end end
local child = mcl_mobs.spawn_child(pos, parent1.name) local child = mcl_mobs.spawn_child(pos, parent1.name)
local ent_c = child:get_luaentity() local ent_c = child:get_luaentity()
-- Use texture of one of the parents -- Use texture of one of the parents
local p = math.random(1, 2) local p = math.random(1, 2)
if p == 1 then if p == 1 then

View File

@ -42,7 +42,6 @@ function mob_class:do_attack(object)
return return
end end
if object:is_player() and not minetest.settings:get_bool("enable_damage") then if object:is_player() and not minetest.settings:get_bool("enable_damage") then
return return
end end
@ -110,14 +109,12 @@ function mob_class:smart_mobs(s, p, dist, dtime)
-- im stuck, search for path -- im stuck, search for path
if not has_lineofsight then if not has_lineofsight then
if los_switcher == true then if los_switcher == true then
use_pathfind = true use_pathfind = true
los_switcher = false los_switcher = false
end -- cannot see target! end -- cannot see target!
else else
if los_switcher == false then if los_switcher == false then
los_switcher = true los_switcher = true
use_pathfind = false use_pathfind = false
@ -131,7 +128,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
end end
if (self.path.stuck_timer > stuck_timeout and not self.path.following) then if (self.path.stuck_timer > stuck_timeout and not self.path.following) then
use_pathfind = true use_pathfind = true
self.path.stuck_timer = 0 self.path.stuck_timer = 0
@ -144,7 +140,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
end end
if (self.path.stuck_timer > stuck_path_timeout and self.path.following) then if (self.path.stuck_timer > stuck_path_timeout and self.path.following) then
use_pathfind = true use_pathfind = true
self.path.stuck_timer = 0 self.path.stuck_timer = 0
@ -157,7 +152,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
end end
if math.abs(vector.subtract(s,target_pos).y) > self.stepheight then if math.abs(vector.subtract(s,target_pos).y) > self.stepheight then
if height_switcher then if height_switcher then
use_pathfind = true use_pathfind = true
height_switcher = false height_switcher = false
@ -208,18 +202,14 @@ function mob_class:smart_mobs(s, p, dist, dtime)
-- no path found, try something else -- no path found, try something else
if not self.path.way then if not self.path.way then
self.path.following = false self.path.following = false
-- lets make way by digging/building if not accessible -- lets make way by digging/building if not accessible
if self.pathfinding == 2 and mobs_griefing then if self.pathfinding == 2 and mobs_griefing then
-- is player higher than mob? -- is player higher than mob?
if s.y < p1.y then if s.y < p1.y then
-- build upwards -- build upwards
if not minetest.is_protected(s, "") then if not minetest.is_protected(s, "") then
local ndef1 = minetest.registered_nodes[self.standing_in] local ndef1 = minetest.registered_nodes[self.standing_in]
if ndef1 and (ndef1.buildable_to or ndef1.groups.liquid) then if ndef1 and (ndef1.buildable_to or ndef1.groups.liquid) then
@ -235,7 +225,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
-- remove one block above to make room to jump -- remove one block above to make room to jump
if not minetest.is_protected(s, "") then if not minetest.is_protected(s, "") then
local node1 = node_ok(s, "air").name local node1 = node_ok(s, "air").name
local ndef1 = minetest.registered_nodes[node1] local ndef1 = minetest.registered_nodes[node1]
@ -245,10 +234,8 @@ function mob_class:smart_mobs(s, p, dist, dtime)
and not ndef1.groups.level and not ndef1.groups.level
and not ndef1.groups.unbreakable and not ndef1.groups.unbreakable
and not ndef1.groups.liquid then and not ndef1.groups.liquid then
minetest.set_node(s, {name = "air"}) minetest.set_node(s, {name = "air"})
minetest.add_item(s, ItemStack(node1)) minetest.add_item(s, ItemStack(node1))
end end
end end
@ -256,7 +243,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
self.object:set_pos({x = s.x, y = s.y + 2, z = s.z}) self.object:set_pos({x = s.x, y = s.y + 2, z = s.z})
else -- dig 2 blocks to make door toward player direction else -- dig 2 blocks to make door toward player direction
local yaw1 = self.object:get_yaw() + math.pi / 2 local yaw1 = self.object:get_yaw() + math.pi / 2
local p1 = { local p1 = {
x = s.x + math.cos(yaw1), x = s.x + math.cos(yaw1),
@ -265,7 +251,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
} }
if not minetest.is_protected(p1, "") then if not minetest.is_protected(p1, "") then
local node1 = node_ok(p1, "air").name local node1 = node_ok(p1, "air").name
local ndef1 = minetest.registered_nodes[node1] local ndef1 = minetest.registered_nodes[node1]
@ -290,7 +275,6 @@ function mob_class:smart_mobs(s, p, dist, dtime)
and not ndef1.groups.level and not ndef1.groups.level
and not ndef1.groups.unbreakable and not ndef1.groups.unbreakable
and not ndef1.groups.liquid then and not ndef1.groups.liquid then
minetest.add_item(p1, ItemStack(node1)) minetest.add_item(p1, ItemStack(node1))
minetest.set_node(p1, {name = "air"}) minetest.set_node(p1, {name = "air"})
end end
@ -327,7 +311,6 @@ local specific_attack = function(list, what)
-- found entity on list to attack? -- found entity on list to attack?
for no = 1, #list do for no = 1, #list do
if list[no] == what then if list[no] == what then
return true return true
end end
@ -481,7 +464,6 @@ function mob_class:dogswitch(dtime)
and self.dogshoot_count > self.dogshoot_count_max) and self.dogshoot_count > self.dogshoot_count_max)
or (self.dogshoot_switch == 2 or (self.dogshoot_switch == 2
and self.dogshoot_count > self.dogshoot_count2_max) then and self.dogshoot_count > self.dogshoot_count2_max) then
self.dogshoot_count = 0 self.dogshoot_count = 0
if self.dogshoot_switch == 1 then if self.dogshoot_switch == 1 then
@ -546,7 +528,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
-- custom punch function -- custom punch function
if self.do_punch then if self.do_punch then
-- when false skip going any further -- when false skip going any further
if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then
return return
@ -590,7 +571,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
tflp = 0.2 tflp = 0.2
end end
for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do
tmp = tflp / (tool_capabilities.full_punch_interval or 1.4) tmp = tflp / (tool_capabilities.full_punch_interval or 1.4)
@ -614,9 +594,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
-- check for tool immunity or special damage -- check for tool immunity or special damage
for n = 1, #self.immune_to do for n = 1, #self.immune_to do
if self.immune_to[n][1] == weapon:get_name() then if self.immune_to[n][1] == weapon:get_name() then
damage = self.immune_to[n][2] or 0 damage = self.immune_to[n][2] or 0
break break
end end
@ -654,13 +632,11 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
local die = false local die = false
if damage >= 0 then if damage >= 0 then
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
if damage >= 0.1 then if damage >= 0.1 then
-- weapon sounds -- weapon sounds
if weapon:get_definition().sounds ~= nil then if weapon:get_definition().sounds ~= nil then
local s = math.random(0, #weapon:get_definition().sounds) local s = math.random(0, #weapon:get_definition().sounds)
minetest.sound_play(weapon:get_definition().sounds[s], { minetest.sound_play(weapon:get_definition().sounds[s], {
@ -709,7 +685,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
up = 0 up = 0
end end
-- check if tool already has specific knockback value -- check if tool already has specific knockback value
if tool_capabilities.damage_groups["knockback"] then if tool_capabilities.damage_groups["knockback"] then
kb = tool_capabilities.damage_groups["knockback"] kb = tool_capabilities.damage_groups["knockback"]
@ -717,7 +692,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
kb = kb * 1.25 kb = kb * 1.25
end end
local luaentity local luaentity
if hitter then if hitter then
luaentity = hitter:get_luaentity() luaentity = hitter:get_luaentity()
@ -764,7 +738,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
-- if skittish then run away -- if skittish then run away
if hitter and is_player and hitter:get_pos() and not die and self.runaway == true and self.state ~= "flop" then if hitter and is_player and hitter:get_pos() and not die and self.runaway == true and self.state ~= "flop" then
local yaw = self:set_yaw( minetest.dir_to_yaw(vector.direction(hitter:get_pos(), self.object:get_pos()))) local yaw = self:set_yaw( minetest.dir_to_yaw(vector.direction(hitter:get_pos(), self.object:get_pos())))
minetest.after(0.2,function() minetest.after(0.2,function()
if self and self.object and self.object:get_pos() and hitter and is_player and hitter:get_pos() then if self and self.object and self.object:get_pos() and hitter and is_player and hitter:get_pos() then
@ -798,7 +771,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
local obj = nil local obj = nil
for n = 1, #objs do for n = 1, #objs do
obj = objs[n]:get_luaentity() obj = objs[n]:get_luaentity()
if obj then if obj then
@ -886,7 +858,6 @@ function mob_class:do_states_attack (dtime)
or not self:object_in_range(self.attack) or not self:object_in_range(self.attack)
or self.attack:get_hp() <= 0 or self.attack:get_hp() <= 0
or (self.attack:is_player() and mcl_mobs.invis[ self.attack:get_player_name() ]) then or (self.attack:is_player() and mcl_mobs.invis[ self.attack:get_player_name() ]) then
clear_aggro(self) clear_aggro(self)
return return
end end
@ -912,7 +883,6 @@ function mob_class:do_states_attack (dtime)
local dist = vector.distance(p, s) local dist = vector.distance(p, s)
if self.attack_type == "explode" then if self.attack_type == "explode" then
if target_line_of_sight then if target_line_of_sight then
local vec = { x = p.x - s.x, z = p.z - s.z } local vec = { x = p.x - s.x, z = p.z - s.z }
yaw = (atan(vec.z / vec.x) +math.pi/ 2) - self.rotate yaw = (atan(vec.z / vec.x) +math.pi/ 2) - self.rotate
@ -993,9 +963,7 @@ function mob_class:do_states_attack (dtime)
or (self.attack_type == "dogshoot" and self:dogswitch(dtime) == 2) and (dist >= self.avoid_distance or not self.shooter_avoid_enemy) or (self.attack_type == "dogshoot" and self:dogswitch(dtime) == 2) and (dist >= self.avoid_distance or not self.shooter_avoid_enemy)
or (self.attack_type == "dogshoot" and dist <= self.reach and self:dogswitch() == 0) then or (self.attack_type == "dogshoot" and dist <= self.reach and self:dogswitch() == 0) then
if self.fly if self.fly and dist > self.reach then
and dist > self.reach then
local p1 = s local p1 = s
local me_y = math.floor(p1.y) local me_y = math.floor(p1.y)
local p2 = p local p2 = p
@ -1003,17 +971,13 @@ function mob_class:do_states_attack (dtime)
local v = self.object:get_velocity() local v = self.object:get_velocity()
if self:flight_check( s) then if self:flight_check( s) then
if me_y < p_y then if me_y < p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = 1 * self.walk_velocity, y = 1 * self.walk_velocity,
z = v.z z = v.z
}) })
elseif me_y > p_y then elseif me_y > p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = -1 * self.walk_velocity, y = -1 * self.walk_velocity,
@ -1022,15 +986,12 @@ function mob_class:do_states_attack (dtime)
end end
else else
if me_y < p_y then if me_y < p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = 0.01, y = 0.01,
z = v.z z = v.z
}) })
elseif me_y > p_y then elseif me_y > p_y then
self.object:set_velocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = -0.01, y = -0.01,
@ -1045,7 +1006,6 @@ function mob_class:do_states_attack (dtime)
if self.path.following if self.path.following
and self.path.way and self.path.way
and self.attack_type ~= "dogshoot" then and self.attack_type ~= "dogshoot" then
-- no paths longer than 50 -- no paths longer than 50
if #self.path.way > 50 if #self.path.way > 50
or dist < self.reach then or dist < self.reach then
@ -1054,7 +1014,6 @@ function mob_class:do_states_attack (dtime)
end end
local p1 = self.path.way[1] local p1 = self.path.way[1]
if not p1 then if not p1 then
self.path.following = false self.path.following = false
return return
@ -1152,11 +1111,9 @@ function mob_class:do_states_attack (dtime)
end end
end end
end end
elseif self.attack_type == "shoot" elseif self.attack_type == "shoot"
or (self.attack_type == "dogshoot" and self:dogswitch(dtime) == 1) or (self.attack_type == "dogshoot" and self:dogswitch(dtime) == 1)
or (self.attack_type == "dogshoot" and (dist > self.reach or dist < self.avoid_distance and self.shooter_avoid_enemy) and self:dogswitch() == 0) then or (self.attack_type == "dogshoot" and (dist > self.reach or dist < self.avoid_distance and self.shooter_avoid_enemy) and self:dogswitch() == 0) then
p.y = p.y - .5 p.y = p.y - .5
s.y = s.y + .5 s.y = s.y + .5
@ -1217,7 +1174,6 @@ function mob_class:do_states_attack (dtime)
-- Shoot arrow -- Shoot arrow
if minetest.registered_entities[self.arrow] then if minetest.registered_entities[self.arrow] then
local arrow, ent local arrow, ent
local v = 1 local v = 1
if not self.shoot_arrow then if not self.shoot_arrow then
@ -1263,5 +1219,4 @@ function mob_class:do_states_attack (dtime)
if self.on_attack then if self.on_attack then
self.on_attack(self, dtime) self.on_attack(self, dtime)
end end
end end

View File

@ -13,7 +13,6 @@ if player_transfer_distance == 0 then player_transfer_distance = math.huge end
-- custom particle effects -- custom particle effects
function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down)
radius = radius or 2 radius = radius or 2
min_size = min_size or 0.5 min_size = min_size or 0.5
max_size = max_size or 1 max_size = max_size or 1
@ -89,7 +88,6 @@ end
-- play sound -- play sound
function mob_class:mob_sound(soundname, is_opinion, fixed_pitch) function mob_class:mob_sound(soundname, is_opinion, fixed_pitch)
local soundinfo local soundinfo
if self.sounds_child and self.child then if self.sounds_child and self.child then
soundinfo = self.sounds_child soundinfo = self.sounds_child
@ -259,8 +257,6 @@ function mob_class:set_animation(anim, fixed_frame)
return return
end end
if self.fly and self:flight_check() and anim == "walk" then anim = "fly" end if self.fly and self:flight_check() and anim == "walk" then anim = "fly" end
self._current_animation = self._current_animation or "" self._current_animation = self._current_animation or ""
@ -358,7 +354,6 @@ end
function mob_class:check_head_swivel(dtime) function mob_class:check_head_swivel(dtime)
if not self.head_swivel or type(self.head_swivel) ~= "string" then return end if not self.head_swivel or type(self.head_swivel) ~= "string" then return end
who_are_you_looking_at (self, dtime) who_are_you_looking_at (self, dtime)
local final_rotation = vector.zero() local final_rotation = vector.zero()
@ -373,7 +368,6 @@ function mob_class:check_head_swivel(dtime)
_locked_object_eye_height = self._locked_object:get_properties().eye_height _locked_object_eye_height = self._locked_object:get_properties().eye_height
end end
if _locked_object_eye_height then if _locked_object_eye_height then
local self_rot = self.object:get_rotation() local self_rot = self.object:get_rotation()
-- If a mob is attached, should we really be messing with what they are looking at? -- If a mob is attached, should we really be messing with what they are looking at?
-- Should this be excluded? -- Should this be excluded?

View File

@ -110,7 +110,6 @@ end
mcl_mobs.spawning_mobs = {} mcl_mobs.spawning_mobs = {}
-- register mob entity -- register mob entity
function mcl_mobs.register_mob(name, def) function mcl_mobs.register_mob(name, def)
mcl_mobs.spawning_mobs[name] = true mcl_mobs.spawning_mobs[name] = true
mcl_mobs.registered_mobs[name] = def mcl_mobs.registered_mobs[name] = def
@ -344,7 +343,6 @@ end
-- register arrow for shoot attack -- register arrow for shoot attack
function mcl_mobs.register_arrow(name, def) function mcl_mobs.register_arrow(name, def)
if not name or not def then return end -- errorcheck if not name or not def then return end -- errorcheck
minetest.register_entity(name, { minetest.register_entity(name, {
@ -378,7 +376,6 @@ function mcl_mobs.register_arrow(name, def)
on_activate = def.on_activate, on_activate = def.on_activate,
on_step = def.on_step or function(self, dtime) on_step = def.on_step or function(self, dtime)
self.timer = self.timer + dtime self.timer = self.timer + dtime
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -396,7 +393,6 @@ function mcl_mobs.register_arrow(name, def)
if def.tail if def.tail
and def.tail == 1 and def.tail == 1
and def.tail_texture then and def.tail_texture then
minetest.add_particle({ minetest.add_particle({
pos = pos, pos = pos,
velocity = {x = 0, y = 0, z = 0}, velocity = {x = 0, y = 0, z = 0},
@ -410,15 +406,12 @@ function mcl_mobs.register_arrow(name, def)
end end
if self.hit_node then if self.hit_node then
local node = node_ok(pos).name local node = node_ok(pos).name
if minetest.registered_nodes[node].walkable then if minetest.registered_nodes[node].walkable then
self.hit_node(self, pos, node) self.hit_node(self, pos, node)
if self.drop == true then if self.drop == true then
pos.y = pos.y + 1 pos.y = pos.y + 1
self.lastpos = (self.lastpos or pos) self.lastpos = (self.lastpos or pos)
@ -444,9 +437,7 @@ function mcl_mobs.register_arrow(name, def)
end end
if self.hit_player or self.hit_mob or self.hit_object then if self.hit_player or self.hit_mob or self.hit_object then
for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do
if self.hit_player if self.hit_player
and object:is_player() then and object:is_player() then
@ -513,7 +504,6 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg
-- register old stackable mob egg -- register old stackable mob egg
minetest.register_craftitem(mob, { minetest.register_craftitem(mob, {
description = desc, description = desc,
inventory_image = invimg, inventory_image = invimg,
groups = grp, groups = grp,
@ -536,7 +526,6 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg
local name = placer:get_player_name() local name = placer:get_player_name()
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
if under.name == "mcl_mobspawners:spawner" then if under.name == "mcl_mobspawners:spawner" then
if minetest.is_protected(pointed_thing.under, name) then if minetest.is_protected(pointed_thing.under, name) then
minetest.record_protection_violation(pointed_thing.under, name) minetest.record_protection_violation(pointed_thing.under, name)

View File

@ -12,7 +12,6 @@ local crash_threshold = 6.5 -- ignored if enable_crash=false
-- --
local node_ok = function(pos, fallback) local node_ok = function(pos, fallback)
fallback = fallback or mcl_mobs.fallback_node fallback = fallback or mcl_mobs.fallback_node
local node = minetest.get_node_or_nil(pos) local node = minetest.get_node_or_nil(pos)
@ -26,7 +25,6 @@ end
local function node_is(pos) local function node_is(pos)
local node = node_ok(pos) local node = node_ok(pos)
if node.name == "air" then if node.name == "air" then
@ -50,7 +48,6 @@ end
local function get_sign(i) local function get_sign(i)
i = i or 0 i = i or 0
if i == 0 then if i == 0 then
@ -62,7 +59,6 @@ end
local function get_velocity(v, yaw, y) local function get_velocity(v, yaw, y)
local x = -math.sin(yaw) * v local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v local z = math.cos(yaw) * v
@ -76,7 +72,6 @@ end
local function force_detach(player) local function force_detach(player)
local attached_to = player:get_attach() local attached_to = player:get_attach()
if not attached_to then if not attached_to then
@ -87,7 +82,6 @@ local function force_detach(player)
if entity.driver if entity.driver
and entity.driver == player then and entity.driver == player then
entity.driver = nil entity.driver = nil
end end
@ -96,7 +90,6 @@ local function force_detach(player)
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
mcl_player.player_set_animation(player, "stand" , 30) mcl_player.player_set_animation(player, "stand" , 30)
player:set_properties({visual_size = {x = 1, y = 1} }) player:set_properties({visual_size = {x = 1, y = 1} })
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -121,7 +114,6 @@ end)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function mcl_mobs.attach(entity, player) function mcl_mobs.attach(entity, player)
local attach_at, eye_offset local attach_at, eye_offset
entity.player_rotation = entity.player_rotation or {x = 0, y = 0, z = 0} entity.player_rotation = entity.player_rotation or {x = 0, y = 0, z = 0}
@ -164,7 +156,6 @@ end
function mcl_mobs.detach(player, offset) function mcl_mobs.detach(player, offset)
force_detach(player) force_detach(player)
mcl_player.player_set_animation(player, "stand" , 30) mcl_player.player_set_animation(player, "stand" , 30)
@ -187,7 +178,6 @@ end
function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
local rot_view = 0 local rot_view = 0
if entity.player_rotation.y == 90 then if entity.player_rotation.y == 90 then
@ -201,17 +191,14 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
-- process controls -- process controls
if entity.driver then if entity.driver then
local ctrl = entity.driver:get_player_control() local ctrl = entity.driver:get_player_control()
-- move forwards -- move forwards
if ctrl.up then if ctrl.up then
entity.v = entity.v + entity.accel / 10 * entity.run_velocity / 2.6 entity.v = entity.v + entity.accel / 10 * entity.run_velocity / 2.6
-- move backwards -- move backwards
elseif ctrl.down then elseif ctrl.down then
if entity.max_speed_reverse == 0 and entity.v == 0 then if entity.max_speed_reverse == 0 and entity.v == 0 then
return return
end end
@ -223,12 +210,10 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate) entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
if can_fly then if can_fly then
-- fly up -- fly up
if ctrl.jump then if ctrl.jump then
velo.y = velo.y + 1 velo.y = velo.y + 1
if velo.y > entity.accel then velo.y = entity.accel end if velo.y > entity.accel then velo.y = entity.accel end
elseif velo.y > 0 then elseif velo.y > 0 then
velo.y = velo.y - 0.1 velo.y = velo.y - 0.1
if velo.y < 0 then velo.y = 0 end if velo.y < 0 then velo.y = 0 end
@ -238,17 +223,14 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if ctrl.sneak then if ctrl.sneak then
velo.y = velo.y - 1 velo.y = velo.y - 1
if velo.y < -entity.accel then velo.y = -entity.accel end if velo.y < -entity.accel then velo.y = -entity.accel end
elseif velo.y < 0 then elseif velo.y < 0 then
velo.y = velo.y + 0.1 velo.y = velo.y + 0.1
if velo.y > 0 then velo.y = 0 end if velo.y > 0 then velo.y = 0 end
end end
else else
-- jump -- jump
if ctrl.jump then if ctrl.jump then
if velo.y == 0 then if velo.y == 0 then
velo.y = velo.y + entity.jump_height velo.y = velo.y + entity.jump_height
acce_y = acce_y + (acce_y * 3) + 1 acce_y = acce_y + (acce_y * 3) + 1
@ -260,7 +242,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
-- if not moving then set animation and return -- if not moving then set animation and return
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
if stand_anim then if stand_anim then
mcl_mobs:set_animation(entity, stand_anim) mcl_mobs:set_animation(entity, stand_anim)
end end
@ -279,7 +260,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
entity.v = entity.v - 0.02 * s entity.v = entity.v - 0.02 * s
if s ~= get_sign(entity.v) then if s ~= get_sign(entity.v) then
entity.object:set_velocity({x = 0, y = 0, z = 0}) entity.object:set_velocity({x = 0, y = 0, z = 0})
entity.v = 0 entity.v = 0
return return
@ -307,19 +287,14 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
local v = entity.v local v = entity.v
if ni == "air" then if ni == "air" then
if can_fly == true then if can_fly == true then
new_acce.y = 0 new_acce.y = 0
end end
elseif ni == "liquid" or ni == "lava" then elseif ni == "liquid" or ni == "lava" then
if ni == "lava" and entity.lava_damage ~= 0 then if ni == "lava" and entity.lava_damage ~= 0 then
entity.lava_counter = (entity.lava_counter or 0) + dtime entity.lava_counter = (entity.lava_counter or 0) + dtime
if entity.lava_counter > 1 then if entity.lava_counter > 1 then
minetest.sound_play("default_punch", { minetest.sound_play("default_punch", {
object = entity.object, object = entity.object,
max_hear_distance = 5 max_hear_distance = 5
@ -336,12 +311,10 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if entity.terrain_type == 2 if entity.terrain_type == 2
or entity.terrain_type == 3 then or entity.terrain_type == 3 then
new_acce.y = 0 new_acce.y = 0
p.y = p.y + 1 p.y = p.y + 1
if node_is(p) == "liquid" then if node_is(p) == "liquid" then
if velo.y >= 5 then if velo.y >= 5 then
velo.y = 5 velo.y = 5
elseif velo.y < 0 then elseif velo.y < 0 then
@ -370,7 +343,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
-- CRASH! -- CRASH!
if enable_crash then if enable_crash then
local intensity = entity.v2 - v local intensity = entity.v2 - v
if intensity >= crash_threshold then if intensity >= crash_threshold then
@ -379,7 +351,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = intensity} damage_groups = {fleshy = intensity}
}, nil) }, nil)
end end
end end
@ -389,7 +360,6 @@ end
-- directional flying routine by D00Med (edited by TenPlus1) -- directional flying routine by D00Med (edited by TenPlus1)
function mcl_mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) function mcl_mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
local ctrl = entity.driver:get_player_control() local ctrl = entity.driver:get_player_control()
local velo = entity.object:get_velocity() local velo = entity.object:get_velocity()
local dir = entity.driver:get_look_dir() local dir = entity.driver:get_look_dir()
@ -417,7 +387,6 @@ function mcl_mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_an
-- firing arrows -- firing arrows
if ctrl.LMB and ctrl.sneak and shoots then if ctrl.LMB and ctrl.sneak and shoots then
local pos = entity.object:get_pos() local pos = entity.object:get_pos()
local obj = minetest.add_entity({ local obj = minetest.add_entity({
x = pos.x + 0 + dir.x * 2.5, x = pos.x + 0 + dir.x * 2.5,
@ -439,7 +408,6 @@ function mcl_mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_an
-- change animation if stopped -- change animation if stopped
if velo.x == 0 and velo.y == 0 and velo.z == 0 then if velo.x == 0 and velo.y == 0 and velo.z == 0 then
mcl_mobs:set_animation(entity, stand_anim) mcl_mobs:set_animation(entity, stand_anim)
else else
-- moving animation -- moving animation

View File

@ -450,11 +450,9 @@ function mob_class:do_jump()
local ndef = minetest.registered_nodes[nod.name] local ndef = minetest.registered_nodes[nod.name]
if self.walk_chance == 0 or ndef and ndef.walkable or self._can_jump_cliff then if self.walk_chance == 0 or ndef and ndef.walkable or self._can_jump_cliff then
if minetest.get_item_group(nod.name, "fence") == 0 if minetest.get_item_group(nod.name, "fence") == 0
and minetest.get_item_group(nod.name, "fence_gate") == 0 and minetest.get_item_group(nod.name, "fence_gate") == 0
and minetest.get_item_group(nod.name, "wall") == 0 then and minetest.get_item_group(nod.name, "wall") == 0 then
local v = self.object:get_velocity() local v = self.object:get_velocity()
v.y = self.jump_height + 0.1 * 3 v.y = self.jump_height + 0.1 * 3
@ -490,11 +488,9 @@ function mob_class:do_jump()
-- if we jumped against a block/wall 4 times then turn -- if we jumped against a block/wall 4 times then turn
if self.object:get_velocity().x ~= 0 if self.object:get_velocity().x ~= 0
and self.object:get_velocity().z ~= 0 then and self.object:get_velocity().z ~= 0 then
self.jump_count = (self.jump_count or 0) + 1 self.jump_count = (self.jump_count or 0) + 1
if self.jump_count == 4 then if self.jump_count == 4 then
local yaw = self.object:get_yaw() or 0 local yaw = self.object:get_yaw() or 0
yaw = self:set_yaw( yaw + 1.35, 8) yaw = self:set_yaw( yaw + 1.35, 8)
@ -546,7 +542,6 @@ function mob_class:is_object_in_view(object_list, object_range, node_range, turn
-- find specific mob to avoid or runaway from -- find specific mob to avoid or runaway from
if name ~= "" and name ~= self.name if name ~= "" and name ~= self.name
and in_list(object_list, name) then and in_list(object_list, name) then
local p = object:get_pos() local p = object:get_pos()
local dist = vector.distance(p, s) local dist = vector.distance(p, s)
@ -561,7 +556,6 @@ function mob_class:is_object_in_view(object_list, object_range, node_range, turn
end end
if not object_pos then if not object_pos then
-- find specific node to avoid or runaway from -- find specific node to avoid or runaway from
local p = minetest.find_node_near(s, node_range, object_list, true) local p = minetest.find_node_near(s, node_range, object_list, true)
local dist = p and vector.distance(p, s) local dist = p and vector.distance(p, s)
@ -573,7 +567,6 @@ function mob_class:is_object_in_view(object_list, object_range, node_range, turn
end end
if object_pos and turn_around then if object_pos and turn_around then
local vec = vector.subtract(object_pos, s) local vec = vector.subtract(object_pos, s)
local yaw = (atan(vec.z / vec.x) + 3 *math.pi/ 2) - self.rotate local yaw = (atan(vec.z / vec.x) + 3 *math.pi/ 2) - self.rotate
if object_pos.x > s.x then yaw = yaw + math.pi end if object_pos.x > s.x then yaw = yaw + math.pi end
@ -599,7 +592,6 @@ function mob_class:follow_holding(clicker)
if t == "string" if t == "string"
and item:get_name() == self.follow then and item:get_name() == self.follow then
return true return true
-- multiple items -- multiple items
elseif t == "table" and in_list(self.follow, item:get_name()) then elseif t == "table" and in_list(self.follow, item:get_name()) then
return true return true
@ -624,7 +616,6 @@ function mob_class:replace_node(pos)
local what, with, y_offset local what, with, y_offset
if type(self.replace_what[1]) == "table" then if type(self.replace_what[1]) == "table" then
local num = math.random(#self.replace_what) local num = math.random(#self.replace_what)
what = self.replace_what[num][1] or "" what = self.replace_what[num][1] or ""
@ -640,7 +631,6 @@ function mob_class:replace_node(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if node.name == what then if node.name == what then
local oldnode = {name = what, param2 = node.param2} local oldnode = {name = what, param2 = node.param2}
local newnode = {name = with, param2 = node.param2} local newnode = {name = with, param2 = node.param2}
local on_replace_return = false local on_replace_return = false
@ -696,7 +686,6 @@ function mob_class:check_follow()
if self.type == "npc" and self.order == "follow" if self.type == "npc" and self.order == "follow"
and self.state ~= "attack" and self.order ~= "sit" and self.owner ~= "" then and self.state ~= "attack" and self.order ~= "sit" and self.owner ~= "" then
if self.following and self.owner and self.owner ~= self.following:get_player_name() then if self.following and self.owner and self.owner ~= self.following:get_player_name() then
self.following = nil self.following = nil
end end
@ -737,7 +726,7 @@ function mob_class:check_follow()
-- anyone but standing npc's can move along -- anyone but standing npc's can move along
if dist > 3 and self.order ~= "stand" then if dist > 3 and self.order ~= "stand" then
self:set_velocity(self.follow_velocity) self:set_velocity(self.follow_velocity)
if self.walk_chance ~= 0 then if self.walk_chance ~= 0 then
self:set_animation( "run") self:set_animation( "run")
end end
@ -876,7 +865,6 @@ function mob_class:do_states_walk()
-- did we find land? -- did we find land?
if lp then if lp then
local vec = { local vec = {
x = lp.x - s.x, x = lp.x - s.x,
z = lp.z - s.z z = lp.z - s.z
@ -890,7 +878,6 @@ function mob_class:do_states_walk()
-- look towards land and move in that direction -- look towards land and move in that direction
yaw = self:set_yaw( yaw, 6) yaw = self:set_yaw( yaw, 6)
self:set_velocity(self.walk_velocity) self:set_velocity(self.walk_velocity)
end end
end end
end end
@ -918,14 +905,12 @@ function mob_class:do_states_walk()
if self.facing_fence == true if self.facing_fence == true
or cliff_or_danger or cliff_or_danger
or math.random(1, 100) <= 30 then or math.random(1, 100) <= 30 then
self:set_velocity(0) self:set_velocity(0)
self.state = "stand" self.state = "stand"
self:set_animation( "stand") self:set_animation( "stand")
local yaw = self.object:get_yaw() or 0 local yaw = self.object:get_yaw() or 0
yaw = self:set_yaw( yaw + 0.78, 8) yaw = self:set_yaw( yaw + 0.78, 8)
else else
self:set_velocity(self.walk_velocity) self:set_velocity(self.walk_velocity)
if self:flight_check() if self:flight_check()
@ -943,7 +928,6 @@ function mob_class:do_states_stand(player_in_active_range)
local yaw = self.object:get_yaw() or 0 local yaw = self.object:get_yaw() or 0
if math.random(1, 4) == 1 then if math.random(1, 4) == 1 then
local s = self.object:get_pos() local s = self.object:get_pos()
local objs = minetest.get_objects_inside_radius(s, 3) local objs = minetest.get_objects_inside_radius(s, 3)
local lp local lp
@ -956,7 +940,6 @@ function mob_class:do_states_stand(player_in_active_range)
-- look at any players nearby, otherwise turn randomly -- look at any players nearby, otherwise turn randomly
if lp and self.look_at_players then if lp and self.look_at_players then
local vec = { local vec = {
x = lp.x - s.x, x = lp.x - s.x,
z = lp.z - s.z z = lp.z - s.z
@ -1017,11 +1000,6 @@ function mob_class:do_states_runaway()
end end
end end
function mob_class:check_smooth_rotation(dtime) 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
@ -1029,7 +1007,6 @@ function mob_class:check_smooth_rotation(dtime)
end end
if self.delay and self.delay > 0 then if self.delay and self.delay > 0 then
local yaw = self.object:get_yaw() or 0 local yaw = self.object:get_yaw() or 0
if self.delay == 1 then if self.delay == 1 then
@ -1038,16 +1015,13 @@ function mob_class:check_smooth_rotation(dtime)
local dif = math.abs(yaw - self.target_yaw) local dif = math.abs(yaw - self.target_yaw)
if yaw > self.target_yaw then if yaw > self.target_yaw then
if dif > math.pi then if dif > math.pi then
dif = 2 * math.pi - dif -- need to add dif = 2 * math.pi - dif -- need to add
yaw = yaw + dif / self.delay yaw = yaw + dif / self.delay
else else
yaw = yaw - dif / self.delay -- need to subtract yaw = yaw - dif / self.delay -- need to subtract
end end
elseif yaw < self.target_yaw then elseif yaw < self.target_yaw then
if dif >math.pi then if dif >math.pi then
dif = 2 * math.pi - dif dif = 2 * math.pi - dif
yaw = yaw - dif / self.delay -- need to subtract yaw = yaw - dif / self.delay -- need to subtract

View File

@ -15,7 +15,6 @@ local show_health = false
-- get node but use fallback for nil or unknown -- get node but use fallback for nil or unknown
local node_ok = function(pos, fallback) local node_ok = function(pos, fallback)
fallback = fallback or mcl_mobs.fallback_node fallback = fallback or mcl_mobs.fallback_node
local node = minetest.get_node_or_nil(pos) local node = minetest.get_node_or_nil(pos)
@ -80,7 +79,6 @@ function mob_class:object_in_range(object)
end end
function mob_class:item_drop(cooked, looting_level) function mob_class:item_drop(cooked, looting_level)
if not mobs_drop_items then return end if not mobs_drop_items then return end
looting_level = looting_level or 0 looting_level = looting_level or 0
@ -124,7 +122,6 @@ function mob_class:item_drop(cooked, looting_level)
item = dropdef.name item = dropdef.name
if cooked then if cooked then
local output = minetest.get_craft_result({ local output = minetest.get_craft_result({
method = "cooking", width = 1, items = {item}}) method = "cooking", width = 1, items = {item}})
@ -138,7 +135,6 @@ function mob_class:item_drop(cooked, looting_level)
end end
if obj and obj:get_luaentity() then if obj and obj:get_luaentity() then
obj:set_velocity({ obj:set_velocity({
x = math.random(-10, 10) / 9, x = math.random(-10, 10) / 9,
y = 6, y = 6,
@ -162,10 +158,8 @@ function mob_class:collision()
local z = 0 local z = 0
local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5 local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
local ent = object:get_luaentity() local ent = object:get_luaentity()
if object:is_player() or (ent and ent.is_mob and object ~= self.object) then if object:is_player() or (ent and ent.is_mob and object ~= self.object) then
if object:is_player() and mcl_burning.is_burning(self.object) then if object:is_player() and mcl_burning.is_burning(self.object) then
mcl_burning.set_on_fire(object, 4) mcl_burning.set_on_fire(object, 4)
end end
@ -265,7 +259,6 @@ function mob_class:update_roll()
end end
local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums) local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums)
if not rot_origin or not rot_target then if not rot_origin or not rot_target then
return return
end end
@ -302,7 +295,6 @@ local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums)
end end
end end
end end
end end
@ -386,7 +378,6 @@ end
-- are we flying in what we are suppose to? (taikedz) -- are we flying in what we are suppose to? (taikedz)
function mob_class:flight_check() function mob_class:flight_check()
local nod = self.standing_in local nod = self.standing_in
local def = minetest.registered_nodes[nod] local def = minetest.registered_nodes[nod]
@ -412,7 +403,6 @@ end
-- check if mob is dead or only hurt -- check if mob is dead or only hurt
function mob_class:check_for_death(cause, cmi_cause) function mob_class:check_for_death(cause, cmi_cause)
if self.state == "die" then if self.state == "die" then
return true return true
end end
@ -507,7 +497,6 @@ function mob_class:check_for_death(cause, cmi_cause)
-- execute custom death function -- execute custom death function
if self.on_die then if self.on_die then
local pos = self.object:get_pos() local pos = self.object:get_pos()
local on_die_exit = self.on_die(self, pos, cmi_cause) local on_die_exit = self.on_die(self, pos, cmi_cause)
if on_die_exit ~= true then if on_die_exit ~= true then
@ -527,7 +516,6 @@ function mob_class:check_for_death(cause, cmi_cause)
self.jockey = nil self.jockey = nil
end end
local collisionbox local collisionbox
if self.collisionbox then if self.collisionbox then
collisionbox = table.copy(self.collisionbox) collisionbox = table.copy(self.collisionbox)
@ -615,7 +603,6 @@ function mob_class:do_env_damage()
-- reset nametag after showing health stats -- reset nametag after showing health stats
if self.htimer < 1 and self.nametag2 then if self.htimer < 1 and self.nametag2 then
self.nametag = self.nametag2 self.nametag = self.nametag2
self.nametag2 = nil self.nametag2 = nil
@ -661,7 +648,6 @@ function mob_class:do_env_damage()
end end
end end
end end
end end
local y_level = self.collisionbox[2] local y_level = self.collisionbox[2]
@ -958,7 +944,6 @@ end
-- falling and fall damage -- falling and fall damage
-- returns true if mob died -- returns true if mob died
function mob_class:falling(pos) function mob_class:falling(pos)
if self.fly and self.state ~= "die" then if self.fly and self.state ~= "die" then
return return
end end

View File

@ -301,7 +301,6 @@ local function count_mobs_all(categorise_by, pos)
local num = 0 local num = 0
for _,entity in pairs(minetest.luaentities) do for _,entity in pairs(minetest.luaentities) do
if entity and entity.is_mob then if entity and entity.is_mob then
local add_entry = false local add_entry = false
--local mob_type = entity.type -- animal / monster / npc --local mob_type = entity.type -- animal / monster / npc
local mob_cat = entity[categorise_by] local mob_cat = entity[categorise_by]
@ -799,8 +798,6 @@ minetest.register_chatcommand("spawn_mob",{
local mod1 = string.find(param, ":") local mod1 = string.find(param, ":")
local mobname = param local mobname = param
if mod1 then if mod1 then
mobname = string.sub(param, 1, mod1-1) mobname = string.sub(param, 1, mod1-1)
@ -856,12 +853,8 @@ minetest.register_chatcommand("spawn_mob",{
}) })
if mobs_spawn then if mobs_spawn then
-- Get pos to spawn, x and z are randomised, y is range -- Get pos to spawn, x and z are randomised, y is range
local function mob_cap_space (pos, mob_type, mob_counts_close, mob_counts_wide, cap_space_hostile, cap_space_non_hostile) local function mob_cap_space (pos, mob_type, mob_counts_close, mob_counts_wide, cap_space_hostile, cap_space_non_hostile)
-- Some mob examples -- Some mob examples
--type = "monster", spawn_class = "hostile", --type = "monster", spawn_class = "hostile",
--type = "animal", spawn_class = "passive", --type = "animal", spawn_class = "passive",
@ -968,7 +961,6 @@ if mobs_spawn then
end end
local function spawn_a_mob(pos, cap_space_hostile, cap_space_non_hostile) local function spawn_a_mob(pos, cap_space_hostile, cap_space_non_hostile)
local spawning_position = find_spawning_position(pos, FIND_SPAWN_POS_RETRIES) local spawning_position = find_spawning_position(pos, FIND_SPAWN_POS_RETRIES)
if not spawning_position then if not spawning_position then
minetest.log("action", "[Mobs spawn] Cannot find a valid spawn position after retries: " .. FIND_SPAWN_POS_RETRIES) minetest.log("action", "[Mobs spawn] Cannot find a valid spawn position after retries: " .. FIND_SPAWN_POS_RETRIES)
@ -1004,7 +996,6 @@ if mobs_spawn then
local mob_def = mob_library_worker_table[mob_index] local mob_def = mob_library_worker_table[mob_index]
if mob_def and mob_def.name and minetest.registered_entities[mob_def.name] then if mob_def and mob_def.name and minetest.registered_entities[mob_def.name] then
local mob_def_ent = minetest.registered_entities[mob_def.name] local mob_def_ent = minetest.registered_entities[mob_def.name]
local mob_spawn_class = mob_def_ent.spawn_class local mob_spawn_class = mob_def_ent.spawn_class
@ -1092,7 +1083,6 @@ if mobs_spawn then
local timer = 0 local timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
timer = timer + dtime timer = timer + dtime
if timer < WAIT_FOR_SPAWN_ATTEMPT then return end if timer < WAIT_FOR_SPAWN_ATTEMPT then return end
initialize_spawn_data() initialize_spawn_data()