# ▼▲▼ XRXS65. CP制御ターンシステム ▼▲▼ # by 桜雅 在土 # # update 2006/ 6/18 # # #============================================================================== # □ カスタマイズポイント #============================================================================== module XRXS65 # # ベースの行動待機時間 # ATTACK_WAIT = 4 SKILL_WAIN = 4 ITEM_WAIT = 3 GUARD_WAIT = 3 # # 強制行動で待機時間をリセットするか # FORCING_RESET = false end #============================================================================== # --- バトラーにCP機能を追加 モジュール --- #============================================================================== module XRXS_CP attr_writer :max_cp # cpの最高値(実質accessor) #-------------------------------------------------------------------------- # ○ 最大 CP の取得 #-------------------------------------------------------------------------- def max_cp @max_cp = 65535 if @max_cp == nil return @max_cp end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy attr_accessor :turn # 個人ターン #-------------------------------------------------------------------------- # ● アクション作成 #-------------------------------------------------------------------------- def make_action # カレントアクションをクリア self.current_action.clear # 動けない場合 unless self.movable? # メソッド終了 return end # 現在有効なアクションを抽出 available_actions = [] rating_max = 0 for action in self.actions # ターン 条件確認 n = self.turn a = action.condition_turn_a b = action.condition_turn_b if (b == 0 and n != a) or (b > 0 and (n < 1 or n < a or n % b != a % b)) next end # HP 条件確認 if self.hp * 100.0 / self.maxhp > action.condition_hp next end # レベル 条件確認 if $game_party.max_level < action.condition_level next end # スイッチ 条件確認 switch_id = action.condition_switch_id if switch_id > 0 and $game_switches[switch_id] == false next end # 条件に該当 : このアクションを追加 available_actions.push(action) if action.rating > rating_max rating_max = action.rating end end # 最大のレーティング値を 3 として合計を計算 (0 以下は除外) ratings_total = 0 for action in available_actions if action.rating > rating_max - 3 ratings_total += action.rating - (rating_max - 3) end end # レーティングの合計が 0 ではない場合 if ratings_total > 0 # 乱数を作成 value = rand(ratings_total) # 作成した乱数に対応するものをカレントアクションに設定 for action in available_actions if action.rating > rating_max - 3 if value < action.rating - (rating_max - 3) self.current_action.kind = action.kind self.current_action.basic = action.basic self.current_action.skill_id = action.skill_id self.current_action.decide_random_target_for_enemy return else value -= action.rating - (rating_max - 3) end end end end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- def update_phase4_step2 # ガードの解除 @active_battler.guarding = false # 呼び戻す xrxs65_update_phase4_step2 # CPゲージのリセット unless $game_temp.forcing_battler.include?(@active_battler) or XRXS65::FORCING_RESET # CPの消費 @active_battler.cp = 0 # CP最大値を更新 @active_battler.max_cp = (8192 * cpmax_set) - 1 end # CP メーターの更新 @cp_meters.refresh end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias xrxs65_update_phase4_step6 update_phase4_step6 def update_phase4_step6 # バトラーターンの更新 @active_battler.turn += 1 if @active_battler.is_a?(Game_Enemy) # 呼び戻す xrxs65_update_phase4_step6 end #-------------------------------------------------------------------------- # ● 待機時間のセット #-------------------------------------------------------------------------- def cpmax_set case @active_battler.current_action.kind when 0 case @active_battler.current_action.basic when 0 amount = XRXS.element_amount(@active_battler.element_set, "待機時間") return (amount == 0 ? XRXS65::ATTACK_WAIT : amount) when 1 if XRXS_CP.method_defined?("guard_wait") return @active_battler.guard_wait else return XRXS65::GUARD_WAIT end end when 1 skill = $data_skills[@active_battler.current_action.skill_id] amount = XRXS.element_amount(skill.element_set, "待機時間") return (amount == 0 ? XRXS65::SKILL_WAIT : amount) when 2 item = $data_items[@active_battler.current_action.item_id] XRXS.element_amount(item.element_set, "待機時間") return (amount == 0 ? XRXS65::ITEM_WAIT : amount) end end end