Code:
// Shop- Oracles-style shop, where you must press A to buy the item. There is no confirmation message, though, so only press A if you want the item!
// Limtations are simply the fact that I can't use the D variables of any other FFCs besides the one this script is set on, thus only four items per shop,
// and the fact that you won't hold up the item when you buy it... But it's useful, regardless! The shop can be anywhere on the screen now! However, this
// means you'll need to waste a few combos to show the item and the price... But it's worth it. Also, think about this: This script means no more leaving and
// exiting a shop just to buy more than one item... ;) Plus, there's more versatility with THIS script. No more wasting Shop Types. Now, one script does it
// all. Each FFC has its own per-screen D variable from 0 to 7. This script uses 0-3 for the items you buy, and 4-7 for their prices. The screen-specificness
// of the D variables adds to the versatility. For example, on one screen, you could set up a shop that sells the 3 Shields, while on another, the very same
// script sets you up a shop that sells Bombs. I made this because I didn't particularly like how Zelda Classic's Z1 shops are done.... Plus, my quest, Realm
// of Mirrors, needed Oracles-styled things... Anyways, have fun with this script! ~Matthew
// Constants:
// nerm- Weird name, yes, but... Message to use when you try to buy an item without the required amount of Rupees. "THAT AIN'T ENOUGH TO BUY!"
// boughtmsg- Message to use when you buy something.
// D variables:
// item1- Variable D0. First item you can buy.
// item2- Variable D1. Second item you can buy.
// item3- Variable D2. Third item you can buy.
// item4- Variable D3. Fourth item you can buy.
// price1- Variable D4. Price of item1.
// price2- Variable D5. Price of item2.
// price3- Variable D6. Price of item3.
// price4- Variable D7. Price of item4.
import "std.zh"
const int nerm = 12;
ffc script shop
{
void run(int item1, int item2, int item3, int item4, int price1, int price2, int price3, int price4) //load up the D variables
{
int nobuy = 0;
int wait = 1;
while(true) //as long as the script is active, it'll NEVER stop. Yay!
{
ffc buy1 = Screen->LoadFFC(31);
ffc buy2 = Screen->LoadFFC(30); //we load the 4 FFCs to be used for the shop here...
ffc buy3 = Screen->LoadFFC(29);
ffc buy4 = Screen->LoadFFC(28);
while((Link->X > buy1->X-4 && Link->X < buy1->X+4) && Link->Y == buy1->Y) //continue only if Link is on the FFC
{
while(Link->InputA) //only allow buying if you press A
{
if(nobuy == 0 && Game->Counter[1] >= price1 && Link->Dir == 0) //buy only if you're not constantly holding A, if you have enough Rupees, and if you are facing the item.
{
nobuy = 1; //helps start the no-buy timer
Link->Item[item1] = true; //gives Link the item
Game->PlaySound(25);
Screen->Message(71);
int drainwait = price1; //places the price of the item you just bought into a new variable to be deducted from...we can't deduct from the price variable, or else the price of the item might go down. XD
while(drainwait > 0)
{
Game->Counter[1] -= 1; //we take away Link's Rupees gradually here...just like with the normal shops.
drainwait -= 1; //take away 1 from the deduction variable so it knows how much more to take away
Waitframe(); //wait one frame...without this, the script would freeze the player...and that could be dangerous. VERY dangerous indeed...
}
}
else if(nobuy == 0 && Game->Counter[1] < price1 && Link->Dir == 0) //check if the player tries to buy an item without enough Rupees
{
Screen->Message(nerm); //bring up a message to tell the player that he/she needs more Rupees
nobuy = 1; //hey, without this, the message will keep repeating! :O
}
Waitframe();
}
if(!Link->InputA)
{
nobuy = 0;
}
Waitframe();
}
while((Link->X > buy2->X-4 && Link->X < buy2->X+4) && Link->Y == buy2->Y)
{
while(Link->InputA) //only allow buying if you press A
{
if(nobuy == 0 && Game->Counter[1] >= price2 && Link->Dir == 0) //buy only if you're not constantly holding A, if you have enough Rupees, and if you are facing the item.
{
nobuy = 1; //helps start the no-buy timer
Link->Item[item2] = true; //gives Link the item
Game->PlaySound(25);
Screen->Message(13);
int drainwait = price2; //places the price of the item you just bought into a new variable to be deducted from...we can't deduct from the price variable, or else the price of the item might go down. XD
while(drainwait > 0)
{
Game->Counter[1] -= 1; //we take away Link's Rupees gradually here...just like with the normal shops.
drainwait -= 1; //take away 1 from the deduction variable so it knows how much more to take away
Waitframe(); //wait one frame...without this, the script would freeze the player...and that could be dangerous. VERY dangerous indeed...
}
}
else if(nobuy == 0 && Game->Counter[1] < price2 && Link->Dir == 0) //check if the player tries to buy an item without enough Rupees
{
Screen->Message(nerm); //bring up a message to tell the player that he/she needs more Rupees
nobuy = 1; //hey, without this, the message will keep repeating! :O
}
Waitframe();
}
if(!Link->InputA)
{
nobuy = 0;
}
Waitframe();
}
while((Link->X > buy3->X-4 && Link->X < buy3->X+4) && Link->Y == buy3->Y)
{
while(Link->InputA) //only allow buying if you press A
{
if(nobuy == 0 && Game->Counter[1] >= price3 && Link->Dir == 0) //buy only if you're not constantly holding A, if you have enough Rupees, and if you are facing the item.
{
nobuy = 1; //helps start the no-buy timer
Link->Item[item3] = true; //gives Link the item
Game->PlaySound(25);
Screen->Message(14);
int drainwait = price3; //places the price of the item you just bought into a new variable to be deducted from...we can't deduct from the price variable, or else the price of the item might go down. XD
while(drainwait > 0)
{
Game->Counter[1] -= 1; //we take away Link's Rupees gradually here...just like with the normal shops.
drainwait -= 1; //take away 1 from the deduction variable so it knows how much more to take away
Waitframe(); //wait one frame...without this, the script would freeze the player...and that could be dangerous. VERY dangerous indeed...
}
}
else if(nobuy == 0 && Game->Counter[1] < price3 && Link->Dir == 0) //check if the player tries to buy an item without enough Rupees
{
Screen->Message(nerm); //bring up a message to tell the player that he/she needs more Rupees
nobuy = 1; //hey, without this, the message will keep repeating! :O
}
Waitframe();
}
if(!Link->InputA)
{
nobuy = 0;
}
Waitframe();
}
while((Link->X > buy4->X-4 && Link->X < buy4->X+4) && Link->Y == buy4->Y)
{
while(Link->InputA) //only allow buying if you press A
{
if(nobuy == 0 && Game->Counter[1] >= price4 && Link->Dir == 0) //buy only if you're not constantly holding A, if you have enough Rupees, and if you are facing the item.
{
nobuy = 1; //helps start the no-buy timer
Link->Item[item4] = true; //gives Link the item
Game->PlaySound(25);
Screen->Message(71);
int drainwait = price4; //places the price of the item you just bought into a new variable to be deducted from...we can't deduct from the price variable, or else the price of the item might go down. XD
while(drainwait > 0)
{
Game->Counter[1] -= 1; //we take away Link's Rupees gradually here...just like with the normal shops.
drainwait -= 1; //take away 1 from the deduction variable so it knows how much more to take away
Waitframe(); //wait one frame...without this, the script would freeze the player...and that could be dangerous. VERY dangerous indeed...
}
}
else if(nobuy == 0 && Game->Counter[1] < price4 && Link->Dir == 0) //check if the player tries to buy an item without enough Rupees
{
Screen->Message(nerm); //bring up a message to tell the player that he/she needs more Rupees
nobuy = 1; //hey, without this, the message will keep repeating! :O
}
Waitframe();
}
if(!Link->InputA)
{
nobuy = 0;
}
Waitframe();
}
Waitframe();
}
}
}
Happy?