=begin #=============================================================================== Title: Custom Equip Conditions Author: Hime Date: Oct 22, 2014 -------------------------------------------------------------------------------- ** Change log Oct 22, 2014 - Initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * 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 * Credits to Hime Works in your project * Preserve this header -------------------------------------------------------------------------------- ** Description This script allows you to add custom equip conditions using formulas to your equips. The condition must be met in order to equip the item. -------------------------------------------------------------------------------- ** Installation Place this script below Materials and above Main -------------------------------------------------------------------------------- ** Usage Note-tag weapons and armors with FORMULA Where the formula returns a true or false. If the formula is true, then the condition is met. You can use the following variables in your formula: a - the battler that will wear this equip p - the party t - the troop s - game switches v - game variables #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_CustomEquipConditions"] = true #=============================================================================== # ** Configuration #=============================================================================== module TH module Custom_Equip_Conditions Regex = /(.*?)<\/custom[-_ ]equip[-_ ]condition>/im end end #=============================================================================== # ** Rest of Script #=============================================================================== module RPG class BaseItem def custom_equip_conditions_met?(user) load_notetag_custom_equip_conditions unless @custom_equip_condition eval_custom_equip_conditions(user) end def load_notetag_custom_equip_conditions @custom_equip_condition = "" result = self.note.match(TH::Custom_Equip_Conditions::Regex) if result @custom_equip_condition = result[1] end end def eval_custom_equip_conditions(a, v=$game_variables, s=$game_switches, t=$game_troop, p=$game_party) return true if @custom_equip_condition.empty? eval(@custom_equip_condition) end end end class Game_BattlerBase alias :th_custom_equip_conditions_equippable? :equippable? def equippable?(item) return false unless custom_equip_conditions_met?(item) th_custom_equip_conditions_equippable?(item) end def custom_equip_conditions_met?(item) return false unless item return false unless item.custom_equip_conditions_met?(self) return true end end