#============================================================================== # ★ パーティ能力 ver1.0 by USK #------------------------------------------------------------------------------ # ・戦闘時パーティコマンドにパーティスキルを使用する項目を追加します。 # ・パーティレベル、パーティ装備の概念を追加します。 #============================================================================== =begin ・PartySymbolActorIDで指定したアクターとパーティの生存しているアクターが覚えてい  るPartySkillTypeIDで指定したスキルタイプのスキルがパーティスキルとして使用可能  になります。パーティスキルを使用するアクターはPartySymbolActorIDで指定したアク  ターです。 ・スキルのメモ欄にと記述すると(必要生存アクター数)  で設定した人数が生存していることをスキル使用条件にできます。例 ・パーティスキル選択時に表示されるパーティステータスの表示位置はPartyBattleStatusX  PartyBattleStatusYで指定できます。 =end #-------------------------------------------------------------------------- # ● 設定項目 #-------------------------------------------------------------------------- PartySymbolActorID = 5 #パーティスキルの使用者となるアクターのID PartySkillTypeID = 3 #パーティスキルに登録されるスキルタイプ PartyBattleStatusX = 12 #戦闘時のパーティMP表示X座標 PartyBattleStatusY = 32 #戦闘時のパーティMP表示X座標 PartyCommandBattleName = "パーティスキル" #パーティスキルのコマンド名 PartyCommandBattleIndex = 1 #パーティスキルの表示位置(0が一番上) PartyCommandBattleFlag = 2 #パーティスキルの表示切り替えスイッチのID PartyCommandMenuName = "パーティ" #メニューのパーティコマンド名 PartyCommandMenuIndex = 3 #メニューのパーティコマンド表示位置(0が一番上) PartyCommandMenuFlag = 2 #パーティコマンドの表示切り替えスイッチのID PartyParams = { :lv => "パーティLV", #レベルの表示名。""とすると非表示 :mp => "PP", #MPの表示名。""とするとデフォルトの表示名 :atk => "攻", #攻撃力の表示名。""とすると非表示 :def => "防", #防御力の表示名。""とすると非表示 :mat => "魔", #魔法力の表示名。""とすると非表示 :mdf => "", #魔法防御の表示名。""とすると非表示 :agi => "速", #敏捷性の表示名。""とすると非表示 :luk => "運", #運の表示名。""とすると非表示 } PartyEquipName = "陣形" #パーティ装備の名称 PartyEquipType = 0 #パーティ装備のタイプ(0=>武器1=>盾2=>頭3=>身体4=>装飾) #============================================================================== # ■ BattleManager #============================================================================== module BattleManager class << BattleManager; alias :usk_ss_make_action_orders :make_action_orders; end #-------------------------------------------------------------------------- # ● 行動順序の作成 #-------------------------------------------------------------------------- def self.make_action_orders usk_ss_make_action_orders if SceneManager.scene.party_skill_flag @action_battlers << $game_party.symbol @action_battlers.each {|battler| battler.make_speed } @action_battlers.sort! {|a,b| b.speed - a.speed } end end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def symbol $game_actors[PartySymbolActorID] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def party_skills ret = [] $game_party.alive_members.each do |actor| ret |= actor.skills.select{|skill| skill.stype_id == PartySkillTypeID} end ret end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor #-------------------------------------------------------------------------- # ● インデックス取得 #-------------------------------------------------------------------------- alias :usk_ss_index :index def index usk_ss_index || (@actor_id == PartySymbolActorID ? 100 : nil) end #-------------------------------------------------------------------------- # ● スキルの使用可能条件チェック #-------------------------------------------------------------------------- alias :usk_ss_skill_conditions_met? :skill_conditions_met? def skill_conditions_met?(skill) usk_ss_skill_conditions_met?(skill) && skill.member_ok? end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- alias :usk_ss_skills :skills def skills ret = usk_ss_skills ret |= $game_party.party_skills if @actor_id == PartySymbolActorID ret end end #============================================================================== # ■ Window_Command #============================================================================== class Window_Command #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def insert_command(index, name, symbol, enabled = true, ext = nil) @list.insert(index, {:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}) end end #============================================================================== # ■ Window_MenuCommand #============================================================================== class Window_MenuCommand #-------------------------------------------------------------------------- # ● 独自コマンドの追加用 #-------------------------------------------------------------------------- alias :usk_ss_add_original_commands :add_original_commands def add_original_commands usk_ss_add_original_commands if $game_switches[PartyCommandMenuFlag] insert_command(PartyCommandMenuIndex, PartyCommandMenuName, :party) end end end #============================================================================== # ■ Window_PartyCommand #============================================================================== class Window_PartyCommand #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- alias :usk_ss_make_command_list :make_command_list def make_command_list usk_ss_make_command_list if $game_switches[PartyCommandBattleFlag] insert_command(PartyCommandBattleIndex, PartyCommandBattleName, :party) end end end #============================================================================== # ■ Window_BattlePartyStatus #============================================================================== class Window_BattlePartyStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(PartyBattleStatusX, PartyBattleStatusY, Graphics.width, fitting_height(1)) @actor = $game_party.symbol self.opacity = 0 hide refresh end #-------------------------------------------------------------------------- # ● 標準パディングサイズの取得 #-------------------------------------------------------------------------- def standard_padding return 0 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show refresh super end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear ox = 4 oy = 0 draw_actor_name(@actor, ox, oy) w = text_size(@actor.name).width ox += w + 12 draw_actor_mp(@actor, ox, oy) end #-------------------------------------------------------------------------- # ● MP の描画 #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 240) draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2) change_color(system_color) s = PartyParams[:mp].empty? ? Vocab::mp_a : PartyParams[:mp] draw_text(x, y, 30, line_height, s) draw_current_and_max_values(x, y, width, actor.mp, actor.mmp, mp_color(actor), normal_color) end end #============================================================================== # ■ Window_PartyStatus #============================================================================== class Window_PartyStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, Graphics.width, 120) @actor = $game_party.symbol refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear ox = 4 oy = 0 draw_actor_face(@actor, contents.width - 144, oy) draw_actor_name(@actor, ox, oy) w = text_size(@actor.name).width draw_actor_level(@actor, w + 24, oy) unless PartyParams[:lv].empty? draw_actor_mp(@actor, ox, line_height + oy) x = ox y = line_height * 2 + oy 6.times do |i| if draw_actor_param(@actor, x, y, i) x += 120 if x > 360 x = ox y += line_height end end end end #-------------------------------------------------------------------------- # ● レベルの描画 #-------------------------------------------------------------------------- def draw_actor_level(actor, x, y) change_color(system_color) w = text_size(PartyParams[:lv]).width draw_text(x, y, w, line_height, PartyParams[:lv]) change_color(normal_color) draw_text(x + w, y, 24, line_height, actor.level, 2) end #-------------------------------------------------------------------------- # ● MP の描画 #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 240) draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2) change_color(system_color) s = PartyParams[:mp].empty? ? Vocab::mp_a : PartyParams[:mp] draw_text(x, y, 30, line_height, s) draw_current_and_max_values(x, y, width, actor.mp, actor.mmp, mp_color(actor), normal_color) end #-------------------------------------------------------------------------- # ● 能力値の描画 #-------------------------------------------------------------------------- def draw_actor_param(actor, x, y, param_id) change_color(system_color) a = [:atk, :def, :mat, :mdf, :agi, :luk] param = PartyParams[a[param_id]] return false if param.empty? draw_text(x, y, 120, line_height, param) change_color(normal_color) draw_text(x + 60, y, 36, line_height, actor.param(param_id + 2), 2) return true end end #============================================================================== # ■ Window_PartySkillList #============================================================================== class Window_PartySkillList < Window_SkillList #-------------------------------------------------------------------------- # ● カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) call_handler(:down) super(wrap) end #-------------------------------------------------------------------------- # ● カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) call_handler(:up) super(wrap) end end #============================================================================== # ■ Window_PartyEquip #============================================================================== class Window_PartyEquip < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #------------------------------------------------------------------------- def initialize(x, y) super(x, y, Graphics.width - x, fitting_height(1)) @actor = $game_party.symbol @index = 0 refresh activate end #-------------------------------------------------------------------------- # ● 全項目の描画 #-------------------------------------------------------------------------- def draw_all_items rect = text_size(PartyEquipName + " ") change_color(system_color) draw_text(rect, PartyEquipName, 1) change_color(normal_color) @rect ||= rect.set(rect.width, 0, contents.width - rect.width, rect.height) name = @actor.equips[PartyEquipType] ? @actor.equips[PartyEquipType].name : "" draw_text(@rect, name, 1) end #-------------------------------------------------------------------------- # ● カーソルの更新 #-------------------------------------------------------------------------- def update_cursor if @cursor_all cursor_rect.set(0, 0, contents.width, row_max * item_height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible cursor_rect.set(@rect) end end #-------------------------------------------------------------------------- # ● カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) call_handler(:down) end #-------------------------------------------------------------------------- # ● カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) call_handler(:up) end #-------------------------------------------------------------------------- # ● カーソルの移動可能判定 #-------------------------------------------------------------------------- def cursor_movable? active && open? end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item @actor.equips[PartyEquipType] end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_item(item) end end #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- alias :usk_ss_post_start :post_start def post_start if $game_switches[PartyCommandMenuFlag] @command_window.set_handler(:party, method(:command_party_usk)) end usk_ss_post_start end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def command_party_usk SceneManager.call(Scene_PartyStatus) end end #============================================================================== # ■ Scene_PartyStatus #============================================================================== class Scene_PartyStatus < Scene_ItemBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super @actor_window.z += 1 @help_window = Window_Help.new @help_window.y = Graphics.height - @help_window.height @status_window = Window_PartyStatus.new y = @status_window.height @equip_window = Window_PartyEquip.new(0, y) @equip_window.help_window = @help_window @equip_window.set_handler(:up , method(:skill_select)) @equip_window.set_handler(:down , method(:skill_select)) @equip_window.set_handler(:ok , method(:item_select)) @equip_window.set_handler(:cancel, method(:return_scene)) y += @equip_window.height h = Graphics.height - @status_window.height - @equip_window.height - @help_window.height @item_window = Window_PartySkillList.new(0, y, Graphics.width, h) @item_window.actor = $game_party.symbol @item_window.stype_id = PartySkillTypeID @item_window.help_window = @help_window @item_window.set_handler(:up , method(:equip_select2)) @item_window.set_handler(:down , method(:equip_select3)) @item_window.set_handler(:ok , method(:determine_item)) @item_window.set_handler(:cancel, method(:equip_select)) @equip_item_window = Window_EquipItem.new(0, y, Graphics.width, h) @equip_item_window.help_window = @help_window @equip_item_window.set_handler(:ok , method(:equip_change)) @equip_item_window.set_handler(:cancel, method(:return_scene)) @equip_item_window.actor = $game_party.symbol @equip_item_window.slot_id = PartyEquipType @equip_item_window.hide end #-------------------------------------------------------------------------- # ● 現在選択されているアイテムの取得 #-------------------------------------------------------------------------- def item @item_window.item end #-------------------------------------------------------------------------- # ● アイテムの使用者を取得 #-------------------------------------------------------------------------- def user $game_party.symbol end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def equip_change $game_party.symbol.change_equip(PartyEquipType, @equip_item_window.item) @equip_window.refresh @equip_item_window.refresh @status_window.refresh equip_select end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def equip_select @equip_window.activate @equip_window.index = 0 @item_window.show @equip_item_window.hide end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def equip_select2 return if @item_window.index > 1 Sound.play_cursor @equip_window.activate @equip_window.index = 0 @item_window.deactivate @item_window.index = -1 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def equip_select3 Sound.play_cursor end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def skill_select Sound.play_cursor @equip_window.deactivate @equip_window.index = -1 @item_window.activate Input.update @item_window.index = 0 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_select @item_window.deactivate.hide @equip_window.deactivate @equip_item_window.activate.show @equip_item_window.index = 0 end #-------------------------------------------------------------------------- # ● アイテム使用時の SE 演奏 #-------------------------------------------------------------------------- def play_se_for_item Sound.play_use_skill end #-------------------------------------------------------------------------- # ● アイテムの使用 #-------------------------------------------------------------------------- def use_item super @status_window.refresh end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- alias :usk_ss_post_start :post_start def post_start @bps_window = Window_BattlePartyStatus.new usk_ss_post_start end #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- alias :usk_ss_start_party_command_selection :start_party_command_selection def start_party_command_selection if $game_switches[PartyCommandBattleFlag] @party_command_window.set_handler(:party, method(:command_party_usk)) end usk_ss_start_party_command_selection end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def party_skill_flag @party_skill_flag end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def command_party_usk @party_skill_flag = true $game_party.symbol.make_actions @bps_window.show @skill_window.actor = $game_party.symbol @skill_window.stype_id = PartySkillTypeID @skill_window.refresh @skill_window.show.activate end #-------------------------------------------------------------------------- # ● スキル[決定] #-------------------------------------------------------------------------- alias :usk_ss_on_skill_ok :on_skill_ok def on_skill_ok if @party_skill_flag @bps_window.hide @skill = @skill_window.item $game_party.symbol.input.set_skill(@skill.id) $game_party.symbol.last_skill.object = @skill if !@skill.need_selection? @skill_window.hide turn_start elsif @skill.for_opponent? select_enemy_selection else select_actor_selection end else usk_ss_on_skill_ok end end #-------------------------------------------------------------------------- # ● スキル[キャンセル] #-------------------------------------------------------------------------- alias :usk_ss_on_skill_cancel :on_skill_cancel def on_skill_cancel if @party_skill_flag @bps_window.hide @skill_window.hide @party_command_window.activate else usk_ss_on_skill_cancel end end #-------------------------------------------------------------------------- # ● アクター[決定] #-------------------------------------------------------------------------- alias :usk_ss_on_actor_ok :on_actor_ok def on_actor_ok if @party_skill_flag $game_party.symbol.input.target_index = @actor_window.index @actor_window.hide @skill_window.hide turn_start else usk_ss_on_actor_ok end end #-------------------------------------------------------------------------- # ● アクター[キャンセル] #-------------------------------------------------------------------------- alias :usk_ss_on_actor_cancel :on_actor_cancel def on_actor_cancel if @party_skill_flag @bps_window.show @actor_window.hide @skill_window.activate else usk_ss_on_actor_cancel end end #-------------------------------------------------------------------------- # ● 敵キャラ[決定] #-------------------------------------------------------------------------- alias :usk_ss_on_enemy_ok :on_enemy_ok def on_enemy_ok if @party_skill_flag $game_party.symbol.input.target_index = @enemy_window.enemy.index @enemy_window.hide @skill_window.hide turn_start else usk_ss_on_enemy_ok end end #-------------------------------------------------------------------------- # ● 敵キャラ[キャンセル] #-------------------------------------------------------------------------- alias :usk_ss_on_enemy_cancel :on_enemy_cancel def on_enemy_cancel if @party_skill_flag @bps_window.show @enemy_window.hide @skill_window.activate else usk_ss_on_enemy_cancel end end #-------------------------------------------------------------------------- # ● アクターコマンド選択の開始 #-------------------------------------------------------------------------- alias :usk_ss_start_actor_command_selection :start_actor_command_selection def start_actor_command_selection @party_skill_flag = false usk_ss_start_actor_command_selection end end #============================================================================== # ■ RPG::Skill #============================================================================== class RPG::Skill #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def member_ok? $game_party.alive_members.size >= member end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def member @member ||= @note =~ //m ? $1.to_i : 1 end end