Custom Item scripts volume 1: Using Global effects for custom items.


This thread will be updated and added to regularly so check back often.


If you don't have a Global script yet, then use this as the "shell".

*NOTE*These won't be complete global scripts, instead they will be "segments" that you copy/paste into your global script.

Code:
//import "std.zh"

//===========================
// Global variables go here
//===========================



global script Name_this_script{

	void run(){

	//===========================
	// other variables go here
	//===========================


		while(true){



			//=========================================
			// insert new effects here
			//=========================================



			//=========================================
			// insert new effects here
			//=========================================



			//=========================================
			// insert new effects here
			//=========================================



		Waitframe();
		}
	}
}
Shield spell: Increases defense. (it gives Link a ring for a short time)

Code:
item script Porfic{

	void run(){

		if(porfic_level == 3 && Link->MP >= 64){
			porfic_shield = 3;Link->MP -= 64; porfic_exp++;}
		else{
			if(porfic_level >= 2 && Link->MP >= 32){
				porfic_shield = 2;Link->MP -= 32; porfic_exp++;}
			else{
				if(porfic_level >= 1 && Link->MP >= 16){
					porfic_shield = 1;Link->MP -= 16; porfic_exp++;}
			}
		}
	}
}

Global add-ons:

-Global variables:

Code:
	int porfic_level = 1;		// shield
	int porfic_exp = 0;
	int porfic_shield = 0;
	int porfic_timer = 0;
Global Script add-on:

Code:
			if(porfic_shield != 0){

				if(porfic_level == 1){Link->Item[17] = true;}
				if(porfic_level == 2){Link->Item[18] = true;}
				if(porfic_level == 3){Link->Item[61] = true;}
				porfic_shield = 0;
				porfic_timer = 300 + porfic_exp;
			}
			if(porfic_timer > 0){
				porfic_timer--;
				if(porfic_timer == 0){
					Link->Item[17] = false;
					Link->Item[18] = false;
					Link->Item[61] = false;
				}
			}
Curently not functional: Actually leveling up the item.

Note that these are default std.zh item numbers.