=begin 攻撃時SP回復スクリプト 作成:稲妻と雷鳴 配布元:RPGの参考書(URL http://19800.net/rpg-sankou/new/) Scene_Debug 〜 Main 間に新しいセクションを作成し、全文を貼り付けてください。 =end #========================================================================== # ▼ 簡易カスタマイズ項目 (始) #========================================================================== =begin ROR_SP_RECOVERY = [回復対象, 回復形式, 回復レート, 回復属性] 詳しくは http://rpg.sankou.client.jp/new/xp/script/sp_recovery/sp_recovery.html をご覧ください。 =end ROR_SP_RECOVERY = [1, 0, 100, "SP回復"] #========================================================================== # ▲ 簡易カスタマイズ項目 (終) #========================================================================== #***************************************************************************** class Scene_Battle #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- def make_basic_action_result # 攻撃の場合 if @active_battler.current_action.basic == 0 # アニメーション ID を設定 @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) case ROR_SP_RECOVERY[0] when 0 $ror_sp_recovery = true when 2 $ror_sp_recovery = true else $ror_sp_recovery = false end if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行動側バトラーがアクターの場合 if @active_battler.is_a?(Game_Actor) case ROR_SP_RECOVERY[0] when 0 $ror_sp_recovery = true when 1 $ror_sp_recovery = true when 3 actor_class = @active_battler.class_id if ROR_SP_ELEMENTS.class == String element_id = $data_system.elements.index(ROR_SP_RECOVERY[3]) else element_id = ROR_SP_RECOVERY[3] end if $data_classes[actor_class].element_ranks[element_id] == 1 $ror_sp_recovery = true end else $ror_sp_recovery = false end if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 対象側バトラーの配列を設定 @target_battlers = [target] # 通常攻撃の効果を適用 for target in @target_battlers target.attack_effect(@active_battler) end return end # 防御の場合 if @active_battler.current_action.basic == 1 # ヘルプウィンドウに "防御" を表示 @help_window.set_text($data_system.words.guard, 1) return end # 逃げるの場合 if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # ヘルプウィンドウに "逃げる" を表示 @help_window.set_text("逃げる", 1) # 逃げる @active_battler.escape return end # 何もしないの場合 if @active_battler.current_action.basic == 3 # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end end #***************************************************************************** class Game_Battler def attack_effect(attacker) # クリティカルフラグをクリア self.critical = false # 第一命中判定 hit_result = (rand(100) < attacker.hit) # 命中の場合 if hit_result == true # 基本ダメージを計算 atk = [attacker.atk - self.pdef / 2, 0].max self.damage = atk * (20 + attacker.str) / 20 # 属性修正 self.damage *= elements_correct(attacker.element_set) self.damage /= 100 # ダメージの符号が正の場合 if self.damage > 0 # クリティカル修正 if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end # 防御修正 if self.guarding? self.damage /= 2 end end # 分散 if self.damage.abs > 0 amp = [self.damage.abs * 15 / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end # 第二命中判定 eva = 8 * self.agi / attacker.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) end # 命中の場合 if hit_result == true # ステート衝撃解除 remove_states_shock # HP からダメージを減算 self.hp -= self.damage if $ror_sp_recovery case ROR_SP_RECOVERY[1] when 0 attacker.sp += ROR_SP_RECOVERY[2].truncate when 1 sp_damage = self.damage * ROR_SP_RECOVERY[2] attacker.sp += sp_damage.truncate end $ror_sp_recovery = false end # ステート変化 @state_changed = false states_plus(attacker.plus_state_set) states_minus(attacker.minus_state_set) # ミスの場合 else # ダメージに "Miss" を設定 self.damage = "Miss" # クリティカルフラグをクリア self.critical = false end # メソッド終了 return true end end #*****************************************************************************