Solved Checking opponent's animation when dealing with multiple opponents

Question that is answered or resolved.

mersox

Active member
Hi all. I'm having trouble scripting an attack. Basically, it's a basic attack that, at the start, checks the enemy's playing animation. If the enemy is currently in "FOLLOW4" (stunned animation), the player's attack switches to a different move (uppercut).

The script works when dealing with only one enemy. But then the player is attacking multiple enemies at the same time, the uppercut is never triggered. I suspect it's because the script doesn't know which entity to consider the "opp" and thus doesn't return any variable when checking (or something along those lines).

Here's the script:

anim attack2
@script
    void self = getlocalvar("self");
void opp = getentityproperty(self,"opponent");
void animID = getentityproperty(opp, "animationid");


if ((frame == 0 ) && (animID == openborconstant("ANI_FOLLOW4")) )
{

changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
}
@end_script
loop 0
delay 5
offset 63 112
bbox 53 71 21 41
delay 10

frame data/chars/player/punch3.png
        attack  55 75 30 16 2 0 0 0 15
frame data/chars/player/punch4.png
        attack  0 0 0 0
frame data/chars/player/punch3.png
 
Hi Merso X :)

Judging from your description, it's similar to Double Dragon, in which Billy and Jimmy performs different animation if they are facing enemy in stunned or dizzied state.
You should use this script for that purpose:
Code:
void finisher(void AniP, void Ani , int RxMin, int RxMax, int Ry, int Rz, int Type, int Flag)
{// Checks closest enemy's animation & range
// If it's accepted, change animation
// AniP  : Enemy's animation
// Ani   : Animation to change to
// RxMin : Minimum x range
// RxMax : Maximum x range
// Ry    : y range
// Rz    : z range
// Type  : 0 = non targetted , 1 = for targetting, 2 = for grabbing
// Flag  : 0 = facing direction not necessary , 1 = facing direction must be opposite

/*Originally smartbomb by
    Damon Vaughn Caskey
    07152008*/

    void self = getlocalvar("self");			//Caller.
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    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.

     //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 Ty = getentityproperty(vEntity, "a");
	float Tz = getentityproperty(vEntity, "z");
        int Anti = getentityproperty(vEntity, "antigrab");
        int Edir = getentityproperty(vEntity, "direction");
	void EAnim = getentityproperty(vEntity, "animationID");

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

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

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

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && Disy <= Ry && dir == 1 ) // Target within range on right facing?
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 0) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 0) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && Disy <= Ry && dir == 0) // Target within range on left facing?
      {
        if(Type == 2){
          if(((Flag == 1 && Edir == 1) || Flag == 0) && Anti < 10){
            dasher(0,0,0);
            setlocalvar("Target" + self, vEntity);
            performattack(self, openborconstant(Ani));
          }
        } else {
          if((Flag == 1 && Edir == 1) || Flag == 0){
            if(Type == 1){
              dasher(0,0,0);
              setlocalvar("Target" + self, vEntity);
            }
            performattack(self, openborconstant(Ani));
          }
        }
      }
        }
      }
    }
}

Usage example:
Code:
anim	attack1 # Kick
	delay	6
	offset	68 131
	bbox	61 76 20 56
	@cmd	finisher "ANI_PAIN3" "ANI_ATTACK2" 0 30 25 15 0 1
	@cmd	finisher "ANI_PAIN13" "ANI_ATTACK2" 0 30 25 15 0 1
	frame	data/chars/billy/kick1.png
	frame	data/chars/billy/kick1.png
	delay	20
	hitfx	data/sounds/kick.wav
	attack13	82 67 15 35 12 0 0 0 0 0
	frame	data/chars/billy/kick2.png
	delay	12
	attack	0
	frame	data/chars/billy/kick3.png

In this example, Billy's atchain is 1 and ATTACK2 is a roundhouse kick.
 
Bloodbane said:
Hi Merso X :)

Judging from your description, it's similar to Double Dragon, in which Billy and Jimmy performs different animation if they are facing enemy in stunned or dizzied state.

Yes, exactly this, thank you so much Bloodbane! I'll give this a try
 
Back
Top Bottom