- Joined
- Jan 28, 2013
- Messages
- 90
- Reaction score
- 1
- First Language
- English
- Primarily Uses
Counting instance items in SHOP
Okay, this is gonna be fun to explain. I am using the script "Instance Items by Enelvon" and it allows me to have an item, armor or weapon to be counted as an individual per every one in your inventory like it shows in the picture below for my inventory. For instance, The "Fire" is just one item, with multiple instances and they are all counted as individuals
SES Core by Solistra and Enelvon(REQUIRED):
Instance Items Script by Enelvon:
Picture Example:
What I am liking to achieve:
Okay, What I would like to achieve is when I am in the "Shop" scene and it shows how many of the items you have in possession, which in my case, it would only show 1 due to each one of my "Fire" being its own individual instance an counting as one. I would like the shop to know that there are 3 in my inventory or however many amounts i have of that same item in my inventory. The way I was thinking about making this possible is to somehow write a notetag script and be able to be a notetag for the script allow it show as its on individual item per instance, but when entering a shop, it will know that there are 3 instances of the same item.. so they would be counted as 3 in my possession.
*I am using the default RPG shop scene..
Okay, this is gonna be fun to explain. I am using the script "Instance Items by Enelvon" and it allows me to have an item, armor or weapon to be counted as an individual per every one in your inventory like it shows in the picture below for my inventory. For instance, The "Fire" is just one item, with multiple instances and they are all counted as individuals
SES Core by Solistra and Enelvon(REQUIRED):
#═╦═════════════════════════════════════════════════════════════════════════════# ║ § SES Core (v1.2) by Solistra and Enelvon [License: CC BY-SA 3.0]# ║ <RMVX Ace>#═╬═════════════════════════════════════════════════════════════════════════════# ║ § Change Log#─╫─────────────────────────────────────────────────────────────────────────────# ║ v1.0 (December ???, 2012) - Initial release# ║ v1.1 (February 26th, 2013) - Enelvon fixed an issue with scanning comments,# ║ but took forever to remember to upload it# ║ v1.2 (March 15, 2013) - Ditto the above# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Summary#─╫─────────────────────────────────────────────────────────────────────────────# ║ This serves as a base script required by some SES scripts released by both# ║ Solistra and Enelvon. It contains some utility methods and methods to help# ║ facilitate the use of tags in note boxes and event comments.# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Installation#─╫─────────────────────────────────────────────────────────────────────────────# ║ For best compatibility, place this script below Materials, but above all# ║ other custom scripts (especially SES scripts).# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § New Methods#─╫─────────────────────────────────────────────────────────────────────────────# ║ ● Game_Event# ║ comments# ║ ● Game_Interpreter# ║ this# ║ event# ║ comments# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ ▼ module SES#═╩═════════════════════════════════════════════════════════════════════════════module SES # Includes SES in the data structures used by RMVX Ace by default. def self.insert RPG.constants.each do |s| (s = RPG.const_get(s)).send
include, self) s.constants.each{|c| s.const_get(c).send
include, self)} end end # Used in Game_Event and Game_Interpreter to collect comments. def self.comment_proc Proc.new do @list.select{|c| c.code == 108 || c.code == 408}.map{|c|c.parameters[0]} end end # An extended version of Kernel.rand. Also takes ranges, arrays, or hashes. def self.rand(arg = nil) if arg.is_a?(Range) then Kernel.rand(1 + arg.max - arg.min) + arg.min elsif arg.kind_of?(Array) then arg[Kernel.rand(arg.size)] elsif arg.is_a?(Hash) then self.rand(arg.values) else Kernel.rand(arg) end end # Note tag scanning method. def scan_ses_notes(tags = {}) return unless defined?(self.note) self.note.split(/[\r\n+]/).each do |line| tags.each{|regex, code| eval(code) if line =~ regex} end end # Allows scan_ses_comments to work. def comments com = [] if self.is_a?(RPG::Event:
age) || self.is_a?(RPG::CommonEvent) @list.each{|c|com.push(c.parameters[0]) if c.code == 108 || c.code == 408} end com end # Event comment scanning method. May be used in common events as well. def scan_ses_comments(tags = {}) self.comments.each do |comment| tags.each{|regex, code| eval(code) if comment =~ regex} end end # Method definitions are complete; include SES in the RPG data structures. self.insertend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ module SES#═╩═════════════════════════════════════════════════════════════════════════════ ($imported ||= {})["SES - Core"] = 1.1#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▼ class Game_Event#═╩═════════════════════════════════════════════════════════════════════════════class Game_Event < Game_Character def comments() self.instance_eval(&SES.comment_proc) endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Game_Event#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class Game_Interpreter#═╩═════════════════════════════════════════════════════════════════════════════class Game_Interpreter def event(id) $game_map.events[id] end def this() @event_id > 0 ? $game_map.events[@event_id] : self end def comments() this.page ? self.instance_eval(&SES.comment_proc) : [] endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Game_Interpreter#═╩═════════════════════════════════════════════════════════════════════════════
#═╦═════════════════════════════════════════════════════════════════════════════# ║ § Instance Items (v1.3) by Enelvon [License: CC BY-SA 3.0]# ║ <RMVX Ace>#═╬═════════════════════════════════════════════════════════════════════════════# ║ § Change Log#─╫─────────────────────────────────────────────────────────────────────────────# ║ v1.0 (December 25th, 2012) - Released the script for the first time# ║ v1.1 (December 26th, 2012) - Fixed a single-word error that could cause# ║ issues with non-unique armor# ║ v1.2 (February 16th, 2013) - Added the ability to check if an item is# ║ instanced# ║ v1.3 (February 17th, 2013) - Fixed a bug with equipping items# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Summary#─╫─────────────────────────────────────────────────────────────────────────────# ║ This script adds the ability to have 'instances' of items. Each instance may# ║ have slightly different stats/effects than the base item. This script# ║ contains only the ability to have stat variance on equip items - it is# ║ intended to be extended by others in order to add more features.#═╬═════════════════════════════════════════════════════════════════════════════# ║ § Required Scripts#─╫─────────────────────────────────────────────────────────────────────────────# ║ SES Core# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Known Incompatibilities#─╫─────────────────────────────────────────────────────────────────────────────# ║ None.# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Installation#─╫─────────────────────────────────────────────────────────────────────────────# ║ Place this below Materials and the SES Script Core, and above all other# ║ non-SES custom scripts (though make sure it's above any Instance Item# ║ extensions).# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Configuration#─╫─────────────────────────────────────────────────────────────────────────────# ║ There is some simple configuration required to use this script. Locate# ║ All_Unique in the SES::InstanceItems module (that should not be hard - it's# ║ at the top of the script). Change the value of each key to change whether or# ║ not items of that type will be treated as unique by default.# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Tags#─╫─────────────────────────────────────────────────────────────────────────────# ║ ● Weapon/Armor# ║ <Unique># ║ Placing this in the Notes box of an item will toggle uniqueness. If its# ║ item type defaults to being unique, the item will be nonunique. If the# ║ item type defaults to nonunique, the item will be unique.# ║ # ║ <Vary !Stat!: !Value!, !Chance!># ║ Place this in a Notes box to set a variance of !Value! for !Stat!.# ║ !Chance is the likelihood (as a percentage) that variance will occur.# ║ This is a very basic implementation of variance - created items of the# ║ type will have a value of up to the given number added or subtracted# ║ from their base value for the stat. Don't expect it to work miracles,# ║ just for it to work.# ║ ► Replacements:# ║ !Stat! with hp, mp, atk, def, mat, mdf, agi, or luk.# ║ !Value! with an integer for the maximum variance of the stat.# ║ !Chance! with a percentage chance of variance occurring.# ║ # ║ ● Item# ║ <Unique># ║ Placing this in the Notes box of an item will toggle uniqueness. If its# ║ item type defaults to being unique, the item will be nonunique. If the# ║ item type defaults to nonunique, the item will be unique.# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Aliased Methods#─╫─────────────────────────────────────────────────────────────────────────────# ║ ● module DataManager# ║ self.create_game_objects# ║ self.make_save_contents# ║ self.extract_save_contents# ║ # ║ ● class Game_BaseItem# ║ initialize# ║ # ║ ● class Game_Party# ║ gain_item - as trade_item so instancing can be avoided# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § Redefined Methods#─╫─────────────────────────────────────────────────────────────────────────────# ║ ● class Game_BaseItem# ║ object# ║ set_equip(is_weapon, item_id, unique)# ║ # ║ ● class Game_Actor# ║ equips_include?(item)# ║ init_equips(equips)# ║ trade_item_with_party(new_item, old_item)# ║ change_equip_by_id(slot_id, item_id)# ║ # ║ ● class Game_Party# ║ gain_item(item, amount, include_equip = false)# ║ lose_item(item, amount, include_equip = false)# ║ # ║ ● class Window_ItemList# ║ draw_item(index)# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ § New Methods#─╫─────────────────────────────────────────────────────────────────────────────# ║ ● class Game_Party# ║ new_item(item, type)# ║ #═╬═════════════════════════════════════════════════════════════════════════════# ║ ▼ module SES::InstanceItems#═╩═════════════════════════════════════════════════════════════════════════════module SES module InstanceItems #═╦═══════════════════════════════════════════════════════════════════════════ # ║ α BEGIN CONFIGURATION #═╩═══════════════════════════════════════════════════════════════════════════ # The hash defining the base uniqueness value of each type of item. Setting # one of these to true makes items of the given type be true by default. # Setting it to false will have them default to nonunique, as in base VXAce. All_Unique = { RPG::Weapon => false, RPG::Armor => true, RPG::Item => true, } #═╦═══════════════════════════════════════════════════════════════════════════ # ║ Ω END CONFIGURATION #═╩═══════════════════════════════════════════════════════════════════════════ # RegExp for toggling uniqueness of an item. Unique = /^<Unique>/i # RegExp for stat variance. StatVariance = /^<Vary (\w+):\s*(\d+),\s*(\d+)%?>/i # List of stat indices. You can add custom stats to this to allow them to # be varied, but the custom stats must be added to the game as part of the # params array for this to have any effect. StatIndex = ['hp', 'mp', 'atk', 'def', 'mat', 'mdf', 'agi', 'luk']end end ($imported ||= {})["SES - Instance Items"] = 1.0#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ module SES::InstanceItems#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class RPG::BaseItem#═╩═════════════════════════════════════════════════════════════════════════════class RPG::BaseItem attr_accessor
ld_id; attr_accessor :instanced def unique; scan_ses_notes if !@unique; return @unique endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class RPG::BaseItem#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class RPG::EquipItem#═╩═════════════════════════════════════════════════════════════════════════════class RPG::EquipItem < RPG::BaseItem # Scans the notes box of the item alias en_ii_ei_ssn scan_ses_notes def scan_ses_notes(tags = {}) @variances = [[0,100]] * 8 @unique = SES::InstanceItems::All_Unique[self.class] tags[SES::InstanceItems::StatVariance] = "stat = SES::InstanceItems::StatIndex.index($1.to_s.downcase) @variances[stat] = [$2.to_i, $3.to_i]" tags[SES::InstanceItems::Unique] = "@unique = !@unique" en_ii_ei_ssn(tags) end def variances; scan_ses_notes if !@variances; return @variances end # Allows basic variance def vary unless @varied (0...@params.size).each do |i| v = rand(variances[0]).to_i; v *= -1 if rand(8) <= 3 @params += v if rand(100) < variances[1] end @varied = true end endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class RPG::EquipItem#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class RPG::Item#═╩═════════════════════════════════════════════════════════════════════════════class RPG::Item < RPG::UsableItem # Scans the Notes box of the item alias en_ii_i_ssn scan_ses_notes def scan_ses_notes(tags = {}) @unique = SES::InstanceItems::All_Unique[self.class] tags[SES::InstanceItems::Unique] = "@unique = !@unique" en_ii_i_ssn(tags) endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class RPG::Item#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ module DataManager#═╩═════════════════════════════════════════════════════════════════════════════module DataManager class << self alias en_fs_dm_cgo create_game_objects alias en_fs_dm_msc make_save_contents alias en_fs_dm_esc extract_save_contents end def self.create_game_objects en_fs_dm_cgo $game_armors, $game_weapons, $game_items = $data_armors, $data_weapons, $data_items end def self.make_save_contents contents = en_fs_dm_msc contents[:armors], contents[:weapons], contents[:items] = $game_armors, $game_weapons, $game_items contents end def self.extract_save_contents(contents) en_fs_dm_esc(contents) $game_armors, $game_weapons, $game_items = contents[:armors], contents[:weapons], contents[:items] endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ module DataManager#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class Game_BaseItem#═╩═════════════════════════════════════════════════════════════════════════════class Game_BaseItem alias en_ii_gbi_i initialize def initialize en_ii_gbi_i @unique = false end def object id = @item_id return $data_skills[@item_id] if is_skill? if is_item? then return $game_items[id] elsif is_weapon? then return $game_weapons[id] elsif is_armor? then return $game_armors[id] end return nil end def set_equip(is_weapon, item_id, unique = false) @class = is_weapon ? RPG::Weapon : RPG::Armor @item_id = item_id @unique = unique endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Game_BaseItem#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class Game_Actor#═╩═════════════════════════════════════════════════════════════════════════════class Game_Actor < Game_Battler def equips_include?(item) equips.compact.each do |e| return true if e.old_id == item.id && e.class == item.class end return false end def init_equips(equips) @equips = Array.new(equip_slots.size) { Game_BaseItem.new } equips.each_with_index do |item_id, i| etype_id = index_to_etype_id(i) slot_id = empty_slot(etype_id) if etype_id == 0 then i, t = $data_weapons[item_id], :weapon else i, t = $data_armors[item_id], :armor end if !i.nil? && i.unique then id, u = $game_party.new_item(i, t).id, true elsif i.nil? then id, u = 0, false else id, u = i.id, false end @equips[slot_id].set_equip(etype_id == 0, id, u) if slot_id end refresh end def trade_item_with_party(new_item, old_item) return false if new_item && !$game_party.has_item?(new_item) $game_party.trade_item(old_item, 1) $game_party.lose_item(new_item, 1) return true end def change_equip_by_id(slot_id, item_id) if equip_slots[slot_id] == 0 change_equip(slot_id, $game_weapons[item_id]) else change_equip(slot_id, $game_armors[item_id]) end endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Game_Actor#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class Game_Party#═╩═════════════════════════════════════════════════════════════════════════════class Game_Party < Game_Unit alias trade_item gain_item def new_item(item, type) newi = Marshal.load(Marshal.dump(item)) newi.old_id = item.id newi.instanced = true newi.id = eval("$game_#{type}s.size") newi = process_new_item(newi) eval("$game_#{type}s.push(newi) $game_#{type}s[newi.id].vary unless type == :item return $game_#{type}s[newi.id]") end def process_new_item(item) return item end [:items, :weapons, :armors].each do |i| define_method(i) do eval("@#{i}.keys.sort.collect { |id| $game_#{i}[id] }") end end def gain_item(*args) oitem = args[0] if !args[0].nil? args[1].times do item = oitem if item && item.unique args[0] = if item.is_a?(RPG::Weapon) then new_item(item, :weapon) elsif item.is_a?(RPG::Armor) then args[0] = new_item(item, :armor) elsif item.is_a?(RPG::Item) then args[0] = new_item(item, :item) end end trade_item(args[0], 1) end end def lose_item(*args) args[1] *= -1 trade_item(*args) endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Game_Party#─╫─────────────────────────────────────────────────────────────────────────────# ║ ▼ class Window_ItemList#═╩═════════════════════════════════════════════════════════════════════════════class Window_ItemList < Window_Selectable def draw_item(index) item = @data[index] if item rect = item_rect(index) rect.width -= 4 draw_item_name(item, rect.x, rect.y, enable?(item)) draw_item_number(rect, item) unless item.unique end endend#═╦═════════════════════════════════════════════════════════════════════════════# ║ ▲ class Window_ItemList#═╩═════════════════════════════════════════════════════════════════════════════
Picture Example:
What I am liking to achieve:
Okay, What I would like to achieve is when I am in the "Shop" scene and it shows how many of the items you have in possession, which in my case, it would only show 1 due to each one of my "Fire" being its own individual instance an counting as one. I would like the shop to know that there are 3 in my inventory or however many amounts i have of that same item in my inventory. The way I was thinking about making this possible is to somehow write a notetag script and be able to be a notetag for the script allow it show as its on individual item per instance, but when entering a shop, it will know that there are 3 instances of the same item.. so they would be counted as 3 in my possession.
*I am using the default RPG shop scene..
