Advertisement
ZoriaRPG

ZC Specific Item and Button Bubbles v0.6.7

Nov 17th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.03 KB | None | 0 0
  1. ////////////////////////////////////////
  2. /// Specific item and Button Bubbles ///
  3. /// By: ZoriaRPG                     ///
  4. /// v0.6.7                           ///
  5. /// 15th February, 2016              ///
  6. /// -------------------------------- //////////////////////////////////
  7. /// The following ghosted enemies replicate bubbles, but instead of ///
  8. /// affecting all non-sword items, or all sword items, they jinx    ///
  9. /// either specific items, or specific buttons.                     ///
  10. ///////////////////////////////////////////////////////////////////////
  11. /// Credits:                                                        ///
  12. /// ZoriaRPG: Button Bubble Concept, Script                         ///
  13. /// Moosh:    Telling me to make it work with specific items.       ///
  14. ///           Some ghost.zh things.                                 ///
  15. /// Lejes:    Debugging/Testing                                     ///
  16. ///////////////////////////////////////////////////////////////////////
  17.  
  18. ///////////////
  19. /// Set-Up ////////////////////////////////////////////////////////////////////////////////////
  20. /// The following ghost attributes determine the item or button toaffect, and the jinxtime. ///
  21. /// --------------------------------------------------------------------------------------- ///
  22. /// ghost->Attributes[GHOST_BUBBLE_ITEM_ID] is the item to affect.                          ///
  23. /// ghost->Attributes[GHOST_BUBBLE_ITEM_TIMER] is the duration to affect the item.          ///
  24. ///       -1 for infinite.                                                                  ///
  25. /// ghost->Attributes[GHOST_BUBBLE_BUTTON_ID] is the button to affect                       ///
  26. /// ghost->Attributes[GHOST_BUBBLE_BUTTON_TIMER] is the duration to jinx that button.       ///
  27. ///       -1 for infinite.                                                                  ///
  28. /// ghost->Attributes[GHOST_BUBBLE_HALT] is the Halt argument for Ghost_HaltingWalk()       ///
  29. /// Probably should be 10 to 45.                                ///
  30. ///////////////////////////////////////////////////////////////////////////////////////////////
  31.  
  32.  
  33. //////////////////
  34. // Global Array //
  35. //////////////////
  36.  
  37. int Jinxes[555]; //Holds timers, and other values for jinxed items, and buttons.
  38.  
  39.  
  40. /////////////////////////////
  41. //    Ghosted Bubbles     ///
  42. // Constants and Settings ///
  43. /////////////////////////////
  44.  
  45.  
  46. ////////////////
  47. /// Settings ///
  48. ////////////////
  49.  
  50. //! Set to '1' to enable, or '0' to disable.
  51.  
  52. const int CLEAR_BUTTON_JINXES_ON_CONTINUE   = 1;    // Clears Button Jinxes on Death, or on F6
  53. const int CLEAR_BUTTON_JINXES_ON_RELOAD     = 1;    // Clears Button Jinxes when resuming a
  54.                                                     // saved game from the game select screen.
  55. const int CLEAR_ITEM_JINXES_ON_CONTINUE     = 1;    // Clears Item Jinxes on Death, or on F6
  56. const int CLEAR_ITEM_JINXES_ON_RELOAD       = 1;    // Clears Button Jinxes when resuming a
  57.                                                     // saved game from the game select screen.
  58.  
  59. /////////////////////
  60. // Array Constants //
  61. /////////////////////
  62.  
  63. // Global Array Indices
  64. const int JINXED_BUTTONS = 512; //Offset for Jinxed Button Timers
  65.  
  66. //Ghost->Attributes[] Indices
  67. const int GHOST_BUBBLE_ITEM_ID      = 0;
  68. const int GHOST_BUBBLE_ITEM_TIMER   = 1;
  69. const int GHOST_BUBBLE_BUTTON_ID    = 2;
  70. const int GHOST_BUBBLE_BUTTON_TIMER = 3;
  71. const int GHOST_BUBBLE_FLAG         = 4; //Not used. What the flidd did I intend to do with this? Lock a bubble from walking on this flag?
  72. const int GHOST_BUBBLE_HALT     = 5;
  73.  
  74. //Bubble FFC Script Local Array ( bubblevars[] ) Indices
  75. const int GHOST_BUBBLE_ARR_ITM      = 0;
  76. const int GHOST_BUBBLE_ARR_ITMDUR   = 1;
  77. const int GHOST_BUBBLE_ARR_BTN      = 2;
  78. const int GHOST_BUBBLE_ARR_BTNDUR   = 3;
  79. const int GHOST_BUBBLE_COUNTER      = 4;
  80.  
  81. //Buttons
  82. const int JINX_BTN_A        = 1;
  83. const int JINX_BTN_B        = 2;
  84. const int JINX_BTN_L        = 3;
  85. const int JINX_BTN_R        = 4;
  86. const int JINX_BTN_UP       = 5;
  87. const int JINX_BTN_DOWN     = 6;
  88. const int JINX_BTN_LEFT     = 7;
  89. const int JINX_BTN_RIGHT    = 8;
  90. const int JINX_BTN_START    = 9;
  91. const int JINX_BTN_MAP      = 10;
  92. const int JINX_BTN_EX1      = 11;
  93. const int JINX_BTN_EX2      = 12;
  94. const int JINX_BTN_EX3      = 13;
  95. const int JINX_BTN_EX4      = 14;
  96.  
  97. //Bubble->Attributes[] Values (for reference)
  98. const int GHOST_BUBBLE_INFINITE_DUR     = -1;
  99.    
  100.  
  101.  
  102. /////////////////////////////
  103. /// FFC AutoGhost Scripts ///
  104. /////////////////////////////
  105.  
  106. //! Apply these to an enemy with the type 'Other'
  107.  
  108. ffc script Bubbles{
  109.     void run(int enemID){
  110.         npc ghost = Ghost_InitAutoGhost(this, enemID); //Init the enemy, and set tis properties...
  111.         Ghost_SetFlag(GHF_NORMAL);  //Can be stunned, affected by clocks, has knockback.
  112.         Ghost_SetFlag(GHF_FULL_TILE_MOVEMENT); //Will not move onto partially solid combos.
  113.         Ghost_SetFlag(GHF_4WAY); //4-Way walking.
  114.        
  115.         int bubblevars[5]; //Array to hold variables.
  116.        
  117.         //Initialise array values using ghost properties.
  118.         bubblevars[GHOST_BUBBLE_ARR_ITM]        = ghost->Attributes[GHOST_BUBBLE_ITEM_ID];
  119.         bubblevars[GHOST_BUBBLE_ARR_ITMDUR]     = ghost->Attributes[GHOST_BUBBLE_ITEM_TIMER];
  120.         bubblevars[GHOST_BUBBLE_ARR_BTN]        = ghost->Attributes[GHOST_BUBBLE_BUTTON_ID];
  121.         bubblevars[GHOST_BUBBLE_ARR_BTNDUR]     = ghost->Attributes[GHOST_BUBBLE_BUTTON_TIMER];
  122.         bubblevars[GHOST_BUBBLE_COUNTER]        = -1;
  123.        
  124.        
  125.        
  126.         while(true){
  127.             if ( LinkCollision(ghost) && ( Link->Action == LA_GOTHURTLAND || Link->Action == LA_GOTHURTWATER ) ){
  128.                 if ( bubblevars[GHOST_BUBBLE_ARR_ITM] && Link->Item[bubblevars[GHOST_BUBBLE_ARR_ITM]] && Jinxes[bubblevars[GHOST_BUBBLE_ARR_ITM]] != GHOST_BUBBLE_INFINITE_DUR ) {
  129.                     Jinxes[bubblevars[GHOST_BUBBLE_ARR_ITM]] = bubblevars[GHOST_BUBBLE_ARR_ITMDUR];
  130.                 }
  131.                    
  132.                 if ( bubblevars[GHOST_BUBBLE_ARR_BTN] && Jinxes[bubblevars[GHOST_BUBBLE_ARR_BTNDUR]] != GHOST_BUBBLE_INFINITE_DUR ) {
  133.                     Jinxes[JINXED_BUTTONS+ bubblevars[GHOST_BUBBLE_ARR_BTN]] = bubblevars[GHOST_BUBBLE_ARR_BTNDUR];
  134.                
  135.                 }
  136.                
  137.             }
  138.             bubblevars[GHOST_BUBBLE_COUNTER] = Ghost_HaltingWalk4(bubblevars[GHOST_BUBBLE_COUNTER], ghost->Step, ghost->Rate, ghost->Homing, ghost->Hunger, ghost->Haltrate, ghost->Attributes[GHOST_BUBBLE_HALT]);
  139.             Ghost_Waitframe(this,ghost);
  140.         }
  141.     }
  142. }
  143.  
  144.  
  145. ffc script AntiBubbles{
  146.     void run(int enemID){
  147.        
  148.         npc ghost = Ghost_InitAutoGhost(this, enemID); //Init the enemy, and set its properties...
  149.         Ghost_SetFlag(GHF_NORMAL);  //Can be stunned, affected by clocks, has knockback.
  150.         Ghost_SetFlag(GHF_FULL_TILE_MOVEMENT); //Will not move onto partially solid combos.
  151.         Ghost_SetFlag(GHF_4WAY); //4-Way walking.
  152.        
  153.         int bubblevars[5]; //Array to hold variables.
  154.        
  155.         //Initialise array values using ghost properties.
  156.         bubblevars[GHOST_BUBBLE_ARR_ITM]        = ghost->Attributes[GHOST_BUBBLE_ITEM_ID];
  157.         //bubblevars[GHOST_BUBBLE_ARR_ITMDUR]   = ghost->Attributes[GHOST_BUBBLE_ITEM_TIMER];
  158.         bubblevars[GHOST_BUBBLE_ARR_BTN]        = ghost->Attributes[GHOST_BUBBLE_BUTTON_ID];
  159.         //bubblevars[GHOST_BUBBLE_ARR_BTNDUR]   = ghost->Attributes[GHOST_BUBBLE_BUTTON_TIMER];
  160.         bubblevars[GHOST_BUBBLE_COUNTER]        = -1;
  161.        
  162.        
  163.        
  164.         while(true){
  165.             if ( LinkCollision(ghost) && ( Link->Action == LA_GOTHURTLAND || Link->Action == LA_GOTHURTWATER ) ){
  166.                 if ( bubblevars[GHOST_BUBBLE_ARR_ITM] && Jinxes[bubblevars[GHOST_BUBBLE_ARR_ITM]] ) {
  167.                     Jinxes[bubblevars[GHOST_BUBBLE_ARR_ITM]] = 0;
  168.                 }
  169.                    
  170.                 if ( bubblevars[GHOST_BUBBLE_ARR_BTN] && Jinxes[bubblevars[GHOST_BUBBLE_ARR_BTNDUR]] ) {
  171.                     Jinxes[JINXED_BUTTONS+ bubblevars[GHOST_BUBBLE_ARR_BTN]] = 0;
  172.                
  173.                 }
  174.                
  175.             }
  176.             bubblevars[GHOST_BUBBLE_COUNTER] = Ghost_HaltingWalk4(bubblevars[GHOST_BUBBLE_COUNTER], ghost->Step, ghost->Rate, ghost->Homing, ghost->Hunger, ghost->Haltrate, ghost->Attributes[GHOST_BUBBLE_HALT]);
  177.             Ghost_Waitframe(this,ghost);
  178.         }
  179.     }
  180. }
  181.  
  182. ////////////////////////
  183. /// Global Functions ///
  184. ////////////////////////
  185.  
  186. //Main function to call before Waitdraw() as Jinxes(JinxedItems);
  187. void DoJinxes(int arr){
  188.     JinxedItems(arr);
  189.     JinxedButtons(arr);
  190.     ReduceJinxTimers(arr);
  191. }
  192.  
  193. //Clears a jinx arbitrarily.
  194. void UnJinx(int itemOrButton){
  195.     Jinxes[itemOrButton] = 0;
  196. }
  197.  
  198. //Clears all jinxes caused by the ghosted bubbles in this header.
  199. void ClearAllJinxes(int arr){
  200.     for ( int q = 0; q < SizeOfArray(arr); q++ ) arr[q] = 0;
  201. }
  202.  
  203. //Clears all item jinxes caused by the ghosted bubbles in this header.
  204. void ClearItemJinxes(int arr){
  205.     for ( int q = 0; q < JINXED_BUTTONS; q++ ) arr[q] = 0;
  206. }
  207.  
  208. //Clears all button jinxer caused by the ghosted bubbles in this header.
  209. void ClearButtonJinxes(int arr){
  210.     for ( int q = JINXED_BUTTONS; q < SizeOfArray(arr); q++ ) arr[q] = 0;
  211. }
  212.  
  213. //! Functions called by Jinxes()
  214.  
  215. // Halts inputs on A/B for jinxed items.
  216. void JinxedItems(int arr){
  217.     if ( Link->PressA && arr[Link->GetEquipmentA()] ) Link->PressA = false;
  218.     if ( Link->PressB && arr[Link->GetEquipmentB()] ) Link->PressB = false;
  219.     if ( Link->InputA && arr[Link->GetEquipmentA()] ) Link->InputA = false;
  220.     if ( Link->InputB && arr[Link->GetEquipmentB()] ) Link->InputB = false;
  221. }
  222.  
  223. // Halts inputs for jinxed buttons.
  224. void JinxedButtons(int arr){
  225.     if ( Link->PressA && arr[JINXED_BUTTONS + JINX_BTN_A] )     Link->PressA = false;
  226.     if ( Link->PressB && arr[JINXED_BUTTONS + JINX_BTN_B] )     Link->PressB = false;
  227.     if ( Link->InputA && arr[JINXED_BUTTONS + JINX_BTN_A] )     Link->InputA = false;
  228.     if ( Link->InputB && arr[JINXED_BUTTONS + JINX_BTN_B] )     Link->InputB = false;
  229.    
  230.     if ( Link->PressL && arr[JINXED_BUTTONS + JINX_BTN_L] )     Link->PressL = false;
  231.     if ( Link->PressR && arr[JINXED_BUTTONS + JINX_BTN_R] )     Link->PressR = false;
  232.     if ( Link->InputL && arr[JINXED_BUTTONS + JINX_BTN_L] )     Link->InputL = false;
  233.     if ( Link->InputR && arr[JINXED_BUTTONS + JINX_BTN_R] )     Link->InputR = false;
  234.  
  235.     if ( Link->PressUp && arr[JINXED_BUTTONS + JINX_BTN_UP] )   Link->PressUp = false;
  236.     if ( Link->PressDown && arr[JINXED_BUTTONS + JINX_BTN_DOWN] )   Link->PressDown = false;
  237.     if ( Link->InputUp && arr[JINXED_BUTTONS + JINX_BTN_UP] )   Link->InputUp = false;
  238.     if ( Link->InputDown && arr[JINXED_BUTTONS + JINX_BTN_DOWN ] )  Link->InputDown = false;
  239.    
  240.     if ( Link->PressLeft && arr[JINXED_BUTTONS + JINX_BTN_LEFT] )   Link->PressLeft = false;
  241.     if ( Link->PressRight && arr[JINXED_BUTTONS + JINX_BTN_RIGHT] ) Link->PressRight = false;
  242.     if ( Link->InputLeft && arr[JINXED_BUTTONS + JINX_BTN_LEFT] )   Link->InputLeft = false;
  243.     if ( Link->InputRight && arr[JINXED_BUTTONS + JINX_BTN_RIGHT] ) Link->InputRight = false;
  244.    
  245.     if ( Link->PressStart && arr[JINXED_BUTTONS + JINX_BTN_START] ) Link->PressStart = false;
  246.     if ( Link->PressMap && arr[JINXED_BUTTONS + JINX_BTN_MAP] )     Link->PressMap = false;
  247.     if ( Link->InputStart && arr[JINXED_BUTTONS + JINX_BTN_START] ) Link->InputStart = false;
  248.     if ( Link->InputMap && arr[JINXED_BUTTONS + JINX_BTN_MAP] )     Link->InputMap = false;
  249.    
  250.     if ( Link->PressEx1 && arr[JINXED_BUTTONS + JINX_BTN_EX1] )     Link->PressEx1 = false;
  251.     if ( Link->PressEx2 && arr[JINXED_BUTTONS + JINX_BTN_EX2] )     Link->PressEx2 = false;
  252.     if ( Link->InputEx1 && arr[JINXED_BUTTONS + JINX_BTN_EX1] )     Link->InputEx1 = false;
  253.     if ( Link->InputEx2 && arr[JINXED_BUTTONS + JINX_BTN_EX2] )     Link->InputEx2 = false;
  254.    
  255.     if ( Link->PressEx3 && arr[JINXED_BUTTONS + JINX_BTN_EX3] )     Link->PressEx3 = false;
  256.     if ( Link->PressEx4 && arr[JINXED_BUTTONS + JINX_BTN_EX4] )     Link->PressEx4 = false;
  257.     if ( Link->InputEx3 && arr[JINXED_BUTTONS + JINX_BTN_EX3] )     Link->InputEx3 = false;
  258.     if ( Link->InputEx4 && arr[JINXED_BUTTONS + JINX_BTN_EX4] )     Link->InputEx4 = false;
  259. }
  260.  
  261. //Reduces timers in the main array by one, each frame.
  262. void ReduceJinxTimers(int arr){
  263.     for ( int q = 0; q < SizeOfArray(arr); q++ ) {
  264.         if ( arr[q] > 0 ) arr[q]--;
  265.     }
  266. }
  267.  
  268.  
  269. //////////////////////////////
  270. /// Example Global Scripts ///
  271. //////////////////////////////
  272.  
  273. global script active{                          
  274.     void run(){
  275.         StartGhostZH();
  276.         if ( CLEAR_BUTTON_JINXES_ON_CONTINUE ) ClearButtonJinxes(Jinxes);
  277.         if ( CLEAR_ITEM_JINXES_ON_CONTINUE ) ClearItemJinxes(Jinxes);
  278.         while(true){
  279.             DoJinxes(Jinxes);
  280.             UpdateGhostZH1();//! Enable if using ghost.zh
  281.             Waitdraw();
  282.             UpdateGhostZH2(); //! Enable if using ghost.zh
  283.             Waitframe();
  284.         }
  285.     }
  286. }
  287.  
  288. global script OnContinue{
  289.     void run(){
  290.         if ( CLEAR_BUTTON_JINXES_ON_RELOAD ) ClearButtonJinxes(Jinxes);
  291.         if ( CLEAR_ITEM_JINXES_ON_RELOAD ) ClearItemJinxes(Jinxes);
  292.     }
  293. }
  294.    
  295.  
  296. ////////////////////
  297. /// Item Scripts /////////////////////////////////////////////////
  298. /// Apply these as item scripts for potions, to clear jinxes.  ///
  299. /// If you already have itemscripts for your potions, call the ///
  300. /// global functions ClearItemJinxes() and ClearButtonJinxes() ///
  301. /// firectly in those scripts.                                 ///
  302. //////////////////////////////////////////////////////////////////
  303.  
  304. //Clears all Item-Specific and Button Jinxes caused by these ghosted bubbles.
  305. item script ItemAndButtonJinxPotion{
  306.     void run(){
  307.         for ( int q = 0; q < SizeOfArray(Jinxes); q++ ) arr[q] = 0;
  308.     }
  309. }
  310.  
  311. //Clears Item Jinxes, but not Button Jinxes caused by these ghosted bubbles.
  312. item script ItemJinxPotion{
  313.     void run(){
  314.         for ( int q = 0; q < JINXED_BUTTONS; q++ ) arr[q] = 0;
  315.     }
  316. }
  317.  
  318. //Clears Button Jinxes, but not Item Jinxes caused by these ghosted bubbles.
  319. item script ButtonJinxPotion{
  320.     void run(){
  321.         for ( int q = JINXED_BUTTONS; q < SizeOfArray(Jinxes); q++ ) arr[q] = 0;
  322.     }
  323. }
  324.  
  325.  
  326.  
  327.  
  328.  
  329.   ///----==----\\\
  330.  //! Deprecated !\\
  331. //----------------\\
  332.  
  333. //const int BUBBLE_COUNTERS = 768;
  334.  
  335. //int GetBubbleCounter(int arr){
  336. //    for ( int q = 768; q < SizeOfArray(arr); q++ ) {
  337. //        if ( !arr[q] ) return q;
  338. //    }
  339. //    return -1;
  340.  
  341. //! DCdprecated by using other attribs for item and button, instead of this.
  342. //Bubble->Attributes[] Values (for reference)
  343. //const int GHOST_BUBBLE_AFFECT_NONE      =  0;
  344. //const int GHOST_BUBBLE_AFFECT_ITEM      =  1;
  345. //const int GHOST_BUBBLE_AFFECT_BUTTON    =  2;
  346. //const int GHOST_BUBBLE_AFFECT_BOTH      =  3;
  347. //const int GHOST_BUBBLE_INFINITE_DUR     = -1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement