Need help making an enemy target player during a dash and does a slam.

Joshiro

Member
I want to make an enemy use a dash that will target player and when close to player , does a slam.  Anybody know how to do this?
 
Yeah there is script for this, I've never tried to use it thou, you can probably check Crime Busters mod for examples.

Code:
void target(float Velx, float Velz, float dx, float dz, int Stop)
{// Targetting opponent before leaping or dashing.
// Velx = x Velocity
// Velz = z Velocity
// dx = x added distance
// dz = z added distance
// Stop = flag to stop moving if no target is found

    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(Tx < x){
        changeentityproperty(self, "direction", 0);
      } else {
        changeentityproperty(self, "direction", 1);
      }

      x = x+dx;
      z = z+dz;
      float Disx = Tx - x;
      float Disz = Tz - z;

//Set both distance as positive value
      if(Disx < 0){
        Disx = -Disx;
      }

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

// Calculate velocity for targetting
      if(Disz < Disx)
      {
        if(Tx < x){
          setlocalvar("x"+self, -Velx);
        } else { setlocalvar("x"+self, Velx); }

        setlocalvar("z"+self, Velx*(Tz-z)/Disx);
      } else {
        if(Tz < z){
          setlocalvar("z"+self, -Velz);
        } else { setlocalvar("z"+self, Velz); }

        setlocalvar("x"+self, Velz*(Tx-x)/Disz);
      }

    } else {
      if(Stop == 1)
      {
        setlocalvar("z"+self, 0);
        setlocalvar("x"+self, 0);
      } else {
        setlocalvar("z"+self, 0);
        if(dir==0){
          setlocalvar("x"+self, -Velx);
        } else { setlocalvar("x"+self, Velx); }
      }
    }
}

Code:
void targetL(float Vy, float dx, float dz)
{// 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(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);
    }
}


Code:
void grabcheck2()
{// Prevents enemy from performing the slam if he/she doesn't have any target
   void self = getlocalvar("self");
   void target = getlocalvar("Target" + self);

   if(target==NULL())
   {
     performattack(self, openborconstant("ANI_IDLE")); //Don't perform the slam.
   }
}
 
I may need to refresh my memories about this but from my memory, in Crime Buster v2.5, enemies who can dash toward player then perform slam are:
- Yamazaki (2nd stage boss)
- Ziza (subboss but appear as regular enemies later)
- Rover

There are other enemies doing slightly different move but ended with a slam
- Vice (boss) : jumps to player's head, if the move connects she slams him/her to ground
- Yuri : teleports to back of player then performs Izuna drop if she grabs a player
 
Thanks for the help guys. I just got it to work. The only problem I have , since it has an attackbox, it attacks the player in air. It doesn't lead into the slam but it knocks the player out of air. Is their some kind of script that makes this not hit the player in air? 

Also, I was wondering, how to make a script that counts how many times an attack happens ? I would like to make it so that when the enemy does this attack a few times, it gets dizzy after doing it again. Then it resets. 
 
since it has an attackbox, it attacks the player in air. It doesn't lead into the slam but it knocks the player out of air. Is their some kind of script that makes this not hit the player in air? 

Strange, I just checked it and there's no function which could prevent enemy from grabbing player in mid air IOW the slam should work against jumping player
I could modify grabcheck function to prevent enemy from grabbing player in mid air but why would you need that?

how to make a script that counts how many times an attack happens ? I would like to make it so that when the enemy does this attack a few times, it gets dizzy after doing it again. Then it resets.

I could think of couple script to do that but why not give MP to enemy? then add mpcost in enemy's attack and a script to change to dizzy animation if MP is not enough?
You can give mp regeneration ability to the enemy or just resets enemy's MP in dizzy animation
 
Strange, I just checked it and there's no function which could prevent enemy from grabbing player in mid air IOW the slam should work against jumping player
I could modify grabcheck function to prevent enemy from grabbing player in mid air but why would you need that?

The way I set up the dash slam is with an attack box that goes into a follow animation that does the slam. When it hits a player in mid air, it knocks the player out of the air. I wanted the player to be able to react to the enemy's dash and be able to do a jump attack. The grab isn't the problem, it's the attackbox. I guess it's fine as is, or I'll just have the enemy slam the player in mid air.

I could think of couple script to do that but why not give MP to enemy? then add mpcost in enemy's attack and a script to change to dizzy animation if MP is not enough?
You can give mp regeneration ability to the enemy or just resets enemy's MP in dizzy animation

Great idea! I didn't think about doing that. I would still like to have a script that could count an attack and change the attack based on amount of times used. For example, Damnd from Final Fight jumps to the side and  whistles for a set of enemies. The next time he does the move, he spawns a different set of enemies.

 
When it hits a player in mid air, it knocks the player out of the air. I wanted the player to be able to react to the enemy's dash and be able to do a jump attack

Oh I see. Just add noreflect 1 after the attackbox to prevent the knock down effect. It won't affect the script cause the script only needs to acquire the player enemy has grabbed not the knockdown status

For example, Damnd from Final Fight jumps to the side and  whistles for a set of enemies. The next time he does the move, he spawns a different set of enemies.

AFAIK Damnd calls enemies based on his current health i.e when his health is more than half, he summons 2 weak thugs (Bred, Simons or Dug, I forgot) but when his health is lesser than half, he summons Poison and Hollywood. I don't think he ever calls more than twice
Regardless, it's doable with script
 
Oh I see. Just add noreflect 1 after the attackbox to prevent the knock down effect. It won't affect the script cause the script only needs to acquire the player enemy has grabbed not the knockdown status

Thanks. I'll try it.

AFAIK Damnd calls enemies based on his current health i.e when his health is more than half, he summons 2 weak thugs (Bred, Simons or Dug, I forgot) but when his health is lesser than half, he summons Poison and Hollywood. I don't think he ever calls more than twice
Regardless, it's doable with script

Oh I see. That isn't what I wanted to do.  So any ideas on how I would do t?
 
So any ideas on how I would do t?

Here's how to do it with script:

anim attack2
@script
    if(frame==0){
      void self = getlocalvar("self");
      int Count = getentityvar(self, 1);

      if(Count > 2){
        setentityvar(self, 1, 0);
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW2"));
      }
    }
    if(frame==10){
      void self = getlocalvar("self");
      int Count = getentityvar(self, 1);

      if(Count==NULL()){
        Count = 0;
      }

      setentityvar(self, 1, Count+1);
    }
@end_script ...

In this script, at 11th frame, counter (stored in entity variable 1) is incremented. After it reaches 3, the attack will be cancelled and enemy performs FOLLOW2 instead; at same time the counter is resetted

I chose the counter to increment at 11th frame to ensure the attack has been performed before incrementing. You can change the value for your need :)
 
Back
Top Bottom