Dash's weird problem [SOLVED]

Steve Craft

Member
some days ago i made a dash script while it's working good and all i have one problem that i couldn't solve it at all,how do i make the key that i assigned for dash(which for testing is attack2) to dash without needing to press again,my problem is that the dash velocity only happen if i press attack2 twice instead of only holding one time like on Mega Man X's dash.
i already passed 2 hours that day trying to understand why it's having this problem and i still haven't found a way to solve it

Code:
 void main()
{
int Player = getlocalvar("player");
       void Self = getplayerproperty(Player, "entity");
       int Direction = getentityproperty(Self, "direction");
       void Animation = getentityproperty(Self, "animationID");
       void frame = getentityproperty(Self, "animpos");
       void PLeft = playerkeys(Player,1,"moveleft");
       void PRight = playerkeys(Player,1,"moveright");
       void NotPLeft = playerkeys(Player,2,"moveleft");
       void NotPRight = playerkeys(Player,2,"moveright");
       void NeverPLeft = playerkeys(Player,0,"moveleft");
       void NeverPRight = playerkeys(Player,0,"moveright");
       void PSpecial = playerkeys(Player,1,"Special");
       void NotPSpecial = playerkeys(Player,2,"Special");
       void PAttack = playerkeys(Player,1,"attack");
       void Pattack2 = playerkeys(Player,1,"attack2");
       void Pattack3 = playerkeys(Player,1,"attack3");
       void Pattack4 = playerkeys(Player,1,"attack4");
       void NotPAttack = playerkeys(Player,2,"attack");
       void NotPAttack2 = playerkeys(Player,2,"attack2");
       void NotPAttack3 = playerkeys(Player,2,"attack3");
       void NotPAttack4 = playerkeys(Player,2,"attack4");
       
      if(Animation == openborconstant("ANI_JUMP") ){ //Moving in the Air
       if(NotPLeft || NotPRight){
         if(NeverPLeft || NeverPRight){
	   changeentityproperty(Self, "velocity", 0);
	   }
	   } else if(PLeft){
	     changeentityproperty(Self, "velocity", -1);
	     changeplayerproperty(Self, "playkeys", 0);
           } else if(PRight){
	     changeentityproperty(Self, "velocity", 1);
	     changeplayerproperty(Self, "playkeys", 0);
	     }
	   }
     if(Pattack2){
     performattack(Self, openborconstant("ANI_FREESPECIAL")); //Dash in ground
   }
      if(frame == 1 && Direction != 0){
        changeentityproperty(Self, "velocity", 1.5);
        changeplayerproperty(Self, "playkeys", 0);
      }
      if(frame == 1 && Direction != 1){
        changeentityproperty(Self, "velocity", -1.5);
        changeplayerproperty(Self, "playkeys", 0);
      }
      if(frame == 2){
        changeentityproperty(Self, "velocity", 0);
      }
      if(frame == 1 && NotPAttack2){
      updateframe(Self, 2);
      changeentityproperty(Self, "velocity", 0);
    }
    }                                             
that's my script,just know that i already tried other ways so "If(Pattack2) and performattack" was my last try,i already tried by using "com A2 freespecial" too
but the problem of having to press attack2 twice still exist,just explaining,my problem isn't speed or something,it's only having to press attack2 twice that is my issue
 
Thanks for the help,me and my brother have managed to solve it by using Dasher and letting key script work only by checking if attack2 was released or not
Code:
 if(Animation == openborconstant("ANI_FREESPECIAL") ){ //Dash in ground
      if(frame == 1 && NotPAttack2 || frame == 0 && NotPAttack2){
      updateframe(Self, 2);
      changeentityproperty(Self, "velocity", 0);
    }
    } 
}                                             

now it's like this,still thanks for the help danno
 
Well steve, after examining xjump.c, I can conclude that the cause of the weird problem you have is the weird keyscript you have there  ::).

In xjump.c , part to change animation and part to apply velocity are seperated. Because of that, you have to press twice to get the dashing effect; the first press to change animation and the second one to apply velocity.

You should've run change animation and velocity application in one part.
Here's example from Jonathan Morris' keyscript:
Code:
//Double jump
    if(vAniID == openborconstant("ANI_JUMP") ){ //Jumping?
      if(iJump){ //Left pressed?
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL"));
        if(iLeftH){ //Left held?
          changeentityproperty(vSelf, "direction", 0);
          tossentity(vSelf, 3, -1, 0);
        } else if(iRightH){ //Right held?
          changeentityproperty(vSelf, "direction", 1);
          tossentity(vSelf, 3, 1, 0);
        } else { //Nothing
          tossentity(vSelf, 3, 0, 0);
        }
      }
    }

In this script part, when he performs double jump, the script changes animation and also applies velocity (using tossentity) at the same time.
If you want test this script, download Castlevania Collab.
Hmmm... haven't I shared that to you before?  ::)

The other alternative is to set velocity in FREESPECIAL animation. That's also simple and easy to do.
 
I tried following Morris's keyscript and now i have another problem,it don't stop dashing until the animation end
Code:
 if(Animation == openborconstant("ANI_IDLE")){
     if(PAttack2 && Direction != 0){
        performattack(Self, openborconstant("ANI_FREESPECIAL"), 0);//Dash in ground
        changeentityproperty(Self, "velocity", 1.3);
      }
      if(NotPAttack2){
      updateframe(Self, 2);
      changeentityproperty(Self, "velocity", 0);
    }
   } 
}
What i'm doing wrong that it's not updating on frame 2 when i stop pressing attack2?
 
it don't stop dashing until the animation end

I thought that's how all dash animations should be  :). But after testing X's aerial dash from Megaman X3, I see what you mean  ::).

it's not updating on frame 2 when i stop pressing attack2?

Cause the script is only run in IDLE animation.
if(Animation == openborconstant("ANI_IDLE")){
    if(PAttack2 && Direction != 0){
        performattack(Self, openborconstant("ANI_FREESPECIAL"), 0);//Dash in ground
        changeentityproperty(Self, "velocity", 1.3);
      }
      if(NotPAttack2){
      updateframe(Self, 2);
      changeentityproperty(Self, "velocity", 0);
    }
  }
}

If you want to stop in FREESPECIAL animation, you should add a line to check if it's in that animation like this:
Code:
   if(Animation == openborconstant("ANI_IDLE")){
     if(PAttack2 && Direction != 0){
        performattack(Self, openborconstant("ANI_FREESPECIAL"), 0);//Dash in ground
        changeentityproperty(Self, "velocity", 1.3);
      }
   }

   if(Animation == openborconstant("ANI_FREESPECIAL")){
     if(NotPAttack2){
       changeentityproperty(Self, "velocity", 0);
       updateframe(Self, 2);
     }
   }
 
Back
Top Bottom