Advertisement
ZoriaRPG

ItemHoldupMessage.zh v1.1 for ZC 2.54+

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