=begin #============================================================================== ** Effect: Required Item Author: Hime Date: Nov 13, 2012 ------------------------------------------------------------------------------ ** Change log Nov 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 -Effect Manager (http://himeworks.com/2012/10/05/effects-manager) ------------------------------------------------------------------------------ Allows you to specify that certain item must exist in the inventory and will be consumed. If it is a item or skill and the required items are not available then it cannot be used. Tag items/skills with Where id is of the form a1 for armor 1, w2 for weapon 2, i3 for item 3 And amount is the number of items you must have and will be consumed. #============================================================================== =end $imported = {} if $imported.nil? $imported["Effect_RequiredItem"] = true #============================================================================== # ** Rest of the script #============================================================================== module Effects module Required_Item Effect_Manager.register_effect(:req_item, 2.3) end end module RPG class BaseItem attr_accessor :required_items def add_effect_req_item(code, data_id, args) # initialize if needed @required_items ||= {} # add requirements id = args[0][1..-1].to_i amount = args[1].to_i case args[0].downcase[0] when "w" item = $data_weapons[id] when "a" item = $data_armors[id] when "i" item = $data_items[id] end # Multiple effects with same item are just added on if @required_items.include?(item) @required_items[item] += amount else @required_items[item] = amount add_effect(code, data_id, [item]) end end end end # Add logic for checking whether the skill/item can be used or not class Game_BattlerBase def eff_req_item_conditions_met?(item) return true if item.required_items.nil? || item.required_items.empty? return false if item.required_items.any? {|req_item, amount| $game_party.item_number(req_item) < amount } return true end alias :eff_req_item_skill_cond_met? :skill_conditions_met? def skill_conditions_met?(skill) eff_req_item_skill_cond_met?(skill) && eff_req_item_conditions_met?(skill) end alias :eff_req_item_cond_met? :item_conditions_met? def item_conditions_met?(item) eff_req_item_cond_met?(item) && eff_req_item_conditions_met?(item) end end class Game_Battler < Game_BattlerBase def effect_req_item(obj, effect) item = effect.value1[0] amount = obj.required_items[item] $game_party.lose_item(item, amount) end alias :item_effect_req_item_global :effect_req_item end