#****************************************************************************** # # * アイテム選択の処理拡張 #011 # # -------------------------------------------------------------------------- # バージョン : 1.0.0 # 対 応 : RPGツクールVX Ace : RGSS3 # 制 作 者 : CACAO # 配 布 元 : http://cacaosoft.web.fc2.com/ # -------------------------------------------------------------------------- # == 概 要 == # # : キーアイテム以外のものも選べるようにします。 # # -------------------------------------------------------------------------- # == 注意事項 == # # ※ 変数には、IDではなくアイテムのデータが代入されます。 # ※ 選択しなかった場合は 0 が代入されます。 # # -------------------------------------------------------------------------- # == 使用方法 == # # ★ 選択アイテムの設定 # $game_message.item_choice_category にキーワードを代入してください。 # :all .. すべての所持品 # :all_item .. すべてのアイテム # :item .. キーアイテム以外のアイテム # :weapon .. すべての武器 # :armor .. すべての防具 # :equip .. 武器と防具 # :sell .. キーアイテム以外で価格が0でないもの # "keyword" .. メモ欄に と書かれているもの # # ★ ショップアイテムから選択 # $game_message.item_choice_from_goods = true # このスクリプトを実行後、ショップの処理でアイテムを設定してください。 # # ★ 所持数を非表示にする # $game_message.item_choice_hide_number = true # # ★ キャンセルを無効にする # $game_message.item_choice_cancel_disabled = true # # ※ これらの設定は、アイテム選択の処理後に初期化されます。 # # # ★ 選択したアイテムの取得方法 # ID .. $game_variables[id].id # 名前 .. $game_variables[id].name # アイコンの番号 .. $game_variables[id].icon_index # 価格 .. $game_variables[id].price # アイテムの増減 .. $game_party.gain_item($game_variables[id], 増減数) # アイテムか? .. $game_variables[id].kind_of?(RPG::Item) # 武器か? .. $game_variables[id].kind_of?(RPG::Weapon) # 防具か? .. $game_variables[id].kind_of?(RPG::Armor) # ※ id は、アイテム選択の処理で指定したEV変数の番号です。 # # #****************************************************************************** #/////////////////////////////////////////////////////////////////////////////# # # # 下記のスクリプトを変更する必要はありません。 # # # #/////////////////////////////////////////////////////////////////////////////# class Game_Message #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :item_choice_category # アイテム選択 カテゴリ attr_accessor :item_choice_from_goods # アイテム選択 商品から選択 attr_accessor :item_choice_goods # アイテム選択 選択アイテム attr_accessor :item_choice_hide_number # アイテム選択 所持数非表示 attr_accessor :item_choice_cancel_disabled # アイテム選択 キャンセル無効 #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def clear_item_choice $game_message.item_choice_category = nil $game_message.item_choice_from_goods = nil $game_message.item_choice_goods = nil $game_message.item_choice_hide_number = nil $game_message.item_choice_cancel_disabled = nil end end class Game_Interpreter #-------------------------------------------------------------------------- # ○ ショップの処理 #-------------------------------------------------------------------------- alias cao011_command_302 command_302 def command_302 if $game_message.item_choice_from_goods goods = [@params] while next_event_code == 605 @index += 1 goods.push(@list[@index].parameters) end $game_message.item_choice_goods = [] goods.each do |param| case param[0] when 0; item = $data_items[param[1]] when 1; item = $data_weapons[param[1]] when 2; item = $data_armors[param[1]] end if item $game_message.item_choice_goods << item end end else cao011_command_302 end end end class Window_ItemList #-------------------------------------------------------------------------- # ○ アイテムをリストに含めるかどうか #-------------------------------------------------------------------------- alias cao011_include? include? def include?(item) case @category when String return item && item.note.include?("<#{@category}>") when :all return item != nil when :all_item return item.kind_of?(RPG::Item) when :equip return item.kind_of?(RPG::Weapon) || item.kind_of?(RPG::Armor) when :sell return false if item == nil return false if item.respond_to?(:key_item?) && item.key_item? return false if item.price == 0 return true else return cao011_include?(item) end end end class Window_KeyItem #-------------------------------------------------------------------------- # ◎ アイテムリストの作成 #-------------------------------------------------------------------------- alias cao011_make_item_list make_item_list def make_item_list if $game_message.item_choice_from_goods @data = $game_message.item_choice_goods else # super cao011_make_item_list end end #-------------------------------------------------------------------------- # ○ アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) return true end #-------------------------------------------------------------------------- # ○ 決定時の処理 #-------------------------------------------------------------------------- def on_ok $game_variables[$game_message.item_choice_variable_id] = (self.item || 0) close end #-------------------------------------------------------------------------- # ○ キャンセル処理の有効状態を取得 #-------------------------------------------------------------------------- def cancel_enabled? return false end #-------------------------------------------------------------------------- # ◎ フレーム更新 #-------------------------------------------------------------------------- alias cao011_update update def update # super cao011_update if open? && self.active && Input.trigger?(:B) Input.update if $game_message.item_choice_cancel_disabled Sound.play_buzzer else Sound.play_cancel deactivate on_cancel end end end #-------------------------------------------------------------------------- # ○ アイテムの個数を描画 #-------------------------------------------------------------------------- alias cao011_draw_item_number draw_item_number def draw_item_number(rect, item) return if $game_message.item_choice_hide_number cao011_draw_item_number(rect, item) end end class Window_Message #-------------------------------------------------------------------------- # ○ アイテムの選択処理 #-------------------------------------------------------------------------- def input_item @item_window.start @item_window.category = ($game_message.item_choice_category || :key_item) Fiber.yield while @item_window.active $game_message.clear_item_choice end end