void keyRange(int RxMin, int RxMax, int Rz, void Ani, int Frame, void Key, int Hflag, int Limit){
// Exclusive for Zangief and any fighter with no close-range attack animations
// This script is based on both keyint and attack1 scripts; both key and range
void self = getlocalvar("self");
void target = findtarget(self);
int Health = getentityproperty(self, "health");
int Dir = getentityproperty(self, "direction");
int iPIndex = getentityproperty(self, "playerindex");
int iRKey;
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
int key_hold = getplayerproperty(iPIndex, "keys");
int key_press = getplayerproperty(iPIndex, "newkeys");
if(target != NULL() ){
float Tx = getentityproperty(target, "x");
float Tz = getentityproperty(target, "z");
float Disx = Tx - x;
float Disz = Tz - z;
if(Disz < 0){
Disz = -Disz;
}
if (Key=="U"){ //Up Required?
iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
} else if (Key=="D"){ //Down Required?
iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
} else if (Key=="L"){ //Left Required?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else if (Key=="R"){ //Right Required?
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
} else if (Key=="F"){ //Forward Required?
if (Dir == 0){ // Facing Left?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else { // Facing Right
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
}
} else if (Key=="B"){ //Backward Required?
if (Dir == 1){ // Facing Right?
iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
} else { // Facing Left
iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
}
} else if (Key=="A"){ //Attack Required?
iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
} else if (Key== "FA3"){ //Forward and Attack3 Required?
if(Dir == 1){
iRKey = playerkeys(iPIndex, 0, "moveright", "attack3"); // "Right" + "Attack3"
}else if(Dir == 0){
iRKey = playerkeys(iPIndex, 0, "moveleft", "attack3"); // "Left" + "Attack3"
}
} else if (Key== "BA3"){ //Back and Attack3 Required?
if(Dir == 1){ // Face left
iRKey = playerkeys(iPIndex, 0, "moveleft", "attack3"); // "Left" + "Attack3"
}else if(Dir == 0){
iRKey = playerkeys(iPIndex, 0, "moveright", "attack3"); // "Right" + "Attack3"
}
} else if (Key== "FA4"){ //Forward and Attack4 Required?
if(Dir == 1){ // Face right
iRKey = playerkeys(iPIndex, 0, "moveright", "attack4"); // "Right" + "Attack4"
}else{
iRKey = playerkeys(iPIndex, 0, "moveleft", "attack4"); // "Left" + "Attack4"
}
} else if (Key== "BA4"){ //Back and Attack4 Required?
if(Dir == 0){
iRKey = playerkeys(iPIndex, 0, "moveright", "attack4"); // "Right" + "Attack4"
}else{
iRKey = playerkeys(iPIndex, 0, "moveleft", "attack4"); // "Left" + "Attack4"
}
}
if (Hflag==1){ //Not holding the button case?
iRKey = !iRKey; //Take the opposite condition
}
//if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && Dir == 1) // Target within range on right facing?
//{
// performattack(self, openborconstant(Ani)); //Change the animation
//} else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && Dir == 0) // Target within range on left facing?
//{
//performattack(self, openborconstant(Ani)); //Change the animation
//}
if(
( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && Dir == 1)
|| ( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && Dir == 0)
&& (Health > Limit)
&& iRKey
)
{
if (Ani=="ANI_IDLE"){ // Going idle?
setidle(self, openborconstant("ANI_IDLE")); //Be idle!
} else {
//changeentityproperty(self, "animation", openborconstant(Ani),2);
performattack(self, openborconstant(Ani));
}
changeentityproperty(self, "animpos", Frame); //Change frame
}
}
}