HeroOfFire
06-10-2007, 07:01 PM
A very simple, yet still useful utility script.
Script #3 Spawn Item
Spawns an item at the FFC's position when activated.
It can be flagged to spawn the item only if Link doesn't already have it.
//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 SpawnItem
//Script that creates an item at the FFC's postion when activated
//Can be used to create common items infinetly or rare items once
//Not good to use with dungeon items (Map, Compass, Keys)
//D0 = FFC Number (starts at 1)
//D1 = Number of the item to be spawned
//D2 = If 1, check Link's inventory to see if he already has the item (good for one-time spawning)
ffc script SpawnItem {
void run(float thisFFC, int itemSpawn, int checkInventory) {
ffc this1 = Screen->LoadFFC(thisFFC);
while (true)
{
if (this1->CSet == 0)
{
if (checkInventory == 1)
{
if (Link->Item[itemSpawn] == false)
{
item iSpawn = Screen->CreateItem(itemSpawn);
iSpawn->X = this1->X;
iSpawn->Y = this1->Y;
}
}
else
{
item iSpawn = Screen->CreateItem(itemSpawn);
iSpawn->X = this1->X;
iSpawn->Y = this1->Y;
}
this1->Data = 0;
Quit();
}
Waitframe();
}
}
}
Quick Overview:
This script has 3 parameters.
The first is the FFC number.
The second is the item ID (via the I constants in std.zh).
The third is a flag. If 1, check Link's inventory for the item about to be spawned and spawn it only if Link doesn't have it.
Basic Uses:
Spawn an item when you trigger a secret (possibly through killing all enemies).
Spawn an item by activating this script through another script (like my FFCInterface).
Cool Things:
Infinite spawning potential: You can spawn the item every time you enter the room and activate the FFC.
Moving Item Spawn: Why can't the FFC be moving around?
2+ items per screen: You can spawn mutliple items by using this script.
Awsome Idea:
Try this. FFC1 = FFCInterface. FFC2 = SpawnItem. FFC3 = ProgressChecker.
FFC2 is placed over a solid block and looks like a treasure chest.
FFC3 is set to waiting for activation and will change the solid block under FFC2 into an open treasure chest.
FFC1 looks like a button and activates both FFC2 and FFC3 when you step on it.
Volia! A treasure chest triggered by FFCs and no secret combos (meaning you can have multiple per screen).
Flaw:
Dungeon items are a bit strange. You can't really check for keys (can you?), and there is no point in infinetly spawning maps, compasses, keys, or boss keys. Triforce items are also a bad idea to mutli-spawn.
Possible Updates:
Maybe I'll add a few if statements to check for problems, but otherwise, this script works well.
Script #3 Spawn Item
Spawns an item at the FFC's position when activated.
It can be flagged to spawn the item only if Link doesn't already have it.
//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 SpawnItem
//Script that creates an item at the FFC's postion when activated
//Can be used to create common items infinetly or rare items once
//Not good to use with dungeon items (Map, Compass, Keys)
//D0 = FFC Number (starts at 1)
//D1 = Number of the item to be spawned
//D2 = If 1, check Link's inventory to see if he already has the item (good for one-time spawning)
ffc script SpawnItem {
void run(float thisFFC, int itemSpawn, int checkInventory) {
ffc this1 = Screen->LoadFFC(thisFFC);
while (true)
{
if (this1->CSet == 0)
{
if (checkInventory == 1)
{
if (Link->Item[itemSpawn] == false)
{
item iSpawn = Screen->CreateItem(itemSpawn);
iSpawn->X = this1->X;
iSpawn->Y = this1->Y;
}
}
else
{
item iSpawn = Screen->CreateItem(itemSpawn);
iSpawn->X = this1->X;
iSpawn->Y = this1->Y;
}
this1->Data = 0;
Quit();
}
Waitframe();
}
}
}
Quick Overview:
This script has 3 parameters.
The first is the FFC number.
The second is the item ID (via the I constants in std.zh).
The third is a flag. If 1, check Link's inventory for the item about to be spawned and spawn it only if Link doesn't have it.
Basic Uses:
Spawn an item when you trigger a secret (possibly through killing all enemies).
Spawn an item by activating this script through another script (like my FFCInterface).
Cool Things:
Infinite spawning potential: You can spawn the item every time you enter the room and activate the FFC.
Moving Item Spawn: Why can't the FFC be moving around?
2+ items per screen: You can spawn mutliple items by using this script.
Awsome Idea:
Try this. FFC1 = FFCInterface. FFC2 = SpawnItem. FFC3 = ProgressChecker.
FFC2 is placed over a solid block and looks like a treasure chest.
FFC3 is set to waiting for activation and will change the solid block under FFC2 into an open treasure chest.
FFC1 looks like a button and activates both FFC2 and FFC3 when you step on it.
Volia! A treasure chest triggered by FFCs and no secret combos (meaning you can have multiple per screen).
Flaw:
Dungeon items are a bit strange. You can't really check for keys (can you?), and there is no point in infinetly spawning maps, compasses, keys, or boss keys. Triforce items are also a bad idea to mutli-spawn.
Possible Updates:
Maybe I'll add a few if statements to check for problems, but otherwise, this script works well.