Double jump problem

Viper Snake

Member
I have character that performs a double jump by canceling the jump animation into a freespecial with a jumpframe by simply pressing jump again. This works perfectly for the normal jump animation, but when I try to put the same cancel into the forwardjump it will perform the cancel as soon as I press jump, not even having a chance to go into the forwardjump animation. I've tried making the cancel not possible until several frames later, but it will automatically perform the cancel if the jump button is still being held. How do I make it work like the normal jump animation? I thought maybe it was an engine bug since I'm forced to use an older version, but this still happens in the newest build.

Code:
anim	forwardjump
	cancel	0 15 0 J freespecial2
	dropframe	7
	bbox	4 0 30 96
	offset	20 96
	delay	5
	frame	data/chars/alucard/a085.png
	bbox	22 0 30 92
	offset	38 92
	frame	data/chars/alucard/a086.png
	delay	4
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	delay	6
	bbox	48 0 30 90
	offset	64 98
	frame	data/chars/alucard/a069.png
	bbox	48 0 30 86
	offset	64 98
	frame	data/chars/alucard/a070.png
	bbox	48 0 30 80
	frame	data/chars/alucard/a071.png
	bbox	48 0 30 78
	frame	data/chars/alucard/a072.png
	bbox	42 12 30 78
	offset	58 106
	frame	data/chars/alucard/a073.png
	bbox	42 14 30 78
	offset	58 110
	frame	data/chars/alucard/a074.png
	bbox	44 16 30 82
	offset	60 112
	frame	data/chars/alucard/a075.png
	bbox	52 30 30 84
	offset	68 124
	frame	data/chars/alucard/a076.png
	bbox	52 36 30 88
	offset	68 128
	frame	data/chars/alucard/a077.png

anim	freespecial2
	jumpframe	0 6 2 0
	dropframe	29
	bbox	4 0 30 96
	offset	42 194
	delay	3
	frame	data/chars/alucard/a081.png
	offset	42 112
	frame	data/chars/alucard/a082.png
	offset	52 92
	delay	2
	frame	data/chars/alucard/a083.png
	frame	data/chars/alucard/a084.png
	delay	4
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	bbox	34 0 30 86
	offset	50 88
	frame	data/chars/alucard/a088.png
	bbox	38 0 30 86
	offset	54 88
	frame	data/chars/alucard/a087.png
	delay	6
	bbox	48 0 30 90
	offset	64 98
	frame	data/chars/alucard/a069.png
	bbox	48 0 30 86
	offset	64 98
	frame	data/chars/alucard/a070.png
	bbox	48 0 30 80
	frame	data/chars/alucard/a071.png
	bbox	48 0 30 78
	frame	data/chars/alucard/a072.png
	bbox	42 12 30 78
	offset	58 106
	frame	data/chars/alucard/a073.png
	bbox	42 14 30 78
	offset	58 110
	frame	data/chars/alucard/a074.png
	bbox	44 16 30 82
	offset	60 112
	frame	data/chars/alucard/a075.png
	bbox	52 30 30 84
	offset	68 124
	frame	data/chars/alucard/a076.png
	bbox	52 36 30 88
	offset	68 128
	frame	data/chars/alucard/a077.png
 
O Ilusionista said:
have you tried to change the start frame, right?
cancel 5 15 0 J freespecial2
Yes, I have tried that. It does keep the cancel from happening immediately however if the jump button is still being held after the initial jump, it cancels into the double jump automatically and feels really awkward.

EDIT: I just tried setting the start frame to 7 instead and now it no longer automatically cancels when held. I don't understand why but it works!
 
ah, I think I got it: its because when you press jump, the engine detects it. But you (without notice) hold the button a little (its not a single press). Then, when you was on the cancel, it still triggers the last button, because you had hold it for a bit and the engine will the button status on the next tick/cicle.
 
O Ilusionista said:
ah, I think I got it: its because when you press jump, the engine detects it. But you (without notice) hold the button a little (its not a single press). Then, when you was on the cancel, it still triggers the last button, because you had hold it for a bit and the engine will the button status on the next tick/cicle.

Why doesn't that happen when the start frame is 0 on a normal jump with cancel then?
 
There's no need to use cancel for a second jump because the character cannot be moved with any direction you toggle and he keeps moving forward in air till land. I did use cancel before and the jump works for me, but like you said about cancel, I had a similar issue like that.

Here's an example of the character code from Unelmia maybe months ago, but it's currently on hold:

Code:
anim	jump
	bbox	13 14 20 63
	@script
		 if(frame==0)
			 setlocalvar("xdir",getentityproperty(getlocalvar("self"),"xdir"));
	@end_script	
	delay	3
	offset	23 76
	sound	data/sounds/jump2.wav
	loop	1 8 15
	landframe	15
	frame	data/chars/jj/jump03.png
	frame	data/chars/jj/jump04.png
	frame	data/chars/jj/jump05.png
	frame	data/chars/jj/jump06.png
	frame	data/chars/jj/jump07.png
	frame	data/chars/jj/jump08.png
	frame	data/chars/jj/jump09.png
	frame	data/chars/jj/jump10.png
	frame	data/chars/jj/jump11.png
	frame	data/chars/jj/jump12.png
	frame	data/chars/jj/jump13.png
	frame	data/chars/jj/jump14.png
	frame	data/chars/jj/jump15.png
	frame	data/chars/jj/jump16.png
	frame	data/chars/jj/jump17.png
	delay	2
	frame	data/chars/jj/jump18.png
	frame	data/chars/jj/jump19.png


anim	freespecial
	bbox	14 14 20 63
	@script
		 if(!frame){
			 void self=getlocalvar("self");
			 void xdir=getlocalvar("xdir");
			 tossentity(self, 3, xdir, 1);
		 }
	@end_script	
	delay	6
	offset	23 76
	sound	data/sounds/jump2.wav
	loop	1 8 15
	landframe	15
	frame	data/chars/jj/jump03.png
	frame	data/chars/jj/jump04.png
	frame	data/chars/jj/jump05.png
	frame	data/chars/jj/jump06.png
	frame	data/chars/jj/jump07.png
	frame	data/chars/jj/jump08.png
	frame	data/chars/jj/jump09.png
	frame	data/chars/jj/jump10.png
	frame	data/chars/jj/jump11.png
	frame	data/chars/jj/jump12.png
	frame	data/chars/jj/jump13.png
	frame	data/chars/jj/jump14.png
	frame	data/chars/jj/jump15.png
	frame	data/chars/jj/jump16.png
	frame	data/chars/jj/jump17.png
	delay	2
	frame	data/chars/jj/jump18.png
	frame	data/chars/jj/jump19.png

Here is the script code which shows the key for double jump, however, I can't attach a c file here:
void main()
{
    int iPlIndex = getlocalvar("player"); //Get calling player
    void vSelf = getplayerproperty(iPlIndex , "entity"); //Get calling entity
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame
    int iDir = getentityproperty(vSelf, "direction");  //Get current facing direction

    void iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    void iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    void iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    void iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    void iJump = playerkeys(iPlIndex, 1, "jump"); //New key status of "Jump"
    void iSpecial = playerkeys(iPlIndex, 1, "Special"); //New key status of "Special"
    void iAttack = playerkeys(iPlIndex, 1, "attack"); //New key status of "Attack"
    void iAttack2 = playerkeys(iPlIndex, 1, "attack2"); // New key of "Attack 2"
    void iAttack3 = playerkeys(iPlIndex, 1, "attack3"); // New key of "Attack 3"
    void iAttack4 = playerkeys(iPlIndex, 1, "attack4"); // New key of "Attack 4"

    void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    void iDownR = playerkeys(iPlIndex, 2, "movedown"); //Release status of "Down"
    void iAttackR = playerkeys(iPlIndex, 2, "attack"); //Release status of "Attack"

    void iUpH = playerkeys(iPlIndex, 0, "moveup");
    void iDownH = playerkeys(iPlIndex, 0, "movedown");
    void iLeftH = playerkeys(iPlIndex, 0, "moveleft");
    void iRightH = playerkeys(iPlIndex, 0, "moveright");

//Double jump
    if(vAniID == openborconstant("ANI_JUMP")){ //Jumping?
      if(iJump){ //Jump pressed?
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL"));
        if(iLeftH){ //Left held?
          changeentityproperty(vSelf, "direction", 0);
          tossentity(vSelf, 3, -1.5, 0);
        } else if(iRightH){ //Right held?
          changeentityproperty(vSelf, "direction", 1);
          tossentity(vSelf, 3, 1.5, 0);
        } else { //Nothing
          tossentity(vSelf, 3, 0, 0);
        }
      }
    }
}

The one highlighted in red, you can change the animation name to whatever animation you want to use for a second jump. Like anim forwardjump, for example. :)
 
maxman said:
There's no need to use cancel for a second jump because the character cannot be moved with any direction you toggle and he keeps moving forward in air till land.

I'm using jumpmove 3 0 on this character and can move left and right during the second jump without any problems.
 
Back
Top Bottom