Jump to content

Photo

Ledge Script.


  • Please log in to reply
40 replies to this topic

#1 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 April 2008 - 06:50 PM

It's a ledge script. Like y'know when you can hop off ledges in LttP and MC and others. Heck, you can even use it for an "automatic jump." I pretty much came up with this for the sake of the player's convenience in my quest-- so the player won't have to go all the way around again.
CODE
//Ledge
//Link will jump off the ledge only when in the specified direction
//D0: All acceptable directions in a masked format:
//Up = 1;
//Down = 2;
//Left = 4;
//Right = 8;
//D1: Minimum direction hold time
//D2: Sound to be played when hopping the ledge
//All other properties are absorbed from the ffc, namely EffectHeight and EffectWidth
const float GRAV=.16; //Insert your game's gravity constant here. (.16 by default)

ffc script Ledge{

    void run(int dir, int hold, int SFX) {

        bool canJump;
        int counter=0;

        while(true) {

            if((dir & 0001b) != 0) {
                canJump = Link->InputUp && !Link->InputDown;
                canJump &&= (Link->X >= this->X-4) && (Link->X <= this->X+this->EffectWidth-12);
                canJump &&= (Link->Y <= this->Y+this->EffectHeight+8) && (Link->X >= this->X+this->EffectHeight+4);
                while(canJump && counter<hold) {
                    counter++;
                    Waitframe();
                    canJump &&= Link->InputUp && !Link->InputDown;
                }
                counter = 0;
                if(canJump) {
                    Link->Jump = ((this->EffectHeight+8)/2)*GRAV;
                    Game->PlaySound(SFX);
                    for(int i=0;i<this->EffectHeight+8;i++) {
                        Link->Y--;
                        Link->InputUp = false;
                        Link->InputDown = false;
                        Link->InputLeft = false;
                        Link->InputRight = false;
                        Link->InputA = false;
                        Link->InputB = false;
                        Link->InputR = false;
                        Link->InputL = false;
                        Waitframe();
                    }
                }
            } if((dir & 0010b) != 0) {
                canJump = Link->InputDown && !Link->InputUp;
                canJump &&= (Link->X >= this->X-4) && (Link->X <= this->X+this->EffectWidth-12);
                canJump &&= (Link->Y >= this->Y-16) && (Link->Y <= this->Y-12);
                while(canJump && counter<hold) {
                    counter++;
                    Waitframe();
                    canJump &&= Link->InputDown && !Link->InputUp;
                }
                counter = 0;
                if(canJump) {
                    Link->Jump = ((this->EffectHeight+8)/2)*GRAV;
                    Game->PlaySound(SFX);
                    for(int i=0;i<this->EffectHeight+8;i++) {
                        Link->Y++;
                        Link->InputUp = false;
                        Link->InputDown = false;
                        Link->InputLeft = false;
                        Link->InputRight = false;
                        Link->InputA = false;
                        Link->InputB = false;
                        Link->InputR = false;
                        Link->InputL = false;
                        Waitframe();
                    }
                }
            } if((dir & 0100b) != 0) {
                canJump = Link->InputLeft && !Link->InputRight;
                canJump &&= (Link->Y >= this->Y-4) && (Link->Y <= this->Y+this->EffectHeight-12);
                canJump &&= (Link->X <= this->X+this->EffectWidth+16) && (Link->X >= this->X+this->EffectWidth+12);
                while(canJump && counter<hold) {
                    counter++;
                    Waitframe();
                    canJump &&= Link->InputLeft && !Link->InputRight;
                }
                counter = 0;
                if(canJump) {
                    Link->Jump = ((this->EffectWidth+16)/2)*GRAV;
                    Game->PlaySound(SFX);
                    for(int i=0;i<this->EffectWidth+16;i++) {
                        Link->X--;
                        Link->InputUp = false;
                        Link->InputDown = false;
                        Link->InputLeft = false;
                        Link->InputRight = false;
                        Link->InputA = false;
                        Link->InputB = false;
                        Link->InputR = false;
                        Link->InputL = false;
                        Waitframe();
                    }
                }
            } if((dir & 1000b) != 0) {
                canJump = Link->InputRight && !Link->InputLeft;
                canJump &&= (Link->Y >= this->Y-4) && (Link->Y <= this->Y+this->EffectHeight-12);
                canJump &&= (Link->X >= this->X-16) && (Link->X <= this->X-12);
                while(canJump && counter<hold) {
                    counter++;
                    Waitframe();
                    canJump &&= Link->InputRight && !Link->InputLeft;
                }
                counter = 0;
                if(canJump) {
                    Link->Jump = ((this->EffectWidth+16)/2)*GRAV;
                    Game->PlaySound(SFX);
                    for(int i=0;i<this->EffectWidth+16;i++) {
                        Link->X++;
                        Link->InputUp = false;
                        Link->InputDown = false;
                        Link->InputLeft = false;
                        Link->InputRight = false;
                        Link->InputA = false;
                        Link->InputB = false;
                        Link->InputR = false;
                        Link->InputL = false;
                        Waitframe();
                    }
                }
            }
    
            Waitframe();
        }
    }
}

This is a very straightforward script to set up.
For D0, you add all the numbers together to get your mask.
For D1, 10-20 are good values. it prevents players from "bumping" off the edge.
For D2, you'll probably just want the default jumping sound, which is 45.
Link now jumps over the whole tile and only the tile.
All input is disabled while hopping off ledges.

When setting up the ffc, you can extend the ledge by changing the width and height of the ffc. The script absorbs these values from the ffc itself.

Edited by Beefster, 23 April 2008 - 05:16 PM.


#2 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 22 April 2008 - 06:56 PM

Wha- Wha- What? This is AMAZING! I just have a quick question:

-What do you actually put in the D1 box? I'm confused...

But anyways, nice script and I will probably be using this.

#3 Feenicks

Feenicks

    still the harpy guy

  • Members
  • Real Name:Robert
  • Location:dn ǝpᴉs ʇɥƃᴉɹ

Posted 22 April 2008 - 07:05 PM

I'm pretty sure it's the number of frames of pushing against the cliff face that are needed to jump off.
Awesome. I'll probably be using this in my quest (thus giving a second use to the hookshot-over cliff tiles in PTUX).

#4 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 April 2008 - 07:05 PM

Phoenix is correct. D1 is a delay. The direction button must be held down for D1 consecutive frames before Link hops the ledge. You should set this to 0 or 1 for auto-jump gaps. (Like in the 3D Zeldas)

Now that I think of it, you could have a treasure chest in a gap which Link jumps over from higher ledges so you can only reach the chest from the lower level.

Edited by Beefster, 22 April 2008 - 07:06 PM.


#5 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 22 April 2008 - 08:14 PM

Oh man.... I've always wanted a script like this... icon_biggrin.gif

Question! Could you possibly change it to where it can react to up to, oh, say... 4 different combos per screen? I'm thinking of some of those jumping puzzles in OoS where there's two "auto-jump" points on a single screen... If you need a screen of what I mean, lemme know. But anyways... Think you could modify this script to get that effect? (It'd make you skip one combo, by the way. You jump on one, skip the next, land on the one after that.) Thanks in advance. icon_biggrin.gif

EDIT: Plus, it'd also be nice if it could merely react to certain combos like this current version does, in case one wishes to have multiple points to jump off of at.

Edited by Matthew, 22 April 2008 - 08:15 PM.


#6 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 April 2008 - 09:51 PM

It doesn't react to specific combo types. It's essentially a dummy placement-- you put it OVER the region you want to make a ledge or autojump. So it uses the ffc's properties rather than a combo type or flag.

To have several per screen, you just set up lots of ledges, which should work, and even if it doesn't, you could just tweak a line or two in the engine's code so multiple ffcs can be running the same script... Unless it isn't that simple.

#7 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 22 April 2008 - 10:34 PM

Amazing! Simply amazing! This adds so many more possibilities to my quest!

#8 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 22 April 2008 - 10:41 PM

WOW, man, this is remarkable. ^_^ There was a way to get ledge jumping to work before this, but this script makes the method too complicated and limited compared to this. Just wow. icon_biggrin.gif

Once I finally start making a Quest in 2.5b, this script will DEFINITELY be used. Thanks for giving this to us! You're the MAN.

Edit: Question. How many Tiles on the screen does Link shift when jumping off a ledge?

Edited by Schwa, 22 April 2008 - 10:42 PM.


#9 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 22 April 2008 - 10:57 PM

QUOTE(Beefster @ Apr 22 2008, 10:51 PM) View Post

It doesn't react to specific combo types. It's essentially a dummy placement-- you put it OVER the region you want to make a ledge or autojump. So it uses the ffc's properties rather than a combo type or flag.

To have several per screen, you just set up lots of ledges, which should work, and even if it doesn't, you could just tweak a line or two in the engine's code so multiple ffcs can be running the same script... Unless it isn't that simple.

I know that. I was asking if you'd please change it so it WOULD react to combo types. You see... If you place multiple FFCs on one screen, all running the same script, NONE of the scripts activate, period. Major flaw. icon_frown.gif I think you understand now?

#10 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 22 April 2008 - 11:14 PM

QUOTE(Matthew @ Apr 22 2008, 08:57 PM) View Post

I know that. I was asking if you'd please change it so it WOULD react to combo types. You see... If you place multiple FFCs on one screen, all running the same script, NONE of the scripts activate, period. Major flaw. icon_frown.gif I think you understand now?

Wow. When you put it that way, there should be a way to make it effect certain combos.

#11 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 April 2008 - 11:18 PM

Ooh. That is a big problem. I suppose I'll make another which uses general purpose flags. It'll take a lot more work. icon_sweat.gif The two aren't exactly the same script.

And Schwa: He jumps as wide or tall as the ffc, depending on the direction he jumps off.

Edited by Beefster, 22 April 2008 - 11:19 PM.


#12 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 22 April 2008 - 11:20 PM

QUOTE(Beefster @ Apr 22 2008, 09:18 PM) View Post

Spit it out, Russ.

Spit what out? icon_confused2.gif

#13 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 22 April 2008 - 11:25 PM

You were on the active users list and I was hoping you would post after me. I knew you'd be amazed with the script, so I thought I might throw in a startling bit of humor.

#14 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 23 April 2008 - 12:25 AM

Very nice! People really needed this. ..Oh, that reminds me. Dude, help me out a little please: http://www.armageddo...744#post1172744

#15 Joe123

Joe123

    Retired

  • Members

Posted 23 April 2008 - 01:55 AM

QUOTE(Matthew @ Apr 23 2008, 04:57 AM) View Post
You see... If you place multiple FFCs on one screen, all running the same script, NONE of the scripts activate


What?!

Really?

I've done this lots of times and it works fine...


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users