OK, I gave your code a thorough going-over and made the following changes. I'll try to explain what I did and why, but let me know if anything here is still confusing:
Code:
// Cane of Byrna (Item)- What? You say we already have an item in ZC called Cane of Byrna? But it doesn't work!
// That's what this is for. :) This is the item half of the Cane of Byrna. Using this modifies a FFC script to
// take away 1/4 of a Magic Container for every second this item is in use. That's 8 pieces of Magic.
import "std.zh"
import "CaneofByrnaFFC.z"
item script CaneByrnaItem
{
void run()
{
//Link->Item[4] = true;
//That would give Link a new clock each time the cane was used,
//even when it is turned off. That is clearly not desirable. I moved
//the giving of the clock to the FFC script.
if (CaneByrnaFFC.Activated == 0)
{
CaneByrnaFFC.Activated = 1;
}
else CaneByrnaFFC.Activated = 0;
}
}
Code:
// Cane of Byrna (FFC)- What? You say we already have an item in ZC called Cane of Byrna? But it doesn't work!
// That's what this is for. :) This is the FFC half of the Cane of Byrna. This half of it is modified by the
// item half, so that the FFC this is attached to becomes the little "ring" of protection around Link, and
// Link can't be damaged this way.
// Changeable Variables:
// FFCSet- The CSet of the FFC.
// FFCombo- The first combo the FFC uses.
// FFCombo2- What combo the FFC reverts to when the item's usage is complete. This is so it doesn't lose any of its Script data. :D
ffc script CaneByrnaFFC
{
int Activated = 0;
int FFCSet = 8;
int FFCombo = 404;
int FFCombo2 = 49;
void run()
{
ffc FFCLoad = Screen->LoadFFC(32);
//This infinite loop is required so that the script doesn't shut down
//after the first frame of the game.
while (true)
{
//The stuff in this loop will happen as long as the Cane is
//on. The Cane stops being on when Link runs out of magic
//or when the player manually toggles it, so we have to
//check for both of these exit conditions here.
while (Activated == 1 && Link->MP >= 8)
{
//As long as the Cane is in use, we have to make sure
//Link keeps the clock.
Link->Item[4] = true;
FFCLoad->TileWidth = 3;
FFCLoad->TileHeight = 3;
FFCLoad->EffectWidth = 48;
FFCLoad->EffectHeight = 48;
FFCLoad->Data = FFCombo;
FFCLoad->CSet = FFCSet;
FFCLoad->X = Link->X - 16;
FFCLoad->Y = Link->Y - 16;
Link->MP -= 8;
Waitframe();
}
//Take away Link's clock. Currently this doesn't quite work.
Link->Item[4] = false;
FFCLoad->TileWidth = 1;
FFCLoad->TileHeight = 1;
FFCLoad->EffectWidth = 16;
FFCLoad->EffectHeight = 16;
FFCLoad->Data = FFCombo2;
FFCLoad->CSet = 0;
//If the above while loop stopped because Link ran out of
//magic, we need to turn the Cane off.
Activated = 0;
Waitframe();
}
}
}
Run the code and you'll see it still doesn't quite work: after turning off the Cane, Link stays invincible for some amount of time until Link's clock runs out. I don't think there's any good workaround for this problem at this time; something like Link->InvincibilityTicks would have to be added.