Advertisement
ZoriaRPG

Automated Z3 Shop (Preliminary)

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