[SCRIPT] Wall Jump without animationscript

O Ilusionista

Captain 100K
Wall Jump without animationscript
Author: O Ilusionista
Version: V2 - 2019.01.26
Thanks: Bloodbane and Damon Caskey.

I've made an alternative way to use Wall Jump. Following a tip by DC, I decided to use another way to make this. OpenBOR already does a great job detecting when you are blocked by walls, platform, screen edge, obstacle.

What are the benefits of this method?
- The engine already does this check (and on a better way) so there is no need to build an animationscript for that - we are making the same job twice.
- Require just one script file - it's set and go, no need to copy and paste to different animations.
- We can check (not present on this version) for the wall index, so it could be set to work in some walls and not on other ones (I will ask if WD could add the Type check support, so it will be even better).

Code:
For memory optimization, we will be using two files
Save this as wallbounce.c in your scripts folder
Code:
#import "data/scripts/wallbounce_actual.c"

void main()
{
    actual_main();

}

Now save this as wallbounce_actual.c in your scripts folder)
Code:
//Wall Jump without animationscript
//Author: O Ilusionista
//Version: V2 - 2019.01.26
//Thanks: Bloodbane and Damon Caskey.
void actual_main()
{
    void vSelf = getlocalvar("self"); //Get calling player
	void facing = getentityproperty(vSelf, "direction"); // Get Direction
	void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
	int iPIndex = getentityproperty(vSelf,"playerindex"); // Get player index
    void iJump = playerkeys(iPIndex, 1, "jump"); //New key status of "Jump"
	int y = getentityproperty(vSelf, "a");	// Get Y pos
	int b = getentityproperty(vSelf, "base");	// Get Base pos
	
	if(vAniID == openborconstant("ANI_JUMP") || vAniID == openborconstant("ANI_FORWARDJUMP") || vAniID == openborconstant("ANI_RUNJUMP"))
	{ //Jumping, jumping forward or Run Jumping?

		if (iJump && y > b+20)
		{ //New jump key press and Y position is greater than the Base position by 20 pixels, so it won't trigger right when you start jumping?
		changeentityproperty(vSelf, "aiflag", "jumping", 0); // Disable jumping aiflag, so the common jump routine won't take action
		changeentityproperty(vSelf, "aiflag", "attacking", 1); // Enable attacking aiflag, so the common jumpattack routine won't take action
		changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW40")); // Change to FOLLOW40 anim
		}
	}
}

Usage:
Add this to your character header
onblockWscript data/scripts/wallbounce.c*
*You should call wallbounce.c and not wallbounce_actual.c ok?

Just jump against a wall (and not screenedge) and press JUMP button in the middle air. The code won't trigger if you are too close to the ground. Your character will go to the "FOLLOW40" animation. Just make sure you have this animation and that you increased the "maxfollows" parameter in your models.txt
jFUEnep.png


This code use something most modders (including myself) forget about:

onblockWscript {path}
~This command defines which script is run when entity is blocked by walls
==For script coding reference==
self: Caller.
plane: Plane of movement blocked.
1 = X
2 = Z
height: Height of blocking wall.
index: wall ID

Want to make it work against screen edges? Use it as "onblocksscript"
Want to make it work against Obstacles? Use it as "onblockoscript "
Want to make it work against Platforms? Use it as "onblockpscript  "
The same logic can be for all other "onblock" scripts.

Quite simple, huh? ;)
 
Long time i didn't post here but i wanted to thank you O Ilusionista for the script, and DC as well.
I've tested it and it works exactly the way i wanted.
I wanted to replicate Guy's walljump like in the original Final Fight and mixed to DC's @cmd Toss001 script, it works perfectly.

So thanks to both of you guys for helping non programmors like us to make what we need for our projects.
Cheers
 
I am glad you liked it. You can use the same code as "onblockpscript" and it will work against platforms too, or even as "onblockoscript" and it will work against obstacles too.

NickyP said:
Damn! So you mean I could have MegaMan X-style wall jumping with this script?

Yes, but you would need change the code a bit - maybe add the ANI_FOLLOW40 on this line
Code:
if(vAniID == openborconstant("ANI_JUMP") || vAniID == openborconstant("ANI_FORWARDJUMP") || vAniID == openborconstant("ANI_RUNJUMP"))
Or make it go to the normal jump state at the end of the animation.
 
How can use this in an enemy?

I need this for Vega, to use the jump on the edge of the screen. and then jump forward again.

I did some tests, based on what I understand, but I did not succeed
Try to adapt the system to use it as a simple script in an enemy's animation, but it did not work.

Here my try:
Code:
anim attack5
@script
    if(frame == 0){
    void vSelf = getlocalvar("self"); //Get calling player
	void facing = getentityproperty(vSelf, "direction"); // Get Direction
	int y = getentityproperty(vSelf, "a");	// Get Y pos
	int b = getentityproperty(vSelf, "base");	// Get Base pos
	
		if (y > b+20)
		{ //New jump key press and Y position is greater than the Base position by 20 pixels, so it won't trigger right when you start jumping?
		changeentityproperty(vSelf, "aiflag", "jumping", 0); // Disable jumping aiflag, so the common jump routine won't take action
		changeentityproperty(vSelf, "aiflag", "attacking", 1); // Enable attacking aiflag, so the common jumpattack routine won't take action
		changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW28")); // Change to FOLLOW28 anim
	}
@end_script
	range	250 350
        rangez  -50 50
	loop	0
	offset	82 177
	delay   12
	bbox	62 83 46 96
        landframe 19
@script
	void vSelf = getlocalvar("self");
	int xpos = openborvariant("xpos");
	int rWidth = openborvariant("hResolution");
	int x = getentityproperty(vSelf, "x");

	if(! (x > xpos && x < xpos + rWidth)){
		setidle(vSelf);
	}
@end_script
	frame	data/chars/Sfighter/vega/rise3.png
	delay	6
	bbox	0 0 0 0
        @cmd    leaper -2 4 0
	frame	data/chars/Sfighter/vega/j00.png
	frame	data/chars/Sfighter/vega/grab07.png
	delay   4
	frame	data/chars/Sfighter/vega/roll06.png
	sound   data/sounds/aroll.wav
	frame	data/chars/Sfighter/vega/roll05.png
	frame	data/chars/Sfighter/vega/roll04.png
	frame	data/chars/Sfighter/vega/roll03.png
	frame	data/chars/Sfighter/vega/roll02.png
	frame	data/chars/Sfighter/vega/roll01.png
	frame	data/chars/Sfighter/vega/roll08.png
	sound   data/sounds/aroll.wav
	frame	data/chars/Sfighter/vega/roll07.png
	frame	data/chars/Sfighter/vega/roll06.png
	frame	data/chars/Sfighter/vega/roll05.png
	frame	data/chars/Sfighter/vega/roll04.png
	frame	data/chars/Sfighter/vega/roll03.png
	frame	data/chars/Sfighter/vega/roll02.png
	frame	data/chars/Sfighter/vega/roll01.png
	delay	6
	frame	data/chars/Sfighter/vega/rollat06.png
	#delay	999
	frame	data/chars/Sfighter/vega/rollat01.png
	delay	6
	bbox	62 83 46 96
	frame	data/chars/Sfighter/vega/rise3.png



anim follow28
	delay	15
        flipframe 0
	offset	82 177
	jumpframe	1 3.3 1.5
        landframe 8
	@script
		void vSelf = getlocalvar("self");

		if(frame==0){
		  int  iTime = openborvariant("elapsed_time");

		  changeentityproperty(vSelf, "velocity", 0, 0 , 0); // This is to stop entity from moving forward
		  changeentityproperty(vSelf, "tosstime", iTime + 17);
		}
	@end_script
	bbox	88 102 37 43
	frame	data/chars/Sfighter/vega/wjump.png
	delay	12
	bbox	83 89 30 86
	offset	82 157
	sound   data/chars/chosen/at1.wav
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk01.png
	delay	7
	bbox	83 97 24 54
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk02.png
	frame	data/chars/Sfighter/vega/jatk02.png
	delay   999
	bbox	83 89 30 86
	frame	data/chars/Sfighter/vega/jatk03.png
	bbox	62 83 46 96
	frame	data/chars/Sfighter/vega/rise3.png
 
dantedevil said:
I need this for Vega, to use the jump on the edge of the screen. and then jump forward again.

You have two script system there so I had to read thoroughly to find the one that you meant :)

Anyways, the script related to screen edge only works like this: if entity is onscreen, cancel current animation and return to IDLE. IOW it can't be used to jump to edge of screen (or jump anywhere)

Now, to make jump to edge of screen, first, how Vega does it? does he check if he's near screen edge first before jumping or does he jumps directly to screen edge? the former is only done if his jump can't cover half screen while the latter is he can
Either way, when he does jumps to screen edge, that's when he should be checking of screen edge. If he's close enough, stop and change to screen bounce animation
That's the general idea
 
Bloodbane said:
dantedevil said:
I need this for Vega, to use the jump on the edge of the screen. and then jump forward again.

You have two script system there so I had to read thoroughly to find the one that you meant :)

Anyways, the script related to screen edge only works like this: if entity is onscreen, cancel current animation and return to IDLE. IOW it can't be used to jump to edge of screen (or jump anywhere)

Now, to make jump to edge of screen, first, how Vega does it? does he check if he's near screen edge first before jumping or does he jumps directly to screen edge? the former is only done if his jump can't cover half screen while the latter is he can
Either way, when he does jumps to screen edge, that's when he should be checking of screen edge. If he's close enough, stop and change to screen bounce animation
That's the general idea

Thanks for your reply dear friend!
Finally I found a solution mixing several scripts and it works correctly.

Here my solution:
Code:
#EDGE BOUNCE
anim attack5
@script
void self = getlocalvar("self"); // Get entity
int x = getentityproperty(self, "x"); // Get entity's x coordinate
int HRes = openborvariant("hresolution"); // Get horizontal resolution of the screen
int Xpos = openborvariant("xpos"); // Get x position, not from entity itself
int Alti = getentityproperty(self, "a");

if(x > Xpos+HRes-20){ // Entity next to the right side of the screen edge and going against it
   changeentityproperty(self, "direction", 0); // Change entity's facing to the left
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW16"));
}else if(x < Xpos+20){ // Entity next to the left side of screen edge and going against it
   changeentityproperty(self, "direction", 1); // Change entity's facing to the right
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW16"));
}
@end_script
	range	250 350
        rangez  -50 50
	loop	0
	offset	82 177
	delay   12
	bbox	62 83 46 96
        landframe 19
@script
	void vSelf = getlocalvar("self");
	int xpos = openborvariant("xpos");
	int rWidth = openborvariant("hResolution");
	int x = getentityproperty(vSelf, "x");

	if(! (x > xpos && x < xpos + rWidth)){
		setidle(vSelf);
	}
@end_script
	frame	data/chars/Sfighter/vega/rise3.png
	delay	6
	bbox	0 0 0 0
        @cmd    leaper -2 4.5 0
	frame	data/chars/Sfighter/vega/j00.png
	frame	data/chars/Sfighter/vega/grab07.png
	delay   4
	frame	data/chars/Sfighter/vega/roll06.png
	sound   data/sounds/aroll.wav
	frame	data/chars/Sfighter/vega/roll05.png
	frame	data/chars/Sfighter/vega/roll04.png
	frame	data/chars/Sfighter/vega/roll03.png
	frame	data/chars/Sfighter/vega/roll02.png
	frame	data/chars/Sfighter/vega/roll01.png
	frame	data/chars/Sfighter/vega/roll08.png
	sound   data/sounds/aroll.wav
	frame	data/chars/Sfighter/vega/roll07.png
	frame	data/chars/Sfighter/vega/roll06.png
	frame	data/chars/Sfighter/vega/roll05.png
	frame	data/chars/Sfighter/vega/roll04.png
	frame	data/chars/Sfighter/vega/roll03.png
	frame	data/chars/Sfighter/vega/roll02.png
	frame	data/chars/Sfighter/vega/roll01.png
	delay	6
	frame	data/chars/Sfighter/vega/rollat06.png
	#delay	999
	frame	data/chars/Sfighter/vega/rollat01.png
	delay	6
	bbox	62 83 46 96
	frame	data/chars/Sfighter/vega/rise3.png


#EDGE BOUNCE COMBO1
anim follow16
        followanim 17
        followcond 3
        fastattack 1
	delay	15
	offset	82 177
	jumpframe 1 3.5 3.5
        landframe  8
	@script
		void vSelf = getlocalvar("self");

		if(frame==0){
		  int  iTime = openborvariant("elapsed_time");

		  changeentityproperty(vSelf, "velocity", 0, 0 , 0); // This is to stop entity from moving forward
		  changeentityproperty(vSelf, "tosstime", iTime + 17);
		}
	@end_script
	bbox	0 0 0 0
	frame	data/chars/Sfighter/vega/wjump.png
	delay	12
	offset	82 157
	sound   data/chars/Sfighter/vega/at4.wav
	bbox	65 55 45 70
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk01.png
	delay	7
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk01.png
	frame	data/chars/Sfighter/vega/jatk02.png
	frame	data/chars/Sfighter/vega/jatk02.png
	delay   999
	forcedirection -1
	hitfx   data/sounds/beat3b.wav
        hitflash flash2
        attack12  107 108 41 31 15 1 0 0 25
        dropv   3 1
	frame	data/chars/Sfighter/vega/jatk03.png
        attack  0 0 0 0
	offset	82 177
	delay	12
	bbox	62 83 46 96
	frame	data/chars/Sfighter/vega/rise3.png
 
Ah the script looks good

My suggestion is to remove this part:
Code:
@script
	void vSelf = getlocalvar("self");
	int xpos = openborvariant("xpos");
	int rWidth = openborvariant("hResolution");
	int x = getentityproperty(vSelf, "x");

	if(! (x > xpos && x < xpos + rWidth)){
		setidle(vSelf);
	}
@end_script

to prevent confusion
 
Bloodbane said:
Ah the script looks good

My suggestion is to remove this part:
Code:
@script
	void vSelf = getlocalvar("self");
	int xpos = openborvariant("xpos");
	int rWidth = openborvariant("hResolution");
	int x = getentityproperty(vSelf, "x");

	if(! (x > xpos && x < xpos + rWidth)){
		setidle(vSelf);
	}
@end_script

to prevent confusion

But I use this Script to prevent the enemy from executing that movement if it is off the screen.
 
That's strange cause the above script already prevents Vega from going offscreen

Hmmm... maybe you should add frame check to prevent each script to be run at wrong frames.
 
Bloodbane said:
That's strange cause the above script already prevents Vega from going offscreen

Hmmm... maybe you should add frame check to prevent each script to be run at wrong frames.

I will take your advice into account, my friend. I'm going to check the animations one by one. Thank you.
 
Back
Top Bottom