New threads (complete scripts) here will go into a moderation queue. You will not see your thread appear when you create it. A moderator will decide if it will be approved or denied.
Introduction: The script allows you to set requirements for weapon and armor. For instance, outfitting a hero with two-handed axe would be possible only after reaching a specific level or having adequate statistics. Also added an option that allows to require certain skills.
Features: - quite simple configuration, - window displaying which stats are too low and which skills are needed, - showing of the required skill can be turn on/off.
Screenshots:
Spoiler:
How to Use: To use the script insert tag into the "Notes" box located in the Weapon or Armor tab of the database:
where: LV - required actor's level MAXHP - maximum HP MAXMP - maximum MP ATK - Attack DEF - Defence SPI - Spirit AGI - Agility
For example: If you want a character to equip a weapon at level 6, provided that it has 120 max HP, 40 Attack, 70 Defence, add in the specified weapon's "Note" box:
CODE
<stat_require 6, 120, 0, 40, 70, 0, 0>
To set that the specified armor can be equipped only after gaining certain skill(s), add in "Note" box:
CODE
<skill_require ID, ID, ...>
where: ID - required skill(s) ID(s)
For example: To equip an weapon, that "requires" skills ID 10 and 40:
CODE
<skill_require 10, 40>
Script:
Spoiler:
CODE
#=================================================================== # Equipment Requirements [VX] # by Ayene # 27.01.2010 ver 1.2 # www.ultimateam.pl #=================================================================== # Opis: # The script allows you to set requirements for weapon and armor. # For instance, outfitting a hero with two-handed axe would be possible # only after reaching a specific level or having adequate statistics. # Also added an option that allows to require certain skills. # # Instruction: # To use the script insert tag into the "Notes" box located in the # Weapon or Armor tab of the database: # <stat_require LV, MAXHP, MAXMP, ATK, DEF, SPI, AGI>, # where: # LV - required actor's level # MAXHP - maximum HP # MAXMP - maximum MP # ATK - Attack # DEF - Defence # SPI - Spirit # AGI - Agility # # For example: # If you want a character to equip a weapon at level 6, provided that # it has 120 max HP, 40 Attack, 70 Defence, # add in the specified weapon's "Note" box: # <stat_require 6, 120, 0, 40, 70, 0, 0> # # Next, to equip an armor, which "requires" adequate agility: # <stat_require 0, 0, 0, 0, 0, 0, 50> # # To set that the specified armor can be equipped only after gaining # certain skill(s), add in "Note" box: # <skill_require ID, ID, ...> # where: # ID - required skill(s) ID(s)
# For example: # To equip an weapon, that "requires" skills ID 10 and 40: # <skill_require 10, 40> #=================================================================== module AYENE module ItemSpec ITEM_SPEC = /<(?:STAT_REQUIRE|stat_require)\s*(\d+)\s*, \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+)>/i WEAPON_TEXT = "To equip this weapon you need:" ARMOR_TEXT = "To equip this armor you need:" ACC_TEXT = "To equip this accessory you need:" PARAM_NAMES = ["Level", "Max HP", "Max MP", "Attack", "Defence", "Spirit", "Agility", "Skills:"] SKILL_SPEC = /<(?:SKILL_REQUIRE|skill_require)[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i SHOW_SKILL_REC = true # Show which skill is needed? (true/false) end end
#=================================================================== # ** RPG::BaseItem #=================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :spec_params #-------------------------------------------------------------------------- # * Requirements Initialization #-------------------------------------------------------------------------- def equip_req_ini @spec_params = {} (0..6).each{|i| @spec_params[i] = 0} @spec_params[7] = [] self.note.split(/[\r\n]+/).each { |line| case line when AYENE::ItemSpec::ITEM_SPEC @spec_params[0] = $1.to_i @spec_params[1] = $2.to_i @spec_params[2] = $3.to_i @spec_params[3] = $4.to_i @spec_params[4] = $5.to_i @spec_params[5] = $6.to_i @spec_params[6] = $7.to_i end } self.note.split(/[\r\n]+/).each { |line| case line when AYENE::ItemSpec::SKILL_SPEC $1.scan(/\d+/).each { |num| skill_id = num.to_i @spec_params[7].push(skill_id) if $data_skills[skill_id] != nil } end } end end
#=================================================================== # ** RPG::Weapon #=================================================================== class RPG::Weapon < RPG::BaseItem #-------------------------------------------------------------------------- # * Requirements Text #-------------------------------------------------------------------------- def eqreq_text return AYENE::ItemSpec::WEAPON_TEXT end end
#=================================================================== # ** RPG::Armor #=================================================================== class RPG::Armor < RPG::BaseItem #-------------------------------------------------------------------------- # * Requirements Text #-------------------------------------------------------------------------- def eqreq_text case kind when 3 return AYENE::ItemSpec::ACC_TEXT else return AYENE::ItemSpec::ARMOR_TEXT end end end
#=================================================================== # ** Game_Actor #=================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Determine if Item can be Equipped (Actor's Parameters) #-------------------------------------------------------------------------- def equip_allowed?(item) return true if (item.spec_params[0] <= level && item.spec_params[1] <= base_maxhp && item.spec_params[2] <= base_maxmp && item.spec_params[3] <= base_atk && item.spec_params[4] <= base_def && item.spec_params[5] <= base_spi && item.spec_params[6] <= base_agi) && equip_skill_allowed?(item) return false end #-------------------------------------------------------------------------- # * Determine if Item can be Equipped (Actor's Skills ) #-------------------------------------------------------------------------- def equip_skill_allowed?(item) item.spec_params[7].each{|skill_id| return false if !skill_learn?($data_skills[skill_id]) } return true end end
#=================================================================== # ** Game_Interpreter #=================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # * Aliased Definitions #-------------------------------------------------------------------------- alias aye_eqreq_command_315 command_315 alias aye_eqreq_command_316 command_316 alias aye_eqreq_command_317 command_317 alias aye_eqreq_command_318 command_318 #-------------------------------------------------------------------------- # * Check Equipment # actor : actor #-------------------------------------------------------------------------- def check_change_equip(actor) for i in 0..4 item = actor.equips[i] actor.change_equip(i, nil) if !item.nil? && !actor.equip_allowed?(item) end end #-------------------------------------------------------------------------- # * Change EXP #-------------------------------------------------------------------------- def command_315 aye_eqreq_command_315 iterate_actor_id(@params[0]) do |actor| check_change_equip(actor) end end #-------------------------------------------------------------------------- # * Change Level #-------------------------------------------------------------------------- def command_316 aye_eqreq_command_316 iterate_actor_id(@params[0]) do |actor| check_change_equip(actor) end end #-------------------------------------------------------------------------- # * Change Parameters #-------------------------------------------------------------------------- def command_317 aye_eqreq_command_317 iterate_actor_id(@params[0]) do |actor| check_change_equip(actor) end end #-------------------------------------------------------------------------- # * Change Skills #-------------------------------------------------------------------------- def command_318 aye_eqreq_command_318 iterate_actor_id(@params[0]) do |actor| check_change_equip(actor) end end end
#=================================================================== # ** Window_EquipItem #=================================================================== class Window_EquipItem < Window_Item #-------------------------------------------------------------------------- # * Determine if item is enabled #-------------------------------------------------------------------------- def enable?(item) return @actor.equip_allowed?(item) end end
#=================================================================== # ** Scene_Title #=================================================================== class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # * Aliased Definitions #-------------------------------------------------------------------------- alias aye_eqreq_sctit_loaddata load_database #-------------------------------------------------------------------------- # * Load Database (aliased) #-------------------------------------------------------------------------- def load_database aye_eqreq_sctit_loaddata for group in [$data_weapons, $data_armors] for obj in group next if obj.nil? obj.equip_req_ini end end end end
#=================================================================== # ** Scene_Equip #=================================================================== class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # * Aliased Definitions #-------------------------------------------------------------------------- alias aye_eqreq_sceq_update update alias aye_eqreq_sceq_upditsel update_item_selection #-------------------------------------------------------------------------- # * Update Frame (aliased) #-------------------------------------------------------------------------- def update if @eqreq_window != nil update_eqreq_window else aye_eqreq_sceq_update end end #-------------------------------------------------------------------------- # * Update Item Selection (aliased) #-------------------------------------------------------------------------- def update_item_selection @item = @item_window.item if @item != nil and !@actor.equip_allowed?(@item) and Input.trigger?(Input::C) Sound.play_buzzer @item_window.active = false show_eqreq_window else aye_eqreq_sceq_upditsel if Input.trigger?(Input::C) for i in 0..4 item = @actor.equips[i] @actor.change_equip(i, nil) if !item.nil? && !@actor.equip_allowed?(item) end @equip_window.refresh for item_window in @item_windows item_window.refresh end end end end #-------------------------------------------------------------------------- # * Show Requirements Window #-------------------------------------------------------------------------- def show_eqreq_window @frame = 0 data = [] @item.spec_params.each {|type, value| data.push([type, value]) if value > 0 if type < 7 } data.sort!{|a,b| a[0] <=> b[0]} skill = @item.spec_params[7] @eqreq_window = Window_EquipReq.new(@item, data, @actor, skill) end #-------------------------------------------------------------------------- # * Update Requirements Window #-------------------------------------------------------------------------- def update_eqreq_window @frame < 200 ? @frame += 1 : @frame = 0 if @frame == 200 or Input.trigger?(Input::C) or Input.trigger?(Input::B) @eqreq_window.dispose @eqreq_window = nil @item_window.active = true end end end
Credit: - Ayene
Author's Notes: I hope I didn't make any language mistakes
This is a very nice script indeed. I have yet to find any bugs with any other equipment enhancement scripts & SBS I am using. Thank you for sharing this.
Excellent script! This is just the kind of equipment system I intended to have in my game. Thanks for creating and posting it! I do have a question for you. Let's say an actor needs Agility 10 to equip a weapon but they are only at 5 Agility. When they gain a level and have now reached Agility 10 or higher, they can equip the weapon perfectly in my game. However, when I run the event, "Change Parameter, Actor #1, Increase by a constant of +5", the actor's agility now becomes 10, but they still cannot equip the item. I can't seem to figure out why the new Agility stat doesn't affect the weapon requirement. I tried different tests and made a skill that has a "States Change" set to "+" for Agility Up and after boosting the Agility to 10, the equipment requirement still did not recognize the change in Agility. Do you know why these examples don't work? The event for "Change Parameter" is more important for me to be recognized by the equipment requirement because it is a permanent increase in Agility, etc. But any help would be greatly appreciated!
That is because 'Change Parameters' command adds to actor's agility not his base agility. Script compares the parameters required by equipment with actor's base parameters. I chose this solution to prevent situation that player uses potions to increase hero's params just to equip an armor, which he couldn't wear before. But in case you don't allow to use temporary potions in menu in your game, you can simply find in script part:
Script in first post has been updated. I totaly forgot about checking params in 'Scene_Equip' to prevent equipping just to increase params required f.ex. to equip new weapon.
The change in script worked like a charm, thanks! I'm a beginner when it comes to scripts but I did notice that chunk of the code and thought that's what needed changing. So, I tried to replace "base_agil" to "current_agil" and other choice words to see if I could get lucky but to no avail. But anyway, thanks again for the help!