Ya, I tried change it. I think the problem seems to be that the program wont enter state2. I updated my code again, still get same result.
================================================================================
action player_cb()
{
ENTITY* enemy = NULL;
//ENEMY IS STANDING ON GROUND=================================================================
VECTOR vFeet;
vec_for_min(vFeet,me);
set(my,FLAG2);
my.STATE = 1;
//ENEMY IS IDLE===============================================================================
if(my.STATE == 1)
{
//DETECT THE ENEMY============================================================================
c_scan(my.x,my.pan,vector(900,0,0),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
while(1)
{
my.ANIMATION += 10 * time_step;
ent_animate(my, "idle", my.ANIMATION, ANM_CYCLE);
if(you)
{
my.ANIMATION = 0;
my.STATE = 2;
enemy = your.PLAYER;
}
wait(1);
}
}
//PERFORM WALK ANIMATION======================================================================
if(my.STATE == 2)
{
VECTOR vDirection;
ANGLE vTargetAngle;
vec_diff(vDirection,enemy.x,my.x);
vec_to_angle(vTargetAngle,vDirection);
my.pan += time_step * sign(ang(vTargetAngle.pan - my.pan));
var dist = vec_dist(my.x, your.x);
while(1)
{
if(dist > 0 || dist < 0)
{
var distance = 5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
walk_percentage += 2* distance;
ent_animate(my,"walk",walk_percentage,ANM_CYCLE);
if(dist == 0)
{
my.ANIMATION = 0;
my.STATE = 3;
}
}
wait(1);
}
===============================================================================
I tried putting in some program that may cause errors in state2, still the program was able to run. I think the problem is in
==========================================================
if(you)
{
my.ANIMATION = 0;
my.STATE = 2;
enemy = your.PLAYER;
}
==========================================================
because the it doesnt seem to detect (you) thats why it doesnt enter the if statement and only perform the idle state. I wonder whats the problem? . . .