diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index a9a1a0dad..623188045 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -97,7 +97,6 @@ function mob_class:get_staticdata() local tmp = {} for _,stat in pairs(self) do - local t = type(stat) if t ~= "function" @@ -149,7 +148,6 @@ function mob_class:mob_activate(staticdata, def, dtime) --If textures in definition change, reload textures if not valid_texture(self, def.textures) then - -- compatiblity with old simple mobs textures if type(def.textures[1]) == "string" then def.textures = {def.textures} @@ -189,7 +187,6 @@ function mob_class:mob_activate(staticdata, def, dtime) end if self.child == true then - vis_size = { x = self.base_size.x * .5, y = self.base_size.y * .5, @@ -289,7 +286,6 @@ function mob_class:mob_activate(staticdata, def, dtime) return end - if self.on_spawn and not self.on_spawn_run then if self.on_spawn(self) then self.on_spawn_run = true @@ -306,9 +302,6 @@ function mob_class:mob_activate(staticdata, def, dtime) self._run_armor_init = true end - - - if def.after_activate then def.after_activate(self, staticdata, def, dtime) end @@ -426,7 +419,6 @@ local function on_step_work (self, dtime) end if mcl_util.check_dtime_timer(self, dtime, "onstep_occassional", 1) then - if player_in_active_range then self:check_item_pickup() self:set_armor_texture() diff --git a/mods/ENTITIES/mcl_mobs/breeding.lua b/mods/ENTITIES/mcl_mobs/breeding.lua index 8d3e03ec6..d743eea8d 100644 --- a/mods/ENTITIES/mcl_mobs/breeding.lua +++ b/mods/ENTITIES/mcl_mobs/breeding.lua @@ -40,7 +40,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake) local consume_food = false -- tame if not still a baby - if tame and not self.child then if not self.owner or self.owner == "" then self.tamed = true @@ -50,7 +49,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake) end -- increase health - if self.health < self.hp_max and not consume_food then consume_food = true 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 -- make children grow quicker - if not consume_food and self.child == true then consume_food = true -- deduct 10% of the time to adulthood @@ -70,7 +67,6 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake) end -- breed animals - if breed and not consume_food and self.hornytimer == 0 and not self.horny then self.food = (self.food or 0) + 1 consume_food = true @@ -158,12 +154,10 @@ function mob_class:check_breeding() --mcl_log("In breed function") -- child takes a long time before growing into adult if self.child == true then - -- When a child, hornytimer is used to count age until adulthood self.hornytimer = self.hornytimer + 1 if self.hornytimer >= CHILD_GROW_TIME then - self.child = false self.hornytimer = 0 @@ -210,7 +204,6 @@ function mob_class:check_breeding() -- find another same animal who is also horny and mate if nearby if self.horny == true and self.hornytimer <= HORNY_TIME then - mcl_log("In breed function. All good. Do the magic.") local pos = self.object:get_pos() @@ -222,14 +215,12 @@ function mob_class:check_breeding() local ent = nil for n = 1, #objs do - ent = objs[n]:get_luaentity() -- check for same animal with different colour local canmate = false if ent then - if ent.name == self.name then canmate = true else @@ -258,13 +249,10 @@ function mob_class:check_breeding() -- found your mate? then have a baby if num > 1 then - self.hornytimer = HORNY_TIME + 1 ent.hornytimer = HORNY_TIME + 1 -- spawn baby - - minetest.after(5, function(parent1, parent2, pos) if not parent1.object:get_luaentity() then return @@ -284,10 +272,8 @@ function mob_class:check_breeding() end local child = mcl_mobs.spawn_child(pos, parent1.name) - local ent_c = child:get_luaentity() - -- Use texture of one of the parents local p = math.random(1, 2) if p == 1 then diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 745a06c5c..2fd8890f9 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -42,7 +42,6 @@ function mob_class:do_attack(object) return end - if object:is_player() and not minetest.settings:get_bool("enable_damage") then return end @@ -110,14 +109,12 @@ function mob_class:smart_mobs(s, p, dist, dtime) -- im stuck, search for path if not has_lineofsight then - if los_switcher == true then use_pathfind = true los_switcher = false end -- cannot see target! else if los_switcher == false then - los_switcher = true use_pathfind = false @@ -131,7 +128,6 @@ function mob_class:smart_mobs(s, p, dist, dtime) end if (self.path.stuck_timer > stuck_timeout and not self.path.following) then - use_pathfind = true self.path.stuck_timer = 0 @@ -144,7 +140,6 @@ function mob_class:smart_mobs(s, p, dist, dtime) end if (self.path.stuck_timer > stuck_path_timeout and self.path.following) then - use_pathfind = true self.path.stuck_timer = 0 @@ -157,7 +152,6 @@ function mob_class:smart_mobs(s, p, dist, dtime) end if math.abs(vector.subtract(s,target_pos).y) > self.stepheight then - if height_switcher then use_pathfind = true height_switcher = false @@ -208,18 +202,14 @@ function mob_class:smart_mobs(s, p, dist, dtime) -- no path found, try something else if not self.path.way then - self.path.following = false -- lets make way by digging/building if not accessible if self.pathfinding == 2 and mobs_griefing then - -- is player higher than mob? if s.y < p1.y then - -- build upwards if not minetest.is_protected(s, "") then - local ndef1 = minetest.registered_nodes[self.standing_in] 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 if not minetest.is_protected(s, "") then - local node1 = node_ok(s, "air").name 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.unbreakable and not ndef1.groups.liquid then - minetest.set_node(s, {name = "air"}) minetest.add_item(s, ItemStack(node1)) - 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}) else -- dig 2 blocks to make door toward player direction - local yaw1 = self.object:get_yaw() + math.pi / 2 local p1 = { 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 - local node1 = node_ok(p1, "air").name 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.unbreakable and not ndef1.groups.liquid then - minetest.add_item(p1, ItemStack(node1)) minetest.set_node(p1, {name = "air"}) end @@ -327,7 +311,6 @@ local specific_attack = function(list, what) -- found entity on list to attack? for no = 1, #list do - if list[no] == what then return true end @@ -481,7 +464,6 @@ function mob_class:dogswitch(dtime) and self.dogshoot_count > self.dogshoot_count_max) or (self.dogshoot_switch == 2 and self.dogshoot_count > self.dogshoot_count2_max) then - self.dogshoot_count = 0 if self.dogshoot_switch == 1 then @@ -546,7 +528,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) -- custom punch function if self.do_punch then - -- when false skip going any further if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then return @@ -590,7 +571,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) tflp = 0.2 end - for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do 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 for n = 1, #self.immune_to do - if self.immune_to[n][1] == weapon:get_name() then - damage = self.immune_to[n][2] or 0 break end @@ -654,13 +632,11 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) local die = false - 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. if damage >= 0.1 then -- weapon sounds if weapon:get_definition().sounds ~= nil then - local s = math.random(0, #weapon:get_definition().sounds) minetest.sound_play(weapon:get_definition().sounds[s], { @@ -709,7 +685,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) up = 0 end - -- check if tool already has specific knockback value if tool_capabilities.damage_groups["knockback"] then kb = tool_capabilities.damage_groups["knockback"] @@ -717,7 +692,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) kb = kb * 1.25 end - local luaentity if hitter then luaentity = hitter:get_luaentity() @@ -764,7 +738,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) -- 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 - local yaw = self:set_yaw( minetest.dir_to_yaw(vector.direction(hitter:get_pos(), self.object:get_pos()))) 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 @@ -798,7 +771,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) local obj = nil for n = 1, #objs do - obj = objs[n]:get_luaentity() if obj then @@ -886,7 +858,6 @@ function mob_class:do_states_attack (dtime) or not self:object_in_range(self.attack) or self.attack:get_hp() <= 0 or (self.attack:is_player() and mcl_mobs.invis[ self.attack:get_player_name() ]) then - clear_aggro(self) return end @@ -912,7 +883,6 @@ function mob_class:do_states_attack (dtime) local dist = vector.distance(p, s) if self.attack_type == "explode" then - if target_line_of_sight then local vec = { x = p.x - s.x, z = p.z - s.z } 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 dist <= self.reach and self:dogswitch() == 0) then - if self.fly - and dist > self.reach then - + if self.fly and dist > self.reach then local p1 = s local me_y = math.floor(p1.y) local p2 = p @@ -1003,17 +971,13 @@ function mob_class:do_states_attack (dtime) local v = self.object:get_velocity() if self:flight_check( s) then - if me_y < p_y then - self.object:set_velocity({ x = v.x, y = 1 * self.walk_velocity, z = v.z }) - elseif me_y > p_y then - self.object:set_velocity({ x = v.x, y = -1 * self.walk_velocity, @@ -1022,15 +986,12 @@ function mob_class:do_states_attack (dtime) end else if me_y < p_y then - self.object:set_velocity({ x = v.x, y = 0.01, z = v.z }) - elseif me_y > p_y then - self.object:set_velocity({ x = v.x, y = -0.01, @@ -1045,7 +1006,6 @@ function mob_class:do_states_attack (dtime) if self.path.following and self.path.way and self.attack_type ~= "dogshoot" then - -- no paths longer than 50 if #self.path.way > 50 or dist < self.reach then @@ -1054,7 +1014,6 @@ function mob_class:do_states_attack (dtime) end local p1 = self.path.way[1] - if not p1 then self.path.following = false return @@ -1152,11 +1111,9 @@ function mob_class:do_states_attack (dtime) end end end - elseif self.attack_type == "shoot" 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 - p.y = p.y - .5 s.y = s.y + .5 @@ -1217,7 +1174,6 @@ function mob_class:do_states_attack (dtime) -- Shoot arrow if minetest.registered_entities[self.arrow] then - local arrow, ent local v = 1 if not self.shoot_arrow then @@ -1263,5 +1219,4 @@ function mob_class:do_states_attack (dtime) if self.on_attack then self.on_attack(self, dtime) end - end diff --git a/mods/ENTITIES/mcl_mobs/effects.lua b/mods/ENTITIES/mcl_mobs/effects.lua index e746fef39..0401a3f78 100644 --- a/mods/ENTITIES/mcl_mobs/effects.lua +++ b/mods/ENTITIES/mcl_mobs/effects.lua @@ -13,7 +13,6 @@ if player_transfer_distance == 0 then player_transfer_distance = math.huge end -- custom particle effects function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) - radius = radius or 2 min_size = min_size or 0.5 max_size = max_size or 1 @@ -89,7 +88,6 @@ end -- play sound function mob_class:mob_sound(soundname, is_opinion, fixed_pitch) - local soundinfo if self.sounds_child and self.child then soundinfo = self.sounds_child @@ -259,8 +257,6 @@ function mob_class:set_animation(anim, fixed_frame) return end - - if self.fly and self:flight_check() and anim == "walk" then anim = "fly" end self._current_animation = self._current_animation or "" @@ -358,7 +354,6 @@ end function mob_class:check_head_swivel(dtime) if not self.head_swivel or type(self.head_swivel) ~= "string" then return end - who_are_you_looking_at (self, dtime) 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 end if _locked_object_eye_height then - local self_rot = self.object:get_rotation() -- If a mob is attached, should we really be messing with what they are looking at? -- Should this be excluded? diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index c981e6a86..c374e204e 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -110,7 +110,6 @@ end mcl_mobs.spawning_mobs = {} -- register mob entity function mcl_mobs.register_mob(name, def) - mcl_mobs.spawning_mobs[name] = true mcl_mobs.registered_mobs[name] = def @@ -344,7 +343,6 @@ end -- register arrow for shoot attack function mcl_mobs.register_arrow(name, def) - if not name or not def then return end -- errorcheck minetest.register_entity(name, { @@ -378,7 +376,6 @@ function mcl_mobs.register_arrow(name, def) on_activate = def.on_activate, on_step = def.on_step or function(self, dtime) - self.timer = self.timer + dtime local pos = self.object:get_pos() @@ -396,7 +393,6 @@ function mcl_mobs.register_arrow(name, def) if def.tail and def.tail == 1 and def.tail_texture then - minetest.add_particle({ pos = pos, velocity = {x = 0, y = 0, z = 0}, @@ -410,15 +406,12 @@ function mcl_mobs.register_arrow(name, def) end if self.hit_node then - local node = node_ok(pos).name if minetest.registered_nodes[node].walkable then - self.hit_node(self, pos, node) if self.drop == true then - pos.y = pos.y + 1 self.lastpos = (self.lastpos or pos) @@ -444,9 +437,7 @@ function mcl_mobs.register_arrow(name, def) end 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 - if self.hit_player 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 minetest.register_craftitem(mob, { - description = desc, inventory_image = invimg, 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 privs = minetest.get_player_privs(name) - if under.name == "mcl_mobspawners:spawner" then if minetest.is_protected(pointed_thing.under, name) then minetest.record_protection_violation(pointed_thing.under, name) diff --git a/mods/ENTITIES/mcl_mobs/mount.lua b/mods/ENTITIES/mcl_mobs/mount.lua index 21c52157a..2042374de 100644 --- a/mods/ENTITIES/mcl_mobs/mount.lua +++ b/mods/ENTITIES/mcl_mobs/mount.lua @@ -12,7 +12,6 @@ local crash_threshold = 6.5 -- ignored if enable_crash=false -- local node_ok = function(pos, fallback) - fallback = fallback or mcl_mobs.fallback_node local node = minetest.get_node_or_nil(pos) @@ -26,7 +25,6 @@ end local function node_is(pos) - local node = node_ok(pos) if node.name == "air" then @@ -50,7 +48,6 @@ end local function get_sign(i) - i = i or 0 if i == 0 then @@ -62,7 +59,6 @@ end local function get_velocity(v, yaw, y) - local x = -math.sin(yaw) * v local z = math.cos(yaw) * v @@ -76,7 +72,6 @@ end local function force_detach(player) - local attached_to = player:get_attach() if not attached_to then @@ -87,7 +82,6 @@ local function force_detach(player) if entity.driver and entity.driver == player then - entity.driver = nil 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}) mcl_player.player_set_animation(player, "stand" , 30) player:set_properties({visual_size = {x = 1, y = 1} }) - end ------------------------------------------------------------------------------- @@ -121,7 +114,6 @@ end) ------------------------------------------------------------------------------- function mcl_mobs.attach(entity, player) - local attach_at, eye_offset entity.player_rotation = entity.player_rotation or {x = 0, y = 0, z = 0} @@ -164,7 +156,6 @@ end function mcl_mobs.detach(player, offset) - force_detach(player) 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) - local rot_view = 0 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 if entity.driver then - local ctrl = entity.driver:get_player_control() -- move forwards if ctrl.up then - entity.v = entity.v + entity.accel / 10 * entity.run_velocity / 2.6 -- move backwards elseif ctrl.down then - if entity.max_speed_reverse == 0 and entity.v == 0 then return 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) if can_fly then - -- fly up if ctrl.jump then velo.y = velo.y + 1 if velo.y > entity.accel then velo.y = entity.accel end - elseif velo.y > 0 then velo.y = velo.y - 0.1 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 velo.y = velo.y - 1 if velo.y < -entity.accel then velo.y = -entity.accel end - elseif velo.y < 0 then velo.y = velo.y + 0.1 if velo.y > 0 then velo.y = 0 end end else - -- jump if ctrl.jump then - if velo.y == 0 then velo.y = velo.y + entity.jump_height 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 entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then - if stand_anim then mcl_mobs:set_animation(entity, stand_anim) end @@ -279,7 +260,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) entity.v = entity.v - 0.02 * s if s ~= get_sign(entity.v) then - entity.object:set_velocity({x = 0, y = 0, z = 0}) entity.v = 0 return @@ -307,19 +287,14 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) local v = entity.v if ni == "air" then - if can_fly == true then new_acce.y = 0 end - elseif ni == "liquid" or ni == "lava" then - if ni == "lava" and entity.lava_damage ~= 0 then - entity.lava_counter = (entity.lava_counter or 0) + dtime if entity.lava_counter > 1 then - minetest.sound_play("default_punch", { object = entity.object, 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 or entity.terrain_type == 3 then - new_acce.y = 0 p.y = p.y + 1 if node_is(p) == "liquid" then - if velo.y >= 5 then velo.y = 5 elseif velo.y < 0 then @@ -370,7 +343,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) -- CRASH! if enable_crash then - local intensity = entity.v2 - v 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, damage_groups = {fleshy = intensity} }, nil) - end end @@ -389,7 +360,6 @@ end -- directional flying routine by D00Med (edited by TenPlus1) function mcl_mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) - local ctrl = entity.driver:get_player_control() local velo = entity.object:get_velocity() 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 if ctrl.LMB and ctrl.sneak and shoots then - local pos = entity.object:get_pos() local obj = minetest.add_entity({ 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 if velo.x == 0 and velo.y == 0 and velo.z == 0 then - mcl_mobs:set_animation(entity, stand_anim) else -- moving animation diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index d2a5ee69c..f9bc0b49c 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -450,11 +450,9 @@ function mob_class:do_jump() local ndef = minetest.registered_nodes[nod.name] 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 and minetest.get_item_group(nod.name, "fence_gate") == 0 and minetest.get_item_group(nod.name, "wall") == 0 then - local v = self.object:get_velocity() 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 self.object:get_velocity().x ~= 0 and self.object:get_velocity().z ~= 0 then - self.jump_count = (self.jump_count or 0) + 1 if self.jump_count == 4 then - local yaw = self.object:get_yaw() or 0 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 if name ~= "" and name ~= self.name and in_list(object_list, name) then - local p = object:get_pos() 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 if not object_pos then - -- find specific node to avoid or runaway from local p = minetest.find_node_near(s, node_range, object_list, true) 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 if object_pos and turn_around then - local vec = vector.subtract(object_pos, s) 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 @@ -599,7 +592,6 @@ function mob_class:follow_holding(clicker) if t == "string" and item:get_name() == self.follow then return true - -- multiple items elseif t == "table" and in_list(self.follow, item:get_name()) then return true @@ -624,7 +616,6 @@ function mob_class:replace_node(pos) local what, with, y_offset if type(self.replace_what[1]) == "table" then - local num = math.random(#self.replace_what) what = self.replace_what[num][1] or "" @@ -640,7 +631,6 @@ function mob_class:replace_node(pos) local node = minetest.get_node(pos) if node.name == what then - local oldnode = {name = what, param2 = node.param2} local newnode = {name = with, param2 = node.param2} local on_replace_return = false @@ -696,7 +686,6 @@ function mob_class:check_follow() if self.type == "npc" and self.order == "follow" 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 self.following = nil end @@ -737,7 +726,7 @@ function mob_class:check_follow() -- anyone but standing npc's can move along 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 self:set_animation( "run") end @@ -876,7 +865,6 @@ function mob_class:do_states_walk() -- did we find land? if lp then - local vec = { x = lp.x - s.x, z = lp.z - s.z @@ -890,7 +878,6 @@ function mob_class:do_states_walk() -- look towards land and move in that direction yaw = self:set_yaw( yaw, 6) self:set_velocity(self.walk_velocity) - end end end @@ -918,14 +905,12 @@ function mob_class:do_states_walk() if self.facing_fence == true or cliff_or_danger or math.random(1, 100) <= 30 then - self:set_velocity(0) self.state = "stand" self:set_animation( "stand") local yaw = self.object:get_yaw() or 0 yaw = self:set_yaw( yaw + 0.78, 8) else - self:set_velocity(self.walk_velocity) 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 if math.random(1, 4) == 1 then - local s = self.object:get_pos() local objs = minetest.get_objects_inside_radius(s, 3) local lp @@ -956,7 +940,6 @@ function mob_class:do_states_stand(player_in_active_range) -- look at any players nearby, otherwise turn randomly if lp and self.look_at_players then - local vec = { x = lp.x - s.x, z = lp.z - s.z @@ -1017,11 +1000,6 @@ function mob_class:do_states_runaway() end end - - - - - function mob_class:check_smooth_rotation(dtime) -- smooth rotation by ThomasMonroe314 if self._turn_to then @@ -1029,7 +1007,6 @@ function mob_class:check_smooth_rotation(dtime) end if self.delay and self.delay > 0 then - local yaw = self.object:get_yaw() or 0 if self.delay == 1 then @@ -1038,16 +1015,13 @@ function mob_class:check_smooth_rotation(dtime) local dif = math.abs(yaw - self.target_yaw) if yaw > self.target_yaw then - if dif > math.pi then dif = 2 * math.pi - dif -- need to add yaw = yaw + dif / self.delay else yaw = yaw - dif / self.delay -- need to subtract end - elseif yaw < self.target_yaw then - if dif >math.pi then dif = 2 * math.pi - dif yaw = yaw - dif / self.delay -- need to subtract diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 705b22dbb..cc289b53c 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -15,7 +15,6 @@ local show_health = false -- get node but use fallback for nil or unknown local node_ok = function(pos, fallback) - fallback = fallback or mcl_mobs.fallback_node local node = minetest.get_node_or_nil(pos) @@ -80,7 +79,6 @@ function mob_class:object_in_range(object) end function mob_class:item_drop(cooked, looting_level) - if not mobs_drop_items then return end looting_level = looting_level or 0 @@ -124,7 +122,6 @@ function mob_class:item_drop(cooked, looting_level) item = dropdef.name if cooked then - local output = minetest.get_craft_result({ method = "cooking", width = 1, items = {item}}) @@ -138,7 +135,6 @@ function mob_class:item_drop(cooked, looting_level) end if obj and obj:get_luaentity() then - obj:set_velocity({ x = math.random(-10, 10) / 9, y = 6, @@ -162,10 +158,8 @@ function mob_class:collision() local z = 0 local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5 for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do - local ent = object:get_luaentity() 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 mcl_burning.set_on_fire(object, 4) end @@ -265,7 +259,6 @@ function mob_class:update_roll() end local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums) - if not rot_origin or not rot_target then return end @@ -302,7 +295,6 @@ local function shortest_term_of_yaw_rotation(self, rot_origin, rot_target, nums) end end end - end @@ -386,7 +378,6 @@ end -- are we flying in what we are suppose to? (taikedz) function mob_class:flight_check() - local nod = self.standing_in local def = minetest.registered_nodes[nod] @@ -412,7 +403,6 @@ end -- check if mob is dead or only hurt function mob_class:check_for_death(cause, cmi_cause) - if self.state == "die" then return true end @@ -507,7 +497,6 @@ function mob_class:check_for_death(cause, cmi_cause) -- execute custom death function if self.on_die then - local pos = self.object:get_pos() local on_die_exit = self.on_die(self, pos, cmi_cause) if on_die_exit ~= true then @@ -527,7 +516,6 @@ function mob_class:check_for_death(cause, cmi_cause) self.jockey = nil end - local collisionbox if self.collisionbox then collisionbox = table.copy(self.collisionbox) @@ -615,7 +603,6 @@ function mob_class:do_env_damage() -- reset nametag after showing health stats if self.htimer < 1 and self.nametag2 then - self.nametag = self.nametag2 self.nametag2 = nil @@ -661,7 +648,6 @@ function mob_class:do_env_damage() end end end - end local y_level = self.collisionbox[2] @@ -958,7 +944,6 @@ end -- falling and fall damage -- returns true if mob died function mob_class:falling(pos) - if self.fly and self.state ~= "die" then return end diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 4108d038c..ca025353e 100755 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -301,7 +301,6 @@ local function count_mobs_all(categorise_by, pos) local num = 0 for _,entity in pairs(minetest.luaentities) do if entity and entity.is_mob then - local add_entry = false --local mob_type = entity.type -- animal / monster / npc local mob_cat = entity[categorise_by] @@ -799,8 +798,6 @@ minetest.register_chatcommand("spawn_mob",{ local mod1 = string.find(param, ":") - - local mobname = param if mod1 then mobname = string.sub(param, 1, mod1-1) @@ -856,12 +853,8 @@ minetest.register_chatcommand("spawn_mob",{ }) if mobs_spawn then - -- 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) - -- Some mob examples --type = "monster", spawn_class = "hostile", --type = "animal", spawn_class = "passive", @@ -968,7 +961,6 @@ if mobs_spawn then end local function spawn_a_mob(pos, cap_space_hostile, cap_space_non_hostile) - local spawning_position = find_spawning_position(pos, FIND_SPAWN_POS_RETRIES) if not spawning_position then 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] 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_spawn_class = mob_def_ent.spawn_class @@ -1092,7 +1083,6 @@ if mobs_spawn then local timer = 0 minetest.register_globalstep(function(dtime) - timer = timer + dtime if timer < WAIT_FOR_SPAWN_ATTEMPT then return end initialize_spawn_data()