ZoriaRPG

Bow Arrow Quiver Combination v0.2.2

Mar 3rd, 2019
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.72 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. ////////////////////////////////////////////
  4. /// Bow, Arrow, and Quiver Bundle Pickup ///
  5. /// v0.2.2 - 3rd March, 2019             ///
  6. /// By: ZoriaRPG                         ///
  7. ////////////////////////////////////////////
  8.  
  9.  
  10. //import "ffcscript.zh"
  11.  
  12. //v0.2.2 : Fixed DeayedItemMessage ffc script. Called script by name, not by const ID.
  13.    
  14. // Script Arguments
  15. // D0: Number of starting arrows to give with this bow.
  16. // D1: Quiver to Give: Small Quiver ( 74 ), medium Quiver ( 75 ), Large Quiver ( 76 ), Magic Quiver ( 105 ) , or custom.
  17. // D2: Type of arrow to give with bow: Wooden ( 13 ), Silver ( 14 ), Gold ( 57 ), or custom.
  18. // D3: Sound Effect to play: Special Item ( 20 ), or custom.
  19. // D4: Message String ID to display (if any). None ( 0 ), or custom.
  20. // D5: Hold-Up Animation to use: None ( 0 ) , 1-Hand ( 1 ), 2-Hand ( 2 ) , 1-Hand-Water ( 3 ), 2-Hand-Water ( 4 ).
  21. // D6: Bow to give: Bow ( 15 ) , Longbow ( 68 ), or custom. This should match the item ID to which you attach this script!
  22.  
  23. item script BowPickup
  24. {
  25.     void run(int giveArrows, int quiver, int arrowType, int playSFX, int showMessage, int holdUp, int bowID)
  26.     {
  27.         int arrowsMax;
  28.         if ( quiver && !Link->Item[quiver] )
  29.         {
  30.             Link->Item[quiver] = true;
  31.             itemdata quiverIT = Game->LoadItemData(quiver);
  32.             arrowsMax = quiverIT->Max;
  33.         }
  34.         if ( Game->MCounter[CR_ARROWS] < arrowsMax ) Game->MCounter[CR_ARROWS] = arrowsMax;
  35.         if ( arrowType && !Link->Item[arrowType] ) Link->Item[arrowType] = true;
  36.         if ( giveArrows ) Game->Counter[CR_ARROWS] += giveArrows;
  37.         if ( giveArrows < 0 ) Game->Counter[CR_RUPEES] -= giveArrows;
  38.         if ( playSFX ) Game->PlaySound(playSFX);
  39.         if ( holdUp && bowID ) _Bow_HoldUpItem(bowID,holdUp);
  40.         if ( showMessage ) Screen->Message(showMessage);
  41.     }
  42. }
  43.  
  44. //Delay the screen message until after the completion of Link's item hold-up animation.
  45. item script BowPickupWithFFC
  46. {
  47.     void run(int giveArrows, int quiver, int arrowType, int playSFX, int showMessage, int holdUp, int bowID)
  48.     {
  49.         int arrowsMax;
  50.         if ( quiver && !Link->Item[quiver] )
  51.         {
  52.             Link->Item[quiver] = true;
  53.             itemdata quiverIT = Game->LoadItemData(quiver);
  54.             arrowsMax = quiverIT->Max;
  55.         }
  56.         if ( Game->MCounter[CR_ARROWS] < arrowsMax ) Game->MCounter[CR_ARROWS] = arrowsMax;
  57.         if ( arrowType && !Link->Item[arrowType] ) Link->Item[arrowType] = true;
  58.         if ( giveArrows ) Game->Counter[CR_ARROWS] += giveArrows;
  59.         if ( giveArrows < 0 ) Game->Counter[CR_RUPEES] -= giveArrows;
  60.         if ( playSFX ) Game->PlaySound(playSFX);
  61.         if ( holdUp && bowID ) _Bow_HoldUpItem(bowID,holdUp);
  62.         int args[1]={showMessage};
  63.         int scrname[]="DelayedItemMessage";
  64.         if ( showMessage ) RunFFCScript(Game->GetFFCScript(scrname),args);
  65.     }
  66. }
  67.  
  68. ffc script DelayedItemMessage{
  69.     void run(int showMessage)
  70.     {
  71.         bool playedMessage = false;
  72.         while(1)
  73.         {
  74.             if ( playedMessage ) break;
  75.             if ( showMessage && !playedMessage )
  76.             {
  77.                 playedMessage = true;
  78.                 Screen->Message(showMessage);
  79.             }
  80.             Waitframe();
  81.         }
  82.     }
  83. }
  84.  
  85. //Global Constants and Functions
  86.  
  87. //Item Hold-Up Constants
  88. const int ITM_HOLD1LAND = 1;
  89. const int ITM_HOLD2LAND = 2;
  90. const int ITM_HOLD1WATER = 3;
  91. const int ITM_HOLD2WATER = 4;
  92.  
  93. //Global Function to force Link to hold up any item specified as itm, using animation specified by holdType.
  94. void _Bow_HoldUpItem(int itm, int holdType)
  95. {
  96.     if ( holdType == ITM_HOLD1LAND )
  97.     {
  98.         Link->Action = LA_HOLD1LAND;
  99.         Link->HeldItem = itm;
  100.     }
  101.     if ( holdType == ITM_HOLD2LAND )
  102.     {
  103.         Link->Action = LA_HOLD2LAND;
  104.         Link->HeldItem = itm;
  105.     }
  106.     if ( holdType == ITM_HOLD1WATER )
  107.     {
  108.         Link->Action = LA_HOLD1WATER;
  109.         Link->HeldItem = itm;
  110.     }
  111.     if ( holdType == ITM_HOLD2WATER )
  112.     {
  113.         Link->Action = LA_HOLD2WATER;
  114.         Link->HeldItem = itm;
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment