Sorry I could not comment earlier as I was getting ready for work so I was brief.
function aiCode(aiObject)
rem aiCode would be included in amongst your existing AI routine to handle the turn direction of the AI object.
minimumTurnThreshold=5
rem this variable holds a dead zone for the AI turning, it should be a higher value than the turn speed and will prevent the object from performing a left/right flicker when facing the player.
turnSpeed=3
rem this variable will determine how much the AI object turns per execution of this code in degrees.
targetBearing#=whereIsHe(aiObject,target(aiObject))
rem this will assertain the bearing 0-360 of the target object from the AI object. If it is to the right, 90 is return. To the left, 270 is returned.
turn#=whichWay(object angle y(aiObject),targetBearing#)
rem This will return a relational direction of the target bearing based upon the AI objects current direction. The value returned is -180 to 180. So if the target object is at bearing 270 and the AI object is facing a bearing of 45, the result is -135.
rem All directions to the right are positive, and all to the left are negative.
if turn#>minimumTurnThreshold
turn object right aiObject,turnSpeed
else
if turn#<-minimumTurnThreshold
turnobject left aiObject,turnSpeed
endIf
endIf
rem This code will determine which direction needs to be turned, if any, and check that it is beyond the dead zone to prevent left/right flickering every execution.
endfunction
function whereIsHe(aiObject,targetObject)
targetBearing#=atanfull(object position x(aiObject)-object
position x(targetObject),object position z(aiObject)-object position z(targetObject))
endfunction targetBearing#
function whichWay(facing#,targetBearing#)
turn#=180-wrapvalue((facing#-targetBearing#)-180)
endfunction turn#

God created the world in 7 days, but we're still waiting for the patch.