//STATUS.ZH//

A library for processing and managing status effects applied to Link/Hero. Those status effects can be poitive, negative or both. Mostly status effects have a time limit, which , if expired, removes the status effect. Status effects and their remaining time are recorded into player`s save file. Maximum number of status effects is 32.

Setup.

1. Global script combining: put InitStatusEffects(); inside your Init global script. Put StatusEffectsUpdate1(); and UpdateStatusTimers(); BACK TO BACK inside the main loop of your Active global script, prior to Waitdraw(); If you have a function for handling custom status effect, you can put it between StatusEffectsUpdate1(); and UpdateStatusTimers(); commands. 
2. If you don`t want for ststus effects to persist into player`s save file, put ClearStatusEffectsOnReload() before main loop of Active GLobal script. 
3. Import and compile the library. It requires StdExtra.zh and all it`s dependencies.
4. Assign item and FFC scripts that come with library to approriate slots, 3 FFC and 3 item scripts total.
P.S. Instructions on adding more status effects as well as handling status effects (i.e. inside enemy scripts) are inside tect file inside downloaded archive.

Library configuration constants

const int UPDATE_TIMERS_WHILE_SCROLLING = 0; //Set this constant to any number other than 0, and status timers will count down even when the screen is scrolling.
const int PERSIST_STATUS_ON_CONTINUE = 0; //Set constant to 0 to prevent status effects from persisting through F6/Continue, or reloading save file.

Status effects have 4 phases:

bool HasStarted(int status){
		//Run code the moment the moment the status effect has been induced.
}

bool IsActive(int status){
	//This event runs once every frame.
}

bool HasExpired(int status){
	//Use this event if you need to run some more code right before expiration of status effect.
	//Do you remember "Doom" status effect from Final Fantasy RPG`s?
}

bool HasRemoved(int status){
	//You could also run code here, if you want to execute some nasty surprises
	//when player attempts to cure this status effect.		
}

Each status effect must have it`s own ID to avoid conflicts.

Functions that manipulate status effects:

void InduceStatusEffect (int status, int duration, int nullifier, bool uncurable)
//Induces given status effect with set time.
//Set "nullifier" to allow specific item to prevent specific status effect/s from being applied to Link.
//"Uncurable" boolean controls whether the status effect can be removed by various means or not.
//Pass STATUS_TIME_PERMANENT into "duration" for permanent status effect (no time limit).
// /!\ WARNING! Current Status effects and their remaining timers are recorded in player`s save file!

void RemoveStatusEffect(int status, bool uncurableforceremove)
//Removes the given status effect.
// "uncurableforceremove" when set to TRUE bypasses default inability to remove status effect by default means and removes this status effect no matter what.

bool IsPermanent (int status)
//Returns TRUE if the given status effect is permanent and therefore does not expire over time.

bool IsCurable(int status)
//Returns TRUE if the given status effect cannot be cured by normal ways.

Item scripts

item script SetStatusEffect
//Item that applies status effect (usually positive) on activation. Best used on potions.
//Can be assigned on either "OnPickup" and "OnAction" script slots.
//D0: ID of Status to apply.
//D1: Effect duration. 
//D2: Sound to play on usage.

item script CureStatusEffect
//Item that removes specific status effect when used/picked up, like various antidotes.
//Can be assigned on either "OnPickup" and "OnAction" script slots.
//D0: Status to remove.
//D1: Clear normally uncurable status effect. 0 - false, 1 - true.

item script CureALL
//Removes ALL curable status effects when used/picked up. Like the milk in Minecraft.
//Can be assigned on either "OnPickup" and "OnAction" script slots.
//No arguments needed.

FFC scripts

ffc script FairyStatusRemover
//Step on FFC with this script and all curable status effect will be removed instantly.
//Place invisible FFC on the same place as Fairy Ring combo flags.
//D0: sound to play on curing status effects.

ffc script CursedZone
//This FFC script curses any character with given status effect as long as this script is active.
//Place invisible FFC anywhere in the screen.
//D0: Index to status array. Set it to define which status effect is induced.
//D1: Item that prevents this curse as long as it`s in character`s inventory.

ffc script StatusDebug
//This is a FFC script for testing and debugging status effects. Any time Link gets hurt by anything
//on the screen with this DDC script active he will instantly cursed by given status effect for the given time.
//Use this script to debug custom status effects.
//Controls: L/R to cycle trough status effects to apply to Link.
//Place FFC anywhere in the screen.
// D0 - Default index to status effect.
// D1 - Duration, in frames.
//  Set D1 to 200000 to render status effect permanent.

Default status effects.
By default, status.zh has 8 negative status effects that can be applied to Link.
0 - Poison. Damages Link over time. 
//Constants used by poison status effect.
const int POISON_DAMAGE = 4; // 1/4 heart every 1/2 second is lost when poisoned.
const int POISON_TIMER = 30; // Feel free to change these two constants prior to compiling.
1 -  Good old "Drunk" status effect from ZC.
2 - Reverses Left and Right + Up and Down.
3 - Makes Link lose all MP and disables gaining any MP. Also known as CURSE.
4 - Jinxes A button.
5 - Jinxes B button.
6 - Fills the screen white for simulating being blinded.
7 - Turns Link into an immobile stone statue.
const int CSET_STONE = 11; //CSet used for drawing pertified Link. Change to 7 for Frozen Link or to 5
//for Midas curse, which means turned into golden statue.
