Advanced: Global Scripts
Section 4.C.5
MidbattleHandlers.add(:midbattle_global, :low_hp_music,
proc { |battle, idxBattler, idxTarget, trigger|
next if !Settings::PLAY_LOW_HP_MUSIC
battler = battle.battlers[idxBattler]
next if !battler || !battler.pbOwnedByPlayer?
track = pbGetBattleLowHealthBGM
next if !track.is_a?(RPG::AudioFile)
playingBGM = battle.playing_bgm
case trigger
#---------------------------------------------------------------------------
# Restores original BGM when HP is restored to healthy.
when "BattlerHPRecovered_player"
next if playingBGM != track.name
next if battle.pbAnyBattlerLowHP?(idxBattler)
battle.pbResumeBattleBGM
PBDebug.log("[Midbattle Global] low HP music ended.")
#---------------------------------------------------------------------------
# Restores original BGM when battler is fainted.
when "BattlerHPReduced_player"
next if playingBGM != track.name
next if battle.pbAnyBattlerLowHP?(idxBattler)
next if !battler.fainted?
battle.pbResumeBattleBGM
PBDebug.log("[Midbattle Global] low HP music ended.")
#---------------------------------------------------------------------------
# Plays low HP music when HP is critical.
when "BattlerHPCritical_player"
next if playingBGM == track.name
battle.pbPauseAndPlayBGM(track)
PBDebug.log("[Midbattle Global] low HP music begins.")
#---------------------------------------------------------------------------
# Restores original BGM when sending out a healthy Pokemon.
# Plays low HP music when sending out a Pokemon with critical HP.
when "AfterSendOut_player"
if battle.pbAnyBattlerLowHP?(idxBattler)
next if playingBGM == track.name
battle.pbPauseAndPlayBGM(track)
PBDebug.log("[Midbattle Global] low HP music begins.")
elsif playingBGM == track.name
battle.pbResumeBattleBGM
PBDebug.log("[Midbattle Global] low HP music ended.")
end
end
}
)Last updated