Jump to content

Photo

Help with an old Script (Roll Script)


  • Please log in to reply
3 replies to this topic

#1 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 05 October 2019 - 11:06 AM

Edit: Looks like I was able to find a solution after playing with it for a while.

 

Hey everyone, so it's been a while since I delved into Zelda Classic, and I decided to load one of my old scripts Purplemandown made for me. It's a roll script and it worked REALLY well back when I used it, I did have one issue with it where you can slash in the middle of it. Any ideas how to fix this? Also, I made a new topic because I didn't want to gravedig. Hopefully this is okay. :)

 

Original thread:

https://www.purezc.n...=55073&hl= roll

import "std.zh"

global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int rollwait;
        int rollSpeed = 300;
        int rollDur = 25; //in frames
        int cooldown = 5;
        int firstSFX = 61;
        int rollSprite = 88; //The first of the 4 rolling sprites (in weapon/misc.)  In order, up, down, left, right.
		int puffSprite = 92; //The sprite to trail behind link as he rolls
        while(true){
            if((Link->PressR == false) && (rolltimer == 0) && (Falling == false)){
                overlay->DeadState = 0;
                Link->CollDetection = true;
                Link->Invisible = false;
            }
            else if((Falling == true)){
                overlay->DeadState = 0;
                Link->CollDetection = true;
                Link->Invisible = true;
			}
            else if(((Link->PressR == true)&&(rolltimer == 0))&&(rollwait == 0)){
                rolltimer = rollDur;
                rollwait = rollDur + cooldown;
                overlay = Screen->CreateLWeapon(LW_SCRIPT1);
                overlay->Dir = Link->Dir;
                overlay->X = Link->X;
                overlay->Y = Link->Y;
				overlay->DrawYOffset = 0;
                overlay->CollDetection = false;
                overlay->UseSprite(rollSprite);
				overlay->OriginalTile += overlay->NumFrames * Link->Dir;
				overlay->Tile += overlay->NumFrames * Link->Dir;
                Link->CollDetection = true;

                Link->Invisible = true;
                Game->PlaySound(firstSFX + Rand(3));
            }
            else if(rolltimer > 0){
				//Check if the roll timer divides evenly by 6
				if(rolltimer%6 == 0){
					//Spawns the puff of smoke
					lweapon smokepuff = CreateLWeaponAt(LW_SCRIPT1, Link->X + Rand(-2, 2), Link->Y + Rand(-2, 2));
					smokepuff->CollDetection = false;
					smokepuff->UseSprite(puffSprite);
					smokepuff->DeadState = smokepuff->NumFrames * smokepuff->ASpeed;
				}
                if(overlay->isValid() == true){
                    if(CanWalk(overlay->X, overlay->Y, overlay->Dir, rollSpeed/100, false) == true){
                        overlay->Step = rollSpeed;
                    }
                    else{
                        overlay->Step = 0;
                    }
                    Link->X = overlay->X;
                    Link->Y = overlay->Y;
                    rolltimer--;
                }
                else{
                    rolltimer = 0;
                    overlay->DeadState = 0;
                    Link->CollDetection = false;
                    Link->Invisible = false;
                }
            }
            if(rollwait > 0){
                rollwait--;
            }
            if((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}

Thank you!

Edit: Looks like I was able to find a solution after playing with it for a while.


Edited by Xenix, 05 October 2019 - 04:07 PM.


#2 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 06 October 2019 - 03:43 PM

Bump

Anyone know of a way to have the roll script check for moving blocks? when you push a block, you can roll through it as it is moving.



#3 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 06 October 2019 - 10:29 PM

"Screen->MovingBlockX" gives you the X position of the moving block, "Screen->MovingBlockY" gives you the Y position. Using that, you can add scripted collision for a 16x16 square where those coordinates represent the upper-left corner, preventing Link from moving through it.
As for how to do scripted collision, that's a whole 'nother question, and one I don't have time to answer right now.



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 23 October 2019 - 11:05 AM

Probably just disable rolling if there is a moving block with:

 

&& !Screen->MovingBlockX && !Screen->MovingBlockY

 

Otherwise, halt the script if Link's position is at the coordinates -/+ based on his dir.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users