############################################################################# # # 装備検索 # 作者:リック(http://mugenrick.seesaa.net) # 最終更新日:2023/10/26 # The MIT License (https://opensource.org/licenses/mit-license.php) # ############################################################################# # # 【説明】 # 装備箇所を選んで装備するものを選ぶ際に、 # 指定した条件の装備のみを一覧に表示させることができます。 # # 【使用方法】 # このスクリプトを導入するだけで適用されます。 # ただし絞り込み条件はデフォルトの特殊効果しか網羅しておりませんので、 # ステートを増やしている場合やスクリプトで特殊効果を増やしている場合は、 # 下記の設定欄を変更したり追加したりする必要があります。 # 絞り込み条件の設定はやや知識が求められますのでご注意ください。 # 導入位置ですが、基本的に「▼ 素材」の下、 # 「▼ メイン」の上であればどこでも構いません。 # # 【更新履歴】 # 2021/ 3/15 公開 # 2023/10/26 ウィンドウの解放し忘れによる強制終了の可能性があったため修正 # ############################################################################# module EqSearch # 装備検索ウィンドウを表示するためのキー入力を指定します。 KEY = :Z # 装備検索をスロットウィンドウ(装備箇所選択中)でも行えるかを指定します。 # true:可能 # false:不可能 SYS = true # ヘルプウィンドウの位置、ウィンドウ幅を指定します。 H_S = [0, 0, Graphics.width] # 装備検索ウィンドウの位置、サイズを指定します。 W_S = [0, 48, Graphics.width, 216] # 装備検索ウィンドウの列の数を指定します。 COL = 4 # 装備検索ウィンドウの各列の間隔をピクセル単位で指定します。 SPA = 8 # ヘルプウィンドウに表示する文章を指定します(1行/特殊文字使用不可)。 HEL = "装備検索:絞り込む条件を選んでください。" # コマンドウィンドウに表示するガイド文章を指定します(1行/特殊文字使用不可)。 GUI = "Zキーで装備の絞り込みが行えます。" # 絞り込み条件指定中のガイド文章の接頭語を指定します(1行/特殊文字使用不可)。 GUX = "絞り込み条件:" # 絞り込みをリセットして全ての装備を表示するコマンドの名称を指定します。 RES = "全て表示" # 検索内容を指定します。 # :nameには項目名を記述。 # :condには条件式を記述(RPG::EquipItem内でeval。やや知識が必要)。 DAT = [{:name => "最大HP", :cond => "params[0]>0||features.any?{|f|f.code==21&&f.data_id==0&&f.value>1}"}, {:name => "最大MP", :cond => "params[1]>0||features.any?{|f|f.code==21&&f.data_id==1&&f.value>1}"}, {:name => "攻撃力", :cond => "params[2]>0||features.any?{|f|f.code==21&&f.data_id==2&&f.value>1}"}, {:name => "防御力", :cond => "params[3]>0||features.any?{|f|f.code==21&&f.data_id==3&&f.value>1}"}, {:name => "魔法力", :cond => "params[4]>0||features.any?{|f|f.code==21&&f.data_id==4&&f.value>1}"}, {:name => "魔法防御", :cond => "params[5]>0||features.any?{|f|f.code==21&&f.data_id==5&&f.value>1}"}, {:name => "敏捷性", :cond => "params[6]>0||features.any?{|f|f.code==21&&f.data_id==6&&f.value>1}"}, {:name => "運", :cond => "params[7]>0||features.any?{|f|f.code==21&&f.data_id==7&&f.value>1}"}, {:name => "命中率", :cond => "features.any?{|f|f.code==22&&f.data_id==0&&f.value>0}"}, {:name => "回避率", :cond => "features.any?{|f|f.code==22&&f.data_id==1&&f.value>0}"}, {:name => "会心率", :cond => "features.any?{|f|f.code==22&&f.data_id==2&&f.value>0}"}, {:name => "会心回避率", :cond => "features.any?{|f|f.code==22&&f.data_id==3&&f.value>0}"}, {:name => "魔法回避率", :cond => "features.any?{|f|f.code==22&&f.data_id==4&&f.value>0}"}, {:name => "魔法反射率", :cond => "features.any?{|f|f.code==22&&f.data_id==5&&f.value>0}"}, {:name => "反撃率", :cond => "features.any?{|f|f.code==22&&f.data_id==6&&f.value>0}"}, {:name => "HP再生", :cond => "features.any?{|f|f.code==22&&f.data_id==7&&f.value>0}"}, {:name => "MP再生", :cond => "features.any?{|f|f.code==22&&f.data_id==8&&f.value>0}"}, {:name => "TP再生", :cond => "features.any?{|f|f.code==22&&f.data_id==9&&f.value>0}"}, {:name => "狙われ率", :cond => "features.any?{|f|f.code==23&&f.data_id==0&&f.value!=1}"}, {:name => "防御効果率", :cond => "features.any?{|f|f.code==23&&f.data_id==1&&f.value>1}"}, {:name => "回復効果率", :cond => "features.any?{|f|f.code==23&&f.data_id==2&&f.value>1}"}, {:name => "薬の知識", :cond => "features.any?{|f|f.code==23&&f.data_id==3&&f.value>1}"}, {:name => "MP消費率", :cond => "features.any?{|f|f.code==23&&f.data_id==4&&f.value<1}"}, {:name => "TPチャージ率", :cond => "features.any?{|f|f.code==23&&f.data_id==5&&f.value>1}"}, {:name => "物理ダメ率", :cond => "features.any?{|f|f.code==23&&f.data_id==6&&f.value<1}"}, {:name => "魔法ダメ率", :cond => "features.any?{|f|f.code==23&&f.data_id==7&&f.value<1}"}, {:name => "床ダメ率", :cond => "features.any?{|f|f.code==23&&f.data_id==8&&f.value<1}"}, {:name => "経験獲得率", :cond => "features.any?{|f|f.code==23&&f.data_id==9&&f.value>1}"}, {:name => "物理耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==1&&f.value<1}"}, {:name => "吸収耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==2&&f.value<1}"}, {:name => "炎耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==3&&f.value<1}"}, {:name => "氷耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==4&&f.value<1}"}, {:name => "雷耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==5&&f.value<1}"}, {:name => "水耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==6&&f.value<1}"}, {:name => "大地耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==7&&f.value<1}"}, {:name => "風耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==8&&f.value<1}"}, {:name => "神聖耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==9&&f.value<1}"}, {:name => "暗黒耐性", :cond => "features.any?{|f|f.code==11&&f.data_id==10&&f.value<1}"}, {:name => "即死耐性", :cond => "features.any?{|f|f.data_id==1&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "毒耐性", :cond => "features.any?{|f|f.data_id==2&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "暗闇耐性", :cond => "features.any?{|f|f.data_id==3&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "沈黙耐性", :cond => "features.any?{|f|f.data_id==4&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "混乱耐性", :cond => "features.any?{|f|f.data_id==5&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "睡眠耐性", :cond => "features.any?{|f|f.data_id==6&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "麻痺耐性", :cond => "features.any?{|f|f.data_id==7&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "スタン耐性", :cond => "features.any?{|f|f.data_id==8&&((f.code==13&&f.value<1)||f.code==14)}"}, {:name => "HP低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==0&&f.value<1}"}, {:name => "MP低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==1&&f.value<1}"}, {:name => "攻撃低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==2&&f.value<1}"}, {:name => "防御低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==3&&f.value<1}"}, {:name => "魔法低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==4&&f.value<1}"}, {:name => "魔防低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==5&&f.value<1}"}, {:name => "敏捷低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==6&&f.value<1}"}, {:name => "運低下耐性", :cond => "features.any?{|f|f.code==12&&f.data_id==7&&f.value<1}"}, {:name => "武器属性", :cond => "features.any?{|f|f.code==31}"}, {:name => "即死付与", :cond => "features.any?{|f|f.code==32&&f.data_id==1&&f.value>0}"}, {:name => "毒付与", :cond => "features.any?{|f|f.code==32&&f.data_id==2&&f.value>0}"}, {:name => "暗闇付与", :cond => "features.any?{|f|f.code==32&&f.data_id==3&&f.value>0}"}, {:name => "沈黙付与", :cond => "features.any?{|f|f.code==32&&f.data_id==4&&f.value>0}"}, {:name => "混乱付与", :cond => "features.any?{|f|f.code==32&&f.data_id==5&&f.value>0}"}, {:name => "睡眠付与", :cond => "features.any?{|f|f.code==32&&f.data_id==6&&f.value>0}"}, {:name => "麻痺付与", :cond => "features.any?{|f|f.code==32&&f.data_id==7&&f.value>0}"}, {:name => "スタン付与", :cond => "features.any?{|f|f.code==32&&f.data_id==8&&f.value>0}"}, {:name => "攻撃速度", :cond => "features.any?{|f|f.code==33&&f.value>0}"}, {:name => "攻撃回数", :cond => "features.any?{|f|f.code==34&&f.value>0}"}, {:name => "スキルタイプ追加", :cond => "features.any?{|f|f.code==41}"}, {:name => "スキル追加", :cond => "features.any?{|f|f.code==43}"}, {:name => "武器種類追加", :cond => "features.any?{|f|f.code==51}"}, {:name => "防具種類追加", :cond => "features.any?{|f|f.code==52}"}, {:name => "二刀流可能", :cond => "features.any?{|f|f.code==55}"}, {:name => "行動追加率", :cond => "features.any?{|f|f.code==61&&f.value>0}"}, {:name => "自動戦闘", :cond => "features.any?{|f|f.code==62&&f.data_id==0}"}, {:name => "常時防御", :cond => "features.any?{|f|f.code==62&&f.data_id==1}"}, {:name => "身代わり", :cond => "features.any?{|f|f.code==62&&f.data_id==2}"}, {:name => "TP持ち越し", :cond => "features.any?{|f|f.code==62&&f.data_id==3}"}, {:name => "エンカ半減", :cond => "features.any?{|f|f.code==64&&f.data_id==0}"}, {:name => "エンカ消滅", :cond => "features.any?{|f|f.code==64&&f.data_id==1}"}, {:name => "不意打ち無効", :cond => "features.any?{|f|f.code==64&&f.data_id==2}"}, {:name => "先制率上昇", :cond => "features.any?{|f|f.code==64&&f.data_id==3}"}, {:name => "獲得金額2倍", :cond => "features.any?{|f|f.code==64&&f.data_id==4}"}, {:name => "ドロップ2倍", :cond => "features.any?{|f|f.code==64&&f.data_id==5}"}, # 以下は不要と判断し除外したもの。 # 必要に応じてコメントアウトを外してください。 #{:name => "スキルタイプ封印", :cond => "features.any?{|f|f.code==42}"}, #{:name => "スキル封印", :cond => "features.any?{|f|f.code==44}"}, #{:name => "装備固定", :cond => "features.any?{|f|f.code==53}"}, #{:name => "装備封印", :cond => "features.any?{|f|f.code==54}"}, ] end class Window_EquipSlot < Window_Selectable #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 (オーバーライド無しエイリアス) #-------------------------------------------------------------------------- alias _eqsearch_process_handling process_handling def process_handling _eqsearch_process_handling return unless open? && active if ok_enabled? && Input.trigger?(EqSearch::KEY) && EqSearch::SYS return call_handler(:search) end end end class Window_EquipItem < Window_ItemList #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :search_cond # 検索条件インデックス #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 (オーバーライド無しエイリアス) #-------------------------------------------------------------------------- alias _eqsearch_process_handling process_handling def process_handling _eqsearch_process_handling return unless open? && active return call_handler(:search) if ok_enabled? && Input.trigger?(EqSearch::KEY) end #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか #-------------------------------------------------------------------------- alias _eqsearch_include? include? def include?(item) return _eqsearch_include?(item) if !search_cond || !item _eqsearch_include?(item) && item.instance_eval(EqSearch::DAT[search_cond][:cond]) end end class Window_EqSearch < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport) super(EqSearch::W_S[0], EqSearch::W_S[1]) self.width = EqSearch::W_S[2] self.height = EqSearch::W_S[3] self.viewport = viewport self.openness = 0 clear_command_list make_command_list create_help_window refresh end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max EqSearch::COL end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number (item_max.to_f / col_max).ceil end #-------------------------------------------------------------------------- # ● 横に項目が並ぶときの空白の幅を取得 #-------------------------------------------------------------------------- def spacing EqSearch::SPA end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list add_command(EqSearch::RES, :search_reset) EqSearch::DAT.each do |d| add_command(d[:name], :search_ok) end end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの作成 #-------------------------------------------------------------------------- def create_help_window wr = EqSearch::H_S @help_window = Window_Base.new(wr[0], wr[1], wr[2], fitting_height(1)) @help_window.viewport = self.viewport @help_window.hide end #-------------------------------------------------------------------------- # ● 開く #-------------------------------------------------------------------------- def open super @help_window.show end #-------------------------------------------------------------------------- # ● 閉じる #-------------------------------------------------------------------------- def close super @help_window.hide end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの更新 #-------------------------------------------------------------------------- def update_help width = @help_window.contents.width @help_window.contents.clear @help_window.draw_text(0, 0, width, line_height, EqSearch::HEL) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose super @help_window.dispose end end class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias _eqsearch_start start def start _eqsearch_start create_eqsearch_window end #-------------------------------------------------------------------------- # ● コマンド[装備変更] #-------------------------------------------------------------------------- alias _eqsearch_command_equip command_equip def command_equip _eqsearch_command_equip command_window_guide_show if EqSearch::SYS end #-------------------------------------------------------------------------- # ● スロット[決定] #-------------------------------------------------------------------------- alias _eqsearch_on_slot_ok on_slot_ok def on_slot_ok _eqsearch_on_slot_ok command_window_guide_show end #-------------------------------------------------------------------------- # ● スロット[キャンセル] #-------------------------------------------------------------------------- alias _eqsearch_on_slot_cancel on_slot_cancel def on_slot_cancel _eqsearch_on_slot_cancel command_window_guide_hide end #-------------------------------------------------------------------------- # ● アイテム[決定] #-------------------------------------------------------------------------- alias _eqsearch_on_item_ok on_item_ok def on_item_ok _eqsearch_on_item_ok command_window_guide_hide if !EqSearch::SYS end #-------------------------------------------------------------------------- # ● アイテム[キャンセル] #-------------------------------------------------------------------------- alias _eqsearch_on_item_cancel on_item_cancel def on_item_cancel _eqsearch_on_item_cancel command_window_guide_hide if !EqSearch::SYS end #-------------------------------------------------------------------------- # ■ 装備検索ウィンドウの作成 #-------------------------------------------------------------------------- def create_eqsearch_window @slot_window.set_handler(:search, method(:on_slot_search)) @item_window.set_handler(:search, method(:on_item_search)) @eqsearch_window = Window_EqSearch.new(@viewport) @eqsearch_window.set_handler(:search_reset, method(:on_search_reset)) @eqsearch_window.set_handler(:search_ok, method(:on_search_ok)) @eqsearch_window.set_handler(:cancel, method(:on_search_cancel)) end #-------------------------------------------------------------------------- # ■ スロット[装備検索] #-------------------------------------------------------------------------- def on_slot_search @eqsearch_prewindow = @slot_window on_slotitem_search end #-------------------------------------------------------------------------- # ■ アイテム[装備検索] #-------------------------------------------------------------------------- def on_item_search @eqsearch_prewindow = @item_window on_slotitem_search end #-------------------------------------------------------------------------- # ■ 装備検索表示共通処理 #-------------------------------------------------------------------------- def on_slotitem_search Sound.play_ok @eqsearch_prewindow.deactivate @eqsearch_window.open @eqsearch_window.activate end #-------------------------------------------------------------------------- # ■ 装備検索[決定] #-------------------------------------------------------------------------- def on_search_ok on_search_ok_reset(@eqsearch_window.index-1) end #-------------------------------------------------------------------------- # ■ 装備検索[リセット] #-------------------------------------------------------------------------- def on_search_reset on_search_ok_reset(nil) end #-------------------------------------------------------------------------- # ■ 装備検索[決定/リセット共通] #-------------------------------------------------------------------------- def on_search_ok_reset(search_cond) @item_window.search_cond = search_cond if @item_window.index >= 0 @item_window.select(0) else @item_window.select(0) #非選択のみだとリストの先頭が変化しない @item_window.unselect end @item_window.refresh @eqsearch_window.activate command_window_guide_show end #-------------------------------------------------------------------------- # ■ 装備検索[キャンセル] #-------------------------------------------------------------------------- def on_search_cancel @eqsearch_prewindow.activate @eqsearch_prewindow = nil @eqsearch_window.close @eqsearch_window.deactivate end #-------------------------------------------------------------------------- # ■ コマンドウィンドウにガイドテキスト表示 #-------------------------------------------------------------------------- def command_window_guide_show if @item_window.search_cond txt = EqSearch::GUX + EqSearch::DAT[@item_window.search_cond][:name] else txt = EqSearch::GUI end width = @command_window.contents.width hight = @command_window.line_height @command_window.cursor_rect.empty @command_window.create_contents @command_window.draw_text(0, 0, width, hight, txt) end #-------------------------------------------------------------------------- # ■ コマンドウィンドウのガイドテキスト非表示 #-------------------------------------------------------------------------- def command_window_guide_hide @command_window.refresh @command_window.update_cursor end end