Solved Run attack targeting

Question that is answered or resolved.

Daniel99j

Member
Hello guys,

I trying to make an enemy with run attack like a Bill Bull on Final Fight, but I dont have an idea how to make him targeting Player on Y axis (up and down) while this animation. Did you have any idea how to make this possible?

Thanks
 
Solution
Bill Bull and Wong Who are the fat guys that charge you,
ah, those guys, sorry.

@Daniel99j you will need some scripts. Add this on your animationscript file:

C-like:
void target(float Velx, float Velz)
{// Targetting opponent before leaping or dashing
    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction"); // Get enemy's facing direction
    float x = getentityproperty(self, "x"); // Get enemy's x coordinate
    float z = getentityproperty(self, "z"); // Get enemy's z coordinate

    setlocalvar("T"+self, findtarget(self)); // Find target and put it in local variable

    if( getlocalvar("T"+self) != NULL()){ // Is there a target?
      void target = getlocalvar("T"+self);
      float Tx =...
ah, that move where the boss jump high for a while and land over the player head?
its doable, there are some ways to do depending on how you wanjt the move to be.
Will it be an instantly teleport? or will it chase the player for a while then drop?
 
ah, that move where the boss jump high for a while and land over the player head?
its doable, there are some ways to do depending on how you wanjt the move to be.
Will it be an instantly teleport? or will it chase the player for a while then drop?
@O Ilusionista,

Bill Bull and Wong Who are the fat guys that charge you, sometimes from off screen @Daniel99j, there are a couple of ways you could do this depending on how sophisticated you wanted to make it. Do you want them to perfectly calculate the angle? Do you want them to guide themselves AFTER they star running (Like Sodom does to an extent) or just rush in a predetermined line exactly like the Bill Bulls?

There's also the really super lazy method of just making them bikers, but I'm going to assume you want something more more polished than that.

DC
 
Bill Bull and Wong Who are the fat guys that charge you,
ah, those guys, sorry.

@Daniel99j you will need some scripts. Add this on your animationscript file:

C-like:
void target(float Velx, float Velz)
{// Targetting opponent before leaping or dashing
    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction"); // Get enemy's facing direction
    float x = getentityproperty(self, "x"); // Get enemy's x coordinate
    float z = getentityproperty(self, "z"); // Get enemy's z coordinate

    setlocalvar("T"+self, findtarget(self)); // Find target and put it in local variable

    if( getlocalvar("T"+self) != NULL()){ // Is there a target?
      void target = getlocalvar("T"+self);
      float Tx = getentityproperty(target, "x"); // Get target's x coordinate
      float Tz = getentityproperty(target, "z"); // Get target's z coordinate
      float Disx = Tx - x; // Get x distance
      float Disz = Tz - z; // Get z distance

      if(Disx < 0){ // Negative Disx?
        Disx = -Disx; // Turn it to positive
        changeentityproperty(self, "direction", 0); // Face left
      } else {
        changeentityproperty(self, "direction", 1); // Face right
      }

      if(Disz < 0){ // Negative Disz?
        Disz = -Disz; // Turn it to positive
      }

      if(Disz < Disx) // Disx bigger than Disz?
      {
        if(Tx < x){ // Player is behind enemy?
          setlocalvar("x"+self, -Velx); // Turn Vx to negative
        } else { setlocalvar("x"+self, Velx); } // Use defined Vx

        setlocalvar("z"+self, Velx*(Tz-z)/Disx); // Calculate Vz then store value in local variable
      } else { // Disz bigger than Disx!
        if(Tz < z){ // Player is behind enemy?
          setlocalvar("z"+self, -Velz); // Turn Vz to negative
        } else { setlocalvar("z"+self, Velz); } // Use defined Vz

        setlocalvar("x"+self, Velz*(Tx-x)/Disz); // Calculate Vx then store value in local variable
      }

    } else { // No target at all!
      setlocalvar("z"+self, 0); // 0 velocity
      if(dir==0){ // Facing left?
        setlocalvar("x"+self, -Velx); // Negative velocity
      } else { setlocalvar("x"+self, Velx); } // Positive velocity
    }
}

void dash()
{// Dash with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self); // Attain x velocity
    float Vz = getlocalvar("z"+self); // Attain z velocity
    if( Vx!=NULL() && Vz!=NULL() ){ // Are both velocity available?
      changeentityproperty(self, "velocity", Vx, Vz); //Move with previous speed
    }
}

void leap(float Vely)
{// Leap with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    float Vz = getlocalvar("z"+self);
    if( Vx!=NULL() && Vz!=NULL() ){
      tossentity(self, Vely, Vx, Vz); //Leap towards target!
    }
}

- target() is used to store the valid target position and calculate the desired speed
usage:
@cmd target 2 2

- dash() is used to make the attacker to dash using the previously attained speed. takes no arguments
usage:
@cmd dash

- leap() is used when you want to do the same thing, but the attack will jump toward the target instead of dashing.
usage:
@cmd leap 2

See it in action at 4:14, it's how Balrog attacks his targets while jumping

edit: Don Drago has a version where you can control the final speed too, so they will jump fast but will reach at the point with the desired velocity
 
Solution
Back
Top Bottom