Advertisement
ZoriaRPG

Item Count/Completion Roadblock

Oct 6th, 2019
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. //import "std.zh"     //uncomment if not called elsewhere
  2. //import "classic.zh" //uncomment if not called elsewhere
  3.  
  4. //Transforms a combo at its location to another combo if Link has the required items
  5. //Place directly over the combo to change
  6. //Enable the ffc flag: Run on screen init
  7. //D0 is the combo to morph your roadblock into
  8. //Fill in the array with item IDs to collect.
  9.  
  10. ffc script roadblock100percent
  11. {
  12.     void run(int new_combo)
  13.     {
  14.         this->Data = CMB_INVISIBLE
  15.         int itemslist[]=
  16.         {
  17.            
  18.             I_SWORD1, I_SWORD2, I_SWORD3
  19.            
  20.         };
  21.         int sz = SizeOfArray(itemslist); //Slightly faster than calling SizeofArray every frame
  22.         bool waiting = true;
  23.         do
  24.         {
  25.             for ( int q = sz; q >= 0; --q )
  26.             {
  27.                 if(Link->Item[ itemslist[q] ] )
  28.                 {
  29.                     waiting = false;
  30.                 }
  31.             }
  32.             Waitframe();
  33.         } while(waiting);
  34.  
  35.         //If we reaxh here, then Link has all of the items
  36.         Game->PlaySound(SFX_SECRET);
  37.         Screen->ComboD[ComboAt(this->X+8, this->Y+8)] = new_combo;
  38.     }
  39. }  
  40.  
  41. //Bonus content: Specify a completion percent as D1
  42. ffc script roadblockSPECIFYpercent
  43. {
  44.     void run(int new_combo, int perc_required)
  45.     {
  46.         this->Data = CMB_INVISIBLE
  47.         int itemslist[]=
  48.         {
  49.            
  50.             I_SWORD1, I_SWORD2, I_SWORD3
  51.            
  52.         };
  53.         int sz = SizeOfArray(itemslist)
  54.         bool waiting = true;
  55.         int count; int actual_perc;
  56.         do
  57.         {
  58.             for ( int q = sz; q >= 0; --q )
  59.             {
  60.                 if(Link->Item[ itemslist[q] ] )
  61.                 {
  62.                     ++count
  63.                 }
  64.             }
  65.             actual_perc = ( 100 / sz ) * count;
  66.             Waitframe();
  67.         } while(actual_perc < perc_required);
  68.         Game->PlaySound(SFX_SECRET);
  69.         Screen->ComboD[ComboAt(this->X+8, this->Y+8)] = new_combo;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement