void frameVel()
{//Update frame with velocity check
void self = getlocalvar("self");
void anim = getentityproperty(self, "animationID");
if(anim == openborconstant("ANI_IDLE")){
float max = 0.6;
float min = 0.3;
int dir = getentityproperty(self, "direction");
int xVel = getentityproperty(self, "xdir");
int zVel = getentityproperty(self, "zdir");
int frame = getentityproperty(self, "animpos");
int frameBlock1 = (frame >= 0 && frame <= 3); //ENTIRE FRAME BLOCK INTERVAL
int frameLoop1 = 2; //FRAME NUMBER USED BY THE LOOPER
int frameBlock2 = (frame >= 4 && frame <= 7);
int frameLoop2 = 6;
int frameBlock3 = (frame >= 8 && frame <= 11);
int frameLoop3 = 10;
int frameBlock4 = (frame >= 12 && frame <= 15);
int frameLoop4 = 14;
int frameBlock5 = (frame >= 16 && frame <= 19);
int frameLoop5 = 18;
int rightDirection = (xVel > max && dir == 1);
int leftDirection = (xVel < -max && dir == 0);
int upDirection = (xVel < min && xVel > -min) && (zVel < 0);
int downDirection = (xVel < min && xVel > -min) && (zVel > 0);
int diagonalRightUp = (xVel <= max && xVel >= min && dir == 1) && (zVel < 0);
int diagonalRightDown = (xVel <= max && xVel >= min && dir == 1) && (zVel > 0);
int diagonalLeftUp = (xVel >= -max && xVel <= -min && dir == 0) && (zVel < 0);
int diagonalLeftDown = (xVel >= -max && xVel <= -min && dir == 0) && (zVel > 0);
//RIGHT DIRECTION
if(rightDirection && !frameBlock1){
updateframe(self, frameLoop1);
}else
//LEFT DIRECTION
if(leftDirection && !frameBlock1){
updateframe(self, frameLoop1);
}else
//DOWN DIRECTION
if(downDirection && !frameBlock4){
updateframe(self, frameLoop4);
}else
//UP DIRECTION
if(upDirection && !frameBlock5){
updateframe(self, frameLoop5);
}else
//DIAGONAL RIGHT DOWN DIRECTION
if(diagonalRightDown && !frameBlock2){
updateframe(self, frameLoop2);
}else
//DIAGONAL RIGHT UP DIRECTION
if(diagonalRightUp && !frameBlock3){
updateframe(self, frameLoop3);
}else
//DIAGONAL LEFT DOWN DIRECTION
if(diagonalLeftDown && !frameBlock2){
updateframe(self, frameLoop2);
}else
//DIAGONAL LEFT UP DIRECTION
if(diagonalLeftUp && !frameBlock3){
updateframe(self, frameLoop3);
}
}
}