PDA

View Full Version : Lelouche's Potion Script



Lelouche Vi Britannia
03-15-2016, 10:51 PM
The idea behind this was an expansion on the potion script provided by Zim. One use potions that restore some HP or MP or both in the case of Rejuvenation potions. The way I have them designed in the quest, they restore about 6 hearts and/or 4 Mana Blocks (max in the quest is set at 24 Hearts and 16 Mana Blocks), equaling about a quarter of full restoration if both meters are maxed out. Max load is provided by invisible items which determine how big the counters can be (8 total per potion, might change later due to balance).

The code is designed to track the amount gained, and work the counter properly by subtracting the items as they are used and removing the item completely once the counter reaches zero. While I could have simplified the code some more, I figured I'd keep it the way it is so if I decided to change how the potions work in a future project, I have the freedom to do that in the editor.

While this code is probably not going to dazzle anyone, I'm quite proud of it. It's personal proof that I'm finally getting the basics down.



//Coding for all three potion types
//Health Potion here is Item 126, Mana Potion is 124, and Rejuv is 125
//D0=Type of potion where 0 is health only, 1 is mana only, and 2 is both
//D1=HP Restored
//D2=MP restored
//Script uses Counters 7,8, and 9, which is Script 1, Script 2, and Script 3 respectively, adjust as needed

const int CR_POTA = 7; //script 1 slot
const int CR_POTB = 8; //script 2 slot
const int CR_POTC = 9; //script 3 slot

item script potions
{
void run(int a,int b, int c)
{
if (a == 0)
{
if (Game->Counter[CR_POTA]==0)
{Quit();} //probably not necessary as there is no instance where the item counter will read 0 and the item is still in inventory
else
{
Link->HP+=b;
Game->Counter[CR_POTA]--;
Game->PlaySound(53);
if (Game->Counter[CR_POTA]==0){Link->Item[126]=false;}
}
}
if (a == 1)
{
if (Game->Counter[CR_POTB]==0)
{Quit();}
else
{
Link->MP+=c;
Game->Counter[CR_POTB]--;
Game->PlaySound(53);
if (Game->Counter[CR_POTB]==0){Link->Item[124]=false;}
}
}
if (a == 2)
{
if (Game->Counter[CR_POTC]==0)
{Quit();}
else
{
Link->HP+=b;
Link->MP+=c;
Game->Counter[CR_POTC]--;
Game->PlaySound(53);
if (Game->Counter[CR_POTB]==0){Link->Item[125]=false;}
}
}
}
}

jeffythedragonslayer
01-19-2024, 10:25 PM
Cool. Has this been used in any quests yet? Any videos?