local U = require "scriptbank\\utillib" local random = math.random local sin = math.sin local cos = math.cos local timerMin = 3000 local timerMax = 6000 local maxDist = 2000 local aiTimer = {} local aiOrigPos = {} function ai_passive_init( e ) Include("utillib.lua") CharacterControlStand( e ) end function ai_passive_main( e ) local aiTime = aiTimer[ e ] if aiTime == nil then local Ent = g_Entity[ e ] aiOrigPos[ e ] = { x = Ent.x, z = Ent.z } aiTimer[ e ] = g_Time + random( 0, timerMax ) return end if U.PlayerCloserThan( e, 200 ) then local Ent = g_Entity[ e ] AIEntityGoToPosition( Ent.obj, Ent.x, Ent.z ) AIEntityStop( e ) RotateToPlayer( e ) elseif g_Time > aiTime then local Ent = g_Entity[ e ] local tempx, tempz = U.RandomPos( random( 200, 600 ), Ent.x, Ent.z ) local op = aiOrigPos[ e ] if U.CloserThan( tempx, 0, tempz, op.x, 0, op.z, maxDist ) then AIEntityGoToPosition( Ent.obj, tempx, tempz ) aiTimer[ e ] = g_Time + random( timerMin, timerMax ) end end end