=begin Marrend's SuikoShop script A RPG Maker VX Ace script made by Kenneth Regewitz. Furnished to the RPG Maker Network community, and maybe even beyond!? Points of contact On RPG Maker network: Marrend I am usually online on this site. It's like a second home to me. Thus, a private message through this site, or a comment on the script-thread, is probably the most sure way of contacting me with questions regarding this script. Through e-mail: kenregewitz (at) yahoo (dot) com I try to look at my e-mail once a week, but, I've been known to leave it for longer periods of time from various circumstances. Please exercise patience! On RPG Maker Web: Marrend I am not particularly active in this community, and get on, maybe, once a month? Thus, this is the least reliable way to get a hold of me. Terms of use As far as I am concerned, one may freely use this in any commercial, or non-commercial game. All I ask is to be credited by my user-name (ie: Marrend)! Introduction The purpose of this script is to allow for certain shops to automatically update their selection whenever players view "see" items in a more regular store. It is possible to manipulate shops to sell specific categories of items (ie: Items, Weapons, or Armor), or multiple categories, based on a variable. Please refer to the instructions later on for the exact use of this script. As a side-note, the player only needs to activate the shop screen to "see" items. Selecting "Buy", and physically viewing the list, is not necessary. Attempting to nail down the exact moment players view the list, and then setting the proper variable(s) was not particularly desired, or involved a workaround that seemed rather headache-inducing to me. Instructions It is highly recommended you set the category, or categories, of items the SuikoShop sells before making the call to SceneManager. By not specifying it/them, the game WILL use whatever value $shop_mode was set to last, with the possible exceptions of loading the game, or starting a new game. Thus, the script-call would ultimately look something like... $shop_mode = mode SceneManager.call(SuikoShop) ...this. The values to replace "mode" with are as follows: 1 - Items only 2 - Weapons only 3 - Items and Weapons 4 - Armor only 5 - Items and Armor 6 - Weapons and Armor Setting $shop_mode to any other value will make the shop "see" all three categories. Script First thing is first. We must allow items that a Suiko-shop would sell be able to be "seen". The most effective way to do it would be to create a variable in the RPG::BaseItem class, as that is the parent class of RPG::Item, RPG::Weapon, and RPG::Armor. =end class RPG::BaseItem attr_accessor :was_seen # This property is going to be a Boolean: A true/false variable. The best # move would be to initialize it as false... def initialize @id = 0 @name = '' @icon_index = 0 @description = '' @features = [] @note = '' @was_seen = false # ...like so. end # It might also behoove us to make a function to alter/check the variable # we just made. def was_seen?(val=nil) if val == nil # If no value was passed into this function... return @was_seen # ... we simply return the variable's current state. Otherwise... else @was_seen = val # ...we set the variable to whatever value "val" contained. As before, # the intent is to make a true/false variable. end end end =begin That was the easy part. However, as things stand, that variable doesn't actually DO anything yet. To make it do what we want, we need to set up Window_ShopBuy so that objects appearing on a normal shop's list will set the was_seen to variable to true. =end class Window_ShopBuy < Window_Selectable # We set the variable via the make_item_list function. def make_item_list @data = [] @price = {} @shop_goods.each do |goods| case goods[0] when 0; item = $data_items[goods[1]] when 1; item = $data_weapons[goods[1]] when 2; item = $data_armors[goods[1]] end if item # This is the place to use the was_seen? function made earlier. item.was_seen?(true) @data.push(item) @price[item] = goods[2] == 0 ? item.price : goods[3] end end end end =begin Obviously, it's not enough to "see" an item being sold elsewhere. We still have to have a SuikShop react to that variable. This class should act a lot like Scene_Shop, but, of course, with a few edits for good measure. =end class SuikoShop < Scene_Shop # In any event, we want window it uses as a Window_SuikBuy object, as # opposed to a Window_Shop_Buy object! def create_buy_window wy = @dummy_window.y wh = @dummy_window.height @buy_window = Window_SuikBuy.new(0, wy, wh, @goods) # We can prety much ignore the passing of @goods from the above function. @buy_window.viewport = @viewport @buy_window.help_window = @help_window @buy_window.status_window = @status_window @buy_window.hide @buy_window.set_handler(:ok, method(:on_buy_ok)) @buy_window.set_handler(:cancel, method(:on_buy_cancel)) end end =begin So, what the heck does a Window_SuikBuy object do? Well, it's like Window_ShopBuy. However, as one could probably guess... =end class Window_SuikBuy < Window_ShopBuy # ...there are added functions/variables. # Particularly of note is the make_item_list method. It's called by the # refresh method, and is where we will make use of was_seen? def make_item_list @data = [] @price = {} # Normally, the selection is set up via the @shop_goods variable/array. # With a SuikoShop, we must search the database for items that we have # "seen". We'll use a different function for this, as it's very similar # processing in regards to each of the item types. shop_mode = $shop_mode case shop_mode when 1, 2, 4 # This shop-mode sells one catagory of items. include_items?(shop_mode) when 3 # The other shop-modes sell multiple categories of items. This particular # shop-mode sells Items and Weapons. include_items?(1) include_items?(2) when 5 # This shop-mode sells Items and Armor include_items?(1) include_items?(4) when 6 # This shop-mode sells Weapons and Armor. include_items?(2) include_items?(4) else # This shop-mode sells all three catagories. include_items?(1) include_items?(2) include_items?(4) end end # Since we have to search the entire database, this sounds like a job for # MISTER LOOP COMMAND! def include_items?(mode) i = 1 case mode when 1 # Method for items. while i < $data_items.size # First, we see if this item was "seen" before. if $data_items[i].was_seen? == true # If it has, throw it into the list. item = $data_items[i] if item @data.push(item) # Setting custom item prices is a bit beyond the scope of this script! @price[item] = item.price # Thus, we use whatever the database price is. end end i += 1 end when 2 # Method for weapons. while i < $data_weapons.size if $data_weapons[i].was_seen? == true item = $data_weapons[i] if item @data.push(item) @price[item] = item.price end end i += 1 end when 4 # Method for armor. while i < $data_armors.size if $data_armors[i].was_seen? == true item = $data_armors[i] if item @data.push(item) @price[item] = item.price end end i += 1 end end end end =begin That should be it! I hope I have been educational, and maybe even humorous, with these comments! =end