PDA

View Full Version : Oh noes! Script problems again!



Nimono
07-30-2007, 07:43 PM
Yes, I'm having problems with my script... But no, this time it's not something simple like me forgetting some ;'s or ints.... No, it's more of how the script is working.

I've set up a global script that constantly checks for one of four items in Link's possession. If he has one, the script does the appropriate thing, and continues on. What is it supposed to do? Refill his hearts by a certain amount when they reach zero. My problem? If his hearts reach zero, the script's effect never kicks in. I had anticipated this problem, but I do not know how to counteract it, or even if I can. This script relies on the thought that scripts work before the Game Over sequence, as the script is supposed to mimic the effect of the Magic Potion in the GB Zeldas, and the Bottled Fairies, in that it refills your Hearts when they hit zero. Problem is, it looks like the Game Over sequence works BEFORE scripts do. Is there any way to fix this? ...Oh, right. The script. ...Ummm... Here's what I've got, after a little changing. It used to have Waitframe();'s and "while" loops....


// Magic Potion/Bottled Fairy- This script will make the Potion items automatically refill your Hearts when you lose them all like the Magic Potion
// in the GB Zeldas and the Bottled Fairy in other games.
// Constants:
// Potion1- First Potion item. Should be set to the normal Potion 1.
// Potion2- Second Potion item. Should be set to the normal Potion 2. When used, reverts to Potion 1, normally.
// Potion3- Third Potion item. Can be used to have a Bottled Fairy if you wish to have Magic Potions and Bottled Fairies in the same quest.
// Potion4- Fourth Potion item. See Potion 3's note. Works much like Potion 2, normally.
// Heal1- How many Hearts Potion 1 restores if used by this script.
// Heal2- How many Hearts Potion 2 restores if used by this script.
// Heal3- How many Hearts Potion 3 restores if used by this script.
// Heal4- How many Hearts Potion 4 restores if used by this script.
// Effect1- If 0, then Potion2 turns into Potion1 when used by this script. If 1, then Potion2 vanishes when used by this script.
// Effect2- Same as above, but with Potion4 and Potion3 instead.
// Effect3- If Effect1 is 1, and this is 1, then if Potion2 is used, Potion1 is removed from your inventory if you have it (If "Can Keep Lower Level Items"
// is on for Potion2).
// Effect4- Like Effect3, but for Potions 3 and 4 instead.

import "std.zh"

const int Potion1 = 29;
const int Potion2 = 30;
const int Potion3 = 0;
const int Potion4 = 0;
const int Heal1 = 384; //384 is 24 Heart Containers in 16ths of a Heart...
const int Heal2 = 394;
const int Heal3 = 96;
const int Heal4 = 96;
const int Effect1 = 0;
const int Effect2 = 0;

global script FairyPotion
{
void run()
{
if(Link->Item[Potion1])
{
if(Link->HP == 0)
{
Link->HP = Heal1;
Link->Item[Potion1] = false; //removes Potion1 from your inventory.
}
}
if(Link->Item[Potion2])
{
if(Link->HP == 0)
{
Link->HP = Heal2;
Link->Item[Potion2] = false; //removes Potion2 from your inventory.
if(Effect1 == 0)
{
if(!Link->Item[Potion1])
{
Link->Item[Potion1] = true; //gives you Potion1.
}
}
}
}
if(Link->Item[Potion3])
{
if(Link->HP == 0)
{
Link->HP = Heal3;
Link->Item[Potion3] = false; //removes Potion3 from your inventory.
}
}
if(Link->Item[Potion4])
{
if(Link->HP == 0)
{
Link->HP = Heal4;
Link->Item[Potion4] = false; //removes Potion4 from your inventory.
if(Effect1 == 0)
{
if(!Link->Item[Potion3])
{
Link->Item[Potion3] = true; //gives you Potion3.
}
}
}
}
}
}

Thanks for any help you can offer me... :(

Edit: Oh yeah, ignore the last two "effect" things. I forgot to add those in... >_>

pkmnfrk
07-30-2007, 09:37 PM
Global scripts only run for 1 frame, then die on Quit() or Waitframe().

Nimono
07-30-2007, 11:06 PM
I figured that, but...

Do you think it'd work better as an FFC script instead?

pkmnfrk
07-31-2007, 12:00 AM
I guess you don't have much choice. On each screen where Link can start, you must put an invisible FFC with the carry over flag, and your script attached.

Nimono
07-31-2007, 12:28 AM
I guess you don't have much choice. On each screen where Link can start, you must put an invisible FFC with the carry over flag, and your script attached.

I'll try that. Thanks...

C-Dawg
07-31-2007, 06:00 PM
That's tricky. Remember that FFCs stop carrying over if:
(1) The player leaves the screen while the FFC's (x,y) location is off of the screen;
(2) The player leaves the screen while the FFC's assigned Combo is Combo 0; (3) The player dies; or
(4) The player is returned to a continue point by a whirlwind or wallmaster.

So you need to make sure you protect your FFCs or compensate for these events.

Nimono
07-31-2007, 06:22 PM
That's tricky. Remember that FFCs stop carrying over if:
(1) The player leaves the screen while the FFC's (x,y) location is off of the screen;
(2) The player leaves the screen while the FFC's assigned Combo is Combo 0; (3) The player dies; or
(4) The player is returned to a continue point by a whirlwind or wallmaster.

So you need to make sure you protect your FFCs or compensate for these events.

There's a bit of a problem with number 3- That is supposed to happen to the player before this script is supposed to kick in. I can't get this script to restore Link's hearts before the death stuff happens. I think that Bottled Fairies are one thing that will remain impossible for the time being...