Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Tip] "Smarter" Shops

I was inspired by Ccoa's NPC topic, So I decided to do the same with a shop.
I want to find out more things with this, and this is the only thing I found out just yet, hope you find it useful :)

--------------------------------------------------------------------------
- Thankful shops. #New
- Moneycounting shops #New
- ...
- ...
--------------------------------------------------------------------------

Thankful shops
"Thanks for buying/selling/coming!"


Let's say: You want a shop that is grateful if you buy something and gives a small gift in return? Now it's possible, but first: The base!

You start up by making an empty event, inserting a event graphic and then inserting a message like: "Welcome!"

Like this:
http://img411.imageshack.us/img411/4287/event013iz.png[/IMG]

Ok, you have this trader say something, now that isn't special. To calculate if you have spend or received money (by selling stuff) we're going to need a variable. So make a variable which checks the money the player currently has:
http://img119.imageshack.us/img119/9048/event026ya.png[/IMG]

That is a start, now, the shop list. List the things in the shop window you want the shopkeeper/trader to sell to you.
Here is what I choosed for:
http://img411.imageshack.us/img411/2916/event037jy.png[/IMG]

Ok, now we need another variable that also counts your money, only, this one checks áfter you bought/sold or anything. We need this variable to check if you bought/sold anything.
So here is the variable:
http://img102.imageshack.us/img102/7590/event040wi.png[/IMG]

Now the event says something, checks your money count, and then sells something to you. And then checks the money count again in another variable. What next?
Right, we are going to make the calculation to see if you have spend, sold something or just took a look what the shop offers.

How are we going to do that?
We're going to need conditional branches for this. The conditional branch checks wether your money count is great, less or the same before you entered the shop window.
Like this: (Sorry, the event window isn't big enough...':|)
http://img119.imageshack.us/img119/3074/event054qp.png[/IMG]

Alright! RMXP makes the calculation now if you have bought or sold anything. The only thing we need to insert now, is some text.
Here you go:
http://img411.imageshack.us/img411/3857/event068gf.png[/IMG]

Ok we're done here! I'm never going to buy at this trader, though...




Moneycounting shops
"You've spend/earned ... Gold!"


We can change this a bit to make it some more interesting, now, this is still a pretty basic shop, we would like to know what we've spend at this shop or earned. Let's do that!
We want to know is: How much money we have spend, to do this, you need to to substract the MoneyCheck2 from the MoneyCheck1 variable. But where do we need to put this? First we need to know that MoneyCheck1 variable is great than the other one, so we put it under the conditional branch which says that the first variable is bigger then variable2:
http://img411.imageshack.us/img411/6125/event076lg.png[/IMG]

Now it calculated the amount of money you spend, but we still don't see that anywhere! Lets put that in the message. You need the code: \v[14] for this, because that show the number of variable 14. Here we go:
http://img161.imageshack.us/img161/2152/event088kt.png[/IMG]

Wow, he counts the amount of money we've given him, he sure is greedy...
Now lets do the same for if you sell something to him.
The thing we need to do is substract the MoneyCheck2 variable from the MoneyCheck1 variable because the second variable is bigger than the first one :). Alright?:
http://img161.imageshack.us/img161/7733/event090wh.png[/IMG]

Now we know how much we've earned and how much the trader lost. But, we don't see the amount anywhere? I think you know what to do ;)
That's right: We need to put \v[15] in the message to show the amount. So here is how to do it:
http://img276.imageshack.us/img276/2986/event109qk.png[/IMG]

Alright! We made a decent shop now!
I'll continue add more later. I would like to know what you all think of it. Seeya!
 

Anonymous

Guest

That is such a cute idea. ^_^ The only problem I could see is if someone bought something, then sold an item that cost the same as the item they bought, thus not changing their gold amount.

One thing you could do is check the amount of items you have of each item the shop sells, instead of or in addition to the gold. That might be more effort than someone wants to go through, though. :P
 
ccoa said:
That is such a cute idea. ^_^ The only problem I could see is if someone bought something, then sold an item that cost the same as the item they bought, thus not changing their gold amount.

One thing you could do is check the amount of items you have of each item the shop sells, instead of or in addition to the gold. That might be more effort than someone wants to go through, though. :P

I thought of that problem too...
Solution: Making prices like: 63, 78, 13, 53. I mean, making unstable prices so it's impossible having the same amount ;):)
 
Nice idea, definately something that'll come in handy...

A little sidenote from me, though: You don't need the second variable, as it's equal to the current amount of gold the party has, therefore no need to story it in a variable. You could just check for it in a script condition, like so:

Code:
Conditional Branch: $game_variables[x] == $game_party.gold
 
What if instead you modified the shop script to add to a variable how much gold you spent, then run that after the shop closes, thus once you reach a certain amount, you get the item or whatever.
 
The only problem I see is that in real life you wouldn't do this:

Me: Hello.
Shopkeeper: Hello.
Me: I am buying this.
Shopkeeper: You bought this for 10 gold.
Me: Ok, I'm closing the shop window now.
Shopkeeper: You bought something? Yay thanks!

/\ What I mean is, the shopkeeper would know you bought something, so this wouldn't be a question. It would be more: "Thank you for buying something".

Sorry, that's just me being picky.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top