//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.