#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ ◆ Usable Equipment - KGC_UsableEquipment ◆ VX ◆ #_/ ◇ Last update : 2008/01/13 ◇ #_/ ◆ Translation by Mr. Anonymous ◆ #_/ ◆ http://ytomy.sakura.ne.jp/ ◆ #_/----------------------------------------------------------------------------- #_/ This script allows equipment to have "usable" effects like items. Note that #_/ for now, only unequipped weapons and equipment have this "usable" effect. #_/============================================================================= #_/ ◆ Instructions For Usage ◆ #_/ To make use of these functions, you must insert the desired tag into the #_/ "Notes" box located in the Skills section of the database. For #_/ example, you want the King's Sword have the same effect as the Fire Scroll #_/ when used (NOT while attacking with it). You would locate King's Sword #_/ in the weapons tab of the database and insert "" #_/ (without quotations) in the note box. Simple, yes? #_/ #_/ The format is , where ItemID = The Item's ID number #_/ in the Items Database. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ $imported = {} if $imported == nil $imported["UsableEquipment"] = true # Whatever word(s) are after the separator ( | ) in the following lines are # what are used to determine what is searched for in the "Notes" section. module KGC module UsableEquipment # Regular Expression Defined module Regexp # Base Item Module module BaseItem # Item Effect tag string ITEM_EFFECT = /<(?:ITEM_EFFECT|itemeffect)[ ]*(\d+)>/i end end end end #============================================================================== # ■ RPG::BaseItem #============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # ○ 使用効果付き装備のキャッシュを作成 #-------------------------------------------------------------------------- def create_usable_equipment_cache @__item_id = 0 self.note.split(/[\r\n]+/).each { |line| case line when KGC::UsableEquipment::Regexp::BaseItem::ITEM_EFFECT # アイテム効果 @__item_id = $1.to_i end } end #-------------------------------------------------------------------------- # ○ 使用時アイテム効果 #-------------------------------------------------------------------------- def item_id create_usable_equipment_cache if @__item_id == nil return @__item_id end #-------------------------------------------------------------------------- # ○ 使用時アイテム #-------------------------------------------------------------------------- def item return (item_id > 0 ? $data_items[item_id] : nil) end #-------------------------------------------------------------------------- # ○ 戦闘時使用可否 #-------------------------------------------------------------------------- def battle_ok? return false if item_id == 0 return item.battle_ok? end #-------------------------------------------------------------------------- # ○ メニュー画面使用可否 #-------------------------------------------------------------------------- def menu_ok? return false end end #============================================================================== # ■ Game_BattleAction #============================================================================== class Game_BattleAction #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :use_equipment # 使用装備品 #-------------------------------------------------------------------------- # ● クリア #-------------------------------------------------------------------------- alias clear_KGC_UsableEquipment clear def clear clear_KGC_UsableEquipment @use_equipment = nil end #-------------------------------------------------------------------------- # ● アイテムを設定 # item_id : アイテム ID #-------------------------------------------------------------------------- alias set_item_KGC_UsableEquipment set_item def set_item(item_id) @use_equipment = nil set_item_KGC_UsableEquipment(item_id) end #-------------------------------------------------------------------------- # ○ 装備品を設定 # item : 装備品 (武器 or 防具) #-------------------------------------------------------------------------- def set_equipment(item) @kind = 2 @use_equipment = item end #-------------------------------------------------------------------------- # ● アイテムオブジェクト取得 #-------------------------------------------------------------------------- alias item_KGC_UsableEquipment item def item if use_equipment? # 装備品を使用する場合、ダミーアイテムを生成 source_item = $data_items[@use_equipment.item_id].clone source_item.name = @use_equipment.name # アイテム名を装備品名にする source_item.consumable = false # 消耗しない return source_item end return item_KGC_UsableEquipment end #-------------------------------------------------------------------------- # ● 装備品判定 #-------------------------------------------------------------------------- def use_equipment? return (item? && @use_equipment != nil && @use_equipment.item_id > 0) end #-------------------------------------------------------------------------- # ● 行動が有効か否かの判定 # イベントコマンドによる [戦闘行動の強制] ではないとき、ステートの制限 # やアイテム切れなどで予定の行動ができなければ false を返す。 #-------------------------------------------------------------------------- alias valid_KGC_UsableEquipment? valid? def valid? return false if nothing? # 何もしない return true if @forcing # 行動強制中 return false unless battler.movable? # 行動不能 result = valid_KGC_UsableEquipment? if !result && use_equipment? # 装備品使用 return true if friends_unit.item_can_use?(@use_equipment) end return result end end #============================================================================== # ■ Window_Item #============================================================================== class Window_Item < Window_Selectable unless $imported["CategorizeItem"] #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか # item : アイテム #-------------------------------------------------------------------------- alias include_KGC_UsableEquipment? include? def include?(item) return false if item == nil result = include_KGC_UsableEquipment?(item) unless result # 使用可能なら追加候補とする result = true if $game_party.item_can_use?(item) end return result end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias refresh_KGC_UsableEquipment refresh def refresh refresh_KGC_UsableEquipment # 装備品を選択した場合のインデックス復元 if $game_party.last_equipment_object != nil last_index = @data.index($game_party.last_equipment_object) self.index = last_index if last_index != nil end end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :last_equipment_object # カーソル記憶用 : 装備品 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KGC_UsableEquipment initialize def initialize initialize_KGC_UsableEquipment @last_equipment_object = nil end #-------------------------------------------------------------------------- # ● カーソル記憶用 : アイテム (attr_writer の再定義) #-------------------------------------------------------------------------- def last_item_id=(value) @last_item_id = value @last_equipment_object = nil end #-------------------------------------------------------------------------- # ● 戦闘テスト用パーティのセットアップ #-------------------------------------------------------------------------- alias setup_battle_test_members_KGC_UsableEquipment setup_battle_test_members def setup_battle_test_members setup_battle_test_members_KGC_UsableEquipment # 武器・防具も 99 個取得 @weapons = {} for i in 1...$data_weapons.size weapon = $data_weapons[i] if weapon.battle_ok? @weapons[i] = 99 unless weapon.name.empty? end end @armors = {} for i in 1...$data_armors.size armor = $data_armors[i] if armor.battle_ok? @armors[i] = 99 unless armor.name.empty? end end end #-------------------------------------------------------------------------- # ● アイテムの使用可能判定 # item : アイテム, 武器, 防具 #-------------------------------------------------------------------------- alias item_can_use_KGC_UsableEquipment? item_can_use? def item_can_use?(item) if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor) return false if item_number(item) == 0 return ($game_temp.in_battle ? item.battle_ok? : item.menu_ok?) else return item_can_use_KGC_UsableEquipment?(item) end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● アイテムの決定 #-------------------------------------------------------------------------- alias determine_item_KGC_UsableEquipment determine_item def determine_item last_active_battler = nil selected_item = nil if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor) # アイテムウィンドウの選択項目を装備品に設定 $game_party.last_item_id = 0 $game_party.last_equipment_object = @item selected_item = @item # 装備品で発動するアイテムを選択したと見なす @active_battler.action.set_equipment(@item) source_item = @active_battler.action.item @item = source_item last_active_battler = @active_battler end determine_item_KGC_UsableEquipment if last_active_battler != nil # 行動時に使用する装備品をセット last_active_battler.action.set_equipment(selected_item) end end end #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ The original untranslated version of this script can be found here: # http://f44.aaa.livedoor.jp/~ytomy/tkool/rpgtech/php/tech.php?tool=VX&cat=tech_vx/equip&tech=add_equipment_options #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_