//walking withOut the sword in hand state
while(1)
{
//default state
if(my.STATE == 0)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
my.ANIMATION += 2 *time_step;
ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
}
//the run state without the sword in hand
if(my.STATE ==1)
{
//rotate player with the left and right keys
my.pan += (key_cul-key_cur)*5* time_step;
//move the entity forward
var distance = 25 *time_step;
c_move(me,vector(distance,0,0),NULL,GLIDE);
ent_blend("runWS",25,45);
//animate the player
my.ANIMATION += 15 * time_step;
ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground
}
if((key_cuu == 1)&& my.STATE == 0)
{
my.ANIMATION = 0;
my.STATE = 1;
}
else if((!key_cuu)&& my.STATE == 1)
{
if(my.ANIMATION > 100)
{
ent_blend("idleSWA",5.5,50);
}
my.STATE = 0;
}