From b2bebd1d8d07a3eb0c9a88599536fded0689959b Mon Sep 17 00:00:00 2001 From: Sumyjkl Date: Thu, 14 Jul 2022 14:57:30 +1000 Subject: [PATCH] comments and changed scare distance --- mods/ENTITIES/extra_mobs/fox.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/extra_mobs/fox.lua b/mods/ENTITIES/extra_mobs/fox.lua index 13ee51dad..bb87d77c4 100644 --- a/mods/ENTITIES/extra_mobs/fox.lua +++ b/mods/ENTITIES/extra_mobs/fox.lua @@ -108,6 +108,7 @@ local fox = { y = lp.y - s.y, z = lp.z - s.z } + -- scare logic if (object and object:is_player() and not object:get_player_control().sneak) @@ -119,11 +120,13 @@ local fox = { self.state = "runaway" self.object:set_rotation({x=0,y=(atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate,z=0}) end - -- this next line causes jittering - if self.reach > vector.distance(self.object:get_pos(), object:get_pos()) then + -- if it is within a distance of the player or wolf + if 6 > vector.distance(self.object:get_pos(), object:get_pos()) then self.timer = self.timer + 1 - if self.timer > 10 then + -- have some time before getting scared + if self.timer > 6 then self.timer = 0 + -- punch the fox for the player, but don't do any damage self.object:punch(object, 0, { full_punch_interval = 0, damage_groups = {fleshy = 0}