def pbActivateBerryEffect(berry=0,consume=true)
berry=self.item if berry==0
berryname=(berry==0) ? "" : PBItems.getName(berry)
PBDebug.log("[Item triggered] #{pbThis}'s #{berryname}")
consumed=false
if isConst?(berry,PBItems,:ORANBERRY)
if hasWorkingAbility(:RIPEN)
amt=self.pbRecoverHP(20,true)
else
amt=self.pbRecoverHP(10,true)
end
if amt>0
@battle.pbDisplay(_INTL("{1} restored its health using its {2}!",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:SITRUSBERRY) ||
isConst?(berry,PBItems,:ENIGMABERRY)
if hasWorkingAbility(:RIPEN)
amt=self.pbRecoverHP((self.totalhp/2).floor,true)
else
amt=self.pbRecoverHP((self.totalhp/4).floor,true)
end
if amt>0
@battle.pbDisplay(_INTL("{1} restored its health using its {2}!",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:CHESTOBERRY)
if self.status==PBStatuses::SLEEP
pbCureStatus(false)
@battle.pbDisplay(_INTL("{1}'s {2} cured its sleep problem.",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:PECHABERRY)
if self.status==PBStatuses::POISON
pbCureStatus(false)
@battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning.",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:RAWSTBERRY)
if self.status==PBStatuses::BURN
pbCureStatus(false)
@battle.pbDisplay(_INTL("{1}'s {2} healed its burn.",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:CHERIBERRY)
if self.status==PBStatuses::PARALYSIS
pbCureStatus(false)
@battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis.",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:ASPEARBERRY)
if self.status==PBStatuses::FROZEN
pbCureStatus(false)
@battle.pbDisplay(_INTL("{1}'s {2} thawed it out.",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:LEPPABERRY)
found=[]
for i in [email protected]
if @pokemon.moves[i].id!=0
if (consume && @pokemon.moves[i].pp==0) ||
(!consume && @pokemon.moves[i].pp<@pokemon.moves[i].totalpp)
found.push(i)
end
end
end
if found.length>0
choice=(consume) ? found[0] : found[@battle.pbRandom(found.length)]
[email protected][choice]
if hasWorkingAbility(:RIPEN)
pokemove.pp+=20
else
pokemove.pp+=10
end
pokemove.pp=pokemove.totalpp if pokemove.pp>pokemove.totalpp
self.moves[choice].pp=pokemove.pp
movename=PBMoves.getName(pokemove.id)
@battle.pbDisplay(_INTL("{1}'s {2} restored {3}'s PP!",pbThis,berryname,movename))
consumed=true
end
elsif isConst?(berry,PBItems,:PERSIMBERRY)
if @effects[PBEffects::Confusion]>0
pbCureConfusion(false)
@battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:LUMBERRY)
if self.status>0 || @effects[PBEffects::Confusion]>0
st=self.status; conf=(@effects[PBEffects::Confusion]>0)
pbCureStatus(false)
pbCureConfusion(false)
case st
when PBStatuses::SLEEP
@battle.pbDisplay(_INTL("{1}'s {2} woke it up!",pbThis,berryname))
when PBStatuses::POISON
@battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!",pbThis,berryname))
when PBStatuses::BURN
@battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",pbThis,berryname))
when PBStatuses::PARALYSIS
@battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",pbThis,berryname))
when PBStatuses::FROZEN
@battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",pbThis,berryname))
end
if conf
@battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!",pbThis,berryname))
end
consumed=true
end
elsif isConst?(berry,PBItems,:FIGYBERRY)
consumed=pbConfusionBerry(0,
_INTL("{1}'s {2} restored health!",pbThis,berryname),
_INTL("For {1}, the {2} was too spicy!",pbThis(true),berryname))
elsif isConst?(berry,PBItems,:WIKIBERRY)
consumed=pbConfusionBerry(3,
_INTL("{1}'s {2} restored health!",pbThis,berryname),
_INTL("For {1}, the {2} was too dry!",pbThis(true),berryname))
elsif isConst?(berry,PBItems,:MAGOBERRY)
consumed=pbConfusionBerry(2,
_INTL("{1}'s {2} restored health!",pbThis,berryname),
_INTL("For {1}, the {2} was too sweet!",pbThis(true),berryname))
elsif isConst?(berry,PBItems,:AGUAVBERRY)
consumed=pbConfusionBerry(4,
_INTL("{1}'s {2} restored health!",pbThis,berryname),
_INTL("For {1}, the {2} was too bitter!",pbThis(true),berryname))
elsif isConst?(berry,PBItems,:IAPAPABERRY)
consumed=pbConfusionBerry(1,
_INTL("{1}'s {2} restored health!",pbThis,berryname),
_INTL("For {1}, the {2} was too sour!",pbThis(true),berryname))
elsif isConst?(berry,PBItems,:LIECHIBERRY)
consumed=pbStatIncreasingBerry(PBStats::ATTACK,berryname)
elsif isConst?(berry,PBItems,:GANLONBERRY) ||
isConst?(berry,PBItems,:KEEBERRY)
consumed=pbStatIncreasingBerry(PBStats::DEFENSE,berryname)
elsif isConst?(berry,PBItems,:SALACBERRY)
consumed=pbStatIncreasingBerry(PBStats::SPEED,berryname)
elsif isConst?(berry,PBItems,:PETAYABERRY)
consumed=pbStatIncreasingBerry(PBStats::SPATK,berryname)
elsif isConst?(berry,PBItems,:APICOTBERRY) ||
isConst?(berry,PBItems,:MARANGABERRY)
consumed=pbStatIncreasingBerry(PBStats::SPDEF,berryname)
elsif isConst?(berry,PBItems,:LANSATBERRY)
if @effects[PBEffects::FocusEnergy]<2
@effects[PBEffects::FocusEnergy]=2
@battle.pbDisplay(_INTL("{1} used its {2} to get pumped!",pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:MICLEBERRY)
if !@effects[PBEffects::MicleBerry]
@effects[PBEffects::MicleBerry]=true
@battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move using its {2}!",
pbThis,berryname))
consumed=true
end
elsif isConst?(berry,PBItems,:STARFBERRY)
stats=[]
for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPATK,PBStats::SPDEF,PBStats::SPEED]
stats.push(i) if pbCanIncreaseStatStage?(i,self)
end
if stats.length>0
stat=stats[@battle.pbRandom(stats.length)]
if hasWorkingAbility(:RIPEN)
consumed=pbIncreaseStatWithCause(stat,4,self,berryname)
else
consumed=pbIncreaseStatWithCause(stat,2,self,berryname)
end
end
end
#
if consumed
# Cheek Pouch
if hasWorkingAbility(:CHEEKPOUCH)
amt=self.pbRecoverHP((@totalhp/3).floor,true)
if amt>0
@battle.pbDisplay(_INTL("{1}'s {2} restored its health!",
pbThis,PBAbilities.getName(ability)))
end
end
pbConsumeItem if consume
self.pokemon.belch=true if self.pokemon
end
end