wrenchman82
Member
Hi All,
I have an enemy boss that has a move where it teleports to the player and executes a custom grab sequence (I have that aspect of it running). I would however like the player to be able to evade by running or jumping out of the way, and so I put together a script aiming to calculate the distance between player and boss once the boss has teleported, with the aim the change the animation if the player is too far. I have the following, which really should work, but it crashes. Hoping someone will see a bug I don't.
@script
void self = getlocalvar("self");
void trgt = findtarget(self);
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Tx = getentityproperty(trgt, "x");
int Tz = getentityproperty(trgt, "z");
float Disx = Tx - x;
float Disz = Tz - z;
if(Disz < 0){
Disz = -Disz;
}
if(Disx < 0){
Disx = -Disx;
}
int RxMin = 8;
int RzMin = 3;
if(frame==37){
if( Disx >= RxMin || Disz >= RzMin ){
performattack(self, openborconstant("ANI_Freespecial5"));
}
}
@end_script
int RxMin and int RzMin are arbitrary distances. Exceeding them should switch the boss into a different animation, namely, a teleport away.
I have an enemy boss that has a move where it teleports to the player and executes a custom grab sequence (I have that aspect of it running). I would however like the player to be able to evade by running or jumping out of the way, and so I put together a script aiming to calculate the distance between player and boss once the boss has teleported, with the aim the change the animation if the player is too far. I have the following, which really should work, but it crashes. Hoping someone will see a bug I don't.
@script
void self = getlocalvar("self");
void trgt = findtarget(self);
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Tx = getentityproperty(trgt, "x");
int Tz = getentityproperty(trgt, "z");
float Disx = Tx - x;
float Disz = Tz - z;
if(Disz < 0){
Disz = -Disz;
}
if(Disx < 0){
Disx = -Disx;
}
int RxMin = 8;
int RzMin = 3;
if(frame==37){
if( Disx >= RxMin || Disz >= RzMin ){
performattack(self, openborconstant("ANI_Freespecial5"));
}
}
@end_script
int RxMin and int RzMin are arbitrary distances. Exceeding them should switch the boss into a different animation, namely, a teleport away.