superjump mvc style tutorial

rafhot

Member
Lagarto has created a very cool superjump script for my project so i decided share it here


first put this code on the character header:
Code:
script  @script
 void main()
 {
	 void self 		= getlocalvar("self");
         int pindex 		= getentityproperty(self,"playerindex");
         void attack1 		=  playerkeys(pindex, 0, "attack");
         void down              =  playerkeys(pindex, 0, "movedown");
         void up                =  playerkeys(pindex, 0, "moveup");
         void moveright 	=  playerkeys(pindex, 0, "moveright");
         void moveleft 		=  playerkeys(pindex, 0, "moveleft");

    if(getentityproperty(self,"animationid")==openborconstant("ani_follow5"))
    {

	int a = getentityproperty(self,"a");
        if(attack1) performattack(self,openborconstant("ani_jumpattack"));
        if(attack1 && down) performattack(self,openborconstant("ani_jumpattack2"));
        if(attack1 && up) performattack(self,openborconstant("ani_jumpattack3"));
        if(moveright && a>0)changeentityproperty(self, "velocity", 0.5,NULL(),NULL());
        if(moveleft && a>0)changeentityproperty(self, "velocity", -0.5,NULL(),NULL());
     }
 }

@end_script


then create a follow5 animations (this could be a copy paste from your jump animation)
Code:
anim	follow5


	dropframe	2
	landframe	3
	offset	94 161
	bbox	86 41 20 105
	delay	1
	frame	data/chars/Dragon/pg18.gif
	delay	100
	frame	data/chars/Dragon/pg18.gif
	delay	100
	offset	98 155
	bbox	89 65 25 64
	frame	data/chars/Dragon/pg19.gif
	delay	8
	offset	95 136
	frame	data/chars/Dragon/pg39.gif


and create a freespecial animation that will trigger the move  in my game i set down up jump to activate it
so

Code:
com D U J freespecial5

Code:
anim freespecial5
@script
     if(frame ==2)
	{
        void self = getlocalvar("self");
	changeentityproperty(self, "aiflag", "attacking", 0);
     	changeentityproperty(self, "aiflag", "idling", 0);
     	changeentityproperty(self, "aiflag", "jumping", 1);
        changeentityproperty(self, "takeaction", "common_jump");
        changeentityproperty(self, "velocity",NULL(),NULL(),7);
     	performattack(self, openborconstant("ani_follow5"));
      }
	@end_script
	delay	6
	offset	95 136
	bbox	85 66 26 69
	frame	data/chars/Dragon/pg39.gif
        frame	data/chars/Dragon/pg39.gif
        frame	data/chars/Dragon/pg39.gif


thats it now you just need put some effects for the jump and a superjump sound
all credit goes to lagarto who did it for me :)
 
to use those @script in header make sure you are using the most recent openbor build

my tests are at build 3994



[attachment deleted by admin]
 
At freespecial5 , if you want to show 2 frames and then the super jump, you'll need 3 frames there (and you have only two). So, at first you'll need to modify frame == 2 to frame == 1 or put antoher  frame there (you can repeat the last frame).

e.g.:

Code:
anim freespecial5
@script
     if(frame ==2)
	{
        void self = getlocalvar("self");
	changeentityproperty(self, "aiflag", "attacking", 0);
     	changeentityproperty(self, "aiflag", "idling", 0);
     	changeentityproperty(self, "aiflag", "jumping", 1);
        changeentityproperty(self, "takeaction", "common_jump");
        changeentityproperty(self, "velocity",NULL(),NULL(),7);
     	performattack(self, openborconstant("ani_follow5"));
      }
	@end_script
sound	data/sounds/jump.wav
	loop	0
	delay	8
	bbox	19 1 32 75
	offset	29 116
	frame	data/chars/bartman/33.gif
	delay	10
	bbox	17 1 45 70
	offset	39 67
	frame	data/chars/bartman/36.gif
        frame	data/chars/bartman/36.gif

 
nsw25 said:
rafhot said:
maybe you reached your max follows or max freespecials and need to increase it on models.txt

yup that was it, i had

maxattacks 50
maxattacktypes 50
maxfreespecials 50
maxrises 50
maxidles 50
maxcancels              50

but no maxfollows defined, which i have now added and this works now :) thanks so much guys, now i have one more cool feature to add to my works

Nice to hear that!
 
i use
jumpmove 2 2

on my character header and he is able to move  left and right even in superjump
 
maybe is your speed value

try increase the value on those lines

        if(moveright && a>0)changeentityproperty(self, "velocity", 0.5,NULL(),NULL());
        if(moveleft && a>0)changeentityproperty(self, "velocity", -0.5,NULL(),NULL());


to a higher value and see if something changes
 
i dont know i dont tried it yet, on my next game i will use superjump with air combos, i think i will use some cancels chained to perform those combos but i dont know how i will start to trigger it yet :P

 
That super jump script uses jumpattack, jumpattack2 and jumpattack3 . You can change that very easy. Just modify these lines  at script to anything you want.

Code:
if(attack1) performattack(self,openborconstant("ani_jumpattack"));
        if(attack1 && down) performattack(self,openborconstant("ani_jumpattack2"));
        if(attack1 && up) performattack(self,openborconstant("ani_jumpattack3"));

Let's say you want to replace the normal jumpattack on super jump to a custom jump attack (e.g anim follow6). Then replace the "ani_jumpattack"  to "ani_follow6".


 
Back
Top Bottom