• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Adding in Sound Effects

42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
def pbEnemyUseItem(item,battler)
return 0 if !@internalbattle
items=pbGetOwnerItems(battler.index)
return if !items
opponent=pbGetOwner(battler.index)
for i in 0...items.length
if items==item
items.delete_at(i)
break
end
end
itemname=PBItems.getName(item)
pbDisplayBrief(_INTL("{1} used the\r\n{2}!",opponent.fullname,itemname))
PBDebug.log("[Opponent used #{itemname}]")
PBSEplay("potion_heal.ogg")
if isConst?(item,PBItems,:POTION)
battler.pbRecoverHP(20,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:SUPERPOTION)
battler.pbRecoverHP(50,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:HYPERPOTION)
battler.pbRecoverHP(200,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:MAXPOTION)
battler.pbRecoverHP(battler.totalhp-battler.hp,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:FULLRESTORE)
fullhp=(battler.hp==battler.totalhp)
battler.pbRecoverHP(battler.totalhp-battler.hp,true)
battler.status=0; battler.statusCount=0
battler.effects[PBEffects::Confusion]=0
if fullhp
pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
else
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
end
elsif isConst?(item,PBItems,:FULLHEAL)
battler.status=0; battler.statusCount=0
battler.effects[PBEffects::Confusion]=0
pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
elsif isConst?(item,PBItems,:XATTACK)
if battler.pbCanIncreaseStatStage?(PBStats::ATTACK)
battler.pbIncreaseStat(PBStats::ATTACK,1,true)
end
elsif isConst?(item,PBItems,:XDEFEND)
if battler.pbCanIncreaseStatStage?(PBStats::DEFENSE)
battler.pbIncreaseStat(PBStats::DEFENSE,1,true)
end
elsif isConst?(item,PBItems,:XSPEED)
if battler.pbCanIncreaseStatStage?(PBStats::SPEED)
battler.pbIncreaseStat(PBStats::SPEED,1,true)
end
elsif isConst?(item,PBItems,:XSPECIAL)
if battler.pbCanIncreaseStatStage?(PBStats::SPATK)
battler.pbIncreaseStat(PBStats::SPATK,1,true)
end
elsif isConst?(item,PBItems,:XSPDEF)
if battler.pbCanIncreaseStatStage?(PBStats::SPDEF)
battler.pbIncreaseStat(PBStats::SPDEF,1,true)
end
elsif isConst?(item,PBItems,:XACCURACY)
if battler.pbCanIncreaseStatStage?(PBStats::ACCURACY)
battler.pbIncreaseStat(PBStats::ACCURACY,1,true)
end
end
end


Where in here do I add "pbSEplay("track",100,100)" to get the potion noise to play?
 
296
Posts
9
Years
The poison noise can be added in the Animation Editor, by selecting the "Common: Poison" (or some like that) animation, and by adding a Sound Effect (SE). To select the exact frame, you must scroll the left/right arrow, in the bottom, and you have to click "Set Frame". I hope this can help you. :)
 
42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
Not poison, "potion". Lol. So it's in the script file, not the animation editor. Thanks tho
 
20
Posts
10
Years
  • Seen Jun 19, 2015
The line

PBSEplay("potion_heal.ogg")

seems to be the potion sound. Do you want to change it to some other sound?
 
42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
What I mean is, where the line is right now; the sound doesn't play. Lol
 
20
Posts
10
Years
  • Seen Jun 19, 2015
Looking in my SE folder, I can't actually seem to find a file called potion_heal.ogg. Maybe it was accidentally removed a while back. If that is the case for you too, just grab the potion healing sound from google or youtube and stick it in your SE folder. Then go back to this line

Code:
pbSEPlay("[COLOR=Red]potion_heal.ogg[/COLOR]")
and change the red part to whatever the name of your sound file is.
 
42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
I should have specified. A while back I ripped a ton of sounds from various sources that provide these sound effect files. So potion_heal was one among the many, specifically the sound I want. Where the line is, however, no sound effect plays in battle or out of battle. So I'm trying to figure out where it's supposed to go
 
20
Posts
10
Years
  • Seen Jun 19, 2015
Also, are you testing the item on yourself or waiting for an npc to use it? The section you showed us is only for enemy battlers.
 
42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
Ah-ha. That I did not know. Would you happen to know which line of code starts the player using a potion?
 
42
Posts
8
Years
  • Age 30
  • Seen Mar 1, 2021
Even if I try to get the sound to play from an enemy perspective, I get a NoMethodError saying pbSEplay is an undefined method in PokeBattle_Battle

EDIT:

I realize it is pbSEPlay with a capital Play. Now when I put that in I get my desired sound effect. Only problem is it plays after the healing animation. Which the order is supposed to be reversed

def pbEnemyUseItem(item,battler)
pbSEPlay("potion_heal")
return 0 if !@internalbattle
items=pbGetOwnerItems(battler.index)
return if !items
opponent=pbGetOwner(battler.index)
for i in 0...items.length
if items==item
items.delete_at(i)
break
end
end
itemname=PBItems.getName(item)
pbDisplayBrief(_INTL("{1} used the\r\n{2}!",opponent.fullname,itemname))
PBDebug.log("[Opponent used #{itemname}]")
if isConst?(item,PBItems,:POTION)
battler.pbRecoverHP(20,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:SUPERPOTION)
battler.pbRecoverHP(50,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:HYPERPOTION)
battler.pbRecoverHP(200,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:MAXPOTION)
battler.pbRecoverHP(battler.totalhp-battler.hp,true)
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
elsif isConst?(item,PBItems,:FULLRESTORE)
fullhp=(battler.hp==battler.totalhp)
battler.pbRecoverHP(battler.totalhp-battler.hp,true)
battler.status=0; battler.statusCount=0
battler.effects[PBEffects::Confusion]=0
if fullhp
pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
else
pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
end
elsif isConst?(item,PBItems,:FULLHEAL)
battler.status=0; battler.statusCount=0
battler.effects[PBEffects::Confusion]=0
pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
elsif isConst?(item,PBItems,:XATTACK)
if battler.pbCanIncreaseStatStage?(PBStats::ATTACK)
battler.pbIncreaseStat(PBStats::ATTACK,1,true)
end
elsif isConst?(item,PBItems,:XDEFEND)
if battler.pbCanIncreaseStatStage?(PBStats::DEFENSE)
battler.pbIncreaseStat(PBStats::DEFENSE,1,true)
end
elsif isConst?(item,PBItems,:XSPEED)
if battler.pbCanIncreaseStatStage?(PBStats::SPEED)
battler.pbIncreaseStat(PBStats::SPEED,1,true)
end
elsif isConst?(item,PBItems,:XSPECIAL)
if battler.pbCanIncreaseStatStage?(PBStats::SPATK)
battler.pbIncreaseStat(PBStats::SPATK,1,true)
end
elsif isConst?(item,PBItems,:XSPDEF)
if battler.pbCanIncreaseStatStage?(PBStats::SPDEF)
battler.pbIncreaseStat(PBStats::SPDEF,1,true)
end
elsif isConst?(item,PBItems,:XACCURACY)
if battler.pbCanIncreaseStatStage?(PBStats::ACCURACY)
battler.pbIncreaseStat(PBStats::ACCURACY,1,true)
end
end
end
 
Last edited:
Back
Top