Solved Animation Check to avoid fake Fatality

Question that is answered or resolved.

dantedevil

Well-known member
After testing the game a lot, I found that on some occasions when there are many enemies together in a small space, our hero executes the fatality and continues with the corresponding animation, but the enemy does not. :confused:

So I decided that the best thing would be to create a script that checks if the enemy is at a specific distance and with a specific animation, if everything is true, the animation continues, if it is not true, it returns to IDLE. :D

I know my script is not right obviously. :cautious:
But before asking for help, I made several attempts and it's the best I could come up with. :unsure:

C++:
void fatAniCheck(int RxMin, int RxMax, int Rz)
{// Dantedevil
// Check if enemy start plays Fatality
// Rx = x distance to find type
// Rz = z distance to find type
    void vself = getlocalvar("self");
    float x = getentityproperty(vself, "x");
    float z = getentityproperty(vself, "z");
    int dir = getentityproperty(self, "direction");

    void vEntity;                                       //Target entity placeholder.
    void vAniID;
    int  iEntity;                                       //Entity enumeration holder.
    int  iType;                                         //Entity name.
    int  iMax      = openborvariant("ent_max");         //Entity count.
    int TDir; float Tx; float Tz; float Disx; float Disz;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iType   = getentityproperty(vEntity, "type"); //Get target name
      vAniID  = getentityproperty(vEntity,"animationID");

      if(iType == openborconstant("TYPE_ENEMY")){
        if(vAniID == openborconstant("ANI_DIE23")){
          Tx = getentityproperty(vEntity, "x");
          Tz = getentityproperty(vEntity, "z");
          TDir = getentityproperty(vEntity, "direction");
          Disx = Tx - x;
          Disz = Tz - z;

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1) // Target within range on right facing?
        return;
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
        setidle(self, openborconstant("ANI_IDLE"));
          }
        }
      }
    }
}


However, I couldn't get it formulated as I wanted, since my main idea was to include the animation check in the script header, but I couldn't achieve it.


My idea would be that the final result would be this: 👇

@cmd fatAniCheck 0 80 4 "ANI_DIE23"

This way you can use the same script for all the different fatalities in the game. :giggle:
 
Last edited:
Solution
I have done trial and error and came with this:
C:
void fatAniCheck(int RxMin, int RxMax, int Rz, void AniP)
{// Finds any enemy with specified animation within defined range
// If at least one is found, do nothing but if none were found, return to IDLE
// RxMin : Minimum x range
// RxMax : Maximum x range
// Rz    : z range
// AniP  : Enemy's animation

/*Originally smartbomb by
    Damon Vaughn Caskey
    07152008*/

    void self = getlocalvar("self");            //Caller.
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");
    void vEntity;                                       //Target entity placeholder.
    int  iEntity...
I have done trial and error and came with this:
C:
void fatAniCheck(int RxMin, int RxMax, int Rz, void AniP)
{// Finds any enemy with specified animation within defined range
// If at least one is found, do nothing but if none were found, return to IDLE
// RxMin : Minimum x range
// RxMax : Maximum x range
// Rz    : z range
// AniP  : Enemy's animation

/*Originally smartbomb by
    Damon Vaughn Caskey
    07152008*/

    void self = getlocalvar("self");            //Caller.
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iType;                                         //Entity type.
    int  iMax      = openborvariant("count_entities");  //Entity count.
    int C = 0;

     //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iType   = getentityproperty(vEntity, "type"); //Get target type.

      //Enemy type?
      if(iType == openborconstant("TYPE_ENEMY")){
        float Tx = getentityproperty(vEntity, "x");
    float Tz = getentityproperty(vEntity, "z");
    void EAnim = getentityproperty(vEntity, "animationID");

        if(EAnim == openborconstant(AniP)){
          float Disx = Tx - x;
          float Disz = Tz - z;

          if(Disz < 0){
            Disz = -Disz;
          }

      if(Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1){ // Target within range on right facing?
        C = C + 1;
      } else if(Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0){ // Target within range on left facing?
        C = C + 1;
      }
        }
      }
    }
    if(C == 0){
      setidle(self, openborconstant("ANI_IDLE"));
    }
}

I've tested this myself and it works to stop player from resuming current animation if enemy with specified animation isn't found within defined range.
 
Solution
Back
Top Bottom