Advertisement
ZoriaRPG

ItemHoldupMessage.zh v1.1

Aug 2nd, 2017
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.41 KB | None | 0 0
  1. ///////////////////////////
  2. /// Item Hold Up Header ///
  3. /// v1.1 for ZC 2.50.x  ///
  4. /// 2nd August, 2017    ///
  5. /// By: ZoriaRPG        ///
  6. ///////////////////////////
  7. // Demo Quest: http://timelord.insomnia247.nl/zc/zc_dev/ItemHoldUpMessage_zh.qst
  8.  
  9. //!!!!!!!!!!!!!!!!!!!!!
  10. //! Settings  
  11.  
  12. const int ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS = 1; //The number of hands to use for the default hold-up animation.
  13. const int ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE = 20; //Change to the sound that you want.
  14. const int ITEM_HOLDUP_ZH__ERROR_ON_NO_ITEM_NUMBER = 1; //Set to 0 to disable some logging.
  15.  
  16. //!!!!!!!!!!!!!!!!!!!!!
  17. //! Scripts
  18.  
  19. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  20. /// Item Script that Runs The FFCs
  21. /// D0: THe integer portion is the string to use, and the decimal portion is the item to display
  22. ///     during the hold-up animation:
  23. /// Example: 27.0016
  24. ///     This will use String 20, and display Item 16 in the hold-up animation.
  25.  
  26. item script PickMessageFFCLauncher
  27. {
  28.     void run(int string_itmID)
  29.     {
  30.         int foundff;
  31.         int __item_message_string = string_itmID << 0;
  32.         int this_item_id = ( string_itmID - __item_message_string ) * 10000;
  33.         int _____ffscript_id; int ___err_aborting[]="Aborting item hold-up.";
  34.  
  35.         if ( this_item_id > 0 && this_item_id < 256 )
  36.         {
  37.             if ( Link->Action == LA_DIVING )
  38.             {
  39.                 int ff[]="FFC_DiveHoldUp";
  40.                 _____ffscript_id = Game->GetFFCScript(ff);
  41.                 if ( _____ffscript_id < 1 )
  42.                 {   //Error and exit if the ffc script is not in the quest matrix.
  43.                     ItemHoldupZH_FFC_Failure_Error(ff, ___err_aborting);
  44.                     Quit();
  45.                 }
  46.             }
  47.             else if ( Link->Action == LA_SWIMMING  )
  48.             {
  49.                 int ff[]="FFC_SwimHoldUp";
  50.                 _____ffscript_id = Game->GetFFCScript(ff);
  51.                 if ( _____ffscript_id < 1 ) {
  52.                     //Error and exit if the ffc script is not in the quest matrix.
  53.                     ItemHoldupZH_FFC_Failure_Error(ff, ___err_aborting);
  54.                     Quit();
  55.                 }
  56.             }
  57.             else
  58.             {
  59.                 //Link is on land.
  60.                 int ff[]="FFC_ItemHoldUp";
  61.                 _____ffscript_id = Game->GetFFCScript(ff);
  62.                 if ( _____ffscript_id < 1 ) {
  63.                     //Error and exit if the ffc script is not in the quest matrix.
  64.                     ItemHoldupZH_FFC_Failure_Error(ff, ___err_aborting);
  65.                     Quit();
  66.                 }
  67.             }
  68.            
  69.             foundff = ItemHoldup_FindFreeFFC(); //Grab a free ffc.
  70.            
  71.             if ( foundff > 0 && foundff < 33 )
  72.             {   //if we find one, set it up to use the correct script.
  73.                 ItemHoldUp_SetUpFFC(foundff, _____ffscript_id, this_item_id, __item_message_string);
  74.                
  75.             }
  76.             if ( foundff <= 0  )
  77.             {
  78.                 //Error if we cannot grab a free ffc.
  79.                 int ferr[]="Cound not find a free ffc slot to run the ffc script for item script PickMessageFFCLauncher. ";
  80.                 TraceNL(); TraceS(ferr); Trace(___err_aborting); TraceNL();
  81.             }
  82.             Quit();
  83.            
  84.         }
  85.         else {
  86.             if ( ITEM_HOLDUP_ZH__ERROR_ON_NO_ITEM_NUMBER ) { ItemHoldupZH_FFC_User_Failure_On_Item_Number(this_item_id, ___err_aborting); }
  87.             //Display the message without holding up the item.
  88.             Screen->Message(__item_message_string);
  89.         }
  90.     }
  91.     int ItemHoldup_FindFreeFFC()
  92.     {
  93.         for ( int q = 32; q > 0; q-- )
  94.         {
  95.             ffc f = Screen->LoadFFC(q);
  96.             if ( f->Data == 0 )
  97.             {
  98.                 if ( f->Script == 0 )
  99.                 return q;
  100.             }
  101.         }
  102.         return -1;
  103.     }
  104.     void ItemHoldUp_SetUpFFC(int screen_ff_index, int ffscript_id, int ________initD0, int ________initD1)
  105.     {
  106.        
  107.         ffc f = Screen->LoadFFC(screen_ff_index);
  108.         f->Data = 1;
  109.         f->Script = ffscript_id;
  110.         f->InitD[0] = ________initD0;
  111.         f->InitD[1] = ________initD1;
  112.        
  113.     }
  114.     void ItemHoldupZH_FFC_Failure_Error(int a, int b)
  115.     {   //a == ff, b == ___err_aborting
  116.         int ___errff[]="Cound not find the script: ";
  117.         TraceNL(); TraceS(___errff); TraceS(a); TraceNL(); TraceS(b); TraceNL();
  118.     }
  119.     void ItemHoldupZH_FFC_User_Failure_On_Item_Number(int this_item_id, int a)
  120.     //a == ___err_aborting
  121.     {
  122.         TraceNL();
  123.         int ____err_itm_id[]="The input for the item ID to display in the script PickMessageFFCLauncher is not valid!";
  124.         int ____err_itm_id2[]="The value that was entered was: ";
  125.         int ____err_itm_id3[]="The valid range is 1 to 255.";
  126.         TraceS(____err_itm_id); TraceS(____err_itm_id2);
  127.         Trace(this_item_id); TraceNL(); TraceS(____err_itm_id3); TraceS(a); TraceNL();
  128.     }
  129. }
  130.  
  131. ////////////////////////////////////////////////////////////////////
  132. /// FFC Scripts
  133. /// These drive the effects for item hold-up and message display,
  134. /// and are called automatically by the launcher.
  135. /// DO NOT PLACE THESE ON A SCREEN!
  136.  
  137. ffc script FFC_SwimHoldUp{
  138.     void run(int itm, int __item_message_string)
  139.     {
  140.         Waitframe();    // An initial waitframe so that the item pick-up script is fully closed,
  141.                 // and so that the item collect script  effects finish running before
  142.                 // we do anything else.
  143.                
  144.         if ( ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE > 0 && ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE < 255)
  145.         {
  146.             Game->PlaySound(ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE);
  147.         }
  148.         Link->Action = LA_HOLD1WATER + (ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS-1);
  149.         Link->HeldItem = itm;
  150.         //do-while loop to delay the message display until the hold-up animation eneds.
  151.         do{
  152.             Waitframe();
  153.         } while( Link->Action == LA_HOLD1WATER || Link->Action == LA_HOLD2WATER );
  154.         Screen->Message(__item_message_string);
  155.         this->Data = 0;
  156.         this->Script = 0;
  157.         Quit();
  158.     }
  159. }
  160.  
  161. ffc script FFC_DiveHoldUp{
  162.     void run(int itm, int __item_message_string){
  163.        
  164.         do {
  165.             Waitframe();
  166.         } while(Link->Action == LA_DIVING);
  167.        
  168.         do {
  169.             Waitframe();
  170.         } while( Link->Action == LA_HOLD1WATER || Link->Action == LA_HOLD2WATER );
  171.        
  172.         //ZC Automatically Holds Up all dive items, and plays the Item Fanfare SFX (SFX: 20, hardcoded).
  173.        
  174.         Screen->Message(__item_message_string);
  175.         this->Data = 0;
  176.         this->Script = 0;
  177.         Quit();
  178.     }
  179. }
  180.  
  181.  
  182. ffc script FFC_ItemHoldUp{
  183.     void run(int itm, int __item_message_string){
  184.        
  185.         Link->Action = LA_HOLD1LAND + (ITEM_HOLDUP_ZH__LA_HOLDUP_HANDS-1);
  186.         Link->HeldItem = itm;
  187.         if ( ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE > 0 && ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE < 255)
  188.         {
  189.             Game->PlaySound(ITEM_HOLDUP_ZH__SFX_HOLD_ITEM_FANFARE);
  190.         }
  191.        
  192.         // This do-while loop is to ensure that the message does not obscure the item during the hold-up animation.
  193.         do {
  194.             Waitframe();
  195.         } while(Link->Action == LA_HOLD1LAND || Link->Action == LA_HOLD2LAND);
  196.        
  197.         Screen->Message(__item_message_string);
  198.         this->Data = 0;
  199.         this->Script = 0;
  200.         Quit();
  201.     }
  202. }
  203. //Maddening, isn't it? -Z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement