 |
|
 |

Back
Low Health Beep Sound
This guide will show you how to add the beeping sound that typical pokemon games play when one of your pokemon has low health. This feature was probably left out of Pokemon Essentials on purpose because the sound probably was annoying to a vast majority of people.
Please Note: While I did my best with coding this, I'm not the best coder there is and this was my first "entire mechanism" so to speak that I ever coded without another user's help. There may be minor glitches and/or excess pieces of code.
I recently fixed two major bugs in this modification (see bottom for details on bugs). If you installed this modification on or before MARCH-03-2009, please re-install the ENTIRE THING, as some code was removed and some code was added.
Okay to start, download one of the following sound files, rename it to "lowhp.wav", and import it into the "SE" folder.
Lowhp - Quiet Version or Lowhp - Loud Version
Now for the code. Some of it may seem like a lot but everything only has minor edits except for the main code. Added or edited parts are in bold.
in script PokeBattle_ActualScene, find:
def pbEndBattle(result) @abortable=false pbShowWindow(BLANK) # Fade out all sprites $game_system.bgm_fade(1.0) pbFadeOutAndHide(@sprites) @spriteskin.dispose pbDisposeSprites end |
and replace with:
def pbEndBattle(result) @battle.pblowhpstop @abortable=false pbShowWindow(BLANK) # Fade out all sprites $game_system.bgm_fade(1.0) pbFadeOutAndHide(@sprites) @spriteskin.dispose pbDisposeSprites end |
also in PokeBattle_ActualScene, find:
|
def pbWildBattleSuccess # This method is called when the player wins a wild Pokemon battle. # This method can change the battle's music for example. $game_system.bgm_play(pbGetWildVictoryME())
end
def pbTrainerBattleSuccess # This method is called when the player wins a Trainer battle. # This method can change the battle's music for example. if @battle.opponent.is_a?(Array) opp=@battle.opponent[0] else opp=@battle.opponent end $game_system.bgm_play(pbGetTrainerVictoryME(opp)) end |
and replace with:
|
def pbWildBattleSuccess @battle.pblowhpstop # This method is called when the player wins a wild Pokemon battle. # This method can change the battle's music for example. $game_system.bgm_play(pbGetWildVictoryME())
end
def pbTrainerBattleSuccess # This method is called when the player wins a Trainer battle. # This method can change the battle's music for example. @battle.pblowhpstop
if @battle.opponent.is_a?(Array) opp=@battle.opponent[0] else opp=@battle.opponent end $game_system.bgm_play(pbGetTrainerVictoryME(opp)) end |
again in PokeBattle_ActualScene, find:
def pbFainted(pkmn) # This method is called whenever a Pokemon faints pkmnsnd=sprintf("Audio/SE/%03dCry",pkmn.species) Audio.se_play(pkmnsnd,90,75) rescue nil 30.times do pbGraphicsUpdate pbInputUpdate end pkmnsprite=@sprites["pokemon#{pkmn.index}"] pkmnsprite.visible=false if @battle.pbIsOpposing?(pkmn.index) tempvp=Viewport.new(0,0,480,144+@yoffset) else tempvp=Viewport.new(0,0,480,224+@yoffset) end |
and replace with:
def pbFainted(pkmn) # This method is called whenever a Pokemon faints pkmnsnd=sprintf("Audio/SE/%03dCry",pkmn.species) Audio.se_play(pkmnsnd,90,75) rescue nil 30.times do pbGraphicsUpdate pbInputUpdate end pkmnsprite=@sprites["pokemon#{pkmn.index}"] pkmnsprite.visible=false if @battle.pbIsOpposing?(pkmn.index) tempvp=Viewport.new(0,0,480,144+@yoffset) else tempvp=Viewport.new(0,0,480,224+@yoffset) @battle.pblowhpstop end |
in PokeBattle_Battle, find:
when 2 #lose if @internalbattle pbDisplayPaused(_INTL("{1} is out of usable Pokemon!",self.pbPlayer.name)) moneylost=pbMaxLevel(@party1) multiplier=[8,16,24,32,48,64,80,100,120] moneylost*=multiplier[[8,self.pbPlayer.numbadges].min] moneylost=self.pbPlayer.money if moneylost>self.pbPlayer.money self.pbPlayer.money-=moneylost if @opponent if @opponent.is_a?(Array) pbDisplayPaused(_INTL("Player lost against {1} and {2}!",@opponent[0].fullname,@opponent[1].fullname)) else pbDisplayPaused(_INTL("Player lost against\r\n{1}!",@opponent.fullname)) end if moneylost>0 pbDisplayPaused(_INTL("{1} paid ${2}\r\nas the prize money...",self.pbPlayer.name,moneylost)) pbDisplayPaused(_INTL("...")) end else if moneylost>0 pbDisplayPaused(_INTL("{1} panicked and lost\r\n${2}...",self.pbPlayer.name,moneylost)) pbDisplayPaused(_INTL("...")) end end pbDisplayPaused(_INTL("{1} whited out!",self.pbPlayer.name)) else @scene.pbShowOpponent(0) pbDisplayPaused(@endspeechwin.gsub(/\\[Pp][Nn]/,self.pbPlayer.name)) if @opponent.is_a?(Array) @scene.pbHideOpponent @scene.pbShowOpponent(1) pbDisplayPaused(@endspeechwin2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name)) end end end @scene.pbEndBattle(@decision) return @decision end |
and replace with:
when 2 #lose if @internalbattle @battle.pblowhpstop pbDisplayPaused(_INTL("{1} is out of usable Pokemon!",self.pbPlayer.name)) moneylost=pbMaxLevel(@party1) multiplier=[8,16,24,32,48,64,80,100,120] moneylost*=multiplier[[8,self.pbPlayer.numbadges].min] moneylost=self.pbPlayer.money if moneylost>self.pbPlayer.money self.pbPlayer.money-=moneylost if @opponent if @opponent.is_a?(Array) pbDisplayPaused(_INTL("Player lost against {1} and {2}!",@opponent[0].fullname,@opponent[1].fullname)) else pbDisplayPaused(_INTL("Player lost against\r\n{1}!",@opponent.fullname)) end if moneylost>0 pbDisplayPaused(_INTL("{1} paid ${2}\r\nas the prize money...",self.pbPlayer.name,moneylost)) pbDisplayPaused(_INTL("...")) end else if moneylost>0 pbDisplayPaused(_INTL("{1} panicked and lost\r\n${2}...",self.pbPlayer.name,moneylost)) pbDisplayPaused(_INTL("...")) end end pbDisplayPaused(_INTL("{1} whited out!",self.pbPlayer.name)) else @scene.pbShowOpponent(0) pbDisplayPaused(@endspeechwin.gsub(/\\[Pp][Nn]/,self.pbPlayer.name)) if @opponent.is_a?(Array) @scene.pbHideOpponent @scene.pbShowOpponent(1) pbDisplayPaused(@endspeechwin2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name)) end end end @scene.pbEndBattle(@decision) return @decision end |
now in PokeBattle_Battle, find the following. There are two examples, yes. Normally you'd see the one on the left, but if you installed my Enhanced Double Wild Battles modification then you will see the one on the right.
# Initialize players in double battles # if @doublebattle if @player.is_a?(Array) sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0)) raise _INTL("Player 1 has no unfainted Pokemon") if sendout1<0 sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0)) raise _INTL("Player 2 has no unfainted Pokemon") if sendout2<0 pbDisplayBrief(_INTL("{1} sent out {2}! Go! {3}!",@player[1].fullname,@party1[sendout2].name,@party1[sendout1].name)) self.pbPlayer.seen[@party1[sendout1].species]=true self.pbPlayer.seen[@party1[sendout2].species]=true else sendout1=pbFindNextUnfainted(@party1,0) sendout2=pbFindNextUnfainted(@party1,sendout1+1) if sendout1<0 || sendout2<0 raise _INTL("Player doesn't have two unfainted Pokemon") end pbDisplayBrief(_INTL("Go! {1} and {2}!",@party1[sendout1].name,@party1[sendout2].name)) end @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) @scene.pbSendOut(0,@party1[sendout1]) @scene.pbSendOut(2,@party1[sendout2]) else # # Initialize player in single battles # sendout=pbFindNextUnfainted(@party1,0) if sendout<0 raise _INTL("Player has no unfainted Pokemon") end playerpoke=@party1[sendout] pbDisplayBrief(_INTL("Go! {1}!",playerpoke.name)) @battlers[0].pbInitialize(playerpoke,sendout,false) @scene.pbSendOut(0,playerpoke) end |
# # Initialize players in double battles # if @doublebattle if @player.is_a?(Array) sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0)) raise _INTL("Player 1 has no unfainted Pokemon") if sendout1<0 sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0)) raise _INTL("Player 2 has no unfainted Pokemon") if sendout2<0 pbDisplayBrief(_INTL("{1} sent out {2}! Go! {3}!",@player[1].fullname,@party1[sendout2].name,@party1[sendout1].name)) self.pbPlayer.seen[@party1[sendout1].species]=true self.pbPlayer.seen[@party1[sendout2].species]=true else sendout1=pbFindNextUnfainted(@party1,0) sendout2=pbFindNextUnfainted(@party1,sendout1+1) if sendout1<0 || sendout2<0 pbDisplayBrief(_INTL("Go! {1}!",@party1[sendout1].name)) else pbDisplayBrief(_INTL("Go! {1} and {2}!",@party1[sendout1].name,@party1[sendout2].name)) end end if sendout1<0 || sendout2<0 @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @scene.pbSendOut(0,@party1[sendout1]) else @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) @scene.pbSendOut(0,@party1[sendout1]) @scene.pbSendOut(2,@party1[sendout2])
end else # # Initialize player in single battles # sendout=pbFindNextUnfainted(@party1,0) if sendout<0 raise _INTL("Player has no unfainted Pokemon") end playerpoke=@party1[sendout] pbDisplayBrief(_INTL("Go! {1}!",playerpoke.name)) @battlers[0].pbInitialize(playerpoke,sendout,false) @scene.pbSendOut(0,playerpoke)
end |
anyway replace it with what corresponds to what code you have:
|
# Initialize players in double battles # if @doublebattle if @player.is_a?(Array) sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0)) raise _INTL("Player 1 has no unfainted Pokemon") if sendout1<0 sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0)) raise _INTL("Player 2 has no unfainted Pokemon") if sendout2<0 pbDisplayBrief(_INTL("{1} sent out {2}! Go! {3}!",@player[1].fullname,@party1[sendout2].name,@party1[sendout1].name)) self.pbPlayer.seen[@party1[sendout1].species]=true self.pbPlayer.seen[@party1[sendout2].species]=true else sendout1=pbFindNextUnfainted(@party1,0) sendout2=pbFindNextUnfainted(@party1,sendout1+1) if sendout1<0 || sendout2<0 raise _INTL("Player doesn't have two unfainted Pokemon") end pbDisplayBrief(_INTL("Go! {1} and {2}!",@party1[sendout1].name,@party1[sendout2].name)) end @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) @scene.pbSendOut(0,@party1[sendout1]) @scene.pbSendOut(2,@party1[sendout2])
@canplaybeepsound = true pblowhploop else # # Initialize player in single battles # sendout=pbFindNextUnfainted(@party1,0) if sendout<0 raise _INTL("Player has no unfainted Pokemon") end playerpoke=@party1[sendout] pbDisplayBrief(_INTL("Go! {1}!",playerpoke.name)) @battlers[0].pbInitialize(playerpoke,sendout,false) @scene.pbSendOut(0,playerpoke)
@canplaybeepsound = true pblowhploop end |
# # Initialize players in double battles # if @doublebattle if @player.is_a?(Array) sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0)) raise _INTL("Player 1 has no unfainted Pokemon") if sendout1<0 sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0)) raise _INTL("Player 2 has no unfainted Pokemon") if sendout2<0 pbDisplayBrief(_INTL("{1} sent out {2}! Go! {3}!",@player[1].fullname,@party1[sendout2].name,@party1[sendout1].name)) self.pbPlayer.seen[@party1[sendout1].species]=true self.pbPlayer.seen[@party1[sendout2].species]=true else sendout1=pbFindNextUnfainted(@party1,0) sendout2=pbFindNextUnfainted(@party1,sendout1+1) if sendout1<0 || sendout2<0 pbDisplayBrief(_INTL("Go! {1}!",@party1[sendout1].name)) else pbDisplayBrief(_INTL("Go! {1} and {2}!",@party1[sendout1].name,@party1[sendout2].name)) end end if sendout1<0 || sendout2<0 @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @scene.pbSendOut(0,@party1[sendout1])
@canplaybeepsound = true pblowhploop else @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) @scene.pbSendOut(0,@party1[sendout1]) @scene.pbSendOut(2,@party1[sendout2]) @canplaybeepsound = true pblowhploop
end else # # Initialize player in single battles # sendout=pbFindNextUnfainted(@party1,0) if sendout<0 raise _INTL("Player has no unfainted Pokemon") end playerpoke=@party1[sendout] pbDisplayBrief(_INTL("Go! {1}!",playerpoke.name)) @battlers[0].pbInitialize(playerpoke,sendout,false) @scene.pbSendOut(0,playerpoke) @canplaybeepsound = true pblowhploop
end
|
now again in PokeBattle_Battle, find
def pbReplace(index,newpoke,batonpass=false) party=pbParty(index) if pbOwnedByPlayer?(index) pbDisplayBrief(_INTL("Go! {1}!",party[newpoke].name)) @battlers[index].pbInitialize(party[newpoke],newpoke,batonpass); @scene.pbSendOut(index,party[newpoke]) |
and replace with:
def pbReplace(index,newpoke,batonpass=false) party=pbParty(index) if pbOwnedByPlayer?(index) pbDisplayBrief(_INTL("Go! {1}!",party[newpoke].name)) @battlers[index].pbInitialize(party[newpoke],newpoke,batonpass); @scene.pbSendOut(index,party[newpoke]) @canplaybeepsound = true |
Now for the main code. At the very bottom of PokeBattle_Battle, put:
|
def pblowhploop th2 = Thread.new do loop do pblowhp sleep(0.15) end end end
def pblowhp loop do if @canplaybeepsound == true if @doublebattle if @battlers[0].hp<=(@battlers[0].totalhp/4).floor and @battlers[0].hp>0 Audio.se_play("Audio/SE/lowhp.wav") sleep(0.15) elsif @battlers[2].hp<=(@battlers[2].totalhp/4).floor and @battlers[2].hp>0 Audio.se_play("Audio/SE/lowhp.wav") sleep(0.15) else break sleep(0.15) end else if @battlers[0].hp<=(@battlers[0].totalhp/4).floor and @battlers[0].hp>0 Audio.se_play("Audio/SE/lowhp.wav") sleep(0.15) else break sleep(0.15) end sleep(0.15) end sleep(0.15) end sleep(0.15) end end
def pblowhpstop @canplaybeepsound = false end
|
And that's it, you're done. :)
Known glitches/problems with this modification:
There isn't always the exact same amount of time in between each beep. The difference is minor, though. This bug is NOT fixed, but it is minor.
When an attack hits that sends the pokemon's hp into the red, the beep will start playing BEFORE the hp bar is done animating (i.e. before it reaches the red). This might annoy suspense-lovers who want to watch the hp bar animate to find out if their pokemon faints or not - because the beeping sound will tell them the answer. This bug is NOT fixed, but it is minor.
If I get into a battle and my pokemon has low hp when the battle ends, then I either heal or switch the hurt pokemon outside of battle, if I get into a battle after that, the beep sound will be heard even though my current pokemon does not have low hp. This bug was fixed on MARCH-03-2009.
Sometimes multiple instances of the beep play at the same time. This bug was fixed on MARCH-03-2009.
A pokemon with low hp might not play the beep sound if it's the last pokemon in a double battle. This bug was fixed on MARCH-11-2009. To fix this bug, just remove the code that is both bold and striked with a line through it. |
|
 |