Remove dead code in mcl_mobs
This commit is contained in:
parent
1d04b52b5a
commit
9c6f5b3573
|
@ -44,7 +44,6 @@ local random = math.random
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local atan = function(x)
|
local atan = function(x)
|
||||||
if not x or x ~= x then
|
if not x or x ~= x then
|
||||||
--error("atan bassed NaN")
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return atann(x)
|
return atann(x)
|
||||||
|
@ -628,7 +627,6 @@ local do_env_damage = function(self)
|
||||||
-- what is mob standing in?
|
-- what is mob standing in?
|
||||||
pos.y = pos.y + y_level + 0.25 -- foot level
|
pos.y = pos.y + y_level + 0.25 -- foot level
|
||||||
self.standing_in = node_ok(pos, "air").name
|
self.standing_in = node_ok(pos, "air").name
|
||||||
-- print ("standing in " .. self.standing_in)
|
|
||||||
|
|
||||||
-- don't fall when on ignore, just stand still
|
-- don't fall when on ignore, just stand still
|
||||||
if self.standing_in == "ignore" then
|
if self.standing_in == "ignore" then
|
||||||
|
@ -735,8 +733,6 @@ local do_jump = function(self)
|
||||||
|
|
||||||
local nod = node_ok(pos)
|
local nod = node_ok(pos)
|
||||||
|
|
||||||
--print ("standing on:", nod.name, pos.y)
|
|
||||||
|
|
||||||
if minetest.registered_nodes[nod.name].walkable == false then
|
if minetest.registered_nodes[nod.name].walkable == false then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -757,8 +753,6 @@ local do_jump = function(self)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--print ("in front:", nod.name, pos.y + 0.5)
|
|
||||||
|
|
||||||
if self.walk_chance == 0
|
if self.walk_chance == 0
|
||||||
or minetest.registered_items[nod.name].walkable then
|
or minetest.registered_items[nod.name].walkable then
|
||||||
|
|
||||||
|
@ -775,11 +769,10 @@ local do_jump = function(self)
|
||||||
|
|
||||||
-- when in air move forward
|
-- when in air move forward
|
||||||
minetest.after(0.3, function(self, v)
|
minetest.after(0.3, function(self, v)
|
||||||
-- self.object:setvelocity({
|
|
||||||
self.object:set_acceleration({
|
self.object:set_acceleration({
|
||||||
x = v.x * 2,--1.5,
|
x = v.x * 2,
|
||||||
y = 0,
|
y = 0,
|
||||||
z = v.z * 2,--1.5
|
z = v.z * 2,
|
||||||
})
|
})
|
||||||
end, self, v)
|
end, self, v)
|
||||||
|
|
||||||
|
@ -1027,8 +1020,6 @@ local replace = function(self, pos)
|
||||||
|
|
||||||
if #minetest.find_nodes_in_area(pos, pos, what) > 0 then
|
if #minetest.find_nodes_in_area(pos, pos, what) > 0 then
|
||||||
|
|
||||||
-- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
|
|
||||||
|
|
||||||
local oldnode = {name = what}
|
local oldnode = {name = what}
|
||||||
local newnode = {name = with}
|
local newnode = {name = with}
|
||||||
local on_replace_return
|
local on_replace_return
|
||||||
|
@ -1151,7 +1142,6 @@ local smart_mobs = function(self, s, p, dist, dtime)
|
||||||
-- round position to center of node to avoid stuck in walls
|
-- round position to center of node to avoid stuck in walls
|
||||||
-- also adjust height for player models!
|
-- also adjust height for player models!
|
||||||
s.x = floor(s.x + 0.5)
|
s.x = floor(s.x + 0.5)
|
||||||
-- s.y = floor(s.y + 0.5) - sheight
|
|
||||||
s.z = floor(s.z + 0.5)
|
s.z = floor(s.z + 0.5)
|
||||||
|
|
||||||
local ssight, sground = minetest.line_of_sight(s, {
|
local ssight, sground = minetest.line_of_sight(s, {
|
||||||
|
@ -1172,24 +1162,6 @@ local smart_mobs = function(self, s, p, dist, dtime)
|
||||||
if self.fear_height ~= 0 then dropheight = self.fear_height end
|
if self.fear_height ~= 0 then dropheight = self.fear_height end
|
||||||
|
|
||||||
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "A*_noprefetch")
|
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "A*_noprefetch")
|
||||||
--[[
|
|
||||||
-- show path using particles
|
|
||||||
if self.path.way and #self.path.way > 0 then
|
|
||||||
print ("-- path length:" .. tonumber(#self.path.way))
|
|
||||||
for _,pos in pairs(self.path.way) do
|
|
||||||
minetest.add_particle({
|
|
||||||
pos = pos,
|
|
||||||
velocity = {x=0, y=0, z=0},
|
|
||||||
acceleration = {x=0, y=0, z=0},
|
|
||||||
expirationtime = 1,
|
|
||||||
size = 4,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "heart.png",
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
self.state = ""
|
self.state = ""
|
||||||
do_attack(self, self.attack)
|
do_attack(self, self.attack)
|
||||||
|
@ -1741,15 +1713,6 @@ local do_states = function(self, dtime)
|
||||||
set_velocity(self, self.walk_velocity)
|
set_velocity(self, self.walk_velocity)
|
||||||
self.state = "walk"
|
self.state = "walk"
|
||||||
set_animation(self, "walk")
|
set_animation(self, "walk")
|
||||||
|
|
||||||
--[[ fly up/down randomly for flying mobs
|
|
||||||
if self.fly and random(1, 100) <= self.walk_chance then
|
|
||||||
|
|
||||||
local v = self.object:getvelocity()
|
|
||||||
local ud = random(-1, 2) / 9
|
|
||||||
|
|
||||||
self.object:setvelocity({x = v.x, y = ud, z = v.z})
|
|
||||||
end--]]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1881,7 +1844,6 @@ local do_states = function(self, dtime)
|
||||||
or self.attack:get_hp() <= 0
|
or self.attack:get_hp() <= 0
|
||||||
or (self.attack:is_player() and mobs.invis[ self.attack:get_player_name() ]) then
|
or (self.attack:is_player() and mobs.invis[ self.attack:get_player_name() ]) then
|
||||||
|
|
||||||
-- print(" ** stop attacking **", dist, self.view_range)
|
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
@ -1920,7 +1882,6 @@ local do_states = function(self, dtime)
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.blinktimer = 0
|
self.blinktimer = 0
|
||||||
mob_sound(self, self.sounds.fuse)
|
mob_sound(self, self.sounds.fuse)
|
||||||
-- print ("=== explosion timer started", self.explosion_timer)
|
|
||||||
|
|
||||||
-- stop timer if out of reach or direct line of sight
|
-- stop timer if out of reach or direct line of sight
|
||||||
elseif self.allow_fuse_reset
|
elseif self.allow_fuse_reset
|
||||||
|
@ -1965,8 +1926,6 @@ local do_states = function(self, dtime)
|
||||||
self.blinkstatus = not self.blinkstatus
|
self.blinkstatus = not self.blinkstatus
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print ("=== explosion timer", self.timer)
|
|
||||||
|
|
||||||
if self.timer > self.explosion_timer then
|
if self.timer > self.explosion_timer then
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
@ -2318,11 +2277,6 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mob health check
|
|
||||||
-- if self.health <= 0 then
|
|
||||||
-- return
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- error checking when mod profiling is enabled
|
-- error checking when mod profiling is enabled
|
||||||
if not tool_capabilities then
|
if not tool_capabilities then
|
||||||
minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled")
|
minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled")
|
||||||
|
@ -2386,8 +2340,6 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print ("Mob Damage is", damage)
|
|
||||||
|
|
||||||
if use_cmi then
|
if use_cmi then
|
||||||
|
|
||||||
local cancel = cmi.notify_punch(self.object, hitter, tflp, tool_capabilities, dir, damage)
|
local cancel = cmi.notify_punch(self.object, hitter, tflp, tool_capabilities, dir, damage)
|
||||||
|
@ -2461,15 +2413,6 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ add healthy afterglow when hit (can cause hit lag with larger textures)
|
|
||||||
core.after(0.1, function()
|
|
||||||
self.object:settexturemod("^[colorize:#c9900070")
|
|
||||||
|
|
||||||
core.after(0.3, function()
|
|
||||||
self.object:settexturemod("")
|
|
||||||
end)
|
|
||||||
end) ]]
|
|
||||||
|
|
||||||
-- knock back effect (only on full punch)
|
-- knock back effect (only on full punch)
|
||||||
if self.knock_back
|
if self.knock_back
|
||||||
and tflp >= punch_interval then
|
and tflp >= punch_interval then
|
||||||
|
@ -2580,8 +2523,6 @@ local mob_staticdata = function(self)
|
||||||
and not self.tamed
|
and not self.tamed
|
||||||
and self.lifetimer < 20000 then
|
and self.lifetimer < 20000 then
|
||||||
|
|
||||||
--print ("REMOVED " .. self.name)
|
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
return ""-- nil
|
return ""-- nil
|
||||||
|
@ -2616,7 +2557,6 @@ local mob_staticdata = function(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
|
|
||||||
return minetest.serialize(tmp)
|
return minetest.serialize(tmp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2799,9 +2739,6 @@ local mob_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- minetest.log("action",
|
|
||||||
-- S("lifetimer expired, removed @1", self.name))
|
|
||||||
|
|
||||||
effect(pos, 15, "tnt_smoke.png", 2, 4, 2, 0)
|
effect(pos, 15, "tnt_smoke.png", 2, 4, 2, 0)
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
@ -2926,8 +2863,6 @@ end
|
||||||
-- default function when mobs are blown up with TNT
|
-- default function when mobs are blown up with TNT
|
||||||
local do_tnt = function(obj, damage)
|
local do_tnt = function(obj, damage)
|
||||||
|
|
||||||
--print ("----- Damage", damage)
|
|
||||||
|
|
||||||
obj.object:punch(obj.object, 1.0, {
|
obj.object:punch(obj.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = damage},
|
damage_groups = {fleshy = damage},
|
||||||
|
@ -3187,7 +3122,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
-- is mob actually registered?
|
-- is mob actually registered?
|
||||||
if not mobs.spawning_mobs[name]
|
if not mobs.spawning_mobs[name]
|
||||||
or not minetest.registered_entities[name] then
|
or not minetest.registered_entities[name] then
|
||||||
--print ("--- mob doesn't exist", name)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3199,7 +3133,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
-- do not spawn if too many of same mob in area
|
-- do not spawn if too many of same mob in area
|
||||||
if active_object_count_wider >= max_per_block
|
if active_object_count_wider >= max_per_block
|
||||||
or count_mobs(pos, name) >= aoc then
|
or count_mobs(pos, name) >= aoc then
|
||||||
--print ("--- too many entities", name, aoc, active_object_count_wider)
|
-- too many entities
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3211,13 +3145,13 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
if tod > 4500 and tod < 19500 then
|
if tod > 4500 and tod < 19500 then
|
||||||
-- daylight, but mob wants night
|
-- daylight, but mob wants night
|
||||||
if day_toggle == false then
|
if day_toggle == false then
|
||||||
--print ("--- mob needs night", name)
|
-- mob needs night
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- night time but mob wants day
|
-- night time but mob wants day
|
||||||
if day_toggle == true then
|
if day_toggle == true then
|
||||||
--print ("--- mob needs day", name)
|
-- mob needs day
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3232,7 +3166,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
if objs[n]:is_player() then
|
if objs[n]:is_player() then
|
||||||
--print ("--- player too close", name)
|
-- player too close
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3240,14 +3174,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
-- mobs cannot spawn in protected areas when enabled
|
-- mobs cannot spawn in protected areas when enabled
|
||||||
if not spawn_protected
|
if not spawn_protected
|
||||||
and minetest.is_protected(pos, "") then
|
and minetest.is_protected(pos, "") then
|
||||||
--print ("--- inside protected area", name)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- are we spawning within height limits?
|
-- are we spawning within height limits?
|
||||||
if pos.y > max_height
|
if pos.y > max_height
|
||||||
or pos.y < min_height then
|
or pos.y < min_height then
|
||||||
--print ("--- height limits not met", name, pos.y)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3256,7 +3188,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
if not light
|
if not light
|
||||||
or light > max_light
|
or light > max_light
|
||||||
or light < min_light then
|
or light < min_light then
|
||||||
--print ("--- light limits not met", name, light)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3269,7 +3200,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
local pos2 = {x = pos.x, y = pos.y + n, z = pos.z}
|
local pos2 = {x = pos.x, y = pos.y + n, z = pos.z}
|
||||||
|
|
||||||
if minetest.registered_nodes[node_ok(pos2).name].walkable == true then
|
if minetest.registered_nodes[node_ok(pos2).name].walkable == true then
|
||||||
--print ("--- inside block", name, node_ok(pos2).name)
|
-- inside block
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3278,11 +3209,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
pos.y = pos.y + 0.5
|
pos.y = pos.y + 0.5
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, name)
|
local mob = minetest.add_entity(pos, name)
|
||||||
--[[
|
|
||||||
print ("[mobs] Spawned " .. name .. " at "
|
|
||||||
.. minetest.pos_to_string(pos) .. " on "
|
|
||||||
.. node.name .. " near " .. neighbors[1])
|
|
||||||
]]
|
|
||||||
if on_spawn then
|
if on_spawn then
|
||||||
|
|
||||||
local ent = mob:get_luaentity()
|
local ent = mob:get_luaentity()
|
||||||
|
@ -3359,7 +3286,7 @@ function mobs:register_arrow(name, def)
|
||||||
or self.timer > 150
|
or self.timer > 150
|
||||||
or not within_limits(pos, 0) then
|
or not within_limits(pos, 0) then
|
||||||
|
|
||||||
self.object:remove() ; -- print ("removed arrow")
|
self.object:remove();
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -3398,7 +3325,7 @@ function mobs:register_arrow(name, def)
|
||||||
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
|
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:remove() ; -- print ("hit node")
|
self.object:remove();
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -3412,7 +3339,7 @@ function mobs:register_arrow(name, def)
|
||||||
and player:is_player() then
|
and player:is_player() then
|
||||||
|
|
||||||
self.hit_player(self, player)
|
self.hit_player(self, player)
|
||||||
self.object:remove() ; -- print ("hit player")
|
self.object:remove();
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3426,7 +3353,7 @@ function mobs:register_arrow(name, def)
|
||||||
|
|
||||||
self.hit_mob(self, player)
|
self.hit_mob(self, player)
|
||||||
|
|
||||||
self.object:remove() ; --print ("hit mob")
|
self.object:remove();
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -155,7 +155,6 @@ function mobs.attach(entity, player)
|
||||||
mcl_player.player_set_animation(player, "sit" , 30)
|
mcl_player.player_set_animation(player, "sit" , 30)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--player:set_look_yaw(entity.object:get_yaw() - rot_view)
|
|
||||||
player:set_look_horizontal(entity.object:get_yaw() - rot_view)
|
player:set_look_horizontal(entity.object:get_yaw() - rot_view)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -192,8 +191,6 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
-- process controls
|
-- process controls
|
||||||
if entity.driver then
|
if entity.driver then
|
||||||
|
|
||||||
--print ("---velo", get_v(velo))
|
|
||||||
|
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
|
|
||||||
-- move forwards
|
-- move forwards
|
||||||
|
@ -367,8 +364,6 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
|
|
||||||
if intensity >= crash_threshold then
|
if intensity >= crash_threshold then
|
||||||
|
|
||||||
--print("----------- crash", intensity)
|
|
||||||
|
|
||||||
entity.object:punch(entity.object, 1.0, {
|
entity.object:punch(entity.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = intensity}
|
damage_groups = {fleshy = intensity}
|
||||||
|
|
Loading…
Reference in New Issue