#◆◇◆◇◆ 死に際攻撃スクリプト ver 1.00 ◇◆◇◆◇ # 全マスタースクリプト共通スクリプト # サポート掲示板 http://www2.ezbbs.net/21/minto-aaa/ # by みんと =begin ■ 更新履歴 ○ ver 1.00(2009/02/14) 公開 ■ 説明 敵のHPが0になった際、 最後に指定したスキルを強制使用させます。 スキルを使用する確率も設定できます。 設定はソース内部を参照してください。 =end #============================================================================== # ☆ MINTO #------------------------------------------------------------------------------ # 様々なフラグを扱うメインモジュールです。 #============================================================================== module MINTO # 死に際攻撃スクリプトを有効化 ( true で有効 / false で無効 ) RGSS["死に際攻撃スクリプト"] = true end # 死に際攻撃スクリプトが有効な場合に以降の処理を実行する if MINTO::RGSS["死に際攻撃スクリプト"] == true then #============================================================================== # ☆ カスタマイズ #------------------------------------------------------------------------------ # 機能のカスタマイズをここで行います。 #============================================================================== module MINTO #-------------------------------------------------------------------------- # ● 死に際攻撃エネミーの取得 # id : エネミーのID #-------------------------------------------------------------------------- def self.daying_attack_enemy(id) # エネミーのIDに応じて分岐 case id # エネミーID1 when 1 then # data = [死に際スキル(ID), 使用確率] data = [2, 100] when 2 then data = [2, 100] when 3 then data = [2, 100] # それ以外(変更しない) else data = nil end # 設定データを返す return data end end #============================================================================== # ☆ Local_Immortal #------------------------------------------------------------------------------ # 一時的な不死身フラグを扱うモジュールです。 #============================================================================== module Local_Immortal #-------------------------------------------------------------------------- # ● 戦闘不能判定 #-------------------------------------------------------------------------- def dead? # スーパークラスを実行(継承先の処理に移行する) bool = super return (bool and not self.local_immortal) end #-------------------------------------------------------------------------- # ● 存在判定 #-------------------------------------------------------------------------- def exist? # スーパークラスを実行(継承先の処理に移行する) bool = super return (bool or self.local_immortal) end #-------------------------------------------------------------------------- # ● HP 0 判定 #-------------------------------------------------------------------------- def hp0? # スーパークラスを実行(継承先の処理に移行する) bool = super return (bool and not self.local_immortal) end #-------------------------------------------------------------------------- # ● 死に際攻撃判定 #-------------------------------------------------------------------------- def daying_attack_effect # 残りHPが0の場合 if self.hp == 0 then # 死に際アクション未実行の場合 if self.daying_attack == nil then # データを取得 data = MINTO.daying_attack_enemy(self.id) # 設定確率をクリアした場合 if (rand(100) < data[1]) # 配列が無効な場合 if $game_temp.daying_forcing_battler == nil then # 配列を初期化 $game_temp.daying_forcing_battler = [] end # 強制アクションを設定 self.current_action.kind = 1 self.current_action.skill_id = data[0] self.current_action.decide_random_target_for_enemy self.current_action.forcing = true self.local_immortal = true # 配列に追加 $game_temp.daying_forcing_battler.push(self) end end end end #-------------------------------------------------------------------------- # ● 通常攻撃の効果適用 # attacker : 攻撃者 (バトラー) # skill : スキル #-------------------------------------------------------------------------- def attack_effect(attacker, skill = nil) # スーパークラスを実行(継承先の処理に移行する) bool = super(attacker) # 対象がエネミーでない場合 unless self.is_a?(Game_Enemy) == true then # メソッドを返す return bool end # 死に際攻撃判定 daying_attack_effect # メソッドを返す return bool end #-------------------------------------------------------------------------- # ● スキルの効果適用 # user : スキルの使用者 (バトラー) # skill : スキル #-------------------------------------------------------------------------- def skill_effect(user, skill) # スーパークラスを実行(継承先の処理に移行する) bool = super(user, skill) # 対象がエネミーでない場合 unless self.is_a?(Game_Enemy) == true then # メソッドを返す return bool end # 死に際攻撃判定 daying_attack_effect # メソッドを返す return bool end end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :daying_forcing_battler # 死に際攻撃バトラー end #============================================================================== # ■ Game_Battler (分割定義 1) #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :local_immortal # 一時不死身フラグ attr_accessor :daying_attack # 死に際攻撃実行フラグ end #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の # 内部で使用されます。 #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● システムインクルード #-------------------------------------------------------------------------- include(Local_Immortal) # 一時不死身モジュール end #============================================================================== # ■ Scene_Battle (分割定義 1) #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias :daying_attack_main :main def main # 死に際攻撃バトラーをクリア $game_temp.daying_forcing_battler = [] # 元の処理を実行 daying_attack_main # 死に際攻撃バトラーをクリア $game_temp.daying_forcing_battler = [] end end #============================================================================== # ■ Scene_Battle (分割定義 4) #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 強制アクションの設定 #-------------------------------------------------------------------------- def forcing_action_set # 死に際攻撃を行うバトラーがいない場合 if $game_temp.daying_forcing_battler == [] then # メソッドを返す return end # ループ処理(死に際アクションバトラー) for battler in $game_temp.daying_forcing_battler do # 死に際アクション未実行の場合 if battler.daying_attack == nil then # 実行済みフラグをオンにする battler.daying_attack = true # 強制アクションバトラーにシフト $game_temp.forcing_battler = battler # ループから抜ける break # 死に際アクション実行済みの場合 else # 戦闘不能を許可 battler.local_immortal = false end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias :update_phase4_step6_forcing_action :update_phase4_step6 def update_phase4_step6 # 元の処理を実行 update_phase4_step6_forcing_action # 強制アクションの実行 forcing_action_set end end end