#===============================================================================
#
# Spirit - By #Not Important
#
# V 1.3.0 #NOTES: V 1.2.0 WAS NOT RELEASED
# -------
# Fixes:
# -------
# -------
# Additions:
# -------
# V 1.2.0
# Amulet shards; boost if held
# -------
# V 1.3.0
# Spirit Pokemon
# Go To pbSpiritEffects to learn how!
# __________
#===============================================================================
#===============================================================================
# ~Installation~
#===============================================================================
# 1) To install, insert a new section below any other battle edits, and paste
# this script there.
#
# 2) Next, you must add the following to your items PBS file:
# XXX,AMULET,Amulet,,1,99999,"An amulet that holds the power to allow a pokémon to tap into its spirit power",0,0,15,
# XXX,ASHARD,Amulet Shard,1,10000,"A shard of an Amulet, if a Pokémon is holding it/, it gets a power boost"
#
# ^MAKE SURE TO ADJUST THE ITEM NUMBER TO MATCH YOUR GAME
#
# Everything below is written for Pokémon Essentials v.17.2
#===============================================================================
# V SETTINGS V
module Spirit_Config
ZPOWER = false #Compatiability for Ludicrous89's Zodiac powers script
ZMOVES = false #Compatiability for the Z-move addon
HELDITEM = false #Allow spirit power if the pokemon holds the amulet,
#if not just if the player has an amulet
end
module PBSpiritEffectsCustom
#This Takes care of custom powers
CustomPowers=[
[:JIRACHI,
8,
"Sleep",
"Damage",
"RaiseAttack",
"RaiseAttack",
"RaiseAttack",
"OppLowerAttack",
"OppLowerAttack",
"OppLowerAttack"],
[:VENUSAUR,
3,
"Leech",
"Damage",
"Sleep"]
]
end
#===============================================================================
# The following script has some parts fully extracted from the Zodiac Powers
# Script and Amethystrain's Z-move addon
#===============================================================================
# Defines when a Pokemon has access to a Spirit Power in battle.
#===============================================================================
module PBEffects
Distort = 200
IcyRend = 201
end
def pbCombineShards
if $PokemonBag.pbQuantity(:ASHARD)==6
if Kernel.pbConfirmMessage("The Amulet Shards are buzzing! Combine them?")
Kernel.pbMessage("They formed into an Amulet!")
6.times do
PokemonMartAdapter.removeItem(:ASHARD)
end
PokemonMartAdapter.addItem(:AMULET)
end
end
end
class PokeBattle_Pokemon
#--------
#Amulet
def spiritAvailable?
if Spirit_Config::HELDITEM
return true if isConst?(self.item,PBItems,:AMULET)
else
next if !hasConst?(PBItems,:ASHARD)
return true if $PokemonBag.pbHasItem?(:ASHARD)
end
end
#--------
def hasBoost?
return true if isConst?(self.item,PBItems,:ASHARD)
end
end
class PokeBattle_Battler
#-------
#Amulet
def canSpirit?
if @pokemon
return (@pokemon.spiritAvailable? rescue false)
end
end
#-------
def canBoost?
if @pokemon
return (@pokemon.hasBoost? rescue false)
end
end
end
#===============================================================================
# Rewrites the PokeBattle_Battle script.
#===============================================================================
class PokeBattle_Battle
attr_reader(:player) # Player trainer
attr_reader(:opponent) # Opponent trainer
attr_accessor(:zodiacPower) if Spirit_Config::ZPOWER
attr_accessor(:spiritPower) #Spirit power
def initialize(scene,p1,p2,player,opponent)
if p1.length==0
raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
return
end
if p2.length==0
raise ArgumentError.new(_INTL("Party 2 has no Pokémon."))
return
end
if p2.length>2 && !opponent
raise ArgumentError.new(_INTL("Wild battles with more than two Pokémon are not allowed."))
return
end
@scene = scene
@decision = 0
@internalbattle = true
@doublebattle = false
@cantescape = false
@shiftStyle = true
@battlescene = true
@debug = false
@debugupdate = 0
if opponent && player.is_a?(Array) && player.length==0
player = player[0]
end
if opponent && opponent.is_a?(Array) && opponent.length==0
opponent = opponent[0]
end
@player = player # PokeBattle_Trainer object
@opponent = opponent # PokeBattle_Trainer object
@party1 = p1
@party2 = p2
@party1order = []
for i in 0...12; @party1order.push(i); end
@party2order = []
for i in 0...12; @party2order.push(i); end
@fullparty1 = false
@fullparty2 = false
@battlers = []
@items = nil
@sides = [PokeBattle_ActiveSide.new, # Player's side
PokeBattle_ActiveSide.new] # Foe's side
@field = PokeBattle_ActiveField.new # Whole field (gravity/rooms)
@environment = PBEnvironment::None # e.g. Tall grass, cave, still water
@weather = 0
@weatherduration = 0
@switching = false
@futuresight = false
@choices = [ [0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1] ]
@successStates = []
for i in 0...4
@successStates.push(PokeBattle_SuccessState.new)
end
@lastMoveUsed = -1
@lastMoveUser = -1
@nextPickupUse = 0
@megaEvolution = []
if @player.is_a?(Array)
@megaEvolution[0]=[-1]*@player.length
else
@megaEvolution[0]=[-1]
end
if @opponent.is_a?(Array)
@megaEvolution[1]=[-1]*@opponent.length
else
@megaEvolution[1]=[-1]
end
#===========================================================================
# Zodiac Powers
if Spirit_Config::ZPOWER
@zodiacPower = []
if @player.is_a?(Array)
@zodiacPower[0]=[-1]*@player.length
else
@zodiacPower[0]=[-1]
end
if @opponent.is_a?(Array)
@zodiacPower[1]=[-1]*@opponent.length
else
@zodiacPower[1]=[-1]
end
end
#===========================================================================
# Z-Moves
if Spirit_Config::ZMOVES
@zMove = []
if @player.is_a?(Array)
@zMove[0]=[-1]*@player.length
else
@zMove[0]=[-1]
end
if @opponent.is_a?(Array)
@zMove[1]=[-1]*@opponent.length
else
@zMove[1]=[-1]
end
end
#===========================================================================
# Spirit Power
@spiritPower = []
if @player.is_a?(Array)
@spiritPower[0]=[-1]*@player.length
else
@spiritPower[0]=[-1]
end
if @opponent.is_a?(Array)
@spiritPower[1]=[-1]*@opponent.length
else
@spiritPower[1]=[-1]
end
#===========================================================================
@amuletcoin = false
@extramoney = 0
@doublemoney = false
@endspeech = ""
@endspeech2 = ""
@endspeechwin = ""
@endspeechwin2 = ""
@rules = {}
@turncount = 0
@peer = PokeBattle_BattlePeer.create()
@priority = []
@usepriority = false
@snaggedpokemon = []
@runCommand = 0
if hasConst?(PBMoves,:STRUGGLE)
@struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE)))
else
@struggle = PokeBattle_Struggle.new(self,nil)
end
@struggle.pp = -1
for i in 0...4
battlers[i] = PokeBattle_Battler.new(self,i)
end
for i in @party1
next if !i
i.itemRecycle = 0
i.itemInitial = i.item
i.belch = false
end
for i in @party2
next if !i
i.itemRecycle = 0
i.itemInitial = i.item
i.belch = false
end
end
#===============================================================================
# Spirit Power Effects
#===============================================================================
#===============================================================================
def pbSpiritEffects(index)
user=@battlers[index]
ally=user.pbPartner
# User is player's left slot
if user==@battlers[0]
opp1=user.pbOpposing2
opp2=user.pbOpposing1
# User is player's right slot
elsif user==@battlers[2]
opp1=user.pbOpposing1
opp2=user.pbOpposing2
# User is opponent's right slot
elsif user==@battlers[1]
opp1=@battlers[2]
opp2=@battlers[0]
# User is opponent's left slot
elsif user==@battlers[3]
opp1=@battlers[0]
opp2=@battlers[2]
end
allyExists = (ally && !ally.isFainted?)
opp1Exists = (opp1 && !opp1.isFainted?)
opp2Exists = (opp2 && !opp2.isFainted?)
$tempCount = 0
$tempRedoAmt = 0
for i in PBSpiritEffectsCustom::CustomPowers
$tempCount+=1
if $tempCount==1
if isConst?(user.species,PBSpecies,i)
matched=true
end
elsif $tempCount==2 && matched
$tempRedoAmt=i
end
if matched && $tempCount>=2
done=true
$tempRedoAmt.times do
if i=="Damage" or i=="damage"
opp1.pbReduceHP((user.totalhp/5).round)
opp2.pbReduceHP((user.totalhp/5).round) if opp2Exists
elsif i=="Sleep" or i=="sleep"
opp1.pbSleep
opp2.pbSleep if opp2Exists
elsif i=="Paralyze" or i=="paralyze"
opp1.pbParalyse
opp2.pbParalyze if opp2Exists
elsif i=="Burn" or i=="burn"
opp1.pbBurn
opp2.pbBurn if opp2Exists
elsif i=="Poison" or i=="poison"
opp1.pbPoison
opp2.pbPoison if opp2Exists
elsif i=="Confuse" or i=="confuse"
opp1.pbConfuse
opp2.pbConfuse if opp2Exists
elsif i=="Freeze" or i=="freeze"
opp1.pbFreeze
opp1.pbFreeze if opp2Exists
elsif i=="RaiseAttack" or i=="raiseattack"
if user.pbCanIncreaseStatStage?(PBStats::ATTACK,user,true)
user.pbIncreaseStat(PBStats::ATTACK,1,user,false)
end
elsif i=="RaiseDefense" or i=="raisedefense"
if user.pbCanIncreaseStatStage?(PBStats::DEFENSE,user,true)
user.pbIncreaseStat(PBStats::DEFENSE,1,user,false)
end
elsif i=="RaiseSpeed" or i=="raisespeed"
if user.pbCanIncreaseStatStage?(PBStats::SPEED,user,true)
user.pbIncreaseStat(PBStats::SPEED,1,user,false)
end
elsif i=="Leech" or i=="leech"
opp1.effects[PBEffects::LeechSeed]=user.index
opp2.effects[PBEffects::LeechSeed]=user.index if opp2Exists
elsif i=="Sandstorm" or i=="sandstorm"
@battle.weather=PBWeather::SANDSTORM
elsif i=="HeavyRain" or i=="heavyrain"
@battle.weather=PBWeather::HEAVYRAIN
elsif i=="OppLowerAttack" or i=="opplowerattack"
if opp1.pbCanReduceStatStage?(PBStats::ATTACK,opp1,true)
opp1.pbRecduceStat(PBStats::ATTACK,1,opp1,false)
end
if opp2Exists
if opp2.pbCanReduceStatStage?(PBStats::ATTACK,opp2,true)
opp2.pbRecduceStat(PBStats::ATTACK,1,opp2,false)
end
end
elsif i=="OppLowerDefense" or i=="opplowerdefense"
if opp1.pbCanReduceStatStage?(PBStats::DEFENSE,opp1,true)
opp1.pbRecduceStat(PBStats::DEFENSE,1,opp1,false)
end
if opp2Exists
if opp2.pbCanReduceStatStage?(PBStats::DEFENSE,opp2,true)
opp2.pbRecduceStat(PBStats::DEFENSE,1,opp2,false)
end
end
elsif i=="OppLowerSpeed" or i=="opplowerspeed"
if opp1.pbCanReduceStatStage?(PBStats::SPEED,opp1,true)
opp1.pbRecduceStat(PBStats::SPEED,1,opp1,false)
end
if opp2Exists
if opp2.pbCanReduceStatStage?(PBStats::SPEED,opp2,true)
opp2.pbRecduceStat(PBStats::SPEED,1,opp2,false)
end
end
elsif i=="Disable" or i=="disable"
if opp2Exists
opp2.effects[PBEffects::Disable]=rand(3)
opp2.effects[PBEffects::DisableMove]=opp2.lastMoveUsed
end
opp1.effects[PBEffects::Disable]=rand(3)
opp1.effects[PBEffects::DisableMove]=opp2.lastMoveUsed
end
end
end
end
#===========================================================================
# Endless Slumber (POWER NAME)
#
# Gives the opponent-3defense+Goes to deep sleep and gives Jirachi +3 attack
# boost (POWER EFFECT)
if isConst?(user.species,PBSpecies,:JIRACHI)
usedPower=true
pbDisplay(_INTL("{1} used Endless Slumber!",user.pbThis)) #Replace Endless Slumber with your power
@battle.pbAnimation(516,user,opp1) #Replace 516 with whatever your move code is for animation
#------------------------------------------
# Here come the effects!
#------------------------------------------
#Sleep
opp1.status=PBStatuses::SLEEP
[email protected](5)
opp1.statusCount=(self.statusCount/2).floor if opp1.hasWorkingAbility(:EARLYBIRD)
opp1.pbCancelMoves
@battle.pbCommonAnimation("Sleep",opp1,nil)
@battle.pbDisplay(_INTL("{1} fell asleep!",opp1.pbThis))
if opp2Exists
opp2.status=PBStatuses::SLEEP
[email protected](5)
opp2.statusCount=(opp2.statusCount/2).floor if opp2.hasWorkingAbility(:EARLYBIRD)
opp2pbCancelMoves
@battle.pbCommonAnimation("Sleep",opp2,nil)
@battle.pbDisplay(_INTL("{1} fell asleep!",opp2.pbThis))
end
#------------------------------------------
if opp1.pbCanReduceStatStage?(PBStats::ATTACK,opp1,true)
opp1.pbReduceStat(PBStats::ATTACK,3,opp1,false)
end #Reduce stat
if opp2Exists
if opp2.pbCanReduceStatStage?(PBStats::ATTACK,opp2,true)
opp2.pbReduceStat(PBStats::ATTACK,3,opp2,false)
end
end
if user.pbCanIncreaseStatStage?(PBStats::ATTACK,user,true)
user.pbIncreaseStat(PBStats::ATTACK,3,user,false)
end #Increase Stat
end
if usedPower; break; end #THIS LINE IS NEEDED
#===========================================================================
# Booming thunder
#
# Halves opponent's hp + paralyse + disables sound moves
if user.type1==PBTypes::ELECTRIC
pbDisplay(_INTL("{1} used Booming thunder!",user.pbThis))
opp1.pbReduceHP((opp1.totalhp/2).floor)
opp1.pbParalyze
opp2.pbReduceHP((opp2.totalhp/2).floor) if opp2Exists
opp2.pbParalyze if opp2Exists
for i in opp1.moves
if i.isSoundBased?
opp1.effects[PBEffects::Disable]=rand(3)
opp1.effects[PBEffects::DisableMove]=i
end
end
if opp2Exists
for i in opp2.moves
if i.isSoundBased?
opp2.effects[PBEffects::Disable]=rand(3)
opp2.effects[PBEffects::DisableMove]=i
end
end
end
if allyExists
for i in ally.moves
if i.isSoundBased?
ally.effects[PBEffects::Disable]=rand(3)
ally.effects[PBEffects::DisableMove]=i
end
end
end
for i in user.moves
if i.isSoundBased?
user.effects[PBEffects::Disable]=rand(3)
user.effects[PBEffects::DisableMove]=i
end
end
#===========================================================================
# Sweeping flood
#
# Does EXACTLY 50 damage to opponent + removes the fire type and adds the
# Water type, if there is a status condition on the user, it is removed
elsif user.type1==PBTypes::WATER
pbDisplay(_INTL("{1} used Sweeping flood!",user.pbThis))
opp1.pbReduceHP(50)
opp2.pbReduceHP(50)
if opp1.type1 == PBTypes::FIRE
opp1.type1 = PBTypes::WATER
end
if opp1.type2 == PBTypes::FIRE
opp1.type2 = PBTypes::WATER
end
if opp2 != nil
if opp2.type1 == PBTypes::FIRE
opp2.type1 = PBTypes::WATER
end
if opp2.type2 == PBTypes::FIRE
opp2.type2 = PBTypes::WATER
end
end
userstatus=(user.status>0 || user.effects[PBEffects::Confusion]>0)
#===========================================================================
# Endless flame
#
# Burns Opponents, does 1/3rd of opponent(1)'s HP, does 40 damage to
# opponent 2, all grass types are KO'ed
elsif user.type1==PBTypes::FIRE
pbDisplay(_INTL("{1} used Endless flame!",user.pbThis))
if opp1Exists && ((opp1.type1 == PBTypes::GRASS) || (opp1.type2 == PBTypes::GRASS))
opp1.pbFaint
end
if opp2Exists && ((opp2.type1 == PBTypes::GRASS) || (opp2.type2 == PBTypes::GRASS))
opp2.pbFaint
end
opp1.pbBurn
opp2.pbBurn if opp2Exists
opp1.pbReduceHP((opp1.hp/3).floor)
opp2.pbReduceHP(40) if opp2Exists
#===========================================================================
# Overgrowing Vines
#
# Seeds all battlers apart from user, puts all opponents to sleep
elsif user.type1==PBTypes::GRASS
pbDisplay(_INTL("{1} used Overgrowing vines!",user.pbThis))
opp1.pbSleep
opp2.pbSleep if opp2 != nil
opp1.effects[PBEffects::LeechSeed]=user.index
opp2.effects[PBEffects::LeechSeed]=user.index if opp2 != nil
ally.effects[PBEffects::LeechSeed]=user.index if ally != nil
#===========================================================================
# Punishment
#
# Does damage equal to the users level to opponents
elsif user.type1==PBTypes::NORMAL
pbDisplay(_INTL("{1} used Punishment!",user.pbThis))
opp1.pbReduceHP(user.level)
opp2.pbReduceHP(user.level) if opp2Exists
#===========================================================================
# Poisoning Wave
#
# Poisons all opponents, does damage equal to the users defence to opponents
# All normal and ghost types have their hp halved
elsif user.type1==PBTypes::POISON
pbDisplay(_INTL("{1} used Poisoning wave!",user.pbThis))
opp1.pbPoison
opp2.pbPoison if opp2 != nil
opp1.pbReduceHP((opp1.hp/2).floor) if (opp1.type1 == (PBTypes::NORMAL || PBTypes::GHOST))
opp1.pbReduceHP((opp1.hp/2).floor) if (opp1.type2 == (PBTypes::NORMAL || PBTypes::GHOST))
if opp2 != nil
opp2.pbReduceHP((opp2.hp/2).floor) if (opp2.type1 == (PBTypes::NORMAL || PBTypes::GHOST))
opp2.pbReduceHP((opp2.hp/2).floor) if (opp2.type2 == (PBTypes::NORMAL || PBTypes::GHOST))
end
opp1.pbReduceHP((opp1.defence).floor)
opp2.pbReduceHP((opp2.defence).floor) if opp2 != nil
#===========================================================================
# Nightfall
#
# Dark types are healed by 1/3 of health, other battlers are all damaged and
# opponents loose speed
elsif user.type1==PBTypes::DARK
pbDisplay(_INTL("{1} used Nightfall!",user.pbThis))
user.pbReduceHP(-(user.hp + (user.hp/3)))
if (opp1.type1==PBTypes::DARK)
opp1.pbRecoverHP((opp1.hp/3).floor)
end
if opp2 != nil
if opp2.type1==PBTypes::DARK
opp2.pbRecoverHP((opp1.hp/3).floor)
end
end
if ally != nil
if ally.type1==PBTypes::DARK
ally.pbRecoverHP((opp1.hp/3).floor)
end
end
opp1.pbReduceHP(50)
opp2.pbReduceHP(50) if opp2 != nil
ally.pbReduceHP(50)
if opp1.pbCanReduceStatStage?(PBStats::SPEED,opp1,true)
opp1.pbReduceStat(PBStats::SPEED,2,opp1,false)
end
if opp2.pbCanReduceStatStage?(PBStats::SPEED,opp2,true) && opp2 != nil
opp2.pbReduceStat(PBStats::SPEED,2,opp2,false)
end
#===========================================================================
# Enchantment
#
# Opponents are damaged and the damage that is done to them is healed by the
# user
elsif user.type1==PBTypes::FAIRY
pbDisplay(_INTL("{1} used Enchantment!",user.pbThis))
opp1.pbReduceHP(((opp1.hp/2) + (opp1.defence/2)).floor)
opp2.pbReduceHP(((opp2.hp/2) + (opp2.defence/2)).floor) if opp2 != nil
user.pbRecoverHP((opp1.hp/2) + (opp1.defence/2) + ((opp2.hp/2) + (opp2.defence/2)).floor)
#===========================================================================
# Sky Dive
#
# Does 50 damage to opponents, 100 if they are airborne
elsif user.type1==PBTypes::FLYING
pbDisplay(_INTL("{1} used Sky Dive!",user.pbThis))
if opp1.isAirborne?
opp1.pbReduceHP(100)
else
opp1.pbReduceHP(50)
end
if opp2 != nil
if opp2.isAirborne?
opp2.pbReduceHP(100)
else
opp2.pbReduceHP(50)
end
end
#===========================================================================
# Icy Rend
#
# Freezes all opponents and water types become ice type also does damage
elsif user.type1==PBTypes::ICE
pbDisplay(_INTL("{1} used Icy Rend!",user.pbThis))
opp1.pbFreeze
opp2.pbFreeze
opp1.pbReduceHP(rand(opp1.hp)+opp1.hp/2)
opp2.pbReduceHP(rand(opp2.hp)+opp2.hp/2) if opp2Exists
if opp1.type1==PBTypes::WATER
opp1.type1 = PBTypes::ICE
opp1.effects[PBEffects::IcyRend]=5
end
if opp2Exists
if opp2.type1==PBTypes::WATER
opp2.type1 = PBTypes::ICE
end
end
if opp1.type2==PBTypes::WATER
opp1.type1 = PBTypes::ICE
end
if opp2Exists
if opp2.type2==PBTypes::WATER
opp2.type1 = PBTypes::ICE
opp1.effects[PBEffects::IcyRend]=5
end
end
#===========================================================================
# Sand Hurricane
#
# Sandstorm goes up, electric types loose the electric type, does more damage
# for each groung type on the field
elsif user.type1==PBTypes::GROUND
pbDisplay(_INTL("{1} used Sand Hurricane!",user.pbThis))
dmgmult = 1 #1 because the user is ground
if opp1.type1 == PBTypes::GROUND
dmgmult += 1
end
if opp1.type2 == PBTypes::GROUND
dmgmult += 1
end
if opp2 != nil
if opp2.type1 == PBTypes::GROUND
dmgmult += 1
end
if opp2.type2 == PBTypes::GROUND
dmgmult += 1
end
end
if ally != nil
if ally.type1 == PBTypes::GROUND
dmgmult += 1
end
if ally.type2 == PBTypes::GROUND
dmgmult += 1
end
end
opp1.pbReduceHP((40*dmgmult).floor)
opp2.pbReduceHP((40*dmgmult).floor) if opp2 != nil
@battle.weather=PBWeather::SANDSTORM
#===========================================================================
# Repeating Punch
#
# If the ally is fighting, the opp1 is damaged twice
elsif user.type1==PBTypes::FIGHTING
pbDisplay(_INTL("{1} used Repeating punch!",user.pbThis))
if (ally.type1 == PBTypes::FIGHTING) || (ally.type2 == PBTypes::FIGHTING)
opp1.pbReduceHP((opp1.defence).floor)
opp2.pbReduceHP((opp1.defence).floor) if opp2 != nil
end
opp1.pbReduceHP((opp1.defence).floor)
opp2.pbReduceHP((opp1.defence).floor) if opp2 != nil
#===========================================================================
# Metamorph
#
# The user doubles in HP and status conditions are removed
elsif user.type1==PBTypes::BUG
pbDisplay(_INTL("{1} used Metamorph!",user.pbThis))
user.pbRecoverHP((user.hp))
user.effects[PBEffects::Confusion]=0
user.healStatus
#===========================================================================
# Reinforce
#
# Defence is maxed out, + 60 HP
elsif user.type1==PBTypes::STEEL
pbDisplay(_INTL("{1} used Reinforce!",user.pbThis))
if user.pbCanIncreaseStatStage?(PBStats::SPEED,user,true)
user.pbIncreaseStat(PBStats::SPEED,6,user,false)
end
user.pbRecoverHP(60)
#===========================================================================
# Fade Out
#
# Does damage, then swaps out
elsif user.type1==PBTypes::GHOST
pbDisplay(_INTL("{1} used Fade Out!",user.pbThis))
opp1.pbReduceHP(50)
opp2.pbReduceHP(50) if opp2 != nil
user.pbUseSelfSwitchOut(index)
#===========================================================================
# dIsToRt
#
# tHE uSER gETS tHE gHOST tYPE [sWAPPED fOR pSYCHIC tYPE] aND tHE oPPONENT gETS tHE nORMAL tYPE
elsif user.type1==PBTypes::PSYCHIC
pbDisplay(_INTL("{1} used Distort!",user.pbThis))
opp1.type1=PBTypes::NORMAL
opp2.type1=PBTypes::NORMAL if opp2 != nil
user.type1=PBTypes::GHOST
user.effects[PBEffects::Distort]=5
#===========================================================================
# Bury
#
# The opponents are disabled + damaged
elsif user.type1==PBtypes::ROCK
pbDisplay(_INTL("{1} used Bury!",user.pbThis))
opp1.effects[PBEffects::Disable]=3
opp1.effects[PBEffects::DisableMove]=opp1.lastMoveUsed.id
opp2.effects[PBEffects::Disable]=3 if opp2 != nil
opp2.effects[PBEffects::DisableMove]=opp2.lastMoveUsed.id if opp2 != nil
opp1.pbReduceHP((opp1.effects[PBEffects::Disable])*40)
#===========================================================================
# Draconic Dive
#
# 80 damage to each opponent for each type the user has and confuses self
elsif user.type1==PBTypes::DRAGON
pbDisplay(_INTL("{1} used Draconic Dive!",user.pbThis))
if user.type2 != nil
opp1.pbReduceHP(160)
else
opp1.pbReduceHP(80)
end
if opp2 != nil
if user.type2 != nil
opp2.pbReduceHP(160)
else
opp2.pbReduceHP(80)
end
end
end
end
#===============================================================================
# More rewrites to PokeBattle_Battle.
#===============================================================================
def pbRegisterSwitch(idxPokemon,idxOther)
return false if !pbCanSwitch?(idxPokemon,idxOther,false)
@choices[idxPokemon][0]=2 # "Switch Pokémon"
@choices[idxPokemon][1]=idxOther # Index of other Pokémon to switch with
@choices[idxPokemon][2]=nil
side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
owner=pbGetOwnerIndex(idxPokemon)
if @megaEvolution[side][owner]==idxPokemon
@megaEvolution[side][owner]=-1
end
#==============================================
# Zodiac Powers
if Spirit_Config::ZPOWER
if @zodiacPower[side][owner]==idxPokemon
@zodiacPower[side][owner]=-1
end
end
#==============================================
# Z-Moves
if Spirit_Config::ZMOVES
if @zMove[side][owner]==idxPokemon
@zMove[side][owner]=-1
end
end
#==============================================
if @spiritPower[side][owner]==idxPokemon
@spiritPower[side][owner]=-1
end
return true
end
def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)
if idxTarget!=nil && idxTarget>=0
for i in 0...4
if !@battlers[i].pbIsOpposing?(idxPokemon) &&
@battlers[i].pokemonIndex==idxTarget &&
@battlers[i].effects[PBEffects::Embargo]>0
pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",@battlers[i].pbThis(true)))
if pbBelongsToPlayer?(@battlers[i].index)
if $PokemonBag.pbCanStore?(idxItem)
$PokemonBag.pbStoreItem(idxItem)
else
raise _INTL("Couldn't return unused item to Bag somehow.")
end
end
return false
end
end
end
if ItemHandlers.hasUseInBattle(idxItem)
if idxPokemon==0 # Player's first Pokémon
if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
# Using Poké Balls or Poké Doll only
ItemHandlers.triggerUseInBattle(idxItem,@battlers[idxPokemon],self)
if @doublebattle
@battlers[idxPokemon].pbPartner.effects[PBEffects::SkipTurn]=true
end
else
if $PokemonBag.pbCanStore?(idxItem)
$PokemonBag.pbStoreItem(idxItem)
else
raise _INTL("Couldn't return unusable item to Bag somehow.")
end
return false
end
else
if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
pbDisplay(_INTL("It's impossible to aim without being focused!"))
end
return false
end
end
@choices[idxPokemon][0]=3 # "Use an item"
@choices[idxPokemon][1]=idxItem # ID of item to be used
@choices[idxPokemon][2]=idxTarget # Index of Pokémon to use item on
side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
owner=pbGetOwnerIndex(idxPokemon)
if @megaEvolution[side][owner]==idxPokemon
@megaEvolution[side][owner]=-1
end
#==============================================
# Zodiac Powers
if Spirit_Config::ZPOWER
if @zodiacPower[side][owner]==idxPokemon
@zodiacPower[side][owner]=-1
end
end
#==============================================
# Z-Moves
if Spirit_Config::ZMOVES
if @zMove[side][owner]==idxPokemon
@zMove[side][owner]=-1
end
end
#==============================================
if @spiritPower[side][owner]==idxPokemon
@spiritPower[side][owner]=-1
end
return true
end
#===============================================================================
# Using Spirit Powers in battle.
#===============================================================================
def pbCanUseZodiacPower?(index)
return false if !Spirit_Config::ZPOWER
return false if (@battlers[index].isShadow? rescue false)
return false if !@battlers[index].hasZodiacPower?
return false if pbIsOpposing?(index) && !@opponent
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
return false if @zodiacPower[side][owner]!=-1
return false if @battlers[index].effects[PBEffects::SkyDrop]
return false if @battlers[index].effects[PBEffects::Embargo]>0
return false if @field.effects[PBEffects::MagicRoom]>0
return false if @battlers[index].hasWorkingAbility(:KLUTZ)
return true
end
def pbCanUseSpiritPower?(index)
return false if (@battlers[index].isShadow? rescue false)
return false if !battlers[index].canSpirit?
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
return false if @spiritPower[side][owner]!=-1
return false if @battlers[index].effects[PBEffects::SkyDrop]
return false if @battlers[index].effects[PBEffects::Embargo]>0
return false if @field.effects[PBEffects::MagicRoom]>0
return false if @battlers[index].hasWorkingAbility(:KLUTZ)
return true
end
def pbRegisterZodiacPower(index)
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
@zodiacPower[side][owner]=index
end
def pbRegisterSpiritPower(index)
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
@spiritPower[side][owner]=index
end
def pbUseZodiacPower(index)
return if !@battlers[index] || !@battlers[index].pokemon
return if !(@battlers[index].hasZodiacPower? rescue false)
pbDisplay(_INTL("{1}'s {2} is reacting to its birthsign!",
@battlers[index].pbThis,PBItems.getName(@battlers[index].item)))
pbCommonAnimation("UseItem",@battlers[index],nil)
pbZodiacEffects(index)
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
#===========================================================================
# Remove comment tag on the line below to have a once-per-battle limit.
#===========================================================================
#@zodiacPower[side][owner]=-2
#===========================================================================
end
# Voyager effect switches opponent out
def pbUseOppSwitchOut(index)
user=@battlers[index]
# User is player's left slot
if user==@battlers[0]
opp=user.pbOpposing1
oppParty=pbCanChooseNonActive?(3)
# User is player's right slot
elsif user==@battlers[2]
opp=user.pbOpposing2
oppParty=pbCanChooseNonActive?(2)
# User is opponent's right slot
elsif @doublebattle && user==@battlers[1]
opp=@battlers[2]
oppParty=pbCanChooseNonActive?(1)
# User is opponent's left slot
elsif @doublebattle && user==@battlers[3]
opp=@battlers[0]
oppParty=pbCanChooseNonActive?(1)
# User is opponent in single battle
elsif user==@battlers[1]
opp=@battlers[0]
oppParty=pbCanChooseNonActive?(1)
end
return if !user || !user.pokemon
return if !(user.ZodiacOppSwitch? rescue false)
if !user.isFainted? && !opp.isFainted? &&
oppParty && opp.effects[PBEffects::Uturn]=true
end
end
# Fugitive effect switches user out
def pbUseSelfSwitchOut(index)
user=@battlers[index]
return if !user || !user.pokemon
return if !(user.ZodiacSelfSwitch? rescue false)
if !user.isFainted? && pbCanChooseNonActive?(index) &&
user.effects[PBEffects::Uturn]=true
end
end
def pbUseSpiritPower(index)
return if !@battlers[index] || !@battlers[index].pokemon
return if !(@battlers[index].canSpirit? rescue false)
pbDisplay(_INTL("{1} is using it's {2} to tap into its spirit power!",
@battlers[index].pbThis,PBItems.getName(@battlers[index].item)))
pbCommonAnimation("UseItem",@battlers[index],nil)
pbSpiritEffects(index)
side=(pbIsOpposing?(index)) ? 1 : 0
owner=pbGetOwnerIndex(index)
@spiritPower[side][owner]=-2
end
#===============================================================================
# Rewrites to PokeBattle_AI
# Allows opposing Pokemon to use Zodiac Powers & Spirit powers
#===============================================================================
def pbEnemyShouldUseZodiac?(index)
return pbCanUseZodiacPower?(index)
end
def pbEnemyShouldUsePower?(index)
return pbCanUseZodiacPower?(index)
end
def pbDefaultChooseEnemyCommand(index)
if !pbCanShowFightMenu?(index)
return if pbEnemyShouldUseItem?(index)
return if pbEnemyShouldWithdraw?(index)
pbAutoChooseMove(index)
return
else
return if pbEnemyShouldUseItem?(index)
return if pbEnemyShouldWithdraw?(index)
return if pbAutoFightMenu(index)
pbRegisterMegaEvolution(index) if pbEnemyShouldMegaEvolve?(index)
#=========================================================================
# Zodiac Powers
if Spirit_Config::ZPOWER
pbRegisterZodiacPower(index) if pbEnemyShouldUseZodiac?(index)
end
#=========================================================================
# Z-Moves
if Spirit_Config::ZMOVES
if pbEnemyShouldZMove?(index)
return pbChooseEnemyZMove(index)
end
end
#=========================================================================
pbRegisterSpiritPower(index) if pbEnemyShouldUsePower?(index)
pbChooseMoves(index)
end
end
end
#===============================================================================
# More rewrites to PokeBattle_Battle.
#===============================================================================
class PokeBattle_Battle
def pbCommandPhase
@scene.pbBeginCommandPhase
# @scene.pbResetCommandIndices
for i in 0...4 # Reset choices if commands can be shown
@battlers[i].effects[PBEffects::SkipTurn]=false
if pbCanShowCommands?(i) || @battlers[i].fainted?
@choices[i][0]=0
@choices[i][1]=0
@choices[i][2]=nil
@choices[i][3]=-1
else
unless !@doublebattle && pbIsDoubleBattler?(i)
PBDebug.log("[Reusing commands] #{@battlers[i].pbThis(true)}")
end
end
end
# Reset choices to perform Mega Evolution if it wasn't done somehow
for i in 0...2
for j in 0...@megaEvolution[i].length
@megaEvolution[i][j]=-1 if @megaEvolution[i][j]>=0
end
end
#=======================================================
# Zodiac Powers
if Spirit_Config::ZPOWER
for i in 0...2
for j in 0...@zodiacPower[i].length
@zodiacPower[i][j]=-1 if @zodiacPower[i][j]>=0
end
end
end
#=======================================================
# Z-Moves
if Spirit_Config::ZMOVES
for i in 0...@zMove[0].length
@zMove[0][i]=-1 if @zMove[0][i]>=0
end
for i in 0...@zMove[1].length
@zMove[1][i]=-1 if @zMove[1][i]>=0
end
end
#=======================================================
for i in 0...2
for j in 0...@spiritPower[0].length
@spiritPower[i][j]=-1 if @spiritPower[i][j]>=0
end
end
for i in 0...4
break if @decision!=0
next if @choices[i][0]!=0
if !pbOwnedByPlayer?(i) || @controlPlayer
if !@battlers[i].fainted? && pbCanShowCommands?(i)
@scene.pbChooseEnemyCommand(i)
end
else
commandDone=false
commandEnd=false
if pbCanShowCommands?(i)
loop do
cmd=pbCommandMenu(i)
if cmd==0 # Fight
if pbCanShowFightMenu?(i)
commandDone=true if pbAutoFightMenu(i)
until commandDone
[email protected](i)
if index<0
side=(pbIsOpposing?(i)) ? 1 : 0
owner=pbGetOwnerIndex(i)
if @megaEvolution[side][owner]==i
@megaEvolution[side][owner]=-1
end
#===================================
# Zodiac Powers
if Spirit_Config::ZPOWER
if @zodiacPower[side][owner]==i
@zodiacPower[side][owner]=-1
end
end
#===================================
# Z-Moves
if Spirit_Config::ZMOVES
if @zMove[side][owner]==i
@zMove[side][owner]=-1
end
end
#===================================
if @spiritPower[side][owner]==i
@spiritPower[side][owner]=-1
end
break
end
next if !pbRegisterMove(i,index)
if @doublebattle
thismove=@battlers[i].moves[index]
target=@battlers[i].pbTarget(thismove)
if target==PBTargets::SingleNonUser # single non-user
[email protected](i,target)
next if target<0
pbRegisterTarget(i,target)
elsif target==PBTargets::UserOrPartner # Acupressure
[email protected](i,target)
next if target<0 || (target&1)==1
pbRegisterTarget(i,target)
end
end
commandDone=true
end
else
pbAutoChooseMove(i)
commandDone=true
end
elsif cmd!=0 && @battlers[i].effects[PBEffects::SkyDrop]
pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[i].pbThis(true)))
elsif cmd==1 # Bag
if !@internalbattle
if pbOwnedByPlayer?(i)
pbDisplay(_INTL("Items can't be used here."))
end
else
item=pbItemMenu(i)
if item[0]>0
if pbRegisterItem(i,item[0],item[1])
commandDone=true
end
end
end
elsif cmd==2 # Pokémon
pkmn=pbSwitchPlayer(i,false,true)
if pkmn>=0
commandDone=true if pbRegisterSwitch(i,pkmn)
end
elsif cmd==3 # Run
run=pbRun(i)
if run>0
commandDone=true
return
elsif run<0
commandDone=true
side=(pbIsOpposing?(i)) ? 1 : 0
owner=pbGetOwnerIndex(i)
if @megaEvolution[side][owner]==i
@megaEvolution[side][owner]=-1
end
#===================================
# Zodiac Powers
if Spirit_Config::ZPOWER
if @zodiacPower[side][owner]==i
@zodiacPower[side][owner]=-1
end
end
#===================================
# Z-Moves
if Spirit_Config::ZMOVES
if @zMove[side][owner]==i
@zMove[side][owner]=-1
end
end
#===================================
if @spiritPower[side][owner]==i
@spiritPower[side][owner]=-1
end
end
elsif cmd==4 # Call
thispkmn=@battlers[i]
@choices[i][0]=4 # "Call Pokémon"
@choices[i][1]=0
@choices[i][2]=nil
side=(pbIsOpposing?(i)) ? 1 : 0
owner=pbGetOwnerIndex(i)
if @megaEvolution[side][owner]==i
@megaEvolution[side][owner]=-1
end
#===================================
# Zodiac Powers
if INCLUDE_Spirit_Config::ZPOWER
if @zodiacPower[side][owner]==i
@zodiacPower[side][owner]=-1
end
end
#===================================
# Z-Moves
if INCLUDE_Spirit_Config::ZMOVES
if @zMove[side][owner]==i
@zMove[side][owner]=-1
end
end
#===================================
if @spiritPower[side][owner]==i
@spiritPower[side][owner]=-1
end
commandDone=true
elsif cmd==-1 # Go back to first battler's choice
@megaEvolution[0][0]=-1 if @megaEvolution[0][0]>=0
@megaEvolution[1][0]=-1 if @megaEvolution[1][0]>=0
#======================================================
# Zodiac Powers
if Spirit_Config::ZPOWER
@zodiacPower[0][0]=-1 if @zodiacPower[0][0]>=0
@zodiacPower[1][0]=-1 if @zodiacPower[1][0]>=0
end
#======================================================
# Z-Moves
if Spirit_Config::ZMOVES
@zMove[0][0]=-1 if @zMove[0][0]>=0
@zMove[1][0]=-1 if @zMove[1][0]>=0
end
#======================================================
@spiritPower[0][0]=-1 if @spiritPower[0][0]>=0
@spiritPower[1][0]=-1 if @spiritPower[1][0]>=0
# Restore the item the player's first Pokémon was due to use
if @choices[0][0]==3 && $PokemonBag && $PokemonBag.pbCanStore?(@choices[0][1])
$PokemonBag.pbStoreItem(@choices[0][1])
end
pbCommandPhase
return
end
break if commandDone
end
end
end
end
end
def pbAttackPhase
@scene.pbBeginAttackPhase
for i in 0...4
@successStates[i].clear
if @choices[i][0]!=1 && @choices[i][0]!=2
@battlers[i].effects[PBEffects::DestinyBond]=false
@battlers[i].effects[PBEffects::Grudge]=false
end
@battlers[i].turncount+=1 if !@battlers[i].fainted?
@battlers[i].effects[PBEffects::Rage]=false if !pbChoseMove?(i,:RAGE)
end
#===================================
# Calculate priority at this time
@usepriority=false
priority=pbPriority(false,true)
# Mega Evolution
megaevolved=[]
for i in priority
if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
side=(pbIsOpposing?(i.index)) ? 1 : 0
owner=pbGetOwnerIndex(i.index)
if @megaEvolution[side][owner]==i.index
pbMegaEvolve(i.index)
megaevolved.push(i.index)
end
end
end
if megaevolved.length>0
for i in priority
i.pbAbilitiesOnSwitchIn(true) if megaevolved.include?(i.index)
end
end
#===========================================================================
# Zodiac Powers
if Spirit_Config::ZPOWER
zodiacUsed=[]
for i in priority
if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
side=(pbIsOpposing?(i.index)) ? 1 : 0
owner=pbGetOwnerIndex(i.index)
if @zodiacPower[side][owner]==i.index
pbUseZodiacPower(i.index)
zodiacUsed.push(i.index)
end
end
end
end
#===========================================================================
# Spirit powers [8901]
spiritUsed=[]
for i in priority
if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
side=(pbIsOpposing?(i.index)) ? 1 : 0
owner=pbGetOwnerIndex(i.index)
if @spiritPower[side][owner]==i.index
pbUseSpiritPower(i.index)
spiritUsed.push(i.index)
end
end
end
# Call at Pokémon
for i in priority
if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
pbCall(i.index)
end
end
# Switch out Pokémon
@switching=true
switched=[]
for i in priority
if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
index=@choices[i.index][1] # party position of Pokémon to switch to
newpokename=index
if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(i.index)
end
self.lastMoveUser=i.index
if !pbOwnedByPlayer?(i.index)
owner=pbGetOwner(i.index)
pbDisplayBrief(_INTL("{1} withdrew {2}!",owner.fullname,i.name))
PBDebug.log("[Withdrew Pokémon] Opponent withdrew #{i.pbThis(true)}")
else
pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name))
PBDebug.log("[Withdrew Pokémon] Player withdrew #{i.pbThis(true)}")
end
for j in priority
#=====================================================================
side=(pbIsOpposing?(j.index)) ? 1 : 0
owner=pbGetOwnerIndex(j.index)
#=====================================================================
next if !i.pbIsOpposing?(j.index)
# if Pursuit and this target ("i") was chosen
if (pbChoseMoveFunctionCode?(j.index,0x88) && # Pursuit
!j.hasMovedThisRound?) ||
#==================================================================
# Adds the Pursuit effect to 'The Hunter' zodiac power.
#==================================================================
if Spirit_Config::ZPOWER
(@zodiacPower[side][owner]==j.index && j.ZodiacPursuit?)
end
#==================================================================
if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
!j.effects[PBEffects::SkyDrop] &&
(!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
@choices[j.index][3]=i.index # Make sure to target the switching Pokémon
j.pbUseMove(@choices[j.index]) # This calls pbGainEXP as appropriate
j.effects[PBEffects::Pursuit]=true
@switching=false
return if @decision>0
end
end
break if i.fainted?
end
if !pbRecallAndReplace(i.index,index,newpokename)
# If a forced switch somehow occurs here in single battles
# the attack phase now ends
if !@doublebattle
@switching=false
return
end
else
switched.push(i.index)
end
end
end
if switched.length>0
for i in priority
i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
end
end
@switching=false
# Use items
for i in priority
if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
if pbIsOpposing?(i.index)
# Opponent use item
pbEnemyUseItem(@choices[i.index][1],i)
else
# Player use item
item=@choices[i.index][1]
if item>0
usetype=$ItemData[item][ITEMBATTLEUSE]
if usetype==1 || usetype==3
if @choices[i.index][2]>=0
pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
end
elsif usetype==2 || usetype==4
if !ItemHandlers.hasUseInBattle(item) # Poké Ball/Poké Doll used already
pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
end
end
end
end
end
end
# Use attacks
for i in priority
next if i.effects[PBEffects::SkipTurn]
if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch
pbCommonAnimation("FocusPunch",i,nil)
pbDisplay(_INTL("{1} is tightening its focus!",i.pbThis))
end
end
10.times do
# Forced to go next
advance=false
for i in priority
next if !i.effects[PBEffects::MoveNext]
next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
advance=i.pbProcessTurn(@choices[i.index])
break if advance
end
return if @decision>0
next if advance
# Regular priority order
for i in priority
next if i.effects[PBEffects::Quash]
#=======================================================================
# Switches out after attacking if Fugitive Zodiac Power is used.
#=======================================================================
if Spirit_Config::ZPOWER
side=(pbIsOpposing?(i.index)) ? 1 : 0
owner=pbGetOwnerIndex(i.index)
if @zodiacPower[side][owner]==i.index
pbUseSelfSwitchOut(i.index)
end
end
#=======================================================================
next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
advance=i.pbProcessTurn(@choices[i.index])
#=======================================================================
# Switches out opponent after attacking if Voyager Zodiac Power is used.
#=======================================================================
if Spirit_Config::ZPOWER
side=(pbIsOpposing?(i.index)) ? 1 : 0
owner=pbGetOwnerIndex(i.index)
if @zodiacPower[side][owner]==i.index
pbUseOppSwitchOut(i.index)
end
end
#=======================================================================
break if advance
end
return if @decision>0
next if advance
# Quashed
for i in priority
next if !i.effects[PBEffects::Quash]
next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
advance=i.pbProcessTurn(@choices[i.index])
break if advance
end
return if @decision>0
next if advance
# Check for all done
for i in priority
advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
!i.effects[PBEffects::SkipTurn]
break if advance
end
next if advance
break
end
10.times do
@scene.pbGraphicsUpdate
@scene.pbInputUpdate
@scene.pbFrameUpdate
end
end
end
#===============================================================================
# Menu Graphic for toggling Zodiac Power.
#===============================================================================
class FightMenuDisplay
attr_reader :battler
attr_reader :index
attr_accessor :megaButton
attr_accessor :zodiacButton
attr_accessor :zButton
attr_accessor :spiritButton
def initialize(battler,viewport=nil)
@display=nil
if PokeBattle_SceneConstants::USEFIGHTBOX
@display=IconSprite.new(0,Graphics.height-96,viewport)
@display.setBitmap("Graphics/Pictures/Battle/overlay_fight")
end
@window=Window_CommandPokemon.newWithSize([],0,Graphics.height-96,320,96,viewport)
@window.columns=2
@window.columnSpacing=4
@window.ignore_input=true
pbSetNarrowFont(@window.contents)
@info=Window_AdvancedTextPokemon.newWithSize(
"",320,Graphics.height-96,Graphics.width-320,96,viewport)
pbSetNarrowFont(@info.contents)
@ctag=shadowctag(PokeBattle_SceneConstants::MENUBASECOLOR,
PokeBattle_SceneConstants::MENUSHADOWCOLOR)
@buttons=nil
@battler=battler
@index=0
@megaButton=0 # 0=don't show, 1=show, 2=pressed
#====================================================
# Zodiac Powers
@zodiacButton=0 # 0=don't show, 1=show, 2=pressed
#====================================================
# Z-Moves
@zButton=0 # 0=don't show, 1=show, 2=pressed
#=====================================================
@spiritButton=0 # 0=don't show, 1=show, 2=pressed
if PokeBattle_SceneConstants::USEFIGHTBOX
@window.opacity=0
@window.x=Graphics.width
@info.opacity=0
@info.x=Graphics.width+Graphics.width-96
@buttons=FightMenuButtons.new(self.index,nil,viewport)
end
refresh
end
def refresh
return if !@battler
commands=[]
for i in 0...4
break if @battler.moves[i].id==0
commands.push(@battler.moves[i].name)
end
@window.commands=commands
[email protected][@index]
movetype=PBTypes.getName(selmove.type)
if selmove.totalpp==0
@info.text=_INTL("{1}PP: ---<br>TYPE/{2}",@ctag,movetype)
else
@info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
@ctag,selmove.pp,selmove.totalpp,movetype)
end
#===========================================================================
@buttons.refresh(self.index,@battler ? @battler.moves : nil,@megaButton,@zodiacButton,@zButton,@spiritButton) if @buttons
#===========================================================================
end
def update
@info.update
@window.update
@display.update if @display
if @buttons
moves=@battler ? @battler.moves : nil
#=========================================================================
@buttons.update(self.index,moves,@megaButton,@zodiacButton,@zButton,@spiritButton)
#=========================================================================
end
end
end
class FightMenuButtons < BitmapSprite
UPPERGAP=46
def initialize(index=0,moves=nil,viewport=nil)
super(Graphics.width,96+UPPERGAP,viewport)
self.x=0
self.y=Graphics.height-96-UPPERGAP
pbSetNarrowFont(self.bitmap)
@buttonbitmap=AnimatedBitmap.new("Graphics/Pictures/Battle/cursor_fight")
@typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
@megaevobitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
#===========================================================================
@zodiacbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Birthsigns/Other/battlezodiac"))
#===========================================================================
@zmovebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/ZMove"))
#===========================================================================
@spiritbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/Spirit_Power_Button"))
refresh(index,moves,0,0,0,0)
end
def dispose
@buttonbitmap.dispose
@typebitmap.dispose
@megaevobitmap.dispose
#======================
@zodiacbitmap.dispose
#======================
@zmovebitmap.dispose
#======================
@spiritbitmap.dispose
super
end
def update(index=0,moves=nil,megaButton=0,zodiacButton=0,zButton=0, spiritButton=0)
refresh(index,moves,megaButton,zodiacButton,zButton,spiritButton)
end
def refresh(index,moves,megaButton,zodiacButton,zButton,spiritButton)
return if !moves
self.bitmap.clear
textpos=[]
for i in 0...4
next if i==index
next if moves[i].id==0
x=((i%2)==0) ? 4 : 192
y=((i/2)==0) ? 6 : 48
y+=UPPERGAP
self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,moves[i].type*46,192,46))
textpos.push([moves[i].name,x+96,y+8,2,
PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
end
ppcolors=[
PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
PokeBattle_SceneConstants::PPTEXTBASECOLORYELLOW,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORYELLOW,
PokeBattle_SceneConstants::PPTEXTBASECOLORORANGE,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORORANGE,
PokeBattle_SceneConstants::PPTEXTBASECOLORRED,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORRED
]
for i in 0...4
next if i!=index
next if moves[i].id==0
x=((i%2)==0) ? 4 : 192
y=((i/2)==0) ? 6 : 48
y+=UPPERGAP
self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(192,moves[i].type*46,192,46))
self.bitmap.blt(416,20+UPPERGAP,@typebitmap.bitmap,Rect.new(0,moves[i].type*28,64,28))
textpos.push([moves[i].name,x+96,y+8,2,
PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
if moves[i].totalpp>0
ppfraction=(4.0*moves[i].pp/moves[i].totalpp).ceil
textpos.push([_INTL("PP: {1}/{2}",moves[i].pp,moves[i].totalpp),
448,50+UPPERGAP,2,ppcolors[(4-ppfraction)*2],ppcolors[(4-ppfraction)*2+1]])
end
end
pbDrawTextPositions(self.bitmap,textpos)
if megaButton>0
self.bitmap.blt(146,0,@megaevobitmap.bitmap,Rect.new(0,(megaButton-1)*46,96,46))
end
#===========================================================================
# Zodiac Powers
if zodiacButton>0
self.bitmap.blt(146,0,@zodiacbitmap.bitmap,Rect.new(0,(zodiacButton-1)*46,96,46))
end
#===========================================================================
# Z-Moves
if zButton>0
self.bitmap.blt(146,0,@zmovebitmap.bitmap,Rect.new(0,(zButton-1)*46,96,46))
end
#===========================================================================
# Spirit Powers
if spiritButton>0
self.bitmap.blt(146,0,@spiritbitmap.bitmap,Rect.new(0,(spiritButton-1)*46,96,46))
end
end
end
class PokeBattle_Scene
def pbFightMenu(index)
pbShowWindow(FIGHTBOX)
cw = @sprites["fightwindow"]
[email protected][index]
cw.battler=battler
lastIndex=@lastmove[index]
if battler.moves[lastIndex].id!=0
cw.setIndex(lastIndex)
else
cw.setIndex(0)
end
cw.megaButton=0
cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
#=====================================================
cw.zodiacButton=0
if Spirit_Config::ZPOWER
cw.zodiacButton=1 if @battle.pbCanUseZodiacPower?(index)
end
#=====================================================
cw.zButton=0
if Spirit_Config::ZMOVES
cw.zButton=1 if @battle.pbCanZMove?(index)
end
#=====================================================
cw.spiritButton=0
cw.spiritButton=1 if @battle.pbCanUseSpiritPower?(index)
pbSelectBattler(index)
pbRefresh
loop do
pbGraphicsUpdate
pbInputUpdate
pbFrameUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT) && (cw.index&1)==1
pbPlayCursorSE if cw.setIndex(cw.index-1)
elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0
pbPlayCursorSE if cw.setIndex(cw.index+1)
elsif Input.trigger?(Input::UP) && (cw.index&2)==2
pbPlayCursorSE if cw.setIndex(cw.index-2)
elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
pbPlayCursorSE if cw.setIndex(cw.index+2)
end
#================I just think this is better than this --> ###############
if Input.trigger?(Input::C) # Confirm choice
ret=cw.index
if cw.zButton==2
if battler.pbCompatibleZMoveFromIndex?(ret)
pbPlayDecisionSE()
@lastmove[index]=ret
return ret
else
@battle.pbDisplay(_INTL("{1} is not compatible with {2}!",PBMoves.getName(battler.moves[ret]),PBItems.getName(battler.item)))
@lastmove[index]=cw.index
return -1
end
else
pbPlayDecisionSE
@lastmove[index]=ret
return ret
end
elsif Input.trigger?(Input::A) # Use Mega Evolution
if @battle.pbCanMegaEvolve?(index)
@battle.pbRegisterMegaEvolution(index)
cw.megaButton=2
pbPlayDecisionSE
end
#=======================================================================
if Spirit_Config::ZPOWER
if @battle.pbCanUseZodiacPower?(index) # Use Zodiac Power
@battle.pbRegisterZodiacPower(index)
cw.zodiacButton=2
pbPlayDecisionSE
end
end
#=======================================================================
if Spirit_Config::ZMOVES
if @battle.pbCanZMove?(index) # Use Z Move
@battle.pbRegisterZMove(index)
cw.zButton=2
pbPlayDecisionSE
end
end
#=======================================================================
if @battle.pbCanUseSpiritPower?(index)
@battle.pbRegisterSpiritPower(index)
cw.spiritButton=2
pbPlayDecisionSE
end
#=======================================================================
elsif Input.trigger?(Input::B) # Cancel fight menu
@lastmove[index]=cw.index
pbPlayCancelSE
return -1
end
end
end
end
class PokeBattle_Battle
def pbEndOfRoundPhase
PBDebug.log("[End of round]")
for i in 0...4
@battlers[i].effects[PBEffects::Electrify]=false
@battlers[i].effects[PBEffects::Endure]=false
@battlers[i].effects[PBEffects::FirstPledge]=0
@battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
@battlers[i].effects[PBEffects::KingsShield]=false
@battlers[i].effects[PBEffects::LifeOrb]=false
@battlers[i].effects[PBEffects::MoveNext]=false
@battlers[i].effects[PBEffects::Powder]=false
@battlers[i].effects[PBEffects::Protect]=false
@battlers[i].effects[PBEffects::ProtectNegation]=false
@battlers[i].effects[PBEffects::Quash]=false
@battlers[i].effects[PBEffects::Roost]=false
@battlers[i].effects[PBEffects::SpikyShield]=false
end
@usepriority=false # recalculate priority
priority=pbPriority(true) # Ignoring Quick Claw here
# Weather
case @weather
when PBWeather::SUNNYDAY
@weatherduration=@weatherduration-1 if @weatherduration>0
if @weatherduration==0
pbDisplay(_INTL("The sunlight faded."))
@weather=0
PBDebug.log("[End of effect] Sunlight weather ended")
else
pbCommonAnimation("Sunny",nil,nil)
# pbDisplay(_INTL("The sunlight is strong."))
if pbWeather==PBWeather::SUNNYDAY
for i in priority
if i.hasWorkingAbility(:SOLARPOWER)
PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/8).floor)
pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
if i.fainted?
return if !i.pbFaint
end
end
end
end
end
when PBWeather::RAINDANCE
@weatherduration=@weatherduration-1 if @weatherduration>0
if @weatherduration==0
pbDisplay(_INTL("The rain stopped."))
@weather=0
PBDebug.log("[End of effect] Rain weather ended")
else
pbCommonAnimation("Rain",nil,nil)
# pbDisplay(_INTL("Rain continues to fall."))
end
when PBWeather::SANDSTORM
@weatherduration=@weatherduration-1 if @weatherduration>0
if @weatherduration==0
pbDisplay(_INTL("The sandstorm subsided."))
@weather=0
PBDebug.log("[End of effect] Sandstorm weather ended")
else
pbCommonAnimation("Sandstorm",nil,nil)
# pbDisplay(_INTL("The sandstorm rages."))
if pbWeather==PBWeather::SANDSTORM
PBDebug.log("[Lingering effect triggered] Sandstorm weather damage")
for i in priority
next if i.fainted?
if !i.pbHasType?(:GROUND) && !i.pbHasType?(:ROCK) && !i.pbHasType?(:STEEL) &&
!i.hasWorkingAbility(:SANDVEIL) &&
!i.hasWorkingAbility(:SANDRUSH) &&
!i.hasWorkingAbility(:SANDFORCE) &&
!i.hasWorkingAbility(:MAGICGUARD) &&
!i.hasWorkingAbility(:OVERCOAT) &&
!i.hasWorkingItem(:SAFETYGOGGLES) &&
![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/16).floor)
pbDisplay(_INTL("{1} is buffeted by the sandstorm!",i.pbThis))
if i.fainted?
return if !i.pbFaint
end
end
end
end
end
when PBWeather::HAIL
@weatherduration=@weatherduration-1 if @weatherduration>0
if @weatherduration==0
pbDisplay(_INTL("The hail stopped."))
@weather=0
PBDebug.log("[End of effect] Hail weather ended")
else
pbCommonAnimation("Hail",nil,nil)
# pbDisplay(_INTL("Hail continues to fall."))
if pbWeather==PBWeather::HAIL
PBDebug.log("[Lingering effect triggered] Hail weather damage")
for i in priority
next if i.fainted?
if !i.pbHasType?(:ICE) &&
!i.hasWorkingAbility(:ICEBODY) &&
!i.hasWorkingAbility(:SNOWCLOAK) &&
!i.hasWorkingAbility(:MAGICGUARD) &&
!i.hasWorkingAbility(:OVERCOAT) &&
!i.hasWorkingItem(:SAFETYGOGGLES) &&
![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/16).floor)
pbDisplay(_INTL("{1} is buffeted by the hail!",i.pbThis))
if i.fainted?
return if !i.pbFaint
end
end
end
end
end
when PBWeather::HEAVYRAIN
hasabil=false
for i in 0...4
if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) && !@battlers[i].fainted?
hasabil=true; break
end
end
@weatherduration=0 if !hasabil
if @weatherduration==0
pbDisplay(_INTL("The heavy rain stopped."))
@weather=0
PBDebug.log("[End of effect] Primordial Sea's rain weather ended")
else
pbCommonAnimation("HeavyRain",nil,nil)
# pbDisplay(_INTL("It is raining heavily."))
end
when PBWeather::HARSHSUN
hasabil=false
for i in 0...4
if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) && !@battlers[i].fainted?
hasabil=true; break
end
end
@weatherduration=0 if !hasabil
if @weatherduration==0
pbDisplay(_INTL("The harsh sunlight faded."))
@weather=0
PBDebug.log("[End of effect] Desolate Land's sunlight weather ended")
else
pbCommonAnimation("HarshSun",nil,nil)
# pbDisplay(_INTL("The sunlight is extremely harsh."))
if pbWeather==PBWeather::HARSHSUN
for i in priority
if i.hasWorkingAbility(:SOLARPOWER)
PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/8).floor)
pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
if i.fainted?
return if !i.pbFaint
end
end
end
end
end
when PBWeather::STRONGWINDS
hasabil=false
for i in 0...4
if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) && !@battlers[i].fainted?
hasabil=true; break
end
end
@weatherduration=0 if !hasabil
if @weatherduration==0
pbDisplay(_INTL("The air current subsided."))
@weather=0
PBDebug.log("[End of effect] Delta Stream's wind weather ended")
else
pbCommonAnimation("StrongWinds",nil,nil)
# pbDisplay(_INTL("The wind is strong."))
end
end
# Shadow Sky weather
if isConst?(@weather,PBWeather,:SHADOWSKY)
@weatherduration=@weatherduration-1 if @weatherduration>0
if @weatherduration==0
pbDisplay(_INTL("The shadow sky faded."))
@weather=0
PBDebug.log("[End of effect] Shadow Sky weather ended")
else
pbCommonAnimation("ShadowSky",nil,nil)
# pbDisplay(_INTL("The shadow sky continues."));
if isConst?(pbWeather,PBWeather,:SHADOWSKY)
PBDebug.log("[Lingering effect triggered] Shadow Sky weather damage")
for i in priority
next if i.fainted?
if !i.isShadow?
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/16).floor)
pbDisplay(_INTL("{1} was hurt by the shadow sky!",i.pbThis))
if i.fainted?
return if !i.pbFaint
end
end
end
end
end
end
# Future Sight/Doom Desire
for i in battlers # not priority
next if i.fainted?
if i.effects[PBEffects::FutureSight]>0
i.effects[PBEffects::FutureSight]-=1
if i.effects[PBEffects::FutureSight]==0
move=i.effects[PBEffects::FutureSightMove]
PBDebug.log("[Lingering effect triggered] #{PBMoves.getName(move)} struck #{i.pbThis(true)}")
pbDisplay(_INTL("{1} took the {2} attack!",i.pbThis,PBMoves.getName(move)))
moveuser=nil
for j in battlers
next if j.pbIsOpposing?(i.effects[PBEffects::FutureSightUserPos])
if j.pokemonIndex==i.effects[PBEffects::FutureSightUser] && !j.fainted?
moveuser=j; break
end
end
if !moveuser
party=pbParty(i.effects[PBEffects::FutureSightUserPos])
if party[i.effects[PBEffects::FutureSightUser]].hp>0
moveuser=PokeBattle_Battler.new(self,i.effects[PBEffects::FutureSightUserPos])
moveuser.pbInitDummyPokemon(party[i.effects[PBEffects::FutureSightUser]],
i.effects[PBEffects::FutureSightUser])
end
end
if !moveuser
pbDisplay(_INTL("But it failed!"))
else
@futuresight=true
moveuser.pbUseMoveSimple(move,-1,i.index)
@futuresight=false
end
i.effects[PBEffects::FutureSight]=0
i.effects[PBEffects::FutureSightMove]=0
i.effects[PBEffects::FutureSightUser]=-1
i.effects[PBEffects::FutureSightUserPos]=-1
if i.fainted?
return if !i.pbFaint
next
end
end
end
end
for i in priority
next if i.fainted?
# Rain Dish
if i.hasWorkingAbility(:RAINDISH) && i.effects[PBEffects::HealBlock]==0 &&
(pbWeather==PBWeather::RAINDANCE ||
pbWeather==PBWeather::HEAVYRAIN)
PBDebug.log("[Ability triggered] #{i.pbThis}'s Rain Dish")
hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
end
# Dry Skin
if i.hasWorkingAbility(:DRYSKIN)
if (pbWeather==PBWeather::RAINDANCE || pbWeather==PBWeather::HEAVYRAIN) &&
i.effects[PBEffects::HealBlock]==0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in rain)")
hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
pbDisplay(_INTL("{1}'s {2} was healed by the rain!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
elsif pbWeather==PBWeather::SUNNYDAY ||
pbWeather==PBWeather::HARSHSUN
PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in sun)")
@scene.pbDamageAnimation(i,0)
hploss=i.pbReduceHP((i.totalhp/8).floor)
pbDisplay(_INTL("{1}'s {2} was hurt by the sunlight!",i.pbThis,PBAbilities.getName(i.ability))) if hploss>0
end
end
# Ice Body
if i.hasWorkingAbility(:ICEBODY) && pbWeather==PBWeather::HAIL &&
i.effects[PBEffects::HealBlock]==0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Ice Body")
hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
end
if i.fainted?
return if !i.pbFaint
end
end
# Wish
for i in priority
next if i.fainted?
if i.effects[PBEffects::Wish]>0
i.effects[PBEffects::Wish]-=1
if i.effects[PBEffects::Wish]==0
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Wish")
hpgain=i.pbRecoverHP(i.effects[PBEffects::WishAmount],true)
if hpgain>0
wishmaker=pbThisEx(i.index,i.effects[PBEffects::WishMaker])
pbDisplay(_INTL("{1}'s wish came true!",wishmaker))
end
end
end
end
# Fire Pledge + Grass Pledge combination damage
for i in 0...2
if sides[i].effects[PBEffects::SeaOfFire]>0 &&
pbWeather!=PBWeather::RAINDANCE &&
pbWeather!=PBWeather::HEAVYRAIN
@battle.pbCommonAnimation("SeaOfFire",nil,nil) if i==0
@battle.pbCommonAnimation("SeaOfFireOpp",nil,nil) if i==1
for j in priority
next if (j.index&1)!=i
next if j.pbHasType?(:FIRE) || j.hasWorkingAbility(:MAGICGUARD)
@scene.pbDamageAnimation(j,0)
hploss=j.pbReduceHP((j.totalhp/8).floor)
pbDisplay(_INTL("{1} is hurt by the sea of fire!",j.pbThis)) if hploss>0
if j.fainted?
return if !j.pbFaint
end
end
end
end
for i in priority
next if i.fainted?
# Shed Skin, Hydration
if (i.hasWorkingAbility(:SHEDSKIN) && pbRandom(10)<3) ||
(i.hasWorkingAbility(:HYDRATION) && (pbWeather==PBWeather::RAINDANCE ||
pbWeather==PBWeather::HEAVYRAIN))
if i.status>0
PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
s=i.status
i.pbCureStatus(false)
case s
when PBStatuses::SLEEP
pbDisplay(_INTL("{1}'s {2} cured its sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::POISON
pbDisplay(_INTL("{1}'s {2} cured its poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::BURN
pbDisplay(_INTL("{1}'s {2} healed its burn!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::PARALYSIS
pbDisplay(_INTL("{1}'s {2} cured its paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::FROZEN
pbDisplay(_INTL("{1}'s {2} thawed it out!",i.pbThis,PBAbilities.getName(i.ability)))
end
end
end
# Healer
if i.hasWorkingAbility(:HEALER) && pbRandom(10)<3
partner=i.pbPartner
if partner && partner.status>0
PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
s=partner.status
partner.pbCureStatus(false)
case s
when PBStatuses::SLEEP
pbDisplay(_INTL("{1}'s {2} cured its partner's sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::POISON
pbDisplay(_INTL("{1}'s {2} cured its partner's poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::BURN
pbDisplay(_INTL("{1}'s {2} healed its partner's burn!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::PARALYSIS
pbDisplay(_INTL("{1}'s {2} cured its partner's paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
when PBStatuses::FROZEN
pbDisplay(_INTL("{1}'s {2} thawed its partner out!",i.pbThis,PBAbilities.getName(i.ability)))
end
end
end
end
for i in priority
next if i.fainted?
# Grassy Terrain (healing)
if @field.effects[PBEffects::GrassyTerrain]>0 && !i.isAirborne?
if i.effects[PBEffects::HealBlock]==0
hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
pbDisplay(_INTL("{1}'s HP was restored.",i.pbThis)) if hpgain>0
end
end
# Held berries/Leftovers/Black Sludge
i.pbBerryCureCheck(true)
if i.fainted?
return if !i.pbFaint
end
end
# Aqua Ring
for i in priority
next if i.fainted?
if i.effects[PBEffects::AquaRing]
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Aqua Ring")
hpgain=(i.totalhp/16).floor
hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
hpgain=i.pbRecoverHP(hpgain,true)
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",i.pbThis)) if hpgain>0
end
end
# Ingrain
for i in priority
next if i.fainted?
if i.effects[PBEffects::Ingrain]
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Ingrain")
hpgain=(i.totalhp/16).floor
hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
hpgain=i.pbRecoverHP(hpgain,true)
pbDisplay(_INTL("{1} absorbed nutrients with its roots!",i.pbThis)) if hpgain>0
end
end
# Leech Seed
for i in priority
next if i.fainted?
if i.effects[PBEffects::LeechSeed]>=0 && !i.hasWorkingAbility(:MAGICGUARD)
recipient=@battlers[i.effects[PBEffects::LeechSeed]]
if recipient && !recipient.fainted?
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Leech Seed")
pbCommonAnimation("LeechSeed",recipient,i)
hploss=i.pbReduceHP((i.totalhp/8).floor,true)
if i.hasWorkingAbility(:LIQUIDOOZE)
recipient.pbReduceHP(hploss,true)
pbDisplay(_INTL("{1} sucked up the liquid ooze!",recipient.pbThis))
else
if recipient.effects[PBEffects::HealBlock]==0
hploss=(hploss*1.3).floor if recipient.hasWorkingItem(:BIGROOT)
recipient.pbRecoverHP(hploss,true)
end
pbDisplay(_INTL("{1}'s health was sapped by Leech Seed!",i.pbThis))
end
if i.fainted?
return if !i.pbFaint
end
if recipient.fainted?
return if !recipient.pbFaint
end
end
end
end
for i in priority
next if i.fainted?
# Poison/Bad poison
if i.status==PBStatuses::POISON
if i.statusCount>0
i.effects[PBEffects::Toxic]+=1
i.effects[PBEffects::Toxic]=[15,i.effects[PBEffects::Toxic]].min
end
if i.hasWorkingAbility(:POISONHEAL)
pbCommonAnimation("Poison",i,nil)
if i.effects[PBEffects::HealBlock]==0 && i.hp<i.totalhp
PBDebug.log("[Ability triggered] #{i.pbThis}'s Poison Heal")
i.pbRecoverHP((i.totalhp/8).floor,true)
pbDisplay(_INTL("{1} is healed by poison!",i.pbThis))
end
else
if !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Status damage] #{i.pbThis} took damage from poison/toxic")
if i.statusCount==0
i.pbReduceHP((i.totalhp/8).floor)
else
i.pbReduceHP(((i.totalhp*i.effects[PBEffects::Toxic])/16).floor)
end
i.pbContinueStatus
end
end
end
# Burn
if i.status==PBStatuses::BURN
if !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Status damage] #{i.pbThis} took damage from burn")
if i.hasWorkingAbility(:HEATPROOF)
PBDebug.log("[Ability triggered] #{i.pbThis}'s Heatproof")
i.pbReduceHP((i.totalhp/16).floor)
else
i.pbReduceHP((i.totalhp/8).floor)
end
end
i.pbContinueStatus
end
# Nightmare
if i.effects[PBEffects::Nightmare]
if i.status==PBStatuses::SLEEP
if !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s nightmare")
i.pbReduceHP((i.totalhp/4).floor,true)
pbDisplay(_INTL("{1} is locked in a nightmare!",i.pbThis))
end
else
i.effects[PBEffects::Nightmare]=false
end
end
if i.fainted?
return if !i.pbFaint
next
end
end
# Curse
for i in priority
next if i.fainted?
if i.effects[PBEffects::Curse] && !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s curse")
i.pbReduceHP((i.totalhp/4).floor,true)
pbDisplay(_INTL("{1} is afflicted by the curse!",i.pbThis))
end
if i.fainted?
return if !i.pbFaint
next
end
end
# Multi-turn attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
for i in priority
next if i.fainted?
if i.effects[PBEffects::MultiTurn]>0
i.effects[PBEffects::MultiTurn]-=1
movename=PBMoves.getName(i.effects[PBEffects::MultiTurnAttack])
if i.effects[PBEffects::MultiTurn]==0
PBDebug.log("[End of effect] Trapping move #{movename} affecting #{i.pbThis} ended")
pbDisplay(_INTL("{1} was freed from {2}!",i.pbThis,movename))
else
if isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:BIND)
pbCommonAnimation("Bind",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:CLAMP)
pbCommonAnimation("Clamp",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:FIRESPIN)
pbCommonAnimation("FireSpin",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:MAGMASTORM)
pbCommonAnimation("MagmaStorm",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:SANDTOMB)
pbCommonAnimation("SandTomb",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:WRAP)
pbCommonAnimation("Wrap",i,nil)
elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:INFESTATION)
pbCommonAnimation("Infestation",i,nil)
else
pbCommonAnimation("Wrap",i,nil)
end
if !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Lingering effect triggered] #{i.pbThis} took damage from trapping move #{movename}")
@scene.pbDamageAnimation(i,0)
amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/8).floor : (i.totalhp/16).floor
if @battlers[i.effects[PBEffects::MultiTurnUser]].hasWorkingItem(:BINDINGBAND)
amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/6).floor : (i.totalhp/8).floor
end
i.pbReduceHP(amt)
pbDisplay(_INTL("{1} is hurt by {2}!",i.pbThis,movename))
end
end
end
if i.fainted?
return if !i.pbFaint
end
end
# Taunt
for i in priority
next if i.fainted?
if i.effects[PBEffects::Taunt]>0
i.effects[PBEffects::Taunt]-=1
if i.effects[PBEffects::Taunt]==0
pbDisplay(_INTL("{1}'s taunt wore off!",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer taunted")
end
end
end
# Encore
for i in priority
next if i.fainted?
if i.effects[PBEffects::Encore]>0
if i.moves[i.effects[PBEffects::EncoreIndex]].id!=i.effects[PBEffects::EncoreMove]
i.effects[PBEffects::Encore]=0
i.effects[PBEffects::EncoreIndex]=0
i.effects[PBEffects::EncoreMove]=0
PBDebug.log("[End of effect] #{i.pbThis} is no longer encored (encored move was lost)")
else
i.effects[PBEffects::Encore]-=1
if i.effects[PBEffects::Encore]==0 || i.moves[i.effects[PBEffects::EncoreIndex]].pp==0
i.effects[PBEffects::Encore]=0
pbDisplay(_INTL("{1}'s encore ended!",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer encored")
end
end
end
end
# Disable/Cursed Body
for i in priority
next if i.fainted?
if i.effects[PBEffects::Disable]>0
i.effects[PBEffects::Disable]-=1
if i.effects[PBEffects::Disable]==0
i.effects[PBEffects::DisableMove]=0
pbDisplay(_INTL("{1} is no longer disabled!",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer disabled")
end
end
end
# Magnet Rise
for i in priority
next if i.fainted?
if i.effects[PBEffects::MagnetRise]>0
i.effects[PBEffects::MagnetRise]-=1
if i.effects[PBEffects::MagnetRise]==0
pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Magnet Rise")
end
end
end
# Telekinesis
for i in priority
next if i.fainted?
if i.effects[PBEffects::Telekinesis]>0
i.effects[PBEffects::Telekinesis]-=1
if i.effects[PBEffects::Telekinesis]==0
pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Telekinesis")
end
end
end
# Heal Block
for i in priority
next if i.fainted?
if i.effects[PBEffects::HealBlock]>0
i.effects[PBEffects::HealBlock]-=1
if i.effects[PBEffects::HealBlock]==0
pbDisplay(_INTL("{1}'s Heal Block wore off!",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer Heal Blocked")
end
end
end
# Embargo
for i in priority
next if i.fainted?
if i.effects[PBEffects::Embargo]>0
i.effects[PBEffects::Embargo]-=1
if i.effects[PBEffects::Embargo]==0
pbDisplay(_INTL("{1} can use items again!",i.pbThis(true)))
PBDebug.log("[End of effect] #{i.pbThis} is no longer affected by an embargo")
end
end
end
# Yawn
for i in priority
next if i.fainted?
if i.effects[PBEffects::Yawn]>0
i.effects[PBEffects::Yawn]-=1
if i.effects[PBEffects::Yawn]==0 && i.pbCanSleepYawn?
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Yawn")
i.pbSleep
i.pbBerryCureCheck
end
end
end
# Perish Song
perishSongUsers=[]
for i in priority
next if i.fainted?
if i.effects[PBEffects::PerishSong]>0
i.effects[PBEffects::PerishSong]-=1
pbDisplay(_INTL("{1}'s perish count fell to {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Perish Song count dropped to #{i.effects[PBEffects::PerishSong]}")
if i.effects[PBEffects::PerishSong]==0
perishSongUsers.push(i.effects[PBEffects::PerishSongUser])
i.pbReduceHP(i.hp,true)
end
end
if i.fainted?
return if !i.pbFaint
end
end
if perishSongUsers.length>0
# If all remaining Pokemon fainted by a Perish Song triggered by a single side
if (perishSongUsers.find_all{|item| pbIsOpposing?(item) }.length==perishSongUsers.length) ||
(perishSongUsers.find_all{|item| !pbIsOpposing?(item) }.length==perishSongUsers.length)
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
end
end
if @decision>0
pbGainEXP
return
end
# Reflect
for i in 0...2
if sides[i].effects[PBEffects::Reflect]>0
sides[i].effects[PBEffects::Reflect]-=1
if sides[i].effects[PBEffects::Reflect]==0
pbDisplay(_INTL("Your team's Reflect faded!")) if i==0
pbDisplay(_INTL("The opposing team's Reflect faded!")) if i==1
PBDebug.log("[End of effect] Reflect ended on the player's side") if i==0
PBDebug.log("[End of effect] Reflect ended on the opponent's side") if i==1
end
end
end
# Light Screen
for i in 0...2
if sides[i].effects[PBEffects::LightScreen]>0
sides[i].effects[PBEffects::LightScreen]-=1
if sides[i].effects[PBEffects::LightScreen]==0
pbDisplay(_INTL("Your team's Light Screen faded!")) if i==0
pbDisplay(_INTL("The opposing team's Light Screen faded!")) if i==1
PBDebug.log("[End of effect] Light Screen ended on the player's side") if i==0
PBDebug.log("[End of effect] Light Screen ended on the opponent's side") if i==1
end
end
end
# Safeguard
for i in 0...2
if sides[i].effects[PBEffects::Safeguard]>0
sides[i].effects[PBEffects::Safeguard]-=1
if sides[i].effects[PBEffects::Safeguard]==0
pbDisplay(_INTL("Your team is no longer protected by Safeguard!")) if i==0
pbDisplay(_INTL("The opposing team is no longer protected by Safeguard!")) if i==1
PBDebug.log("[End of effect] Safeguard ended on the player's side") if i==0
PBDebug.log("[End of effect] Safeguard ended on the opponent's side") if i==1
end
end
end
# Mist
for i in 0...2
if sides[i].effects[PBEffects::Mist]>0
sides[i].effects[PBEffects::Mist]-=1
if sides[i].effects[PBEffects::Mist]==0
pbDisplay(_INTL("Your team's Mist faded!")) if i==0
pbDisplay(_INTL("The opposing team's Mist faded!")) if i==1
PBDebug.log("[End of effect] Mist ended on the player's side") if i==0
PBDebug.log("[End of effect] Mist ended on the opponent's side") if i==1
end
end
end
# Tailwind
for i in 0...2
if sides[i].effects[PBEffects::Tailwind]>0
sides[i].effects[PBEffects::Tailwind]-=1
if sides[i].effects[PBEffects::Tailwind]==0
pbDisplay(_INTL("Your team's Tailwind petered out!")) if i==0
pbDisplay(_INTL("The opposing team's Tailwind petered out!")) if i==1
PBDebug.log("[End of effect] Tailwind ended on the player's side") if i==0
PBDebug.log("[End of effect] Tailwind ended on the opponent's side") if i==1
end
end
end
# Lucky Chant
for i in 0...2
if sides[i].effects[PBEffects::LuckyChant]>0
sides[i].effects[PBEffects::LuckyChant]-=1
if sides[i].effects[PBEffects::LuckyChant]==0
pbDisplay(_INTL("Your team's Lucky Chant faded!")) if i==0
pbDisplay(_INTL("The opposing team's Lucky Chant faded!")) if i==1
PBDebug.log("[End of effect] Lucky Chant ended on the player's side") if i==0
PBDebug.log("[End of effect] Lucky Chant ended on the opponent's side") if i==1
end
end
end
# End of Pledge move combinations
for i in 0...2
if sides[i].effects[PBEffects::Swamp]>0
sides[i].effects[PBEffects::Swamp]-=1
if sides[i].effects[PBEffects::Swamp]==0
pbDisplay(_INTL("The swamp around your team disappeared!")) if i==0
pbDisplay(_INTL("The swamp around the opposing team disappeared!")) if i==1
PBDebug.log("[End of effect] Grass Pledge's swamp ended on the player's side") if i==0
PBDebug.log("[End of effect] Grass Pledge's swamp ended on the opponent's side") if i==1
end
end
if sides[i].effects[PBEffects::SeaOfFire]>0
sides[i].effects[PBEffects::SeaOfFire]-=1
if sides[i].effects[PBEffects::SeaOfFire]==0
pbDisplay(_INTL("The sea of fire around your team disappeared!")) if i==0
pbDisplay(_INTL("The sea of fire around the opposing team disappeared!")) if i==1
PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the player's side") if i==0
PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the opponent's side") if i==1
end
end
if sides[i].effects[PBEffects::Rainbow]>0
sides[i].effects[PBEffects::Rainbow]-=1
if sides[i].effects[PBEffects::Rainbow]==0
pbDisplay(_INTL("The rainbow around your team disappeared!")) if i==0
pbDisplay(_INTL("The rainbow around the opposing team disappeared!")) if i==1
PBDebug.log("[End of effect] Water Pledge's rainbow ended on the player's side") if i==0
PBDebug.log("[End of effect] Water Pledge's rainbow ended on the opponent's side") if i==1
end
end
end
# Gravity
if @field.effects[PBEffects::Gravity]>0
@field.effects[PBEffects::Gravity]-=1
if @field.effects[PBEffects::Gravity]==0
pbDisplay(_INTL("Gravity returned to normal."))
PBDebug.log("[End of effect] Strong gravity ended")
end
end
# Trick Room
if @field.effects[PBEffects::TrickRoom]>0
@field.effects[PBEffects::TrickRoom]-=1
if @field.effects[PBEffects::TrickRoom]==0
pbDisplay(_INTL("The twisted dimensions returned to normal."))
PBDebug.log("[End of effect] Trick Room ended")
end
end
# Wonder Room
if @field.effects[PBEffects::WonderRoom]>0
@field.effects[PBEffects::WonderRoom]-=1
if @field.effects[PBEffects::WonderRoom]==0
pbDisplay(_INTL("Wonder Room wore off, and the Defense and Sp. Def stats returned to normal!"))
PBDebug.log("[End of effect] Wonder Room ended")
end
end
# Magic Room
if @field.effects[PBEffects::MagicRoom]>0
@field.effects[PBEffects::MagicRoom]-=1
if @field.effects[PBEffects::MagicRoom]==0
pbDisplay(_INTL("The area returned to normal."))
PBDebug.log("[End of effect] Magic Room ended")
end
end
# Mud Sport
if @field.effects[PBEffects::MudSportField]>0
@field.effects[PBEffects::MudSportField]-=1
if @field.effects[PBEffects::MudSportField]==0
pbDisplay(_INTL("The effects of Mud Sport have faded."))
PBDebug.log("[End of effect] Mud Sport ended")
end
end
# Water Sport
if @field.effects[PBEffects::WaterSportField]>0
@field.effects[PBEffects::WaterSportField]-=1
if @field.effects[PBEffects::WaterSportField]==0
pbDisplay(_INTL("The effects of Water Sport have faded."))
PBDebug.log("[End of effect] Water Sport ended")
end
end
# Electric Terrain
if @field.effects[PBEffects::ElectricTerrain]>0
@field.effects[PBEffects::ElectricTerrain]-=1
if @field.effects[PBEffects::ElectricTerrain]==0
pbDisplay(_INTL("The electric current disappeared from the battlefield."))
PBDebug.log("[End of effect] Electric Terrain ended")
end
end
# Grassy Terrain (counting down)
if @field.effects[PBEffects::GrassyTerrain]>0
@field.effects[PBEffects::GrassyTerrain]-=1
if @field.effects[PBEffects::GrassyTerrain]==0
pbDisplay(_INTL("The grass disappeared from the battlefield."))
PBDebug.log("[End of effect] Grassy Terrain ended")
end
end
# Misty Terrain
if @field.effects[PBEffects::MistyTerrain]>0
@field.effects[PBEffects::MistyTerrain]-=1
if @field.effects[PBEffects::MistyTerrain]==0
pbDisplay(_INTL("The mist disappeared from the battlefield."))
PBDebug.log("[End of effect] Misty Terrain ended")
end
end
# Uproar
for i in priority
next if i.fainted?
if i.effects[PBEffects::Uproar]>0
for j in priority
if !j.fainted? && j.status==PBStatuses::SLEEP && !j.hasWorkingAbility(:SOUNDPROOF)
PBDebug.log("[Lingering effect triggered] Uproar woke up #{j.pbThis(true)}")
j.pbCureStatus(false)
pbDisplay(_INTL("{1} woke up in the uproar!",j.pbThis))
end
end
i.effects[PBEffects::Uproar]-=1
if i.effects[PBEffects::Uproar]==0
pbDisplay(_INTL("{1} calmed down.",i.pbThis))
PBDebug.log("[End of effect] #{i.pbThis} is no longer uproaring")
else
pbDisplay(_INTL("{1} is making an uproar!",i.pbThis))
end
end
end
for i in priority
next if i.fainted?
# Speed Boost
# A Pokémon's turncount is 0 if it became active after the beginning of a round
if i.turncount>0 && i.hasWorkingAbility(:SPEEDBOOST)
if i.pbIncreaseStatWithCause(PBStats::SPEED,1,i,PBAbilities.getName(i.ability))
PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
end
end
# Bad Dreams
if i.status==PBStatuses::SLEEP && !i.hasWorkingAbility(:MAGICGUARD)
if i.pbOpposing1.hasWorkingAbility(:BADDREAMS) ||
i.pbOpposing2.hasWorkingAbility(:BADDREAMS)
PBDebug.log("[Ability triggered] #{i.pbThis}'s opponent's Bad Dreams")
hploss=i.pbReduceHP((i.totalhp/8).floor,true)
pbDisplay(_INTL("{1} is having a bad dream!",i.pbThis)) if hploss>0
end
end
if i.fainted?
return if !i.pbFaint
next
end
# Pickup
if i.hasWorkingAbility(:PICKUP) && i.item<=0
item=0; index=-1; use=0
for j in 0...4
next if j==i.index
if @battlers[j].effects[PBEffects::PickupUse]>use
item=@battlers[j].effects[PBEffects::PickupItem]
index=j
use=@battlers[j].effects[PBEffects::PickupUse]
end
end
if item>0
i.item=item
@battlers[index].effects[PBEffects::PickupItem]=0
@battlers[index].effects[PBEffects::PickupUse]=0
@battlers[index].pokemon.itemRecycle=0 if @battlers[index].pokemon.itemRecycle==item
if !@opponent && # In a wild battle
i.pokemon.itemInitial==0 &&
@battlers[index].pokemon.itemInitial==item
i.pokemon.itemInitial=item
@battlers[index].pokemon.itemInitial=0
end
pbDisplay(_INTL("{1} found one {2}!",i.pbThis,PBItems.getName(item)))
i.pbBerryCureCheck(true)
end
end
# Harvest
if i.hasWorkingAbility(:HARVEST) && i.item<=0 && i.pokemon.itemRecycle>0
if pbIsBerry?(i.pokemon.itemRecycle) &&
(pbWeather==PBWeather::SUNNYDAY ||
pbWeather==PBWeather::HARSHSUN || pbRandom(10)<5)
i.item=i.pokemon.itemRecycle
i.pokemon.itemRecycle=0
i.pokemon.itemInitial=i.item if i.pokemon.itemInitial==0
pbDisplay(_INTL("{1} harvested one {2}!",i.pbThis,PBItems.getName(i.item)))
i.pbBerryCureCheck(true)
end
end
# Moody
if i.hasWorkingAbility(:MOODY)
randomup=[]; randomdown=[]
for j in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
randomup.push(j) if i.pbCanIncreaseStatStage?(j,i)
randomdown.push(j) if i.pbCanReduceStatStage?(j,i)
end
if randomup.length>0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (raise stat)")
r=pbRandom(randomup.length)
i.pbIncreaseStatWithCause(randomup[r],2,i,PBAbilities.getName(i.ability))
for j in 0...randomdown.length
if randomdown[j]==randomup[r]
randomdown[j]=nil; randomdown.compact!
break
end
end
end
if randomdown.length>0
PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (lower stat)")
r=pbRandom(randomdown.length)
i.pbReduceStatWithCause(randomdown[r],1,i,PBAbilities.getName(i.ability))
end
end
end
for i in priority
next if i.fainted?
# Toxic Orb
if i.hasWorkingItem(:TOXICORB) && i.status==0 && i.pbCanPoison?(nil,false)
PBDebug.log("[Item triggered] #{i.pbThis}'s Toxic Orb")
i.pbPoison(nil,_INTL("{1} was badly poisoned by its {2}!",i.pbThis,
PBItems.getName(i.item)),true)
end
# Flame Orb
if i.hasWorkingItem(:FLAMEORB) && i.status==0 && i.pbCanBurn?(nil,false)
PBDebug.log("[Item triggered] #{i.pbThis}'s Flame Orb")
i.pbBurn(nil,_INTL("{1} was burned by its {2}!",i.pbThis,PBItems.getName(i.item)))
end
# Sticky Barb
if i.hasWorkingItem(:STICKYBARB) && !i.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Item triggered] #{i.pbThis}'s Sticky Barb")
@scene.pbDamageAnimation(i,0)
i.pbReduceHP((i.totalhp/8).floor)
pbDisplay(_INTL("{1} is hurt by its {2}!",i.pbThis,PBItems.getName(i.item)))
end
if i.fainted?
return if !i.pbFaint
end
end
# Slow Start's end message
if i.hasWorkingAbility(:SLOWSTART) && i.turncount==6
pbDisplay(_INTL("{1} finally got its act together!",i.pbThis))
end
# Form checks
for i in 0...4
next if @battlers[i].fainted?
@battlers[i].pbCheckForm
end
pbGainEXP
pbSwitch
return if @decision>0
for i in priority
next if i.fainted?
i.pbAbilitiesOnSwitchIn(false)
end
# Healing Wish/Lunar Dance - should go here
# Spikes/Toxic Spikes/Stealth Rock - should go here (in order of their 1st use)
for i in 0...4
if @battlers[i].turncount>0 && @battlers[i].hasWorkingAbility(:TRUANT)
@battlers[i].effects[PBEffects::Truant]=!@battlers[i].effects[PBEffects::Truant]
end
if @battlers[i].effects[PBEffects::LockOn]>0 # Also Mind Reader
@battlers[i].effects[PBEffects::LockOn]-=1
@battlers[i].effects[PBEffects::LockOnPos]=-1 if @battlers[i].effects[PBEffects::LockOn]==0
end
@battlers[i].effects[PBEffects::Flinch]=false
@battlers[i].effects[PBEffects::FollowMe]=0
@battlers[i].effects[PBEffects::HelpingHand]=false
@battlers[i].effects[PBEffects::MagicCoat]=false
@battlers[i].effects[PBEffects::Snatch]=false
@battlers[i].effects[PBEffects::Charge]-=1 if @battlers[i].effects[PBEffects::Charge]>0
@battlers[i].lastHPLost=0
@battlers[i].tookDamage=false
@battlers[i].lastAttacker.clear
@battlers[i].effects[PBEffects::Counter]=-1
@battlers[i].effects[PBEffects::CounterTarget]=-1
@battlers[i].effects[PBEffects::MirrorCoat]=-1
@battlers[i].effects[PBEffects::MirrorCoatTarget]=-1
if @battlers[i].effects[PBEffects::Distort] != 0
@battlers[i].type1=PBTypes::PSYCHIC
else
@battlers[i].effects[PBEffects::Distort] -= 1
end
if @battlers[i].effects[PBEffects::IcyRend] != 0
@battlers[i].type1=PBTypes::Water
else
@battlers[i].effects[PBEffects::IcyRend] -= 1
end
if @battlers[i].canBoost?
@battlers[i].speed=(speed*1.5).round
@battlers[i].attack=(user.attack*2).round
@battlers[i].defense=(user.defense*2).round
end
end
for i in 0...2
if !@sides[i].effects[PBEffects::EchoedVoiceUsed]
@sides[i].effects[PBEffects::EchoedVoiceCounter]=0
end
@sides[i].effects[PBEffects::EchoedVoiceUsed]=false
@sides[i].effects[PBEffects::MatBlock]= false
@sides[i].effects[PBEffects::QuickGuard]=false
@sides[i].effects[PBEffects::WideGuard]=false
@sides[i].effects[PBEffects::CraftyShield]=false
@sides[i].effects[PBEffects::Round]=0
end
@field.effects[PBEffects::FusionBolt]=false
@field.effects[PBEffects::FusionFlare]=false
@field.effects[PBEffects::IonDeluge]=false
@field.effects[PBEffects::FairyLock]-=1 if @field.effects[PBEffects::FairyLock]>0
# invalidate stored priority
@usepriority=false
end
end