PDA

View Full Version : Dungeon Script #1: Color Path



HeroOfFire
07-22-2007, 02:38 AM
Last tested in build 478.
Dungeon scripts are for dungeon puzzles/dungeon specific events.

Here's a script based off of a puzzle in Oracle Of Ages. It's the 'Colored Path' puzzle! In the game, all the floor tiles start out blue, turn yellow when Link steps on them, and then turn red when Link steps off them. If Link can turn all the tiles either yellow or red without stepping on a red tile, then the puzzle is completed!


//Various Scripts, by HeroOfFire

//NOTE: When I say activation of a script, I mean setting its CSet to 0.
//This is how I tell a script its been activated, triggered, etc.

import "std.zh"

//FFC Script ColorPath
//Dungeon Specific script based off of a puzzle in Oracle Of Ages
//Walk accross 3 different combos
//Combo 1 changes to combo 2 when stepped on.
//Combo 3 ends the script, testing to see how many combo 1's still exist
//If the number of combo 1's is low enough, another FFC is activated
//D0 = FFC Number (starts at 1)
//D1 = The fist of 3 consecutive combos used for this script
//Combo 1 is used for the count and changes to combo 2 when stepped on.
//Combo 2 changes into combo 3 when Link steps on an adjacent combo 1
//Combo 3 ends the script, first testing to see how many combo 1's are left
//D2 = The maximum number of combo 1's left at the end of the script allowed that will activate another FFC
//D3 The number of the FFC that will be activated
//D4 Height Flag. If not 0, Link can only trigger combos when on the ground
ffc script ColorPath {

int countCombos(int tc) {
int cTile;
int tCount = 0;
for (cTile = 0; cTile < 176; cTile++)
{
if (Screen->ComboD[cTile] == tc)
{
tCount++;
}
if (Screen->ComboD[cTile] == tc + 1)
{
Screen->ComboD[cTile] = tc + 2;
}
}
return tCount;
}
void run(float thisFFC, int firstCombo, int maxBlues, int targetFFC, int heightFlag) {
int targetLoc = 0;
int targetTile = 0;
ffc this1 = Screen->LoadFFC(thisFFC);
while (true)
{
Waitframe();
targetLoc = ComboAt(Link->X + 8, Link->Y + 8);
if (Screen->ComboD[targetLoc] >= firstCombo && Screen->ComboD[targetLoc] <= firstCombo + 2 && (heightFlag

== 0 || Link->Z < 1))
{
targetTile = Screen->ComboD[targetLoc];
targetTile = targetTile - firstCombo;
if (targetTile == 0)
{
Screen->ComboD[targetLoc]++;
if (targetLoc > 15)
{
if (Screen->ComboD[targetLoc - 16] == firstCombo + 1)
{
Screen->ComboD[targetLoc - 16] = firstCombo + 2;
}
}
if (targetLoc < 160)
{
if (Screen->ComboD[targetLoc + 16] == firstCombo + 1)
{
Screen->ComboD[targetLoc + 16] = firstCombo + 2;
}
}
if (targetLoc % 16 > 0)
{
if (Screen->ComboD[targetLoc - 1] == firstCombo + 1)
{
Screen->ComboD[targetLoc - 1] = firstCombo + 2;
}
}
if (targetLoc % 16 < 15)
{
if (Screen->ComboD[targetLoc + 1] == firstCombo + 1)
{
Screen->ComboD[targetLoc + 1] = firstCombo + 2;
}
}
}
else if (targetTile == 2)
{
if (countCombos(firstCombo) <= maxBlues)
{
ffc this2 = Screen->LoadFFC(targetFFC);
this2->CSet = 0;
}
this1->Data = 0;
Quit();
}
}
}
}
}

Description:
5 parameters, but you can leave the last one at 0 and it will work.
The first parameter is the FFC number.
The second parameter is the number of the first of 3 consecutive combos used for this script.
- The first is the 'blue' tile. This changes to the second combo when Link steps on it while the script is running. Blue tiles are counted when the script ends.
- The second is the 'yellow' tile. This is simply what a blue tile turns into when Link steps on it. When Link steps on a blue tile, all adjacent yellow tiles are changed into the third combo.
- The third is the 'red' tile. If Link steps on one of these, the script starts wrapping up by turning all the yellow tiles red and counting the blue tiles left.
The third parameter is the maximum count of blue tiles that will activate another FFC when this one ends. If the count at the end of the script exceeds this number, then the other FFC will not be activated.
The fourth parameter is the number of the FFC that will be activated when this script ends and the number of blue tiles left is low enough.
The fifth parameter is a flag. If not set to 0, then Link will not 'step' on a tile if in the air.

Basic Uses:
Unfortunetly, you'll need another FFC that reacts to its CSet getting set to 0 in order to fully use this script. Try using one of my Utility Scripts.
This puzzle is as functional as it is in Oracle of Ages with one exception: the script only ends when you step on a red tile. Otherwise, the script creates a puzzle when Link must find a way to step on every blue tile without stepping on the same tile twice.

Cool Things:
Nothing prevents Link from stepping on combos that are not used in this script (in order to avoid stepping on red tiles).
The puzzle aspect is cool, but don't ingore the other uses this script has. The red combo could cycle to an unfavorable combo, thus creating one-time walkable floors.
If you don't want this script to ever trigger another FFC, hide a blue tile somewhere Link can't reach and set the second parameter to 0.
The Height Flag is a new twist on the puzzle. With it set, Link can avoid stepping on red tiles by jumping over them.
The script only tests the blue tile count if Link steps on a red tile. If the red tiles get cycled to a different combo, then Link can't finish the puzzle. I'll let you decide how to use this information.

Potential Updates:
I will add another flag that determines what happens when Link steps on a combo not used in this script. The options would include treating all other combos as red combos or simply making other combos change adjacent yellow combos to red. Also, I could modify the height flag to have tile effects dependant on Link being on the ground (such as blue tiles only changing to yellow if Link is on the ground, but changing yellow tiles into red tiles no matter what).