Jump to content

Photo

Shop Script v1.0


  • Please log in to reply
14 replies to this topic

#1 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 26 October 2007 - 05:52 PM

Let's just get to the script, shall we?

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!"
// 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 && Link->Y == buy1->Y) //continue only if Link is on the FFC
            {
                if(nobuy == 1) //checks if it shouldn't allow buying, "no-buy timer"
                {
                    while(wait > 0)
                    {            //this whole section prevents you from buying an item over and over again if you hold down A, AKA "no-buy timer"
                        wait -= 1; //take away from the timer
                        Waitframes(60); //wait one full second before continuing. 60 frames = 1 second....therefore, the value of "wait" is the amount of seconds on the no-buy timer... I wouldn't try 3, though. Too long, trust me.
                    }
                    nobuy = 0; //reset everything back to normal
                    wait = 1;
                }
                if(Link->InputA && nobuy == 0 && Game->Counter[1] >= price1 && Link->Dir == 0) //only allow buying if you press A, if the no-buy timer has expired, if you have enough Rupees, and if you're...y'know, FACING the item...
                {
                    Link->InputA = false; //stops Link from attacking....can't have that
                    nobuy = 1;        //helps start the no-buy timer
                    Screen->CreateItem(item1); //create the item that we're buying
                    int itemcount = Screen->NumItems(); //find out how many items are on-screen...just a simple precaution. Since the item you're buying is most likely going to be the last item in the list, NumItems will give you the item's ID all the time...but then, that's if no other script creates items...
                    item newitem = Screen->LoadItem(itemcount);
                    newitem->X = Link->X;            //this section places the item on Link...simply GIVING it to him isn't enough... After all, what will tell the player they bought it successfully?
                    newitem->Y = Link->Y;
                    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(Link->InputA && Game->Counter[1] < price1) //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();
            }
            while(Link->X == buy2->X && Link->Y == buy2->Y)
            {
                if(nobuy == 1)
                {
                    while(wait > 0)
                    {
                        wait -= 1;
                        Waitframes(60);
                    }
                    nobuy = 0;
                    wait = 1;
                }
                if(Link->InputA && nobuy == 0 && Game->Counter[1] >= price2 && Link->Dir == 0)
                {
                    Link->InputA = false;
                    nobuy = 1;
                    Screen->CreateItem(item2);
                    int itemcount = Screen->NumItems();
                    item newitem = Screen->LoadItem(itemcount);
                    newitem->X = Link->X;
                    newitem->Y = Link->Y;
                    int drainwait = price2;
                    while(drainwait > 0)
                    {
                        Game->Counter[1] -= 1;
                        drainwait -= 1;
                        Waitframe();
                    }
                }
                else if(Link->InputA && Game->Counter[1] < price2)
                {
                    Screen->Message(nerm);
                    nobuy = 1;
                }
                Waitframe();
            }
            while(Link->X == buy3->X && Link->Y == buy3->Y)
            {
                if(nobuy == 1)
                {
                    while(wait > 0)
                    {
                        wait -= 1;
                        Waitframes(60);
                    }
                    nobuy = 0;
                    wait = 1;
                }
                if(Link->InputA && nobuy == 0 && Game->Counter[1] >= price3 && Link->Dir == 0)
                {
                    Link->InputA = false;
                    nobuy = 1;
                    Screen->CreateItem(item3);
                    int itemcount = Screen->NumItems();
                    item newitem = Screen->LoadItem(itemcount);
                    newitem->X = Link->X;
                    newitem->Y = Link->Y;
                    int drainwait = price3;
                    while(drainwait > 0)
                    {
                        Game->Counter[1] -= 1;
                        drainwait -= 1;
                        Waitframe();
                    }
                }
                else if(Link->InputA && Game->Counter[1] < price3)
                {
                    Screen->Message(nerm);
                    nobuy = 1;
                }
                Waitframe();
            }
            while(Link->X == buy4->X && Link->Y == buy4->Y)
            {
                if(nobuy == 1)
                {
                    while(wait > 0)
                    {
                        wait -= 1;
                        Waitframes(60);
                    }
                    nobuy = 0;
                    wait = 1;
                }
                if(Link->InputA && nobuy == 0 && Game->Counter[1] >= price4 && Link->Dir == 0)
                {
                    Link->InputA = false;
                    nobuy = 1;
                    Screen->CreateItem(item4);
                    int itemcount = Screen->NumItems();
                    item newitem = Screen->LoadItem(itemcount);
                    newitem->X = Link->X;
                    newitem->Y = Link->Y;
                    int drainwait = price4;
                    while(drainwait > 0)
                    {
                        Game->Counter[1] -= 1;
                        drainwait -= 1;
                        Waitframe();
                    }
                }
                else if(Link->InputA && Game->Counter[1] < price4)
                {
                    Screen->Message(nerm);
                    nobuy = 1;
                }
                Waitframe();
            }
            Waitframe();
        }
    }
}

Yes, Oracles-style. It's actually more of LttP-style, since you don't pick up the item you buy and take it to the shopkeeper... But anyways...

REPLACE THIS WITH ALL NORMAL Z1 SHOPS IN YOUR QUESTS OR ELSE YOU WILL DIE! icon_razz.gif Just kidding. This is more versatile than normal shops. For starters, since I'm using the FFCs... You get to put your items anywhere you want. They don't even have to be right next to each other. Second, you get up to FOUR items in your shop! My original plan was to have that limit only be limited by the number of FFCs you could use...but I can't figure out how to access the D variables on other FFCs. If I could do THAT... Well, the script would be super-awesome. But oh well. Third, this one script, thanks again to the D variables, allows you to make MANY shops! Just one script is all that's needed. icon_smile.gif Now, how to work it...

D0-D3 are the item IDs for the items you buy. Look in std.zh for the info for THAT. D4-D7 are the prices for those items. Yes, it's respective. The only constant in the entire script decides what message appears when you don't have enough Rupees to buy an item. I actually thought about adding in a message for when you buy an item, but decided against that. For one, I don't have any D variables left for that, and two, you can do that with another script, placed on the item... Anyways, I don't wanna do it.

Don't mess with anything else, 'kay? Well, except "wait". Change that if you want to wait LONGER before you can try to buy an item again. Change the value in the "Waitframes", too, if you wanna try to make it wait a SHORTER amount of time. 60 frames = 1 second, by the way. If you wanna know how anything works, look at my little notes there. Just began using them with this script... And for this very reason, I might add! So, have fun with the script and stuffs! icon_biggrin.gif Let me know if there's anything else you wish to know about this script...

#2 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 26 October 2007 - 08:04 PM

Eh, maybe I'm not reading this right but how do I set up where to put each item? Do I need 4 separate ffcs?

#3 Zemious

Zemious

    Magicite: Bahamut

  • Members

Posted 26 October 2007 - 09:58 PM

Holy crap Matthew, very nice. icon_smile.gif

#4 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 27 October 2007 - 01:54 PM

QUOTE(Plissken @ Oct 26 2007, 09:04 PM) View Post

Eh, maybe I'm not reading this right but how do I set up where to put each item? Do I need 4 separate ffcs?

Yup, you do. Is there a problem with that?

Also, in case you guys haven't noticed, there's one major flaw in checking if Link is on the FFC with "if(Link->X == ffc->X)" and the Y stuff. Link has to be exactly in the center of the FFC for him to be "on" it. In other words, the top-left corner of Link's tiles MUST be at the same location as the top-left corner of the FFC's tiles. icon_frown.gif Thus, I have a suggestion. For X position, do you want me to change it to where you can be at most 3 pixels away from the center for it to work? With Z3 Movement, you move pixel-by-pixel. Thus, if the FFC isn't right next to a solid combo, it's hard to position him correctly. Thus, I wanna know your opinions. And for Y position, I'd like to extend the range 8 more pixels up, too. That way, you need only stand on top of the FFC for it to work. The GB Zeldas have shops set up to where one 16x16 tile is fully solid everywhere, then the next 8x8 tile below that is, then the spot below that, where Link stands, ISN'T. AKA, you have a 16x16 tile that's half-walkable. I had that in mind when I set up this script, but forgot about if you wanna have him stand exactly 1 tile away from it. Personally, I'd rather you guys have Link stand directly in front of the item you're gonna buy instead of 16 pixels away on the Y-axis, but... It's your choice. Want me to change it up so he can be 16 pixels away on the Y-axis?

#5 Bayta

Bayta

    Follower of Destiny

  • Members
  • Real Name:Robin Evans
  • Location:Suffolk County, NY

Posted 27 October 2007 - 02:44 PM

Wow, why does everyone seem to have a problem with having to use combos for the items and prices? The items never really disappear anyway. But this script is pwnage! I was originally going to use the advanced shop script from AGN. But this looks better than that. Just one question though; when you buy an item, are the rupees taken away one-by-one, or all at once?

#6 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 27 October 2007 - 03:27 PM

QUOTE(Matthew @ Oct 27 2007, 02:54 PM) View Post

Yup, you do. Is there a problem with that?


...No? icon_eyebrow.gif

Just to make sure the FFC for say item one only has the information for item one right?

#7 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 27 October 2007 - 05:55 PM

QUOTE(Beta Link @ Oct 27 2007, 03:44 PM) View Post

Wow, why does everyone seem to have a problem with having to use combos for the items and prices? The items never really disappear anyway. But this script is pwnage! I was originally going to use the advanced shop script from AGN. But this looks better than that. Just one question though; when you buy an item, are the rupees taken away one-by-one, or all at once?

One-by-one. Look at my comments. icon_wink.gif I felt that doing it that way was better than taking them all at once.

QUOTE(Plissken @ Oct 27 2007, 04:27 PM) View Post

...No? icon_eyebrow.gif

Just to make sure the FFC for say item one only has the information for item one right?

No. Place the script on an FFC. Set the information for the items on THAT FFC. Set the other FFCs where you are to stand when buying an item. And don't ask why I didn't set it to where each FFC has its own data for the items. If you READ my script, you'll see that it's one of the limitations...

#8 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 27 October 2007 - 06:15 PM

Oh well, thanks for the help.

EDIT: Ok now that I got that set up nothing is still working. The first FFC is the one with script added onto it, All the D Variables have the right information, and the location is 0,0. The second FFC has no script attached and is placed where you need to buy that item. Is something wrong with what I've done so far? Nothing seems to be working.

Edited by Plissken, 27 October 2007 - 07:07 PM.


#9 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 27 October 2007 - 09:10 PM

Isn't it possible to have seven items per shop using this? I mean, you could very easily put this into a regular shop room to have a Wal-Mart of sorts.

#10 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 28 October 2007 - 09:23 AM

Nice to see this Matthew, I'll try it sometime.
1 Suggestion,
You're a ZC developer right? Why can't you try to put this in ZC as an option? I mean, so you don't have to use scripts and you have another room type: "Oracle type Shop" or something like that. It would be very nifty. icon_naughty.gif

#11 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 28 October 2007 - 12:09 PM

QUOTE(Twilight_Knight @ Oct 28 2007, 10:23 AM) View Post

Nice to see this Matthew, I'll try it sometime.
1 Suggestion,
You're a ZC developer right? Why can't you try to put this in ZC as an option? I mean, so you don't have to use scripts and you have another room type: "Oracle type Shop" or something like that. It would be very nifty. icon_naughty.gif

Easy answer: I don't want to.
Real answer: Get with the times. Ever heard of FEATURE FREEZE? I'm not allowed to add in anything new. Worse yet, no other dev will fix anything up now to make 'em better simply 'cause it seems like a "new feature". -_-

#12 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 28 October 2007 - 04:48 PM

Ok, I got it all working and stuff like shields and keys and magic works. But when I assign an item to be some bomb ammo or a candle or hookshot (any B button item) it will always (no matter what amount I set it at to pay for it) GIVE me one ruppee and give me the bomb ammo on the counter but not the bombs on the active subscreen. I've tried and tried and it doesn't seem to be a problem with my subscreen, is it just a problem with versions? Since you made it in 357 and I'm using 635.

EDIT: Nevermind, got it fixed. Thanks for the great script.

Edited by Plissken, 28 October 2007 - 05:17 PM.


#13 Teilyr

Teilyr

  • Members
  • Real Name:Adam
  • Location:Louisiana

Posted 28 October 2007 - 09:50 PM

Would you mind posting a screensho of your shopt? It's been years since I played the Oracle games.

#14 Limzo

Limzo

    _

  • Members

Posted 29 October 2007 - 05:57 AM

QUOTE(Ebola Zaire @ Oct 28 2007, 03:10 AM) View Post
Isn't it possible to have seven items per shop using this? I mean, you could very easily put this into a regular shop room to have a Wal-Mart of sorts.


Lol. By having four normal shops with this script in all attatched together you could create something to rival Wal*Mart.


#15 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 29 October 2007 - 08:30 AM

QUOTE(Matthew @ Oct 28 2007, 06:09 PM) View Post

Easy answer: I don't want to.
Real answer: Get with the times. Ever heard of FEATURE FREEZE? I'm not allowed to add in anything new. Worse yet, no other dev will fix anything up now to make 'em better simply 'cause it seems like a "new feature". -_-


Man, that feature freeze is so stupid. icon_evil.gif I forgot about it.-.-
Well, you could whenever the feature freeze is over right? When all the current bugs are fixed?
And BTW, I said it was a suggestion, so don't act like I'm stupid.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users