Advertisement
ZoriaRPG

Ten Rupee Room

Nov 29th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. ffc script tenrupee
  2. {
  3.     void run(int item_id, sdd, imiscd)
  4.     {
  5.         int ten_rupees_x[10] = {120,112,128,96,112,128,144,112,128,120};
  6.         int ten_rupees_y[10] = {49,65,65,81,81,81,81,97,97,113};
  7.         item ten_rupees[10];
  8.         if ( !Screen->D[sdd] )
  9.         {
  10.             Screen->D[sdd] = ( 1 << 11 );
  11.        
  12.             for ( int q = 0; q < 10; ++q ) //We've never collected any, so make all of them.
  13.             {
  14.                 ten_rupees[q] = Screen->CreateItem(Cond((item_id > 0), item_id, I_RUPEE));
  15.                 ten_rupees[q]->X = ten_rupees_x[q];
  16.                 ten_rupees[q]->Y = ten_rupees_y[q];
  17.                 ten_rupees[q]->Misc[imiscd] = 101010+q; //the index of the item, out of ten, wso that we know what Screen->D bit it will use.
  18.                 ten_rupees[q]->InitD[0] = imiscd; //Pass-through.
  19.                 ten_rupees[q]->InitD[1] = sdd; //Pass-through.
  20.                 ten_rupees[q]->PScript = Game->GetItemScript("TenRupeePickup");
  21.             }
  22.         }
  23.         else
  24.         {
  25.             for ( int q = 0; q < 10; ++q )
  26.             {
  27.                 if ( !GetScreenDBit(sdd, ( 1 << q )) //Only create the item if Link did not pick up that particular rupee on a previous visit.
  28.                 {
  29.                     ten_rupees[q] = Screen->CreateItem(Cond((item_id > 0), item_id, I_RUPEE));
  30.                     ten_rupees[q]->X = ten_rupees_x[q];
  31.                     ten_rupees[q]->Y = ten_rupees_y[q];
  32.                     ten_rupees[q]->Misc[imiscd] = 101010+q; //We still mark which (n/10) it is.
  33.                     ten_rupees[q]->InitD[0] = imiscd;
  34.                     ten_rupees[q]->InitD[1] = sdd;
  35.                     ten_rupees[q]->PScript = Game->GetItemScript("TenRupeePickup");
  36.                 }
  37.             }
  38.         }
  39.     }
  40. }
  41.  
  42. item script TenRupeePickup
  43. {
  44.     void run(int imiscd, int sdd) //set by the ffc. Do not manually assign!
  45.     {
  46.         int bit = this->Misc[imiscd]-101010; //Mark one bit of Screen D with the ID (n/10) of this rupee.
  47.         //That way, if Link collects it, it won't respawn, because the bit is set, and we only create them
  48.         //if this bit is false.
  49.         SetScreenDBit(sdd, ( (1 << bit), true);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement