#============================================================================== # ■ RGSS3 装備アイテムソート機能 Ver1.01 by 星潟 #------------------------------------------------------------------------------ # 新たに装備するアイテムを選択する際、特定のボタンを押す事で # ソート設定を行う事が出来るようになります。 #============================================================================== # このスクリプトの為に、比較に用いるダミーアクター用として # アクターIDと職業IDを1つ占有します。 #============================================================================== module EquipSort #前回のソート設定を引き継ぐ為のスイッチIDを指定。 #このスイッチがONの時のみ、装備画面を閉じてもソート設定を引き継ぐ。 SID = 99 #比較用のダミーとして用いるアクターIDを指定。 #このアクターは、その職業も含め一切の特徴を付けず #何も装備させないで下さい。 #メモ欄も含め、ほぼまっさらな状態を推奨します。 AID = 11 #便宜上使用する非常に大きな数字を指定。 Over = 1000000000000000000000 #ソート項目数を指定。 Max = 4 #ソート項目桁数を指定。 CMax = 4 #アイテムリストでのソート起動キーを指定。 Key1 = :Y #ソートウィンドウでの項目解除キーを指定。 Key2 = :A #ソート実行コマンドの名前を指定。 Name = "ソート実行" #ソート可能な事を示すサブウィンドウに表示する文字列を指定。 Text = "Yボタン(デフォルトSキー):ソート" #ソート項目選択中のヘルプ項目を指定。 Help = "各項目行でAボタン(デフォルトではシフトキー)を押すと その行の設定が解除されソートなしになります" #ソート可能な事を示すサブウィンドウの #X座標、Y座標、幅、高さ、フォントサイズを指定。 A = [244,240,300,44,20,false]#解像度544×416サイズ用の設定 #A = [340,240,300,44,20,false]#解像度640×480サイズ用の設定例。 #ソート可能な事を示すサブウィンドウの背景グラデーション表示に用いる色を2色指定。 #(赤・緑・蒼・透明度の順に指定) #真ん中側 Color1 = [0,0,0,150] #端側 Color2 = [0,0,0,150] #空のハッシュを用意。(変更不要) H = {} #設定簡易化の為のID定義。(変更不要) def self.s H.size end #最初の項目はこれで固定。(変更不要) H[s] = ["ソートなし","0"] #以下に各種ソート用項目を指定。 #例1. #H[s] = ["ID",:item,"id","昇順","降順"] #この場合、項目名は「ID」で、アイテムIDの値を以て比較します。 #ソート順1の名称は「昇順」、ソート順2の名称は「降順」になります。 #例2. #H[s] = ["名前",:item,"name","昇順","降順"] #この場合、項目名は「名前」で #アイテム名を以て比較します。 #ソート順1の名称は「昇順」、ソート順2の名称は「降順」になります。 #例3. #H[s] = ["最大HP",:actor,"param(0)","高い","低い"] #この場合、項目名は「最大HP」で #装備時のアクターのparam(0)の値を以て比較します。(param(0)は最大HP) #ソート順1の名称は「高い」、ソート順2の名称は「低い」になります。 #例4. #H[s] = ["MP効率",:actor,"sparam(4) * -1","高い","低い"] #この場合、項目名は「MP効率」で #装備時のアクターの消費MP割合の値×-1の値を以て比較します。(sparam(0)は消費MP割合) #消費MP割合の値は基本的に小さければ小さいほど #優秀(消費MPが少なくなる)なので-1で乗算しています。 #これは物理ダメージ率や属性有効度やステート有効度等にも言える事です。 #ソート順1の名称は「高い」、ソート順2の名称は「低い」になります。 H[s] = ["ID",:item,"id","昇順","降順"] H[s] = ["名前",:item,"name","昇順","降順"] H[s] = ["種類",:item,"eq_sort_wa_type_check","昇順","降順"] H[s] = ["最大HP",:actor,"param(0)","高い","低い"] H[s] = ["最大MP",:actor,"param(1)","高い","低い"] H[s] = ["攻撃力",:actor,"param(2)","高い","低い"] H[s] = ["防御力",:actor,"param(3)","高い","低い"] H[s] = ["魔法力",:actor,"param(4)","高い","低い"] H[s] = ["魔法防御",:actor,"param(5)","高い","低い"] H[s] = ["敏捷性",:actor,"param(6)","高い","低い"] H[s] = ["運",:actor,"param(7)","高い","低い"] H[s] = ["命中率",:actor,"xparam(0)","高い","低い"] H[s] = ["回避率",:actor,"xparam(1)","高い","低い"] H[s] = ["会心率",:actor,"xparam(2)","高い","低い"] H[s] = ["会心回避",:actor,"xparam(3)","高い","低い"] H[s] = ["魔法回避",:actor,"xparam(4)","高い","低い"] H[s] = ["魔法反射",:actor,"xparam(5)","高い","低い"] H[s] = ["反撃率",:actor,"xparam(6)","高い","低い"] H[s] = ["HP再生",:actor,"xparam(7)","高い","低い"] H[s] = ["MP再生",:actor,"xparam(8)","高い","低い"] H[s] = ["TP再生",:actor,"xparam(9)","高い","低い"] H[s] = ["狙われ率",:actor,"sparam(0)","高い","低い"] H[s] = ["防御効果",:actor,"sparam(1)","高い","低い"] H[s] = ["回復効果率",:actor,"sparam(2)","高い","低い"] H[s] = ["薬の知識",:actor,"sparam(3)","高い","低い"] H[s] = ["MP効率",:actor,"sparam(4) * -1","高い","低い"] H[s] = ["TPC",:actor,"sparam(5)","高い","低い"] H[s] = ["物理軽減",:actor,"sparam(6) * -1","高い","低い"] H[s] = ["魔法軽減",:actor,"sparam(7) * -1","高い","低い"] H[s] = ["床D軽減",:actor,"sparam(8) * -1","高い","低い"] H[s] = ["EXP率",:actor,"sparam(9)","高い","低い"] H[s] = ["炎耐性",:actor,"element_rate(3) * -1","高い","低い"] H[s] = ["氷耐性",:actor,"element_rate(4) * -1","高い","低い"] H[s] = ["雷耐性",:actor,"element_rate(5) * -1","高い","低い"] H[s] = ["水耐性",:actor,"element_rate(6) * -1","高い","低い"] H[s] = ["大地耐性",:actor,"element_rate(7) * -1","高い","低い"] H[s] = ["風耐性",:actor,"element_rate(8) * -1","高い","低い"] H[s] = ["神聖耐性",:actor,"element_rate(9) * -1","高い","低い"] H[s] = ["暗黒耐性",:actor,"element_rate(10) * -1","高い","低い"] H[s] = ["HP弱体耐性",:actor,"debuff_rate(0) * -1","高い","低い"] H[s] = ["MP弱体耐性",:actor,"debuff_rate(1) * -1","高い","低い"] H[s] = ["攻撃弱体耐性",:actor,"debuff_rate(2) * -1","高い","低い"] H[s] = ["防御弱体耐性",:actor,"debuff_rate(3) * -1","高い","低い"] H[s] = ["魔法弱体耐性",:actor,"debuff_rate(4) * -1","高い","低い"] H[s] = ["魔防弱体耐性",:actor,"debuff_rate(5) * -1","高い","低い"] H[s] = ["敏捷弱体耐性",:actor,"debuff_rate(6) * -1","高い","低い"] H[s] = ["運弱体耐性",:actor,"debuff_rate(7) * -1","高い","低い"] H[s] = ["即死耐性",:actor,"state_rr(1) * -1","高い","低い"] H[s] = ["毒耐性",:actor,"state_rr(2) * -1","高い","低い"] H[s] = ["暗闇耐性",:actor,"state_rr(3) * -1","高い","低い"] H[s] = ["沈黙耐性",:actor,"state_rr(4) * -1","高い","低い"] H[s] = ["混乱耐性",:actor,"state_rr(5) * -1","高い","低い"] H[s] = ["睡眠耐性",:actor,"state_rr(6) * -1","高い","低い"] H[s] = ["麻痺耐性",:actor,"state_rr(7) * -1","高い","低い"] H[s] = ["スタン耐性",:actor,"state_rr(8) * -1","高い","低い"] H[s] = ["攻撃速度補正",:actor,"atk_speed","高い","低い"] H[s] = ["攻撃追加回数",:actor,"atk_times_add","高い","低い"] end class Game_Actor < Game_Battler attr_accessor :e_sort_mode #-------------------------------------------------------------------------- # ステート抵抗関係判定 #-------------------------------------------------------------------------- def state_rr(sid) state_rate(sid) + (state_resist?(sid) ? -EquipSort::Over : 0) end #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def eq_sort(a) value = eval(EquipSort::H[a[0]][2]) rescue 0 value ? value : 0 end #-------------------------------------------------------------------------- # 通常能力値の最大値取得 #-------------------------------------------------------------------------- alias param_max_e_sort_system param_max def param_max(param_id) param_max_e_sort_system(param_id) * (@e_sort_mode ? EquipSort::Over : 1) end #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def init_equip_eq_sort @equips = Array.new(equip_slots.size) { Game_BaseItem.new } end #-------------------------------------------------------------------------- # 武器装備可能の判定 #-------------------------------------------------------------------------- alias equippable_e_sort_system? equippable? unless $! def equippable?(item) @e_sort_mode ? item.is_a?(RPG::EquipItem) : equippable_e_sort_system?(item) end end class RPG::EquipItem < RPG::BaseItem #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def eq_sort(a) value = eval(EquipSort::H[a[0]][2]) rescue 0 value ? value : 0 end #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def eq_sort_wa_type_check -1 end end class RPG::Weapon < RPG::EquipItem #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def eq_sort_wa_type_check wtype_id end end class RPG::Armor < RPG::EquipItem #-------------------------------------------------------------------------- # 装備比較用 #-------------------------------------------------------------------------- def eq_sort_wa_type_check atype_id + EquipSort::Over end end class Game_Party < Game_Unit attr_accessor :equip_last_sort_data end class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # 開始処理 #-------------------------------------------------------------------------- alias start_e_sort_system start def start create_sort_data start_e_sort_system create_equip_sort_window1 create_equip_sort_window2 create_equip_sort_subtext_window sort_auto_apply end #-------------------------------------------------------------------------- # 終了前処理 #-------------------------------------------------------------------------- alias pre_terminate_e_sort_system pre_terminate unless $! def pre_terminate $game_party.equip_last_sort_data = @last_sort if $game_switches[EquipSort::SID] pre_terminate_e_sort_system end #-------------------------------------------------------------------------- # アイテムウィンドウの作成 #-------------------------------------------------------------------------- alias create_item_window_e_sort_system create_item_window def create_item_window create_item_window_e_sort_system @item_window.set_handler(:sort_setting,method(:sort_setting)) end #-------------------------------------------------------------------------- # ソート関連のデータを作成 #-------------------------------------------------------------------------- def create_sort_data @last_sort = {} @equip_sort_type = {} EquipSort::Max.times {|i| @last_sort[i] = [0,true];@equip_sort_type[i] = [0,true]} $game_party.equip_last_sort_data ||= @last_sort.clone end #-------------------------------------------------------------------------- # ソートウィンドウその1を作成(現在のソート状態) #-------------------------------------------------------------------------- def create_equip_sort_window1 sort_window_centering(@equip_sort_window1 = Window_EquipSortCommand1.new(@last_sort)) @equip_sort_window1.viewport = @viewport @equip_sort_window1.set_handler(:sort_type_select1,method(:sort_type_select1)) @equip_sort_window1.set_handler(:sort_type_select2,method(:sort_type_select2)) @equip_sort_window1.set_handler(:sort_type_select3,method(:sort_type_select3)) @equip_sort_window1.set_handler(:sort_ok,method(:sort_ok)) @equip_sort_window1.set_handler(:cancel,method(:sort_cancel1)) end #-------------------------------------------------------------------------- # ソートウィンドウその2を作成(ソート種類一覧) #-------------------------------------------------------------------------- def create_equip_sort_window2 sort_window_centering(@equip_sort_window2 = Window_EquipSortCommand2.new(0,0,@last_sort)) @equip_sort_window2.viewport = @viewport @equip_sort_window2.set_handler(:sort_type_select4,method(:sort_type_select4)) @equip_sort_window2.set_handler(:cancel,method(:sort_cancel2)) end #-------------------------------------------------------------------------- # ソート関連サブテキストウィンドウを作成 #-------------------------------------------------------------------------- def create_equip_sort_subtext_window @equip_sort_subtext_window = Window_EquipSortSubText.new(@item_window) @equip_sort_subtext_window.viewport = @viewport end #-------------------------------------------------------------------------- # ソート内容をアイテムウィンドウに適用 #-------------------------------------------------------------------------- def sort_auto_apply return unless $game_switches[EquipSort::SID] @last_sort = $game_party.equip_last_sort_data.clone @item_window.last_sort = @last_sort.values.all? {|v| v[0] == 0} ? nil : @last_sort.clone end #-------------------------------------------------------------------------- # ソートウィンドウを中央へ #-------------------------------------------------------------------------- def sort_window_centering(w) w.x = (Graphics.width - w.width) / 2 w.y = (Graphics.height - w.height) / 2 end #-------------------------------------------------------------------------- # ソートウィンドウへの設定 #-------------------------------------------------------------------------- def sort_setting @item_window.deactivate @equip_sort_type = Marshal.load(Marshal.dump(@last_sort)) @equip_sort_window1.equip_sort_type = @equip_sort_type.clone @equip_sort_window2.equip_sort_type = @equip_sort_type.clone @equip_sort_window1.index = 0 @equip_sort_window2.index = 0 @equip_sort_window1.refresh @equip_sort_window1.show @equip_sort_window1.activate @help_window.set_text(EquipSort::Help) end #-------------------------------------------------------------------------- # ソート項目選択開始 #-------------------------------------------------------------------------- def sort_type_select1 @equip_sort_window2.equip_sort_type = @equip_sort_type.clone @equip_sort_window2.refresh @equip_sort_window2.show @equip_sort_window1.deactivate @equip_sort_window2.activate end #-------------------------------------------------------------------------- # 昇降順切り替え #-------------------------------------------------------------------------- def sort_type_select2 i = @equip_sort_window1.index / 2 @equip_sort_type[i][1] = @equip_sort_type[i][1] ? false : true @equip_sort_window1.equip_sort_type = @equip_sort_type @equip_sort_window1.refresh @equip_sort_window1.activate end #-------------------------------------------------------------------------- # 指定項目無効 #-------------------------------------------------------------------------- def sort_type_select3 i = @equip_sort_window1.index / 2 @equip_sort_type[i] = [0,true] @equip_sort_window1.equip_sort_type = @equip_sort_type @equip_sort_window1.refresh @equip_sort_window1.activate end #-------------------------------------------------------------------------- # 指定ソート項目設定 #-------------------------------------------------------------------------- def sort_type_select4 i = @equip_sort_window1.index / 2 @equip_sort_type[i][0] = @equip_sort_window2.index @equip_sort_type[i][1] = true if @equip_sort_window2.index == 0 @equip_sort_window2.deactivate @equip_sort_window2.hide @equip_sort_window1.equip_sort_type = @equip_sort_type @equip_sort_window1.refresh @equip_sort_window1.activate end #-------------------------------------------------------------------------- # ソート実行 #-------------------------------------------------------------------------- def sort_ok @last_sort = @equip_sort_type.clone @equip_sort_window1.deactivate @equip_sort_window1.hide @item_window.last_sort = @last_sort.values.all? {|v| v[0] == 0} ? nil : @last_sort.clone @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # ソート実行キャンセル #-------------------------------------------------------------------------- def sort_cancel1 @equip_sort_window1.deactivate @equip_sort_window1.hide @item_window.activate end #-------------------------------------------------------------------------- # ソート項目選択キャンセル #-------------------------------------------------------------------------- def sort_cancel2 @equip_sort_window2.deactivate @equip_sort_window2.hide @equip_sort_window1.activate end end class Window_EquipSortCommand1 < Window_Command attr_accessor :equip_sort_type attr_accessor :last_sort #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(h) @equip_sort_type = h super(0,0) deactivate hide end #-------------------------------------------------------------------------- # 桁数 #-------------------------------------------------------------------------- def col_max 2 end #-------------------------------------------------------------------------- # コマンドリスト作成 #-------------------------------------------------------------------------- def make_command_list h = EquipSort::H return if @equip_sort_type.empty? @equip_sort_type.each_value {|a1| a2 = h[a1[0]] add_command(h[a1[0]][0],:sort_type_select1) add_command(a1[0] == 0 ? "--" : (a1[1] ? a2[3] : a2[4]),:sort_type_select2,a1[0] != 0)} add_command(EquipSort::Name,:sort_ok) end #-------------------------------------------------------------------------- # ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width return 320 end #-------------------------------------------------------------------------- # 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number m = item_max m = m / col_max + (m % col_max != 0 ? 1 : 0) [(Graphics.height - 24) / line_height,m].min end #-------------------------------------------------------------------------- # ハンドリング処理 #-------------------------------------------------------------------------- def process_handling super return sort_type_select3 if active && handle?(:sort_type_select3) && Input.trigger?(EquipSort::Key2) end #-------------------------------------------------------------------------- # ソート項目初期化実行 #-------------------------------------------------------------------------- def sort_type_select3 return if self.index == @list.size - 1 Sound.play_cursor Input.update call_handler(:sort_type_select3) end end class Window_EquipSortCommand2 < Window_Command attr_accessor :equip_sort_type #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(x,y,s) @equip_sort_type = s super(x,y) deactivate hide end #-------------------------------------------------------------------------- # 桁数 #-------------------------------------------------------------------------- def col_max EquipSort::CMax end #-------------------------------------------------------------------------- # コマンドリスト作成 #-------------------------------------------------------------------------- def make_command_list a = (@equip_sort_type.values.inject([]) {|r,v| r += [v[0]]}).compact EquipSort::H.each {|k,v| add_command(v[0],:sort_type_select4,(k == 0 or !a.include?(k)),k)} end #-------------------------------------------------------------------------- # ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number m = item_max m = m / col_max + (m % col_max != 0 ? 1 : 0) [(Graphics.height - 24) / line_height,m].min end end class Window_EquipItem < Window_ItemList attr_accessor :last_sort #-------------------------------------------------------------------------- # アイテムリストの作成 #-------------------------------------------------------------------------- alias make_item_list_e_sort_system make_item_list unless $! def make_item_list make_item_list_e_sort_system return unless @last_sort @data.compact! h = EquipSort::H @last_sort.values.reverse.each {|v| @data = @data.sort {|a,b| case h[v[0]][1] when :item r1 = a.eq_sort(v) r2 = b.eq_sort(v) when :actor ac = Marshal.load(Marshal.dump($game_actors[EquipSort::AID])) ac.e_sort_mode = a ac.init_equip_eq_sort ac.force_change_equip(@slot_id, a) r1 = ac.eq_sort(v) ac = Marshal.load(Marshal.dump($game_actors[EquipSort::AID])) ac.e_sort_mode = b ac.init_equip_eq_sort ac.force_change_equip(@slot_id, b) r2 = ac.eq_sort(v) end (r2 <=> r1) * (v[1] ? -1 : 1) * (h[v[0]][1] == :item ? 1 : -1) }} @data.push(nil) if include?(nil) end #-------------------------------------------------------------------------- # 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- alias process_handling_e_sort_system process_handling unless $! def process_handling process_handling_e_sort_system return process_sort_setting if active && handle?(:sort_setting) && Input.trigger?(EquipSort::Key1) end #-------------------------------------------------------------------------- # ソート実行用プロセス #-------------------------------------------------------------------------- def process_sort_setting Sound.play_cursor Input.update call_handler(:sort_setting) end end class Window_EquipSortSubText < Window_Base #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(w) a = EquipSort::A super(a[0],a[1],a[2],a[3]) create_contents contents.font.size = a[4] @main_window = w unless a[5] self.opacity = 0 self.contents_opacity = 255 r = contents.rect a1 = EquipSort::Color1 a2 = EquipSort::Color2 color1 = Color.new(a1[0],a1[1],a1[2],a1[3]) color2 = Color.new(a2[0],a2[1],a2[2],a2[3]) wd = r.width / 4 r.width = wd contents.gradient_fill_rect(r, color2, color1) r.x += wd r.width *= 2 contents.fill_rect(r, color1) r.x += r.width r.width /= 2 contents.gradient_fill_rect(r, color1, color2) end refresh hide end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh draw_text(contents.rect,EquipSort::Text,1) end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- def update super if @main_window.active show unless self.visible else hide if self.visible end end end