Shopkeeper Dialogue Different if you Buy

2d_quest

Veteran
Veteran
Joined
Oct 18, 2013
Messages
60
Reaction score
7
First Language
English
Primarily Uses
Is there a way to tell whether you bought or didn't buy something at a shop if you use shop processing?  I'd like this so that the shopkeeper would say something if you: didn't buy anything, didn't have enough money, or bought a particular item.  I know you could do it with switches if it was a one of a kind item, but what if it's not. 
 

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
346
Primarily Uses
It should all be quite possible with variables set before and after the shop processing as well as condition branches.


Set Variable [before] -> Game Data / Gold or Game Data / Item in inventory


Shop Processing


Set Variable [After] -> Same as before.


Conditional branch comparing Before and After and changing the dialogue based on which circumstances you want. You can set multiple before and after variables if you want to check for various things at the same time.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That's probably the easiest way, but not the most accurate.

If you have more gold after the shop screen, it could indicate that you only sold something, or it could be that you bought something and sold something, and the item you sold was worth more than the item you bought.

If you have less gold after the shop screen, it could indicate that you only bought something, or it could be that you both bought and sold, and that the item you bought was worth more than the gold you got from selling.

If you have the same amount after the shop screen, it could indicate that you didn't buy or sell anything, or that you both bought and sold, for the same amount.

To be certain, you'd have to allocate switches which would be turned off at the beginning of the shop screen, then turned on after a buy or sell transaction, and you'd have to check the switches afterwards. I'm sure it wouldn't be too difficult to make something like that.

Edit: In fact, here you go. Make sure you change the 1 and 2 for the switch numbers on the first couple of lines, and preferably name those switches so you don't accidentally use them for anything else.

Code:
class Scene_Shop < Scene_MenuBase  #--------------------------------------------------------------------------  # Set the following constants to the id of the switches that will be turned  # on after buying and selling  #--------------------------------------------------------------------------  BUY_SWITCH = 1  SELL_SWITCH = 2  #--------------------------------------------------------------------------  # * Prepare  #--------------------------------------------------------------------------  alias shaz_shop_notice_prepare prepare  def prepare(goods, purchase_only)    shaz_shop_notice_prepare(goods, purchase_only)    $game_switches[BUY_SWITCH] = false    $game_switches[SELL_SWITCH] = false  end  #--------------------------------------------------------------------------  # * Execute Purchase  #--------------------------------------------------------------------------  alias shaz_shop_notice_do_buy do_buy  def do_buy(number)    shaz_shop_notice_do_buy(number)    $game_switches[BUY_SWITCH] = true  end  #--------------------------------------------------------------------------  # * Execute Sale  #--------------------------------------------------------------------------  alias shaz_shop_notice_do_sell do_sell  def do_sell(number)    shaz_shop_notice_do_sell(number)    $game_switches[SELL_SWITCH] = true  endend
 
Last edited by a moderator:

2d_quest

Veteran
Veteran
Joined
Oct 18, 2013
Messages
60
Reaction score
7
First Language
English
Primarily Uses
Is there a way to tell whether you bought or didn't buy something at a shop if you use shop processing?  I'd like this so that the shopkeeper would say something if you: didn't buy anything, didn't have enough money, or bought a particular item. 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Merged. Please stick with a single thread for your issue, since the two are closely related.


If you want to know if they bought a particular item, you would have to use Rachael's original suggestion - put the number of those items on hand into a variable, do the shop processing, put the number of those items on hand into a second variable, then compare the two.


The "didn't have enough money" is more complicated, since a shop can stock half a dozen different items, and you might be able to afford 3 of them, but the developer would have no way of knowing which of the 6 items the player might WANT to purchase, and they could ATTEMPT to buy the other 3 items and get the buzzer, so a "didn't have enough money" wouldn't specify a particular item either.


If it's a shopkeeper with only one item and you want a different message if they don't have enough money, I just skip the shop processing altogether, have the NPC ask if you'd like the item, and add conditional branches and choices depending on whether there's enough money or not.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Because I merged the two threads (as indicated by my saying "Merged" ;) ).


Post 1 and post 4 are yours, asking pretty much the same question. You still haven't said if the script I provided less than half an hour after you originally asked, does the job or not.
 
Last edited by a moderator:

2d_quest

Veteran
Veteran
Joined
Oct 18, 2013
Messages
60
Reaction score
7
First Language
English
Primarily Uses
You still haven't said if the script I provided, does the job or not.
Sorry I know I'm way late, life got busy for awhile and I forgot to answer this.  The script works and will be useful.  I did want it to do 2 more things though.  Check what specific items you bought or sold, and also if you try to buy something too expensive set a switch and exit shop processing with the ability to enable and disable this.  If keeping track of all items bought and sold is too much then maybe just checking if a particular item has been bought or a particular one sold.  I don't know how much is actually possible in RM, so I may not know what I'm asking.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top