////////////////////////////// /// GENERAL POTIONS SCRIPT /// //////////////////////////////////////////////////////////////////////////////////////////////////// /// By: ZoriaRPG - v4.4 - Updated 29th April 2014 /// //////////////////////////////////////////////////////////////////////////////////////////////////// /// This ITEM SCRIPT is used to create a variety of portion types, using a series of flags that /// /// determine if the potion will restore health (HP), magic (MP), or both; and if the potion is /// /// to fully restore these, set D0 to 3, and leave D1 and D2 set to 0. /// /// /// ///======================================{ARGUMENT D0}===========================================/// /// /// /// If you set D0 to 1, the potion will restore FULL HP. If you also set D2 to a value greater /// /// than zero, you can restore full HP and restore a specific amount of MP with the item. /// ///----------------------------------------------------------------------------------------------/// /// If you set D0 to 2, the potion will restore FULL MP. If you also set D1 to a value greater /// /// than zero, you can restore full MP, and a specific amount of HP with the item. /// ///----------------------------------------------------------------------------------------------/// /// If you set D0 to 0, then you must specify HP and MP amounts. It will not restore either to /// /// maximum by default. Set the amount of HP to restore as a value for argument D1, keeping in /// /// mind that BY DEFAULT, one heart is 16HP, so for every heart that you wish to restore, use a /// /// multiple of 16 (e.g. 64 for FOUR HEARTS). /// /// /// /// Likewise, set the amount of MP that you wish to restore, using D2. Magic is calculated in /// /// block of 32 BY DEFAULT, so for every block of magic that you wish to restore, use a multiple /// /// of 64 (e.g. 256 for FOUR BLOCKS of MAGIC). /// ///----------------------------------------------------------------------------------------------/// /// RESTORE ALL (D0) Flag List: 0 = None --- 1 = HP --- 2 = MP --- 3 = BOTH /// /// /// ///======================================{ARGUMENT D1}===========================================/// /// /// /// Set D1 to a value of HEALTH that you wish to restore, if not restored in full by Argument D0 /// /// keeping in mind that ONE HEART is 16HP by DEFAULT. If you have changed the value of blocks /// /// of health, then use those new values; else set any specific amount that you desire. /// /// /// ///======================================{ARGUMENT D2}===========================================/// /// /// /// Set D1 to a value of MAGIC that you wish to restore, if not restored in full by Argument D0 /// /// keeping in mind that ONE MAGIC BLOCK is 32MP by DEFAULT. If you have changed the value of /// /// of MAGIC BLOCKS, then use those new values; else set any specific amount that you desire. /// /// /// ///======================================{ARGUMENT D3}===========================================/// /// /// /// Argument D3 sets a flag, that determines if the item will make a check, to see if the HP/MP /// /// of the player is FULL, and prevent WASTING the item. This prevents accidental use of potions /// /// when rotating through inventory (e.g. with L/R). /// ///----------------------------------------------------------------------------------------------/// /// Setting D3 to a value of 0, always checks BOTH HP and MP, and if they are full, will either /// /// present a CONFIRMATION MESSAGE, set in ARGUMENT D4, and play a ERROR SOUND, set in ARGUMENT /// /// D6; or if no CONFIRMATION MESSAGE is set, will simply play the ERROR SOUND. /// ///----------------------------------------------------------------------------------------------/// /// Setting D3 to a value of 1, checks only if HP is full. if HP is full, the sound set as the /// /// ERROR SOUND in Argument D4 will play, and a CONFIRMATION message will give the player the /// /// choice of using the item anyway, if you set ARGUMENT D4 with a value GREATER THAN ZERO. /// /// Else, it will only play the error sound. /// ///----------------------------------------------------------------------------------------------/// /// Setting D3 with a value of 2, works as with a value of 1, but for MP. The game will check to /// /// see if the MAGIC gauge is fill, and if it is, it will play the ERROR SOUND, and display the /// /// CONFIRMATION MESSAGE. If the value of D4 is ZERO, then it will only play the ERROR SOUND. /// ///----------------------------------------------------------------------------------------------/// /// Setting D3 to a value of 3, will ALWAYS use the item, even if HP/MP are FULL! /// ///----------------------------------------------------------------------------------------------/// /// Setting D4 to a value of 4, will ALWAYS display the CONFIRMATION PROMPT that you set in D4. /// /// Use this, if you want to display a message, asking the player to confirm item use, whether /// /// the HP/MP is full, or not. /// ///----------------------------------------------------------------------------------------------/// /// CHECK CURRENT (D3) Flag List: /// /// 0 = BOTH -- 1 = HP -- 2 = MP -- 3 = NONE (ALWAYS USE) -- 4 = NONE (ALWAYS PROMPT) /// /// /// ///======================================{ARGUMENT D4}===========================================/// /// /// /// Arguent D4 is used to set the CONFIRMATION MESSAGE STRING. Create a string in ZQuest, and /// /// set this to the NUMERIC VALUE of that string. /// /// /// ///======================================{ARGUMENT D5}===========================================/// /// /// /// Set this to the SOUND EFFECTS (in Quest>Audio->SFX Data), that you wish to play when the /// /// item is USED, refilling HEALTH or MAGIC. Use the number of the SOUND EFFECT from the SFX /// /// EDITOR to set the sound to play. /// /// /// ///======================================{ARGUMENT D6}===========================================/// /// /// /// Set this to the ERROR SOUND (in Quest>Audio->SFX Data), that you wish to play if the HEALTH /// /// or MAGIC gauges are full, as set by the D3 FLAG, whe displaying a CONFIRMATION MESSAGE, or /// /// otherwise producing an ERROR SOUND: Use the number of the SOUND EFFECT from the SFX EDITOR. /// /// /// ///======================================{ARGUMENT D7}===========================================/// /// /// /// Set this value to the ITEM NUMBER for this SPECIFIC ITEM, using the numeric value from the /// /// ITEM EDITOR (the ITEM ID). THis is ued to clear the item after use, and can be used as a /// /// pointer for other functions. /// /// /// /// Further, this argument sets the FFC slot to run the FFC component of this script, that the /// /// script calls to generate the CONFIRMATION MESSAGE strings, and confirmation effects. /// /// /// /// Set the ITEM NUMBER as a DECIMAL VALUE, and the FFC SLOT as the INTEGER VALUE of D7! /// /// Example: if the Item Number of this item is 150, and the FFC Slot for ConfirmationPrompt FFC /// /// is 3, your woul enter a vale of 3.0150 in Argument D7. The Integer portion (3) is the FFC /// /// slot, and the decimal portion (0150, thus 150), is the item number! /// //////////////////////////////////////////////////////////////////////////////////////////////////// int GetIntArgument(int arg) {return arg >> 0;} int GetDecArgument(int arg) {return (arg - (arg >> 0)) * 10000;} item script Potions { void run(int FullRefillType, int hp, int mp, int Gradual_HPMP_Flag, int ERROR_STRING, int POTION_SFX, int ERROR_SFX, int ffcSlot_itemNumber) { int MP_Max = Game->MCounter[CR_MAGIC]; int HP_Max = Game->MCounter[CR_LIFE]; int itemNumber = GetDecArgument(ffcSlot_itemNumber); int ffcSlot = GetIntArgument(ffcSlot_itemNumber); int Gradual = GetDecArgument(Gradual_HPMP_Flag) int HPMP_Flag = GetDecArgument(Gradual_HPMP_Flag) if ( HPMP_Flag == 0 ) { //Check if HP & MP are full. if ( FullRefillType == 3 && Link->MP < Link->MaxMP && Link->HP < Link->MaxHP ){ Link->HP += HP_Max; Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp == 0 && Link->MP < Link->MaxMP ){ Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp > 0 && Link->MP < Link->MaxMP && Link->HP < Link->MaxHP ){ Link->MP += MP_Max; Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp == 0 && Link->HP < Link->MaxHP ){ Link->HP += HP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp > 0 && Link->HP < Link->MaxHP && Link->MP < Link->MaxMP ){ Link->HP += HP_Max; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } if ( FullRefillType == 0 && hp > 0 && mp > 0 && Link->MP < Link->MaxMP && Link->HP < Link->MaxHP ){ Link->HP += hp; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && hp > 0 && Link->HP < Link->MaxHP ){ Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && mp > 0 && Link->MP < Link->MaxMP ){ Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else { if ( ERROR_STRING == 0) { Game->PlaySound(ERROR_SFX); } if ( ERROR_STRING > 0) { if(CountFFCsRunning(ffcSlot) == 0){ int args[8] = {FullRefillType, hp, mp, HPMP_Flag, ERROR_STRING, POTION_SFX, ERROR_SFX, ffcSlot_itemNumber}; RunFFCScript(ffcSlot, args); } } } } else if ( HPMP_Flag == 1 ) { //Check only if HP is full. if ( FullRefillType == 3 && Link->HP < Link->MaxHP ){ Link->HP += HP_Max; Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp == 0 ){ Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp > 0 && Link->HP < Link->MaxHP ){ Link->MP += MP_Max; Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp == 0 && Link->HP < Link->MaxHP ){ Link->HP += HP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp > 0 && Link->HP < Link->MaxHP ){ Link->HP += HP_Max; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } if ( FullRefillType == 0 && hp > 0 && mp > 0 && Link->HP < Link->MaxHP ){ Link->HP += hp; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && hp > 0 && Link->HP < Link->MaxHP ){ Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && mp > 0 ){ Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else { if ( ERROR_STRING == 0) { Game->PlaySound(ERROR_SFX); } if ( ERROR_STRING > 0) { if(CountFFCsRunning(ffcSlot) == 0){ int args[8] = {FullRefillType, hp, mp, HPMP_Flag, ERROR_STRING, POTION_SFX, ERROR_SFX, ffcSlot_itemNumber}; RunFFCScript(ffcSlot, args); } } } } else if ( HPMP_Flag == 2 ) { //Check only if MP is full. if ( FullRefillType == 3 && Link->MP < Link->MaxMP ){ Link->HP += HP_Max; Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp == 0 && Link->MP < Link->MaxMP ){ Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp > 0 && Link->MP < Link->MaxMP ){ Link->MP += MP_Max; Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp == 0 ){ Link->HP += HP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp > 0 && Link->MP < Link->MaxMP ){ Link->HP += HP_Max; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } if ( FullRefillType == 0 && hp > 0 && mp > 0 && Link->MP < Link->MaxMP ){ Link->HP += hp; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && hp > 0 ){ Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && mp > 0 && Link->MP < Link->MaxMP ){ Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else { if ( ERROR_STRING == 0) { Game->PlaySound(ERROR_SFX); } if ( ERROR_STRING > 0) { if(CountFFCsRunning(ffcSlot) == 0){ int args[8] = {FullRefillType, hp, mp, HPMP_Flag, ERROR_STRING, POTION_SFX, ERROR_SFX, ffcSlot_itemNumber}; RunFFCScript(ffcSlot, args); } } } } else if ( HPMP_Flag == 3 ) { //Use even if HP & MP are full. if ( FullRefillType == 3 ){ Link->HP += HP_Max; Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp == 0 ){ Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp > 0 ){ Link->MP += MP_Max; Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp == 0 ){ Link->HP += HP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp > 0 ){ Link->HP += HP_Max; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } if ( FullRefillType == 0 && hp > 0 && mp > 0 ){ Link->HP += hp; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && hp > 0 ){ Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && mp > 0 ){ Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else { Game->PlaySound(ERROR_SFX); } } else if ( HPMP_Flag == 4 ) { //Use this flag to always prompt the player with an 'Are you sure?' message, with A for yes, and B for no. if(CountFFCsRunning(ffcSlot) == 0) { int args[8] = {FullRefillType, hp, mp, HPMP_Flag, ERROR_STRING, POTION_SFX, ERROR_SFX, ffcSlot_itemNumber}; RunFFCScript(ffcSlot, args); } } } } ffc script ConfirmationPrompt { void run(int FullRefillType, int hp, int mp, int HPMP_Flag, int ERROR_STRING, int POTION_SFX, int ERROR_SFX, int ffcSlot_itemNumber) { bool waiting = true; int itemNumber = GetDecArgument(ffcSlot_itemNumber); int ffcSlot = GetIntArgument(ffcSlot_itemNumber); int MP_Max = Game->MCounter[CR_MAGIC]; int HP_Max = Game->MCounter[CR_LIFE]; while(true) { if (waiting == true) { Screen->Message(ERROR_STRING); if ( Link->PressA ) { waiting = false; if ( FullRefillType == 3 ){ Link->HP += HP_Max; Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp == 0 ){ Link->MP += MP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 2 && hp > 0 ){ Link->MP += MP_Max; Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp == 0 ){ Link->HP += HP_Max; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 1 && mp > 0 ){ Link->HP += HP_Max; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } if ( FullRefillType == 0 && hp > 0 && mp > 0 ){ Link->HP += hp; Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && hp > 0 ){ Link->HP += hp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } else if ( FullRefillType == 0 && mp > 0 ){ Link->MP += mp; Game->PlaySound(POTION_SFX); Link->Item[itemNumber] = false; } } else if ( Link->PressL ) { waiting = false; } else if ( Link->PressR ) { waiting = false; } else if ( Link->PressB ) { waiting = false; } } Waitframe(); } } }