you're using atan, thats for angles >0 and <90, try atanfull, where it returns an angle between 0 and 360 (or maybe it's -180 and 180, idk). The other thing that might be a problem is the third parameter of the curveangle is 1, that means it will turn directly to the target angle, if you want that then you could use the point object command and point the enemy at the target, otherwise make the third parameter something like 4 or 5.
angle# = wrapvalue(atanfull((players(1).xloc - players(2).xloc),(players(1).zloc - players(2).zloc)))
turn_angle#=wrapvalue(angle#-object angle y(players(2).obj))
if turn_angle#>180 then dec turn_angle#,360
`turn the computer towards the player
if abs(turn_angle#) > 0
a# = curveangle(angle#, object angle y(players(2).obj), 5)
yrotate object players(2).obj, a#
endif
if abs(turn_angle#) < 2 then aistate = 1
i don't know if this way works, cuz i don't have the rest of the code, but it should work.
you have these in an array:
players(1).xloc
players(1).zloc
when you
could use this, and make the code more simple:
object position x(players(1).obj)
object position z(players(1).obj)
-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.