PDA

View Full Version : Blue/Red Switch Gates



_L_
08-31-2007, 08:13 AM
//
// "Blue/Red Gates"
// As seen in "A Link to the Past".
//
// d0: the combo ID of the open gate.
// d1: the combo ID of the closed gate.
// d2: the combo ID of the Switch Orb.
//
// Flags:
// * Run Script on Screen Init
// Screen Variables Used:
// * Screen 0, d0
// Limitations:
// * Only one Switch Orb allowed per screen!
//
ffc script BlueRedGates {
void run(int bluegate, int redgate, int offorb) {
int blue = Game->GetScreenD(0, 0);
int orb = -1;
bool switched = false;
for (int i = 0; i<=176; i++) {
if (Screen->ComboD[i]==offorb) orb=i;
}
while(true) {
if (blue==1 || switched) {
for (int i = 0; i<=176; i++) {
if (Screen->ComboD[i]==bluegate) Screen->ComboD[i]=redgate;
else if (Screen->ComboD[i]==redgate) Screen->ComboD[i]=bluegate;
}
}
switched = false;
while (!switched) {
Waitframe();
if (orb>=0 && Screen->ComboD[orb]!=offorb)
{
Waitframes(10);
switched=true;
Screen->ComboD[orb]=offorb;
if (blue>0) {
blue=0;
} else {
blue=1;
}
Game->SetScreenD(0, 0, blue);
}
}
}
}
}
Notes:

* The switch gate status is stored in screen variable d0 on screen 0 of the current DMap. This can be replaced with a global variable if you so desire.

* The "Switch Orb" is a combo whose ID is equal to d2. It assumes that there is only one of these combos on the screen, and that when the screen's Secret Combos are triggered, this combo will be changed.

When the Switch Orb's combo changes (presumably to a "lit orb" combo), the script will restore it to its original combo after ten frames. This script currently does not alter the CSet of the Switch Orb, because hey, I don't know what tileset you're using.

* Currently, this can only affect two types of combos per screen. If you want a script that raises/lowers multiple varieties of combos simultaneously, some alteration is required.

Pheonix
09-01-2007, 10:48 AM
Are you supposed to put flags on the gates? When I tried that and hit the switch, the gate that was originally up came down, and then changed into the combo that was before the closed gate. I doubt that is what is supposed to happen.

Anyway, once I get this working, it will let me make my version of the Tower of Hera. (That is what everyone using a set with LTTP tiles will probably do with this. Doubtless some other people will make something crazy like a 6-floor Cerbat Shrine)

_L_
09-03-2007, 03:24 AM
Are you supposed to put flags on the gates?
What? Oh no, not at all. That's what the script is for!

Pheonix
09-03-2007, 09:57 AM
The second dungeon I'm making for NeoFirst is Winter Garden. There will be red/blue gates on all the screens I have made so far (I am not joking). However, despite setting it up exactly as it is set up in the little dungeon showing the red/blue gates, I still cannot get them to work. Rather annoying...

Also, the script stops working if you exit and then reenter a room using the script. Not sure about warps, though.

_L_
11-26-2007, 08:35 AM
Hmm... I suppose you're right. I've made a fix to the script just now.