My suggestion would be to take this part of that code:
elseif (MyState == ATTACK_ST) then
OnATTACK_ST()
And take it to the top, so the code now looks like this:
if (MyState == ATTACK_ST) then
OnATTACK_ST()
elseif (MyState == IDLE_ST) then
OnIDLE_ST()
elseif (MyState == CHASE_ST) then
OnCHASE_ST()
elseif (MyState == EVADE_ST) then
OnEVADE_ST()
elseif (MyState == FOLLOW_ST) then
OnFOLLOW_ST()
elseif (MyState == BUGPOSI_ST) then
OnBUGPOSI_ST()
Afterwards you may insert the suggested code so it will look something like this:
local zx, zy = GetV( V_POSITION, MyEnemy )
if (MyState == ATTACK_ST) then
OnATTACK_ST ()
Move(MyID,zx+1,zy)
Move(MyID,zx-1,zy)
elseif (MyState == IDLE_ST) then
OnIDLE_ST()
elseif (MyState == CHASE_ST) then
OnCHASE_ST()
elseif (MyState == EVADE_ST) then
OnEVADE_ST()
elseif (MyState == FOLLOW_ST) then
OnFOLLOW_ST()
elseif (MyState == BUGPOSI_ST) then
OnBUGPOSI_ST()
Hopefully it works as coded, if not, writing the extension into the actual OnAttack_ST() code might be necessary.