=begin #============================================================================== ** Feature: Switch Condition Author: Hime Date: Oct 13, 2012 ------------------------------------------------------------------------------ ** Change log Oct 13, 2012 - 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 * Preserve this header ------------------------------------------------------------------------------ ** Required -Feature Manager (http://himeworks.com/2012/10/13/feature-manager) ------------------------------------------------------------------------------ Allows you to require a switch to be ON (or off) in order to equip an item or use a skill Tag weapons, armors, skills with Where n is a switch ID and value is 1 or 0 (for ON or OFF) #============================================================================== =end $imported = {} if $imported.nil? $imported["Feature_SwitchCond"] = true #============================================================================== # ** Rest of the script #============================================================================== module Features module Switch_Condition FeatureManager.register(:switch_cond) end end class RPG::BaseItem # Store switch as data ID and value as true/false value def add_feature_switch_cond(code, data_id, args) data_id = args[0].to_i value = args[1] == "1" ? true : false add_feature(code, data_id, value) end end class Game_BattlerBase alias :ft_switch_cond_weapon_ok? :feature_equip_weapon_ok? def feature_equip_weapon_ok?(item) set = item_features(item, :switch_cond) return false if set.any? {|ft| $game_switches[ft.data_id] != ft.value} return ft_switch_cond_weapon_ok?(item) end alias :ft_switch_cond_armor_ok? :feature_equip_armor_ok? def feature_equip_armor_ok?(item) set = item_features(item, :switch_cond) return false if set.any? {|ft| $game_switches[ft.data_id] != ft.value} return ft_switch_cond_armor_ok?(item) end alias :ft_switch_cond_skill_cond_met? :skill_conditions_met? def skill_conditions_met?(skill) return false unless ft_switch_cond_skill_cond_met?(skill) return false if item_features(skill, :switch_cond).any? {|ft| $game_switches[ft.data_id] != ft.value} return true end end