Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int FLAG_SHOP_ITEM = 100; // A flag to use for shop items.
- const int CMB_SHOP_ITEM = 2500; // Blank, solid combo.
- const int SHOP_PRICE_Y_OFFSET = 18;
- const int SHOP_PRICE_X_OFFSET = -4;
- const int SFX_BUYITEM = 63;
- const int SHOP_STRING_LAYER = 2;
- const int SHOP_STRING_SHADOW_X_OFFSET = 1;
- const int SHOP_STRING_SHADOW_Y_OFFSET = 1;
- const int SHOP_STRING_BG_COLOUR = 0x0F;
- const int SHOP_STRING_FG_COLOUR = 0x01;
- ffc script Automatic_Z3_Shop
- {
- void run(int shop_id)
- {
- item shopitems[4]; int count;
- shopdata sd = Game->LoadShopData(shop_id);
- for ( int q = 0; q < 176; ++q )
- {
- //FInd the flags and place the items
- if ( Screen->ComboF[q] == FLAG_SHOP_ITEM )
- {
- Screen->ComboD[q] = CMB_SHOP_ITEM;
- shopitems[count] = Screen->CreateItem(sd->Item[0]);
- shopitems[count]->X = ComboX(q);
- shopitems[count]->Y = ComboY(q);
- shopitems[count]->HitXOffset = -32768;
- shopitems[count]->PString = sd->String[0];
- shopitems[count]->PStringFlags |= 0x04;
- ++count;
- if ( count > 2 ) { break; }
- }
- }
- while(1)
- {
- //Draw the prices
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[0]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[0]), OP_OPAQUE);
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[0]->X+SHOP_PRICE_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[0]), OP_OPAQUE);
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[1]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[1]), OP_OPAQUE);
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[1]->X+SHOP_PRICE_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[1]), OP_OPAQUE);
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[2]->X+SHOP_PRICE_X_OFFSET+SHOP_STRING_SHADOW_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET+SHOP_STRING_SHADOW_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_BG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[2]), OP_OPAQUE);
- Screen->DrawString( SHOP_STRING_LAYER, shopitems[2]->X+SHOP_PRICE_X_OFFSET,
- shopitems[0]->Y+SHOP_PRICE_Y_OFFSET, FONT_Z3_SMALL, SHOP_STRING_FG_COLOUR,
- 0, 0, Game->GetMessage(sd->String[2]), OP_OPAQUE;
- //Don't do shop interactivity while Link is holding up an item!
- if ( Link->Action == LA_HOLD1LAND ) continue;
- if ( Link->Action == LA_HOLD2LAND ) continue;
- for ( int q = 0; q < 3; ++q )
- {
- if ( PressedBuyButton() )
- {
- if ( Link->Dir == DIR_UP )
- {
- if ( Game->Counter[CR_RUPEES] >= sd->Price[q] )
- {
- if ( Below(shopitems[q]) )
- {
- if ( DistXY(shopitems[q], 12) )
- {
- shopitems[3] = Screen->CreateItem(shopitems[q]->ID);
- Audio->PlaySound(SFX_BUYITEM);
- Game->DCounter[CR_RUPEES] -= sd->Price[q];
- shopitems[3]->Pickup = IP_HOLDUP;
- shopitems[3]->HitXOffset = 0;
- shopitems[3]->X = Link->X;
- shopitems[3]->Y = Link->Y;
- }
- }
- }
- }
- }
- }
- Waitframe();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement