#============================================================================== # ■PT編成画面セカンド Ver1.00-β2-Ex1 for RGSS3 # □作成者 kure # # 呼び出し方法  SceneManager.call(Scene_Party_Organize) #============================================================================== $kure_integrate_script = {} if $kure_integrate_script == nil $kure_integrate_script[:Party_Organize] = 100 p "PT編成画面セカンド" module KURE module Party_Organize #初期設定(変更しない事)---------------------------------------------------- COMMAND_NAME = [] #動作設定------------------------------------------------------------------ #パーティーの最大メンバー数 MAX_PARTY_MEBER = 8 #PTM数0人プロテクト(0=OFF 1=ON) ZERO_PROTECT = 1 #表示設定------------------------------------------------------------------ #ゲームに使用する歩行グラフィックの高さと横幅 #RTPのサイズ32で調節しています。 CHARACTER_HEIGHT = 32 CHARACTER_WIDTH = 32 end end #============================================================================== # ■ RPG::Actor(追加定義) #============================================================================== class RPG::Actor < RPG::BaseItem #-------------------------------------------------------------------------- # ☆ 編成固定の定義(追加定義) #-------------------------------------------------------------------------- def no_organize @note.match(/<編成固定\s?(\d+)\s?>/) return $1 ? $1.to_i : 0 end #-------------------------------------------------------------------------- # ☆ 編成許可の定義(追加定義) #-------------------------------------------------------------------------- def permit_organize @note.match(/<編成許可\s?(\d+)\s?>/) return $1 ? $1.to_i : 0 end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit attr_reader :actors # アクターID配列 #-------------------------------------------------------------------------- # ● 指定位置のアクターを入れ替える(追加定義) #-------------------------------------------------------------------------- def set_add_actor(actor, index) @actors[index] = actor.id if actor && @actors[index] @actors.push(actor.id) if actor && !@actors[index] @actors.delete(@actors[index]) if !actor && @actors[index] $game_player.refresh end end #============================================================================== # ■ Scene_Party_Organize #============================================================================== class Scene_Party_Organize < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_help_window create_ptm_window create_actor_select_window create_status_window window_setting end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの作成 #-------------------------------------------------------------------------- def create_help_window @help_window = Window_Help.new(1) @help_window.set_text("メニューを選択してください") end #-------------------------------------------------------------------------- # ● パーティーメンバーウィンドウの作成 #-------------------------------------------------------------------------- def create_ptm_window wx = 0 wy = @help_window.height wh = Graphics.height - @help_window.height @ptm_window = Window_AO_ALL_PartyMember_List.new(wx, wy, wh) #ハンドラのセット @ptm_window.set_handler(:cancel, method(:ptm_cancel)) @ptm_window.set_handler(:ok, method(:ptm_ok)) @ptm_window.activate end #-------------------------------------------------------------------------- # ● アクター選択ウィンドウの作成 #-------------------------------------------------------------------------- def create_actor_select_window wx = @ptm_window.width wy = @help_window.height ww = Graphics.width - wx wh = 24 + (KURE::Party_Organize::CHARACTER_HEIGHT + 4) * 4 @actor_selet_window = Window_AO_ALL_Actor_List.new(wx, wy, ww, wh) #ハンドラのセット @actor_selet_window.set_handler(:cancel, method(:as_cancel)) @actor_selet_window.set_handler(:ok, method(:as_ok)) @actor_selet_window.set_handler(:CTRL, method(:as_mode)) @actor_selet_window.deactivate @actor_selet_window.unselect end #-------------------------------------------------------------------------- # ● アクター選択ウィンドウの作成 #-------------------------------------------------------------------------- def create_status_window wx = @ptm_window.width wy = @help_window.height + @actor_selet_window.height ww = Graphics.width - wx wh = Graphics.height - wy @status_window = Window_AO_Status_Window.new(wx, wy, ww, wh) end #-------------------------------------------------------------------------- # ● ウィンドウのセット #-------------------------------------------------------------------------- def window_setting @ptm_window.set_actor_list @actor_selet_window.set_actor_list @ptm_window.status_window = @status_window @actor_selet_window.status_window = @status_window end #-------------------------------------------------------------------------- # ● パーティーウィンドウ[決定] #-------------------------------------------------------------------------- def ptm_ok #全て外すの処理を追加実装 if @ptm_window.actor == "all" KURE::Party_Organize::MAX_PARTY_MEBER.downto(0){|index| next if index == 0 && KURE::Party_Organize::ZERO_PROTECT == 1 $game_party.set_add_actor(nil, index) } @ptm_window.set_actor_list @actor_selet_window.set_actor_list @ptm_window.select(0) @ptm_window.activate else @ptm_window.deactivate @actor_selet_window.activate @actor_selet_window.select(0) name = @ptm_window.actor ? @ptm_window.actor.name + "と" : "" @help_window.set_text(name + "交代するメンバーを選択してください") end end #-------------------------------------------------------------------------- # ● パーティーウィンドウ[キャンセル] #-------------------------------------------------------------------------- def ptm_cancel return_scene end #-------------------------------------------------------------------------- # ● アクター選択ウィンドウ[決定] #-------------------------------------------------------------------------- def as_ok change_actor_process as_cancel end #-------------------------------------------------------------------------- # ● アクター選択ウィンドウ[キャンセル] #-------------------------------------------------------------------------- def as_cancel @actor_selet_window.deactivate @actor_selet_window.unselect @ptm_window.activate @help_window.set_text("メンバーを選択してください") end #-------------------------------------------------------------------------- # ● アクター選択ウィンドウ[SHIFT] #-------------------------------------------------------------------------- def as_mode @actor_selet_window.change_sort end #-------------------------------------------------------------------------- # ● アクター入れ替え処理 #-------------------------------------------------------------------------- def change_actor_process $game_party.set_add_actor(@actor_selet_window.actor, @ptm_window.index) @ptm_window.set_actor_list @actor_selet_window.set_actor_list @ptm_window.index = @ptm_window.index end end #============================================================================== # ■ Window_AO_ALL_PartyMember_List #============================================================================== class Window_AO_ALL_PartyMember_List< Window_Command attr_accessor :actor attr_accessor :status_window #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, height) @window_height = height @max_page = 0 @page_index = 0 @last_index = 0 @actor_list = nil super(x,y) end #-------------------------------------------------------------------------- # ● アクターリストの設定 #-------------------------------------------------------------------------- def set_actor_list @actor_list = $game_party.all_members ; refresh end #-------------------------------------------------------------------------- # ● ウィンドウ幅と高さ、項目の高さの取得 #-------------------------------------------------------------------------- def window_width ; 200 ; end def window_height ; @window_height ; end def item_height ; KURE::Party_Organize::CHARACTER_HEIGHT + 2 ; end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color, command_enabled?(index)) rect = item_rect(index) draw_text(rect, (index + 1).to_s , alignment) rect.x += 20 rect.x += KURE::Party_Organize::CHARACTER_WIDTH / 2 actor = @list[index][:ext] if actor && actor != "all" draw_character(actor.character_name, actor.character_index , rect.x, rect.y + rect.height) end rect.x += (KURE::Party_Organize::CHARACTER_WIDTH / 2) + 2 draw_text(rect, command_name(index), alignment) end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list return unless @actor_list KURE::Party_Organize::MAX_PARTY_MEBER.times{|index| actor = @actor_list[index] if actor add_command(actor.name, :ok, enable?(actor), actor) else add_command("-empty-", :ok, enable_empty?(index), nil) end } #全員外すコマンド add_command("全員外す", :ok, true , "all") end #-------------------------------------------------------------------------- # ● コマンドの有効判定 #-------------------------------------------------------------------------- def enable?(actor) return true if actor.actor.no_organize == 0 return false if $game_switches[actor.actor.no_organize] return true end #-------------------------------------------------------------------------- # ● コマンドの有効判定 #-------------------------------------------------------------------------- def enable_empty?(index) return true if @actor_list.size >= index return false end #-------------------------------------------------------------------------- # ● カーソル位置の設定 #-------------------------------------------------------------------------- def index=(index) @index = index update_cursor call_update_help @actor = current_ext @status_window.actor1 = current_ext if @status_window end end #============================================================================== # ■ Window_AO_ALL_Actor_List #============================================================================== class Window_AO_ALL_Actor_List< Window_Command attr_accessor :actor attr_accessor :status_window #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) @window_height = height ; @window_width = width @max_page = 0 ; @page_index = 0 ; @last_index = 0 @actor_list = nil @sort = 0 super(x,y) end #-------------------------------------------------------------------------- # ● 選択中のアクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor ; @actor = actor ; refresh end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理(エイリアス) #-------------------------------------------------------------------------- alias k_before_process_handling process_handling unless $! def process_handling k_before_process_handling return process_ctrl if handle?(:CTRL) && Input.trigger?(:CTRL) end #-------------------------------------------------------------------------- # ● CTRL ボタン(CTRL)が押されたときの処理 #-------------------------------------------------------------------------- def process_ctrl Input.update call_handler(:CTRL) end #-------------------------------------------------------------------------- # ● 並べ替えモードの切り替え #-------------------------------------------------------------------------- def change_sort @sort += 1 @sort = 0 if @sort > 10 set_actor_list @actor = current_ext @status_window.actor2 = current_ext if @status_window end #-------------------------------------------------------------------------- # ● アクターリストの設定 #-------------------------------------------------------------------------- def set_actor_list @actor_list = $data_actors.select{|actor| include?(actor)}.collect{|actor| $game_actors[actor.id]} case @sort when 0 when 1 ; @actor_list = @actor_list.sort{ |a,b| a.level <=> b.level} when 2 ; @actor_list = @actor_list.sort{ |a,b| b.level <=> a.level} when 3 ; @actor_list = @actor_list.sort{ |a,b| b.mhp <=> a.mhp} when 4 ; @actor_list = @actor_list.sort{ |a,b| b.mmp <=> a.mmp} when 5 ; @actor_list = @actor_list.sort{ |a,b| b.atk <=> a.atk} when 6 ; @actor_list = @actor_list.sort{ |a,b| b.def <=> a.def} when 7 ; @actor_list = @actor_list.sort{ |a,b| b.mat <=> a.mat} when 8 ; @actor_list = @actor_list.sort{ |a,b| b.mdf <=> a.mdf} when 9 ; @actor_list = @actor_list.sort{ |a,b| b.agi <=> a.agi} when 10 ; @actor_list = @actor_list.sort{ |a,b| b.luk <=> a.luk} end refresh end #-------------------------------------------------------------------------- # ● コマンドの有効判定 #-------------------------------------------------------------------------- def include?(actor) return false unless actor #return false if $game_party.actors.include?(actor.id) return false if actor.permit_organize != 0 && !$game_switches[actor.permit_organize] return true end #-------------------------------------------------------------------------- # ● ウィンドウ幅と高さ、項目の高さの取得 #-------------------------------------------------------------------------- def window_width ; @window_width ; end def window_height ; @window_height ; end def item_height ; KURE::Party_Organize::CHARACTER_HEIGHT + 4 ; end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max ; return 4 ; end #-------------------------------------------------------------------------- # ● 横に項目が並ぶときの空白の幅を取得 #-------------------------------------------------------------------------- def spacing ; return 8 ; end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color, command_enabled?(index)) rect = item_rect(index) actor_x = (KURE::Party_Organize::CHARACTER_WIDTH / 2) + 1 actor = @list[index][:ext] if actor draw_character_ex(actor.character_name, actor.character_index , rect.x + actor_x, rect.y + rect.height - 2, $game_party.actors.include?(actor.id)) last_size = contents.font.size contents.font.size = 18 change_color(system_color) case @sort when 0,1,2 ; txt = "Lv" ; txt2 = actor.level.to_s when 3 ; txt = "MHP" ; txt2 = actor.mhp.to_s when 4 ; txt = "MMP" ; txt2 = actor.mmp.to_s when 5 ; txt = "ATK" ; txt2 = actor.atk.to_s when 6 ; txt = "DEF" ; txt2 = actor.def.to_s when 7 ; txt = "MATK" ; txt2 = actor.mat.to_s when 8 ; txt = "MDEF" ; txt2 = actor.mdf.to_s when 9 ; txt = "AGI" ; txt2 = actor.agi.to_s when 10 ; txt = "LUK" ; txt2 = actor.luk.to_s end draw_text(rect.x + (actor_x * 2) - 2, rect.y, rect.width - (actor_x * 2), 18 , txt, 1) change_color(normal_color) draw_text(rect.x + (actor_x * 2) - 2, rect.y + 18, rect.width - (actor_x * 2), 18 , txt2, 1) contents.font.size = last_size else draw_text(rect, command_name(index), 1) end end #-------------------------------------------------------------------------- # ● カーソルを 1 ページ後ろに移動 #-------------------------------------------------------------------------- def cursor_pagedown @page_index += 1 ; cursor_fix end #-------------------------------------------------------------------------- # ● カーソルを 1 ページ前に移動 #-------------------------------------------------------------------------- def cursor_pageup @page_index -= 1 ; cursor_fix end #-------------------------------------------------------------------------- # ● カーソル位置修正 #-------------------------------------------------------------------------- def cursor_fix refresh @index = [@index,@last_index].min update_cursor call_update_help @actor = current_ext @status_window.actor2 = current_ext if @status_window end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list return unless @actor_list data = @actor_list @max_page = data.size.divmod(11)[0] - 1 @max_page += 1 if data.size.divmod(11)[1] != 0 @max_page += 1 if data.size == 0 @page_index = 0 if @page_index > @max_page @page_index = @max_page if @page_index < 0 first = @page_index * 11 last = [((@page_index + 1 ) * 11) - 1, data.size - 1].min @last_index = last - first + 1 data = data[first..last] add_command("外す", :ok, protect?, nil) data.each{|actor| add_command(actor.name, :ok, enable?(actor), actor)} end #-------------------------------------------------------------------------- # ● コマンドの有効判定 #-------------------------------------------------------------------------- def protect? return true if KURE::Party_Organize::ZERO_PROTECT == 0 return true if KURE::Party_Organize::ZERO_PROTECT == 1 && $game_party.all_members.size >= 2 return false end #-------------------------------------------------------------------------- # ● コマンドの有効判定 #-------------------------------------------------------------------------- def enable?(actor) return true end #-------------------------------------------------------------------------- # ● カーソル位置の設定 #-------------------------------------------------------------------------- def index=(index) @index = index update_cursor call_update_help @actor = current_ext @status_window.actor2 = current_ext if @status_window end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_guide last_size = contents.font.size contents.font.size = 20 change_color(normal_color) draw_text(0, contents.height - line_height, contents.width / 2 - 30, line_height, "LR:切替 " + "(" + (@page_index + 1).to_s + "/" + (@max_page + 1).to_s + ")", 1) case @sort when 0 ; txt = "ID順" when 1 ; txt = "Lv昇順" when 2 ; txt = "Lv降順" when 3 ; txt = "最大HP順" when 4 ; txt = "最大MP順" when 5 ; txt = "攻撃力順" when 6 ; txt = "防御力順" when 7 ; txt = "魔法攻撃力順" when 8 ; txt = "魔法防御順" when 9 ; txt = "敏捷性順" when 10 ; txt = "運順" end draw_text(contents.width / 2 - 30, contents.height - line_height, contents.width / 2 + 30, line_height, "CTRL:切替(" + txt + ")", 1) contents.font.size = last_size end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh super draw_guide end #-------------------------------------------------------------------------- # ● 歩行グラフィックの描画 #-------------------------------------------------------------------------- def draw_character_ex(character_name, character_index, x, y, enabled = false) return unless character_name bitmap = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign && sign.include?('$') cw = bitmap.width / 3 ch = bitmap.height / 4 else cw = bitmap.width / 12 ch = bitmap.height / 8 end n = character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? translucent_alpha : 255) end end #============================================================================== # ■ Window_AO_Status_Window #============================================================================== class Window_AO_Status_Window < Window_Base attr_accessor :actor1 attr_accessor :actor2 #-------------------------------------------------------------------------- # ● 選択中のアクターの設定 #-------------------------------------------------------------------------- def actor1=(actor) return if @actor1 == actor ; @actor1 = actor ; refresh end #-------------------------------------------------------------------------- # ● 選択中のアクターの設定 #-------------------------------------------------------------------------- def actor2=(actor) return if @actor2 == actor ; @actor2 = actor ; refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear return if @actor1 == "all" if @actor1 draw_actor_face(@actor1, 20, 0) draw_actor_name(@actor1, 20, line_height * 4) draw_actor_class(@actor1, 20, line_height * 5) draw_actor_level(@actor1, 20, line_height * 6) end change_color(system_color) last_size = contents.font.size contents.font.size += 12 draw_text((contents.width - 45)/ 2, contents.height / 2 , 45, line_height + 12, "→", 1) contents.font.size = last_size change_color(normal_color) if @actor2 draw_actor_face(@actor2, contents.width - 130, 0) draw_actor_name(@actor2, contents.width - 130, line_height * 4) draw_actor_class(@actor2, contents.width - 130, line_height * 5) draw_actor_level(@actor2, contents.width - 130, line_height * 6) end end end