Bloodbane
Well-known member
If you know how to use animation script, you can use this function:
As the name implies, this function is for finding target and calculates velocity to leap there. However it also has autoface to target feature so you can use the function for that purpose
Example:
TargetL function will find opponent and if it finds any, it will flip facing direction toward the opponent. Since it's used for autofacing target, the first three parameters are useless and can be ignored
How often entity autofaces target depends on delay. The shorter delay, the more often entity autofaces
I said it's unstable cause there's no opponent check so if there were other enemy type entities (such as projectiles), player might autoface those instead of the real opponent
You can try this method and see if it's stable enough for your purpose
Code:
void targetL(float Vy, float dx, float dz, int Flip)
{// Targetting opponent before performing targetted leap attack
// Vy = y Velocity
// dx = x added distance
// dz = z added distance
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
if (dir == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
setlocalvar("T"+self, findtarget(self)); //Get nearest player
if( getlocalvar("T"+self) != NULL()){
void target = getlocalvar("T"+self);
float Tx = getentityproperty(target, "x");
float Tz = getentityproperty(target, "z");
if(Flip == 1){
if(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
}
x = x+dx;
z = z+dz;
setlocalvar("x"+self, (Tx-x)/(22*Vy));
setlocalvar("z"+self, (Tz-z)/(22*Vy));
} else {
setlocalvar("z"+self, 0);
setlocalvar("x"+self, 0);
}
setlocalvar("T"+self, NULL()); //Clears variable
}
As the name implies, this function is for finding target and calculates velocity to leap there. However it also has autoface to target feature so you can use the function for that purpose
Example:
Code:
anim idle
loop 1
delay 5
offset 36 42
bbox 24 1 21 42
@cmd targetL 3 0 0 1
frame data/chars/raphael/177.PNG
@cmd targetL 3 0 0 1
frame data/chars/raphael/178b.PNG
TargetL function will find opponent and if it finds any, it will flip facing direction toward the opponent. Since it's used for autofacing target, the first three parameters are useless and can be ignored
How often entity autofaces target depends on delay. The shorter delay, the more often entity autofaces
I said it's unstable cause there's no opponent check so if there were other enemy type entities (such as projectiles), player might autoface those instead of the real opponent
You can try this method and see if it's stable enough for your purpose