Disable entire mob ai to work on vanilla walking

This commit is contained in:
jordan4ibanez 2021-04-13 07:39:57 -04:00
parent f851f5c7ca
commit 3fc0184182
1 changed files with 115 additions and 102 deletions

View File

@ -42,6 +42,9 @@ local math_atan = math.atan
local math_random = math.random local math_random = math.random
local math_floor = math.floor local math_floor = math.floor
-- localize vector functions
local vector_new = vector.new
mobs = {} mobs = {}
-- mob constants -- mob constants
local MAX_MOB_NAME_LENGTH = 30 local MAX_MOB_NAME_LENGTH = 30
@ -3538,43 +3541,48 @@ local mob_step = function(self, dtime)
return false return false
end end
if self.state == "die" then
print("need custom die stop moving thing")
return
end
-- can mob be pushed, if so calculate direction -- do this first to prevent issues -- can mob be pushed, if so calculate direction -- do this first to prevent issues
-- you can push mobs when they're in the dead state
if self.pushable then if self.pushable then
collision(self) collision(self)
end end
if not self.fire_resistant then
mcl_burning.tick(self.object, dtime)
end
if use_cmi then
cmi.notify_step(self.object, dtime)
end --if not self.fire_resistant then
-- mcl_burning.tick(self.object, dtime)
--end
--if use_cmi then
--cmi.notify_step(self.object, dtime)
--end
local pos = self.object:get_pos() local pos = self.object:get_pos()
local yaw = 0 local yaw = 0
if mobs_debug then --if mobs_debug then
update_tag(self) --update_tag(self)
end --end
if self.state == "die" then
return
end
if self.jump_sound_cooloff > 0 then
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end
if self.opinion_sound_cooloff > 0 then --if self.jump_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime -- self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
end --end
if falling(self, pos) then --if self.opinion_sound_cooloff > 0 then
-- self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
--end
--if falling(self, pos) then
-- Return if mob died after falling -- Return if mob died after falling
return -- return
end --end
-- smooth rotation by ThomasMonroe314 -- smooth rotation by ThomasMonroe314
@ -3621,24 +3629,24 @@ local mob_step = function(self, dtime)
-- end rotation -- end rotation
-- run custom function (defined in mob lua file) -- run custom function (defined in mob lua file)
if self.do_custom then --if self.do_custom then
-- when false skip going any further -- when false skip going any further
if self.do_custom(self, dtime) == false then --if self.do_custom(self, dtime) == false then
return -- return
end --end
end --end
-- knockback timer -- knockback timer
if self.pause_timer > 0 then --if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime -- self.pause_timer = self.pause_timer - dtime
return -- return
end --end
-- attack timer -- attack timer
self.timer = self.timer + dtime --self.timer = self.timer + dtime
--[[ --[[
if self.state ~= "attack" then if self.state ~= "attack" then
@ -3653,58 +3661,60 @@ local mob_step = function(self, dtime)
]]-- ]]--
-- never go over 100 -- never go over 100
if self.timer > 100 then --if self.timer > 100 then
self.timer = 1 -- self.timer = 1
end --end
-- mob plays random sound at times -- mob plays random sound at times
if math_random(1, 70) == 1 then --if math_random(1, 70) == 1 then
mob_sound(self, "random", true) -- mob_sound(self, "random", true)
end --end
-- environmental damage timer (every 1 second) -- environmental damage timer (every 1 second)
self.env_damage_timer = self.env_damage_timer + dtime --self.env_damage_timer = self.env_damage_timer + dtime
if (self.state == "attack" and self.env_damage_timer > 1)
or self.state ~= "attack" then
self.env_damage_timer = 0
-- check for environmental damage (water, fire, lava etc.)
if do_env_damage(self) then
return
end
--if (self.state == "attack" and self.env_damage_timer > 1)
--or self.state ~= "attack" then
--
-- self.env_damage_timer = 0
--
-- -- check for environmental damage (water, fire, lava etc.)
-- if do_env_damage(self) then
-- return
-- end
--
-- node replace check (cow eats grass etc.) -- node replace check (cow eats grass etc.)
replace(self, pos) -- replace(self, pos)
end --end
monster_attack(self) --monster_attack(self)
npc_attack(self) --npc_attack(self)
breed(self) --breed(self)
if do_states(self, dtime) then --if do_states(self, dtime) then
return -- return
end --end
do_jump(self) --do_jump(self)
runaway_from(self) --runaway_from(self)
if is_at_water_danger(self) and self.state ~= "attack" then
if math_random(1, 10) <= 6 then --if is_at_water_danger(self) and self.state ~= "attack" then
set_velocity(self, 0) -- if math_random(1, 10) <= 6 then
self.state = "stand" -- set_velocity(self, 0)
set_animation(self, "stand") -- self.state = "stand"
yaw = yaw + math_random(-0.5, 0.5) -- set_animation(self, "stand")
yaw = set_yaw(self, yaw, 8) -- yaw = yaw + math_random(-0.5, 0.5)
end -- yaw = set_yaw(self, yaw, 8)
end -- end
--end
-- Add water flowing for mobs from mcl_item_entity -- Add water flowing for mobs from mcl_item_entity
--[[
local p, node, nn, def local p, node, nn, def
p = self.object:get_pos() p = self.object:get_pos()
node = minetest_get_node_or_nil(p) node = minetest_get_node_or_nil(p)
@ -3716,9 +3726,9 @@ local mob_step = function(self, dtime)
-- Move item around on flowing liquids -- Move item around on flowing liquids
if def and def.liquidtype == "flowing" then if def and def.liquidtype == "flowing" then
--[[ Get flowing direction (function call from flowlib), if there's a liquid. -- Get flowing direction (function call from flowlib), if there's a liquid.
NOTE: According to Qwertymine, flowlib.quickflow is only reliable for liquids with a flowing distance of 7. NOTE: According to Qwertymine, flowlib.quickflow is only reliable for liquids with a flowing distance of 7.
Luckily, this is exactly what we need if we only care about water, which has this flowing distance. ]] Luckily, this is exactly what we need if we only care about water, which has this flowing distance.
local vec = flowlib.quick_flow(p, node) local vec = flowlib.quick_flow(p, node)
-- Just to make sure we don't manipulate the speed for no reason -- Just to make sure we don't manipulate the speed for no reason
if vec.x ~= 0 or vec.y ~= 0 or vec.z ~= 0 then if vec.x ~= 0 or vec.y ~= 0 or vec.z ~= 0 then
@ -3746,6 +3756,7 @@ local mob_step = function(self, dtime)
--Mob following code. --Mob following code.
follow_flop(self) follow_flop(self)
if is_at_cliff_or_danger(self) then if is_at_cliff_or_danger(self) then
set_velocity(self, 0) set_velocity(self, 0)
self.state = "stand" self.state = "stand"
@ -3774,6 +3785,7 @@ local mob_step = function(self, dtime)
end end
end end
end end
]]--
end end
@ -4006,6 +4018,7 @@ minetest.register_entity(name, {
self.object:set_properties({ self.object:set_properties({
collide_with_objects = false, collide_with_objects = false,
}) })
self.object:set_acceleration(vector_new(0,-9.81, 0))
return mob_activate(self, staticdata, def, dtime) return mob_activate(self, staticdata, def, dtime)
end, end,