sacred-ritual-academy/Scripts/_RGSS3_Ver1_00_by_.rb
2025-03-18 19:45:34 -05:00

130 lines
No EOL
4.8 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ RGSS3 先制/不意打ちイベントバトル Ver1.00 by 星潟
#------------------------------------------------------------------------------
# イベント戦闘での先制攻撃/不意打ちを可能にします。
# 指定した変数1の値に対応する効果は以下の通りです。
#------------------------------------------------------------------------------
# ★0の場合
#
# 本来の処理(先制/不意打ち禁止)を行います。
#------------------------------------------------------------------------------
# ★1の場合
#
# 通常エンカウントと同様の形で先制/不意打ちの確率計算を行います。
#指定した変数2の値は結果に影響を与えません
#------------------------------------------------------------------------------
# ★2の場合
#
# 先制のみ計算。
#指定した変数2の値が1以上の時は、その値が先制率となる
#------------------------------------------------------------------------------
# ★3の場合
#
# 不意打ちのみ計算。
#指定した変数2の値が1以上の時は、その値が不意打ち率となる
#==============================================================================
module ON_ENCOUNT_EXECUTE
#イベント戦闘時の先制/不意打ちを行うかどうかを判定する変数IDを指定。
VARIABLES1 = 145
#イベント戦闘時の先制/不意打ち率を指定する変数IDを指定。
VARIABLES2 = 146
#戦闘後、自動的に上記変数の値を0にするかを指定。
#trueで0に戻し、falseでそのままとする。
AUTO_ERASE = true
end
class Game_Temp
attr_accessor :interpreter_battle_flag
end
class Game_Interpreter
#--------------------------------------------------------------------------
# バトルの処理
#--------------------------------------------------------------------------
alias command_301_on_encount_execute command_301
def command_301
#イベントバトルフラグを有効にする。
$game_temp.interpreter_battle_flag = true
#本来の処理を実行。
command_301_on_encount_execute
#自動的に変数の値を消去する設定の場合は、その処理を行う。
if ON_ENCOUNT_EXECUTE::AUTO_ERASE
$game_variables[ON_ENCOUNT_EXECUTE::VARIABLES1] = 0
$game_variables[ON_ENCOUNT_EXECUTE::VARIABLES2] = 0
end
#イベントバトルフラグを無効にする。
$game_temp.interpreter_battle_flag = nil
end
end
class << BattleManager
#--------------------------------------------------------------------------
# セットアップ
#--------------------------------------------------------------------------
alias setup_on_encount_execute setup
def setup(troop_id, can_escape = true, can_lose = false)
#本来の処理を実行。
setup_on_encount_execute(troop_id, can_escape, can_lose)
#イベントバトルでなければ処理しない。
return unless $game_temp.interpreter_battle_flag
#変数の値で分岐。
case $game_variables[ON_ENCOUNT_EXECUTE::VARIABLES1]
#1の場合は通常のエンカウントと同じにする。
when 1;on_encounter
#2の場合は先制攻撃のみ有効とする。
when 2;preemptive_rate_only_making
#3の場合は不意打ちのみ有効とする。
when 3;surprise_rate_only_making
end
end
#--------------------------------------------------------------------------
# 先制のみ有効とする場合の処理
#--------------------------------------------------------------------------
def preemptive_rate_only_making
#変数にデータが設定されている場合はその変数のデータで処理し
#そうでない場合はデフォルトの処理を行う。
if $game_variables[ON_ENCOUNT_EXECUTE::VARIABLES2] == 0;@preemptive = (rand < rate_preemptive)
else;@preemptive = (rand(100) < $game_variables[ON_ENCOUNT_EXECUTE::VARIABLES2])
end
end
#--------------------------------------------------------------------------
# 不意打ちのみ有効とする場合の処理
#--------------------------------------------------------------------------
def surprise_rate_only_making
#変数にデータが設定されている場合はその変数のデータで処理し
#そうでない場合はデフォルトの処理を行う。
if $game_variables[ON_ENCOUNT_EXECUTE::VARIABLES2] == 0;@surprise = (rand < rate_surprise)
else;@surprise = (rand(100) < $game_variables[ON_ENCOUNT_EXECUTE::VARIABLES2])
end
end
end