From c761db86c7e67aab27d3806a76b7a58504a7d5c6 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 16 Apr 2021 18:29:42 -0400 Subject: [PATCH] re-arrange mob logic for random wandering --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 080d02b22..6eb0b99d9 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -126,25 +126,29 @@ local state_execution = function(self,dtime) --enable rotation locking mobs.movement_rotation_lock(self) - --set the velocity of the mob - mobs.set_velocity(self,1) + --check for nodes to jump over local node_in_front_of = jump_check(self) if node_in_front_of == 1 then mobs.jump(self) - end - --turn if on the edge of cliff --(this is written like this because unlike --jump_check which simply tells the mob to jump --this requires a mob to turn, removing the --ease of a full implementation for it in a single --function) - if node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then + elseif node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then --turn 45 degrees if so quick_rotate_45(self,dtime) + mobs.set_velocity(self,0) + end + + --only move forward if path is clear + if node_in_front_of == 0 or node_in_front_of == 1 then + --set the velocity of the mob + mobs.set_velocity(self,1) end --print("walk")