#============================================================================== # ■アイテムコピー for RGSS3 Ver0.70-β # □作成者 kure #============================================================================== #メモ欄処理用共通モジュール-------------------------------------------------------- module KURE #-------------------------------------------------------------------------- # ★ 数値配列に畳む(追加定義) #-------------------------------------------------------------------------- def self.arr_num_slice(arr) result_arr = Array.new unless arr == [] and arr.empty? arr.flatten! arr.each{|value| value.scan(/\d+/).each { |num| result_arr.push(num.to_i)}} end return result_arr end end #============================================================================== # ●■ RPG::BaseItem(追加定義集積) #============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # ● コピー対象の定義 #-------------------------------------------------------------------------- def copy_type @note.match(/<複製能力\s?(\d+)\s?>/) return $1 ? $1.to_i : nil end #-------------------------------------------------------------------------- # ● コピー不可アイテムの定義 #-------------------------------------------------------------------------- def can_copy_type KURE.arr_num_slice(@note.scan(/<複製対象\s?(\d+(?:\s?*,\s?*\d+)*)>/)) end end #============================================================================== # ■ Scene_Item #============================================================================== class Scene_Item < Scene_ItemBase #-------------------------------------------------------------------------- # ● アイテムの決定(エイリアス) #-------------------------------------------------------------------------- alias k_before_item_copy_determine_item determine_item def determine_item if item.copy_type item_copy_flag return end if @item_copy item_copy_process return end k_before_item_copy_determine_item end #-------------------------------------------------------------------------- # ● アイテム[キャンセル](再定義) #-------------------------------------------------------------------------- def on_item_cancel if @item_copy #フラグをOFF @item_copy = false @select_item = nil @item_window.stop_help_update = false @item_window.refresh @item_window.activate else @item_window.unselect @category_window.activate end end #-------------------------------------------------------------------------- # ● アイテムのコピー選択フラグをON[決定] #-------------------------------------------------------------------------- def item_copy_flag #フラグをON @item_copy = true ; @select_item = item #ウィンドウに情報を渡す @item_window.stop_help_update = true @item_window.able_type = item.copy_type #ヘルプテキストを更新 @help_window.set_text("複製するアイテムを選択してください") @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # ● アイテムのコピーの実行[決定] #-------------------------------------------------------------------------- def item_copy_process #フラグをON play_se_for_item $game_party.gain_item(item, 1) $game_party.lose_item(@select_item, 1) @item_copy = false @select_item = nil @item_window.able_type = nil @item_window.stop_help_update = false @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help return if @item_copy @help_window.set_item(item) end end #============================================================================== # ■ Window_ItemList #============================================================================== class Window_ItemList < Window_Selectable attr_accessor :stop_help_update #表示変更の一時停止 attr_accessor :able_type #選択可能なタイプ #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_item(item) unless @stop_help_update end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得(エイリアス) #-------------------------------------------------------------------------- alias k_before_item_copy_enable? enable? def enable?(item) if @stop_help_update item.can_copy_type.include?(@able_type) else k_before_item_copy_enable?(item) end end end