Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
This script enhances the game shop, providing useful options that allow you to customize each shop good individually.

This script provides functionality for remembering a shop’s “state”. Each shop is uniquely identified by a shop ID, and if you visit the same shop repeatedly, you should see the same settings.

For example, if a shop holds 10 potions, and you bought 5, then you can expect that the next time you visit the shop, it will only have 5 potions remaining. Of course, you will need extra plugins to have that kind of functionality.

Download

Script: get it at Hime Works

Updates

Hiding or disabling shop goods - Control when shop goods should appear on the list or be available

Price Formulas for shop goods

Plugins

The following scripts are written for the Shop Manager and extend its functionality.

Sell Only Shop - You can only sell items in this shop.

Common Event Shop - set up common event items for sale

Learn Skill Shop - buy and learn skills directly from shops
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
Good work so far. This script has a slight problem though...I am able to buy goods even with no money though. :unsure: B)

I believe this might be because that enable? in Window_ShopBuy is overwrote with this:
 

def enable?(shopGood) true endTo solve this issue I replaced that with this:

def enable?(shopGood) item && price(shopGood) <= @money && !$game_party.item_max?(shopGood) end
Thank you for this script. Can't wait to see what becomes of it further down the road.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
That overwrite was a mistake lol the updated version has addressed it.

I will need to come up with a different name...
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
That overwrite was a mistake lol the updated version has addressed it.

I will need to come up with a different name...
Yup works great now, thank you. :D
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
There was a bug where common event shops were not handled correctly.

I have solved the problem, but not sure if there will be compatibility issues.

This is what it looks like

class Game_Temp # even if we're not actually calling a shop, it shouldn't affect anything # because we are always setting this at each common event call by an event attr_accessor :shop_common_event_idend#--------------------------------------------------------------------------# * Common Event#--------------------------------------------------------------------------alias :th_shop_manager_command_117 :command_117def command_117 $game_temp.shop_common_event_id = @params[0] th_shop_manager_command_117endThe "shop common event ID" is always set whenever a common event is called by an event (and not by an item use or something)

Since it is a global variable, this will lead to problems if you have common events with shops calling other common events with shops...maybe I will have to use an array and index by depth.

Anyways hopefully this won't be much of an issue for other scripts.
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
No problems with it so far with the update. :)
Hope you don't mind but I've wrote an little add-on, that I can/will update anytime you update yours... unless you just want to use my code in your work (or a similar, maybe better code).

Either way is fine with me.

Let me know what ya think. If you like it please post it on your first post (and anywhere else you like).
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
You should alias the `include?` method defined in Window_ShopBuy to determine whether an Shop Good should be included in the list or not.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
You should alias the `include?` method defined in Window_ShopBuy to determine whether an Shop Good should be included in the list or not.
Thanks for the tip, I actually did think of that... only after I had wrote all the others. lol, I will attempt to change the code to alias the 'include?' method instead.

Attempting it now...

Edit:

Wow, that was pretty easy...

Title:

Shop Manager - Hide Items Add-On

Script:

Removed. This will be posted in a new topic.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
It would be better to write the `include?` logic like this

alias :th_include? :include?def include?(shopGood) return false if (your condition is not met) th_include?(shopGood)endThis way, if a lot of people were aliasing that method, it would end up looking like

return false if condition1 not metreturn false if condition2 not metreturn false if condition3 not met...# conditions all met, so we can include itreturn true I will see how I can make the draw_item method more flexible.

I might have to overwrite the default Scene_Shop methods though.
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
Tsukihime, on 25 Feb 2013 - 19:30, said:

It would be better to write the `include?` logic like this

alias :th_include? :include?def include?(shopGood) return false if (your condition is not met) th_include?(shopGood)end
This way, if a lot of people were aliasing that method, it would end up looking like
 
Code:
return false if condition1 not metreturn false if condition2 not metreturn false if condition3 not met...# conditions all met, so we can include itreturn true
Like this?

alias :my_include? :include? def include?(shopGood) if $game_switches[REGEXP::SWITCH_ID] return false if $game_switches[REGEXP::ALWAYS_HIDE_SWITCH_ID] return false if shopGood.item.noshow_token == REGEXP::TOKEN end my_include?(shopGood) end
I will see how I can make the draw_item method more flexible.
I might have to overwrite the default Scene_Shop methods though.
Best of luck to ya, unfortunately it seems like the only way would be to overwrite.

Full Script:

=begin#=============================================================================== Title: Shop Manager - Hide Items Add-On Shop Manager Author: Tsukihime Add-on Author: CT_Bolt Date: Feb 22, 2013-------------------------------------------------------------------------------- ** Change log 1.0 Feb 25, 2013 - Initial Release-------------------------------------------------------------------------------- ** Terms of Use * Free to use in commercial/non-commercial projects * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Preserve this header-------------------------------------------------------------------------------- ** Installation--------------------------------------------------------------------------------Place this script below Shop Manager & YEA - Ace Shop Options (if used)Place this script above Shop Stock (if used) & main. ** Description Hides items, weapons, & armor from being presented in the shop with a notetag Hides prices from being presented in the shop with a notetag Hides all items, weapons, & armor from being presented in the shop with a switch Hides all prices from being presented in the shop with a switch-------------------------------------------------------------------------------- Compatibility: Compatible with Yanfly Engine Ace - Ace Shop Options v1.01 * Overwrite methods: class Window_ShopBuy < Window_Selectable def draw_item(index) * Alias Methods: class Window_ShopBuy < Window_Selectable def include?(shopGood) module DataManager def load_database class Scene_Title < Scene_Base def command_new_game-------------------------------------------------------------------------------- ** Usage Place <hide item> in an item, weapon, or armor notebox on a newline to have these not show up in a shop. Place <hide item price> in an item, weapon, or armor notebox on a newline to have the price of these not show up in a shop.#================================================================================endmodule REGEXP TOKEN = "<hide item>" #Token to Hide the items/weapons/armor TOKEN_PRICE_ONLY = "<hide item price>" #Token to Hide price of the #items/weapons/armor SWITCH_ID = 128 #Switch that determines weather the items will show up AUTO_ON = true #Set this to true to turn the above switch on when the #user loads a new game ALWAYS_HIDE_PRICE_SWITCH_ID = 130 #Switch that determines weather the items #price will show up ever ALWAYS_HIDE_SWITCH_ID = 131 #Switch that determines weather the items #will show up everendmodule DataManager #-------------------------------------------------------------------------- # ● Loads the database #-------------------------------------------------------------------------- class << self alias_method:)my_load_database, :load_database) end def self.load_database my_load_database load_noshow_notetags end #-------------------------------------------------------------------------- # ● Loads the note tags #-------------------------------------------------------------------------- def self.load_noshow_notetags groups = [$data_items, $data_weapons, $data_armors] for group in groups for obj in group next if obj.nil? obj.load_noshow_notetags end end puts "Read: Hide Item Notetags" endend#==========================================================================# ■ RPG::Item#==========================================================================class RPG::Item < RPG::UsableItem #-------------------------------------------------------------------------- # ● Public instance variables #-------------------------------------------------------------------------- attr_reader :noshow_token #-------------------------------------------------------------------------- # ● Loads the note tags #-------------------------------------------------------------------------- def load_noshow_notetags @noshow_token = "" @note.split(/[\r\n]+/).each do |line| case line when REGEXP::TOKEN @noshow_token = line when REGEXP::TOKEN_PRICE_ONLY @noshow_token = line end end endend#==========================================================================# ■ RPG::EquipItem#==========================================================================class RPG::EquipItem < RPG::BaseItem #-------------------------------------------------------------------------- # ● Public instance variables #-------------------------------------------------------------------------- attr_reader :noshow_token #-------------------------------------------------------------------------- # ● Loads the note tags #-------------------------------------------------------------------------- def load_noshow_notetags @noshow_token = "" @note.split(/[\r\n]+/).each do |line| case line when REGEXP::TOKEN @noshow_token = line when REGEXP::TOKEN_PRICE_ONLY @noshow_token = line end end endend#-------------------------------------------------------------------------------# @shop_goods is now an array of Game_ShopGoods#-------------------------------------------------------------------------------class Window_ShopBuy < Window_Selectable alias :my_include? :include? def include?(shopGood) if $game_switches[REGEXP::SWITCH_ID] return false if $game_switches[REGEXP::ALWAYS_HIDE_SWITCH_ID] return false if shopGood.item.noshow_token == REGEXP::TOKEN end my_include?(shopGood) end unless $imported["YEA-ShopOptions"].nil? #-------------------------------------------------------------------------- # overwrite method: draw_item #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] return if item.nil? rect = item_rect(index) draw_item_name(item, rect.x, rect.y, enable?(item), rect.width-24) rect.width -= 4 contents.font.size = YEA::LIMIT::SHOP_FONT if $imported["YEA-AdjustLimits"] if item.noshow_token != REGEXP::TOKEN_PRICE_ONLY || $game_switches[REGEXP::SWITCH_ID] != true if $game_switches[REGEXP::ALWAYS_HIDE_PRICE_SWITCH_ID] != true draw_text(rect, price(item).group, 2) end end reset_font_settings end else #-------------------------------------------------------------------------- # overwrite method: draw_item #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] rect = item_rect(index) draw_item_name(item, rect.x, rect.y, enable?(item)) rect.width -= 4 if item.noshow_token != REGEXP::TOKEN_PRICE_ONLY || $game_switches[REGEXP::SWITCH_ID] != true if $game_switches[REGEXP::ALWAYS_HIDE_PRICE_SWITCH_ID] != true draw_text(rect, price(item), 2) end end end end endclass Scene_Title < Scene_Base alias my_new command_new_game def command_new_game my_new $game_switches[REGEXP::SWITCH_ID] = REGEXP::AUTO_ON if $game_switches[REGEXP::SWITCH_ID] == true puts "Switch " + REGEXP::SWITCH_ID.to_s + " is turned on." else puts "Switch " + REGEXP::SWITCH_ID.to_s + " is turned off." end endend
I will make a new topic for this, but for now until it is all optimized I will just post that above.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
Another option is to create your own shop scene and windows, inheriting from the base scenes and windows as needed.


Then you don't have to worry about it too much, and any changes made to the base classes will be inherited by your classes as well.


That is how I did the SellOnlyShop scene and windows with minimal coding.
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
Good idea, unfortunately I can't really figure out how you did that one... that's a bit over my head (I just started writing in RGSS3 real recently).


If/when I do understand how to do this... would I create a new shop scene for hiding items & then have to set the @shop_type to something like "HideItems" before calling a shop?

If that is the case, would it break compatibility with the SellOnlyShop script?
I'm getting really confused by this concept. :dizzy:
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
No, it won't break compatibility with the other window, but it also means other windows won't have the same properties as your window.

OrM2EfD.jpg


Both classes can exist simultaneously and will not conflict with one another. You can inherit any methods or properties defined in any parent classes and overwrite them to suit your own classes.

Since they exist side-by-side, anything defined in one class will not be available in the other. Which is great if you really need to overwrite things and is afraid of breaking compatibility.

To create and use a new type of shop, it is done in 3 steps

1. Choose a name:

SellOnlyShop2. Define some required classes. Everything else is optional.

class Game_SellOnlyShop < Game_Shopendclass Scene_SellOnlyShop < Scene_Shopend3. In an event, before shop processing, make script call

@shop_type = "SellOnlyShop"And then it should work.
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
No, it won't break compatibility with the other window, but it also means other windows won't have the same properties as your window.
Oh I'm sorry I should have been more clear. What I meant by it breaking compatibility was that if I was to call my own shop scene (ex. "HideItemsShop").

Then I wouldn't be able to hide items in the other scenes (ex. "SellShopOnly") like I can with my current script. Maybe I'm misunderstanding again.

Wow, thank you for all that info! :cutesmile:   I'll be playing around with this until I can get it to work. :rock-left:

Edit:

Such an excellent way of putting it... I didn't realize that in the shop manager you have a great method that takes care of the shop_type.

This one:

Code:
  def self.shop_class(shop_type)    shop_type = "Game_" + shop_type.to_s    return Object.const_get(shop_type.to_sym)  end
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
Yes unfortunately you would need to make changes directly to the base windows in order for other window classes to have those nice effects. But there are probably a lot of other things you could do that don't require other types of shops to be affected.


Maybe in the next update there will be more flexible window management.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
The Shop Manager now comes with the ability to set two "shop options". You can now choose whether a shop good should be included on the list, or whether a shop good should be selectable or not.

These options apply to all shops as long as they inherit from the base classes provided by the Shop Manager.

I have updated existing shops to support these options.

shopOptions1.jpg


trans.gif


Usage

Hidden shop goods

To hide a shop good, you can specify a "hidden condition", which is any valid ruby statement that evaluates to true or false. When the hidden condition is met, the shop good will not be listed in the buy window.

To specify a hidden condition, before the Shop Processing command in your event editor, make a script call

 hide_good(good_id, condition)
shopOptions2.jpg


For example, if we wanted to hide the 2nd good if actor 1's level is below 10, we can say

hide_good(2, "$game_actors[1].level < 10")Disable Shop Goods

To disable a shop good, you can specify a "disable condition", which is any valid ruby statement that evaluates to true or false. When the disable condition is met, the shop good will not be selectable even if you have enough money to buy it.

To specify a disable condition, before the Shop Processing command in your event editor, make a script call

disable_good(good_id, condition)
shopOptions3.jpg


For example, if we wanted to disable the 3rd good if the party leader's level is less than 5, we can say

Code:
disable_good(3, "$game_party.leader.level < 5")
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,241
Reaction score
793
First Language
Javascript
Primarily Uses
RMMZ
The Shop Manager now comes with the ability to set two "shop options". You can now choose whether a shop good should be included on the list, or whether a shop good should be selectable or not.
AWESOME! BD   Gonna try it out in a little bit when I have more time. :rock-left:
 
Last edited by a moderator:

Kalwin

Villager
Member
Joined
Dec 21, 2012
Messages
9
Reaction score
0
First Language
English
Hello Tsukihime,

I was wondering, if two different shops can exist in the same Event using this script?

I am using this with Bubble's Crafting Script and your add-on, using YanFly's Shop Options script. I created a event "Woodsman" who is able to sell wood to the player, but also

is a Carpenter using the crafting scripts. When I enter the normal shop scene, everything works fine. Then if I do the TOCraftingShop it shows the "normal" shop scene. The

reverse happened when I do the Crafting Scene before doing a normal shop scene.

I've have looked through everything, I don't see any errors, and everything works fine, unless I try to access the other shop scene. The only time it happens is when you are

trying to have two different shops in the same event. I may have missed a script command in there. I don't think this is a bug, but I am trying something if can't do, or I mssed

a step, please let me know.

Thank you for your time, again. :)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,917
First Language
English
This script uses an event as a shop, so one event can only have one shop.


I tried to make it so that each page can be its own shop since you might have the same NPC providing different services over the course of the game, but I don't think I ever got it working.


So for now one shop per event.
 
Last edited by a moderator:

Kalwin

Villager
Member
Joined
Dec 21, 2012
Messages
9
Reaction score
0
First Language
English
Thanks for the reply.

Ah, I see. Now I know instead of banging my head on a wall, heh. Thanks again for the wonderful scripts.
 

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_10_1_2022_3_48_29.png
Wave's Elite guard comes to attack while you traverse Lab 5... They've got jetpacks too.
Making a weapon stronger according to the user level!
God, I wish I could afford a big band for my game. Not like... Foo Fighters or whatever. A big brass band. For ridiculous jazzy nonsense ala
Let it be known that I am very forgetful, and I often forget that I was engaged in conversation with people
here (and every other community I'm on). So if I ever stop replying to PMs or comments, please don't take it personally and just send me a reminder to reply XD
Darklord99 wrote on Restart's profile.
Hi I tried to download the fossil plugin but I got a 404 message from github

Forum statistics

Threads
125,707
Messages
1,172,935
Members
164,841
Latest member
tommy8bit
Top