_L_
11-06-2007, 04:55 AM
//
// "Freeform Raft"
// A freeform raft. If it's under your feet, you can move across water.
// * Single screen only!
// * Requires the "Link Drowns in Walkable Water" rule.
// * Saves its position when you leave the screen!
// * Doesn't support swim warps or dive warps.
//
// Flags:
// * Run Script on Screen Init
// Screen Variables Used:
// * Current screen, d0
// * Current screen, d1
//
ffc script FreeformRaft
{
void run() {
// On init:
if (Screen->D[0] != 0 && Screen->D[1] != 0) {
this->X = Screen->D[0];
this->Y = Screen->D[1];
}
while(true) {
Waitframe();
// If Link is right on the raft, move him into the centre.
if (Distance(Link->X+8, Link->Y+4, this->X+8, this->Y) < 4 && Link->Z == 0) {
Link->X = this->X;
Link->Y = this->Y-4;
int dx = Link->X+8;
int dy = Link->Y+12;
// Keep Link above water until he reaches dry land again.
while(Screen->ComboT[ComboAt(dx,dy)]==CT_WATER && Link->Jump == 0) {
this->X = Link->X;
this->Y = Link->Y+4;
Waitframe();
Link->Jump = 0;
Link->Z = 0;
dx = Link->X+8;
dy = Link->Y+12;
if (Link->Dir == DIR_UP) {
dy -= 8;
} else if (Link->Dir == DIR_DOWN) {
dy += 4;
} else if (Link->Dir == DIR_LEFT) {
dx -= 8;
} else if (Link->Dir == DIR_RIGHT) {
dx += 8;
}
}
// Step off the raft
for (int i=0; i<6; i++) {
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
if (Link->Dir == DIR_UP) {
Link->InputUp = true;
} else if (Link->Dir == DIR_DOWN) {
Link->InputDown = true;
} else if (Link->Dir == DIR_LEFT) {
Link->InputLeft = true;
} else if (Link->Dir == DIR_RIGHT) {
Link->InputRight = true;
}
Waitframe();
}
// Store position
Screen->D[0] = this->X;
Screen->D[1] = this->Y;
}
}
}
}
A little something I made for future use in NeoFirst.
// "Freeform Raft"
// A freeform raft. If it's under your feet, you can move across water.
// * Single screen only!
// * Requires the "Link Drowns in Walkable Water" rule.
// * Saves its position when you leave the screen!
// * Doesn't support swim warps or dive warps.
//
// Flags:
// * Run Script on Screen Init
// Screen Variables Used:
// * Current screen, d0
// * Current screen, d1
//
ffc script FreeformRaft
{
void run() {
// On init:
if (Screen->D[0] != 0 && Screen->D[1] != 0) {
this->X = Screen->D[0];
this->Y = Screen->D[1];
}
while(true) {
Waitframe();
// If Link is right on the raft, move him into the centre.
if (Distance(Link->X+8, Link->Y+4, this->X+8, this->Y) < 4 && Link->Z == 0) {
Link->X = this->X;
Link->Y = this->Y-4;
int dx = Link->X+8;
int dy = Link->Y+12;
// Keep Link above water until he reaches dry land again.
while(Screen->ComboT[ComboAt(dx,dy)]==CT_WATER && Link->Jump == 0) {
this->X = Link->X;
this->Y = Link->Y+4;
Waitframe();
Link->Jump = 0;
Link->Z = 0;
dx = Link->X+8;
dy = Link->Y+12;
if (Link->Dir == DIR_UP) {
dy -= 8;
} else if (Link->Dir == DIR_DOWN) {
dy += 4;
} else if (Link->Dir == DIR_LEFT) {
dx -= 8;
} else if (Link->Dir == DIR_RIGHT) {
dx += 8;
}
}
// Step off the raft
for (int i=0; i<6; i++) {
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
if (Link->Dir == DIR_UP) {
Link->InputUp = true;
} else if (Link->Dir == DIR_DOWN) {
Link->InputDown = true;
} else if (Link->Dir == DIR_LEFT) {
Link->InputLeft = true;
} else if (Link->Dir == DIR_RIGHT) {
Link->InputRight = true;
}
Waitframe();
}
// Store position
Screen->D[0] = this->X;
Screen->D[1] = this->Y;
}
}
}
}
A little something I made for future use in NeoFirst.