Advertisement
ZoriaRPG

Z3 Shop (2.54, v0.3)

Apr 19th, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.29 KB | None | 0 0
  1. const int FLAG_SHOP_ITEM = 100; // A flag to use for shop items.
  2. const int CMB_SHOP_ITEM = 2500; // Blank, solid combo.
  3. const int SHOP_PRICE_Y_OFFSET = 18;
  4. const int SHOP_PRICE_X_OFFSET = -4;
  5. const int SFX_BUYITEM = 63;
  6. const int SHOP_STRING_LAYER = 2;
  7. const int SHOP_STRING_SHADOW_X_OFFSET = 1;
  8. const int SHOP_STRING_SHADOW_Y_OFFSET = 1;
  9. const int SHOP_STRING_BG_COLOUR = 0x0F;
  10. const int SHOP_STRING_FG_COLOUR = 0x01;
  11.  
  12. ffc script Automatic_Z3_Shop
  13. {
  14.     void run(int shop_id)
  15.     {
  16.         item shopitems[4];  int count;
  17.         shopdata sd = Game->LoadShopData(shop_id);
  18.         for ( int q = 0; q < 176; ++q )
  19.         {
  20.             //FInd the flags and place the items
  21.             if ( Screen->ComboF[q] == FLAG_SHOP_ITEM )
  22.             {
  23.                 Screen->ComboD[q] = CMB_SHOP_ITEM;
  24.                 shopitems[count] = Screen->CreateItem(sd->Item[0]);
  25.                 shopitems[count]->X = ComboX(q);
  26.                 shopitems[count]->Y = ComboY(q);
  27.                 shopitems[count]->HitXOffset = -32768;
  28.                 shopitems[count]->PString = sd->String[0];
  29.                 shopitems[count]->PStringFlags |= 0x04;
  30.                 ++count;
  31.                 if ( count > 2 ) { break; }
  32.             }
  33.         }
  34.         while(1)
  35.         {
  36.            
  37.             //Draw the prices
  38.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[0]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
  39.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
  40.                 0, 0, Game->GetMessage(sd->String[0]), OP_OPAQUE);
  41.                
  42.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[0]->X+SHOP_PRICE_X_OFFSET,
  43.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
  44.                 0, 0, Game->GetMessage(sd->String[0]), OP_OPAQUE);
  45.            
  46.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[1]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
  47.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
  48.                 0, 0, Game->GetMessage(sd->String[1]), OP_OPAQUE);
  49.                
  50.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[1]->X+SHOP_PRICE_X_OFFSET,
  51.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
  52.                 0, 0, Game->GetMessage(sd->String[1]), OP_OPAQUE);
  53.                
  54.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[2]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
  55.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
  56.                 0, 0, Game->GetMessage(sd->String[2]), OP_OPAQUE);
  57.                
  58.             Screen->DrawString( SHOP_STRING_LAYER, shopitems[2]->X+SHOP_PRICE_X_OFFSET,
  59.                 shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
  60.                 0, 0, Game->GetMessage(sd->String[2]), OP_OPAQUE;
  61.  
  62.                 //Don't do shop interactivity while Link is holding up an item!
  63.                 if ( Link->Action == LA_HOLD1LAND ) continue;
  64.                 if ( Link->Action == LA_HOLD2LAND ) continue;
  65.  
  66.             for ( int q = 0; q < 3; ++q )
  67.             {
  68.                 if ( PressedBuyButton() )
  69.                 {
  70.                     if ( Link->Dir == DIR_UP )
  71.                     {
  72.                         if ( Game->Counter[CR_RUPEES] >= sd->Price[q] )
  73.                         {
  74.                             if ( Below(shopitems[q]) )
  75.                             {
  76.                                 if ( DistXY(shopitems[q], 12) )
  77.                                 {
  78.                                     shopitems[3] = Screen->CreateItem(shopitems[q]->ID);
  79.                                     Audio->PlaySound(SFX_BUYITEM);
  80.                                     Game->DCounter[CR_RUPEES] -= sd->Price[q];
  81.                                     shopitems[3]->Pickup = IP_HOLDUP;
  82.                                     shopitems[3]->HitXOffset = 0;
  83.                                     shopitems[3]->X = Link->X;
  84.                                     shopitems[3]->Y = Link->Y;
  85.                                 }
  86.                             }
  87.                         }
  88.                     }
  89.                 }
  90.             }
  91.             Waitframe();
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement