Have enemy target for dash attack

DJGameFreakTheIguana

Active member
Need help getting an enemy to target players and do a dash attack in the direction they're in, along with Z placement. Think of Big Ben's fire breathing or Glasia's knife charge attacks from the Streets of Rage games. I bought got this right using the target and leap @cmd's but even with nopain and nodrop, the enemy still falls if attacked in mid air, keeping in mind I set the leap to 1. It's a rolling attack actually. Here's the coding and what I tried last with the script.

Code:
	delay	2
	move 7
	bbox.position.x 75
	bbox.position.y 47
	bbox.size.x 41
	bbox.size.y 40
	attack.block.penetrate 0
	attack.damage.force 10
	attack.damage.type 2
	attack.effect.hit.flash.disable 0
	attack.position.x 75
	attack.position.y 47
	attack.reaction.fall.force 0
	attack.reaction.pause.time 0
	attack.size.x 41
	attack.size.y 40
	attack.size.z.1 20
        @cmd    target 1 0 1 0
       # @cmd    leap 0.1
	frame	data/chars/Golem2/A1-14.gif
        #@cmd    dash 1
	frame	data/chars/Golem2/A1-14.gif
	frame	data/chars/Golem2/A1-15.gif
	frame	data/chars/Golem2/A1-15.gif
	frame	data/chars/Golem2/A1-16.gif
	frame	data/chars/Golem2/A1-16.gif
	frame	data/chars/Golem2/A1-17.gif
	frame	data/chars/Golem2/A1-17.gif
	frame	data/chars/Golem2/A1-18.gif

x)
 
I'm not sure why you have move 7 there cause it can disrupt enemy's movement while dashing toward player

Anyways, here's an example from D&D Rise of Warduke
Code:
anim attack2
	range	100 200
	rangez	-25 25
	delay	1
	offset	180 190
	bbox	135 70 86 120
	frame	data/chars/demon2/idle1.png
	delay	40
	hitfx	data/sounds/Slash1.wav
	@cmd	target 3 1.5 0 0 0 1
	frame	data/chars/demon2/slash1.png
	delay	10
	bbox	174 68 60 122
	@cmd	dash 0 0
	frame	data/chars/demon2/slash2.png
	sound	data/sounds/DAttack.wav
	frame	data/chars/demon2/slash3.png
	bbox	170 96 75 95
	attack  230 103 103 37 30 1 0 0 30
	dropv	2 4 0
	frame	data/chars/demon2/slash4.png
	attack  18 132 313 33 30 1 0 0 30
	dropv	2 4 0
	frame	data/chars/demon2/slash5.png
	attack  0
	frame	data/chars/demon2/slash5.png
	delay	20
	@cmd	dasher 0 0 0
	bbox	135 70 86 120
	frame	data/chars/demon2/slash1.png

You should be able to learn from this :)

but even with nopain and nodrop, the enemy still falls if attacked in mid air

You'd needt o set nodrop 2 to prevent enemy from falling in mid air
 
Don't know if I'm missing something or not but the enemy doesn't move on the Z axis and just going left and right and changing the digits for the Y axis, since that's all that was there, didn't help. I'm also noticing that "1" at the end of the script but it's one more digit then the script says, is there a reason for it? Here's the code to.
Code:
        @cmd    target 3 1.5 0 0 0 1
	frame	data/chars/Golem2/A1-14.gif
	@cmd	dash 0 0
       # @cmd    dash 1
	frame	data/chars/Golem2/A1-14.gif
	frame	data/chars/Golem2/A1-15.gif
	frame	data/chars/Golem2/A1-15.gif
	frame	data/chars/Golem2/A1-16.gif
	frame	data/chars/Golem2/A1-16.gif
	frame	data/chars/Golem2/A1-17.gif
	frame	data/chars/Golem2/A1-17.gif
	frame	data/chars/Golem2/A1-18.gif
	frame	data/chars/Golem2/A1-18.gif
	frame	data/chars/Golem2/A1-19.gif
	frame	data/chars/Golem2/A1-19.gif
	frame	data/chars/Golem2/A1-20.gif
	frame	data/chars/Golem2/A1-20.gif
	frame	data/chars/Golem2/A1-21.gif
	frame	data/chars/Golem2/A1-21.gif
	frame	data/chars/Golem2/A1-22.gif
	frame	data/chars/Golem2/A1-22.gif
	frame	data/chars/Golem2/A1-23.gif
	frame	data/chars/Golem2/A1-23.gif
	frame	data/chars/Golem2/A1-24.gif
	frame	data/chars/Golem2/A1-24.gif
	frame	data/chars/Golem2/A1-25.gif
	frame	data/chars/Golem2/A1-25.gif
	delay	8
	#move 2
	#@cmd	dash 0 0
	bbox.position.x 70
	bbox.position.y 60
	bbox.size.x 49
	bbox.size.y 27
	@cmd	dasher 0 0 0
	frame	data/chars/Golem2/A1-9.gif
	frame	data/chars/Golem2/A1-10.gif
	frame	data/chars/Golem2/A1-11.gif

You'd needt o set nodrop 2 to prevent enemy from falling in mid air
Thanks for that, another enemy I have planned only moves by jumping around and I didn't want him taking pain either, so this helps.  ;D

x)
 
That's strange, dash function is the on moving entities. It should move entity in z axis too

BTW here's dash function:
Code:
void dash(int X, int Z)
{// Dash with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    float Vz = getlocalvar("z"+self);

    if( X==1 ){
      Vz = 0;
    } else if( Z==1 ){
      Vx = 0;
    }

    changeentityproperty(self, "velocity", Vx, Vz); //Move towards target!
}

The 2 parameters controls if you want entity to move in just one axis, X or Z
 
Seems like your function is different from what I had.
Code:
void dash()
{// Dash with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    float Vy = getlocalvar("y"+self);
    if( Vx!=NULL() && Vy!=NULL() ){
      changeentityproperty(self, "velocity", Vx, 0, Vy); //Move towards target!
    }
}

I pasted your's over this in my Escript but I got the same result, no movement on Z axis, even after setting both digits from 0 to 1.

X)
 
Oh, that former dash function you had was for 2D movement. I'm sure the related target functions are for 2D movement as well.

The one for 3D movement is this function:
Code:
void target(float Velx, float Velz, float dx, float dz, int Stop, int Flip)
{// 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(Flip == 1){
        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); }
      }
    }

    setlocalvar("T"+self, NULL()); //Clears variable
}

If your target function is not like this, then change it with that
 
Ok Blood, we got it working now. Like with the dash scritp, I had an older version of the target script to.
Code:
void target(float Velx, float Vely, float dx, float dy, int Stop)
{// Targetting opponent before leaping or dashing.
// Velx = x Velocity
// Vely = y Velocity
// dx = x added distance
// dy = y added distance
// Stop = flag to stop moving if no target is found

    void self = getlocalvar("self");

    setlocalvar("T"+self, findtarget(self)); //Get nearest player

    void target = getlocalvar("T"+self);
    setlocalvar("x"+self, target1(target, Velx, Vely, dx, dy, Stop, "x") );
    setlocalvar("y"+self, target1(target, Velx, Vely, dx, dy, Stop, "y") );
    setlocalvar("T"+self, NULL()); //Clears variable
}

Thanks man.
X)
 
Back
Top Bottom