I was looking for a script to implement bottles, but I couldn't find one, so I made one.
These scripts implements 4 bottles and 4 different types of potions. Setting them up is quite involved, and requires 20 custom items and 4 custom item classes. Rather than writing a prolonged explanation I'll just post the code, and if you can't figure it out ask me. I have tested this and it works on the quest I am building. Note that the item numbers in the script apply to my custom quest, and they'll be different for you, as will sound effect and string numbers. I'm still new to scripting, so feel free to improve on them in any way, but please give me credit if you use this.
Once this is implemented, you can add each of the custom item classes to your subscreen, and you have 4 independent bottles, each one can have different contents, and be used individually. The bottles can be used over and over. And since you are slotting the script into the built-in potion items, you can still use the Letter item to activate the shop. Let me know what you think, and please feel free to ask if you need help setting the items up.Code://Bottle Scripts //by FlounderMAJ //This is a script for empty bottles! //D0 is the item number for the pickup potion/bottle item, D1, D2, D3 and D4 are //the item numbers for each potion or other bottle item. //The four Bottle variables in the script are the item numbers of your bottles. //These will always be the same for your quest. //D5 is a pickup string, and D6 is a String stating there are no empty bottles. //D7 is the amount of Rupees to return to Link if there is no empty bottle available. //For this script to work, Each bottle must be a separate item in a separate custom item class, //and EACH potion type will have an item for EACH bottle, in the custom item class mathing the respective bottle. //For 4 Bottles and 4 types of potions/bottle items, this requires 20 custom items in 4 custom item classes. //This script should be slotted as a pickup script for the built-in potion type items. //Use this table to organize the D0-D7 needed to set up each item. //+------------+--------+------------+-------------+--------------+---------------+----------+ //| Item class | Bottle | Red Potion | Blue Potion | Green Potion | Purple Potion | Variable | //+------------+--------+------------+-------------+--------------+---------------+----------+ //| Potions (for pickup)| 29 | 30 | 125 | 126 | D0 | //| Custom 1 | 127 | 129 | 135 | 139 | 63 | D1 | //| Custom 2 | 128 | 130 | 136 | 140 | 55 | D2 | //| Custom 3 | 131 | 133 | 137 | 141 | 121 | D3 | //| Custom 4 | 132 | 134 | 138 | 50 | 120 | D4 | //| Pickup String | 10 | 11 | 12 | 13 | D5 | //| No Bottle String | 14 | 14 | 14 | 14 | D6 | //| Rupees to return | 40 | 160 | 40 | 60 | D7 | //+---------------------+------------+-------------+--------------+---------------+----------+ item script emptybottle { void run(int pickup, int potion1, int potion2, int potion3, int potion4, int string1, int string2, int rupees) { int bottle1=127; int bottle2=128; int bottle3=131; int bottle4=132; Link->Item[pickup]=false; if (Link->Item[bottle1]) { Link->Item[potion1]=true; Link->Item[bottle1]=false; Screen->Message(string1); } else if (Link->Item[bottle2]) { Link->Item[potion2]=true; Link->Item[bottle2]=false; Screen->Message(string1); } else if (Link->Item[bottle3]) { Link->Item[potion3]=true; Link->Item[bottle3]=false; Screen->Message(string1); } else if (Link->Item[bottle4]) { Link->Item[potion4]=true; Link->Item[bottle4]=false; Screen->Message(string1); } else { Game->Counter[1]=(Game->Counter[1]+rupees); Game->PlaySound(69); Screen->Message(string2); } } } //This Script is for the bottle potions. //D0 is the item number of the potion you are using, D1-D4 are the items corresponding to the 4 potion types. //D5 is the corresponding empty bottle for that potion set, and D6 is a string that is displayed when //Link tries to use an empty bottle. D7 is a sound effect to play. //The item numbers should be listed in the table above. //This script should be slotted as the action script for each bottle item, including the empty bottle. item script potions { void run(int PotionUsed, int Red, int Blue, int Green, int Purple, int Bottle, int String, int sfx) { Link->Item[29]=false; //These lines remove any pickup potions Link has, Link->Item[30]=false; //see table above and change item numbers to match Link->Item[125]=false; Link->Item[126]=false; Link->Item[Bottle]=true; Game->PlaySound(sfx); if (PotionUsed==Red) { Link->HP=Link->MaxHP; Link->Item[PotionUsed]=false; } if (PotionUsed==Blue) { Link->HP=Link->MaxHP; Link->MP=Link->MaxMP; Link->Item[PotionUsed]=false; } if (PotionUsed==Green) { Link->MP=Link->MaxMP; Link->Item[PotionUsed]=false; } if (PotionUsed==Purple) { if (Link->MaxHP<129) { Link->HP=Link->MaxHP; Link->Item[PotionUsed]=false; } else { Link->HP=Link->HP+128; Link->Item[PotionUsed]=false; } } if (PotionUsed==Bottle) { Screen->Message(String); } } } //This Global script is designed to work with the purple potion, and to automatically restore 4 hearts of health to Link //if his health drops to 0. May be used to implement bottle fairies also. the Item numbers used should match the table //above, and the sound effect and amount of health restored can be adjusted as well. Paste the contents of the while(true) //loop into your own loop on your own custom global script if you want to. Remember to copy the variable declarations also. global script BottlesGlobal { void run() { int purple1=63; int purple2=55; int purple3=121; int purple4=120; int bottle1=127; int bottle2=128; int bottle3=131; int bottle4=132; int sfx=25; int RestoreAmt=64; while (true) { if (Link->HP==0) { if (Link->Item[purple1]) { Link->Item[bottle1]=true; Link->Item[purple1]=false; Game->PlaySound(sfx); if (Link->MaxHP<(RestoreAmt-1)) { Link->HP=Link->MaxHP; } else { Link->HP=Link->HP+RestoreAmt; } } else if (Link->Item[purple2]) { Link->Item[bottle2]=true; Link->Item[purple2]=false; Game->PlaySound(sfx); if (Link->MaxHP<(RestoreAmt-1)) { Link->HP=Link->MaxHP; } else { Link->HP=Link->HP+RestoreAmt; } } else if (Link->Item[purple3]) { Link->Item[bottle3]=true; Link->Item[purple3]=false; Game->PlaySound(sfx); if (Link->MaxHP<(RestoreAmt-1)) { Link->HP=Link->MaxHP; } else { Link->HP=Link->HP+RestoreAmt; } } else if (Link->Item[purple4]) { Link->Item[bottle4]=true; Link->Item[purple4]=false; Game->PlaySound(sfx); if (Link->MaxHP<(RestoreAmt-1)) { Link->HP=Link->MaxHP; } else { Link->HP=Link->HP+RestoreAmt; } } } Waitframe(); } } }
Happy Questing,
FlounderMAJ