User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: Roll Script. MC style... sort of.

  1. #1
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.3%

    Talking Roll Script. MC style... sort of.

    Code:
    import "std.zh"
    
    bool isSolid(int x, int y) {
    
    	// x=23, y=130
    	// Obviously in range...
    	if(x<0 || x>255 || y<0 || y>175)
    					return false;
    	int mask=1111b;
    		
    	// x &#37; 16 = 7, so
    	// mask = 1111 & 0011 = 0011
    	if(x%16<8)
    		mask&=0011b;
    	else
    		mask&=1100b;
    	
    	// y % 16 = 2, so
    	// mask = 0011 & 0101 = 0001
    	if(y%16<8)
    		mask&=0101b;
    	else
    		mask&=1010b;
    
    	// All but the top-right quarter of the combo is solid, so ComboS = 1011
    	// mask & ComboS = 0001 & 1011 = 0001
    	// The result wasn't 0, so return false
    	return (!(Screen->ComboS[ComboAt(x, y)]&mask)==0);
    
    }
    
    
    
    global script roll {
    
    	void run() {
    
    		int counter;
    		bool justRolled = false;
    		int DustTile = 20; //the starting animation tile of the 5-frame dust animation.
    		int DustCSet = 7; //the CSet of the tile animation.
    		int xca; int xcb; int xcc; int xcd; int xce;
    		int yca; int ycb; int ycc; int ycd; int yce;
    		int DustFrame;
    
    		while(true) {
    
    			if(Link->InputL && Link->Action == LA_WALKING) {
    
    				Link->Jump = 2;
    				counter = 20;
    				DustFrame = 1;
    				xca = -1;
    				xcb = -1;
    				xcc = -1;
    				xcd = -1;
    				xce = -1;
    				yca = -1;
    				ycb = -1;
    				ycc = -1;
    				ycd = -1;
    				yce = -1;
    				Game->PlaySound(66); //Change/Disable SFX if needed
    
    				while(counter > 0) {
    
    					Link->Z = 0;
    					Link->InputUp = false;
    					Link->InputDown = false;
    					Link->InputLeft = false;
    					Link->InputRight = false;
    					Link->InputA = false;
    					Link->InputB = false;
    					Link->InputR = false;
    					Link->InputL = false;
    
    					if(Floor(counter/2) == counter/2) { //trigger animation every other frame
    
    						xce = xcd;
    						xcd = xcc;
    						xcc = xcb;
    						xcb = xca;
    
    						yce = ycd;
    						ycd = ycc;
    						ycc = ycb;
    						ycb = yca;
    
    						xca = Link->X;
    						yca = Link->Y;
    
    						if(DustFrame >= 5) {
    
    							xca = -1;
    							yca = -1;
    
    						}
    
    						DustFrame ++;
    
    					}
    
    					if(!(xca == -1) && !(yca == -1)) {Screen->DrawTile(2, xca, yca, DustTile, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
    					if(!(xcb == -1) && !(ycb == -1)) {Screen->DrawTile(2, xcb, ycb, DustTile + 1, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
    					if(!(xcc == -1) && !(ycc == -1)) {Screen->DrawTile(2, xcc, ycc, DustTile + 2, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
    					if(!(xcd == -1) && !(ycd == -1)) {Screen->DrawTile(2, xcd, ycd, DustTile + 3, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
    					if(!(xce == -1) && !(yce == -1)) {Screen->DrawTile(2, xce, yce, DustTile + 4, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
    
    					if(Link->Dir == DIR_UP) {
    
    						if(!isSolid(Link->X+4, Link->Y+6) && !isSolid(Link->X+12, Link->Y+6) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+6)] != 98)) {Link->Y -= 2;}
    
    					} else if(Link->Dir == DIR_DOWN) {
    
    						if(!isSolid(Link->X+4, Link->Y+18) && !isSolid(Link->X+12, Link->Y+18) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+18)] != 98)) {Link->Y += 2;}
    
    					} else if(Link->Dir == DIR_LEFT) {
    
    						if(!isSolid(Link->X-2, Link->Y+12) && (Screen->ComboF[ComboAt(Link->X-2, Link->Y+4)] != 98)) {Link->X -= 2;}
    
    					} else if (Link->Dir == DIR_RIGHT) {
    
    						if(!isSolid(Link->X+18, Link->Y+12) && (Screen->ComboF[ComboAt(Link->X+18, Link->Y+4)] != 98)) {Link->X += 2;}
    
    					} //end if
    
    				counter --;
    				justRolled = true;
    
    				Waitframe();
    
    				} //end while
    
    			} //end if
    
    		if(justRolled) {
    
    			Link->Jump = 0;
    			justRolled = false;
    
    		}
    
    		Link->InputL = false;
    
    		Waitframe();
    
    		} //end while
    
    	} //end void run
    
    } //end script
    Notes:

    *It's a global script, so there are no parameters and it cannot be disabled without another script.
    *By default, L is used to roll. To change it, replace InputL with InputR and vice-versa.
    *It is customizable by the options at the top. You can change the CSet and Starting dust "kick up" tile. You can also change the sound effect. It is SFX #66 by default.
    *You can roll through layers if you don't mark them with flag 98.
    *Mark anything you don't want roll-onto-able on layer 0 with flag 98. G'head. Use it. That's what the general purpose flags are for!
    *You can roll over warps, so be careful with cutscenes by marking the tiles ahead of the pits/warps with flag 98s.
    *You need jump tiles for this to work. And your jump tiles must be of the rolling variety.
    *As of now, the collision detection isn't very accurate, so if there is any unwalkable part of the tile, you cannot roll through it. This is no longer true. It now goes down to the quarter-combo.
    *It really is a psudo-roll. You actually do a jump that brings you to Z = 0 each frame and moves you forward if possible.
    *You'll probably want the "poof" tiles or similar for the dust "kick up."
    *the dust "kick up" is at a fixed 5-frame animation. If you want more frames, you'll have to edit the script. If you want less, leave blanks at the end of the animation
    *You can't perform anything else during a roll.
    *I forgot to mention this before, but it is designed for the smaller Link hitbox. To enable it for the large hitbox, change the +6s to -2s on the up rolling fork and add !isSolid(Link->X-2, Link->Y+4) to the left fork and !isSolid(Link->X+18, Link->Y+4) to the right DIR fork.

    EDIT: Due to the new allocation of general purpose flags I changed flag 97 to flag 98! Thankfully, I don't have a whole lot to change in AMN to make it consistent. You WILL have to painstakingly change every last flag 97 to a flag 98. With the improved collision detection, it is now sensitive down to the quarter-combo!
    Avatar: Just who the SPAAAACE do you think I am?

  2. #2
    Octorok
    Join Date
    Nov 2006
    Age
    29
    Posts
    463
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,770
    Level
    14
    vBActivity - Bars
    Lv. Percent
    8.05%

    Re: Roll Script. MC style... sort of.

    This script works nicely! It's official. It's a scripting revolution! Anyway thanks for the script Beefster!

    Click here to level up my card, or be sacrificed... ^_^

    Want to see Shattered Earth, AGN's RPG, back? Got a computer that is capable of running a server? PM me!

  3. #3
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.49%

    Re: Roll Script. MC style... sort of.

    Wait, so, you CAN have a multiple-frame global script?!
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  4. #4
    Wizrobe The_Amaster's Avatar
    Join Date
    Dec 2005
    Location
    St. Mystere
    Age
    32
    Posts
    3,803
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    8,810
    Level
    28
    vBActivity - Bars
    Lv. Percent
    26.05%

    Re: Roll Script. MC style... sort of.

    Right. Time for the person with no scripting experiance to ask a question...

    How do I actually set it up?

    So far I've gone to Scripts->Compile ZScript, imported then compiled and assigned it to one of my three Global slots. Now what do I do?

  5. #5
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.3%

    Re: Roll Script. MC style... sort of.

    That should do it.. Maybe get the newest version of the script. You might have grabbed it before I edited it to be correct.
    Avatar: Just who the SPAAAACE do you think I am?

  6. #6
    Wizrobe The_Amaster's Avatar
    Join Date
    Dec 2005
    Location
    St. Mystere
    Age
    32
    Posts
    3,803
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    8,810
    Level
    28
    vBActivity - Bars
    Lv. Percent
    26.05%

    Re: Roll Script. MC style... sort of.

    No I grabbed the most recent one. I just assumed it was more comlicated then that, and never tested it. I'll see if that works.

  7. #7
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.7%

    Re: Roll Script. MC style... sort of.

    If you're using this script, you may find it useful to accompany it with this one:
    Code:
    ffc script disable_roll{
         void run(){
              while(true){
                   Link->InputL = false;
                   Waitframe();
              }
         }
    }
    Which stops you from using it on a screen when you don't want it to be used, courtesy of Matthew at purezc.

  8. #8
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.3%

    Re: Roll Script. MC style... sort of.

    I updated it to deal with the new flag standards, I fixed a bug, and improved the collision detection similarly to Saffith's CanMove function. (I actually copy-pasted it and negated the return value) Enjoy while I bump this.
    Avatar: Just who the SPAAAACE do you think I am?

  9. #9
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.7%

    Re: Roll Script. MC style... sort of.

    Oh dear, now Link doesn't roll for long enough, so it only plays the first tile of the jump animation and looks like he's doing some funny headbutt or something. Could you make it go for a bit longer please? I can't seem to fathom how it works at all.

  10. #10
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.3%

    Re: Roll Script. MC style... sort of.

    It shouldn't have anything to do with my script... It should work fine. Talk to a dev. In the meantime, I'll check the code. I gotta go to bed since I have to wake up at the buttcrack of dawn, otherwise I'd do it now.
    Avatar: Just who the SPAAAACE do you think I am?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social