Improved Pursuit's code (improved 12/30):
In 'PokeBattle_Battler' script, add 'attr_accessor :switching' below 'attr_accessor :captured';
Inside Follow Me's code, add '!target.switching':
Now, replace the code below '# Pokémon switching caused by U-Turn, Volt Switch, Eject Button' for:
Finally, replace the function for Pursuit inside 'PokeBattle_MoveEffects' script:
Wimp Out and Emergency Exit:
In 'PokeBattle_Battler' script, look for 'def pbEffectsAfterHit(user,target,thismove,turneffects)' and replace Shell Bell's code:
Also, I edited the codes for Red Card and Eject Button. If you want:
Now, add the code for these abilities, below Color Change's code:
Then, we need add these abilities inside Stealth Rock and Spike code:
And finally, replace the code for the move, inside 'PokeBattle_MoveEffects':
Hyperspace Hole:
Spoiler:
In 'PokeBattle_Battler' script, add 'attr_accessor :switching' below 'attr_accessor :captured';
Inside Follow Me's code, add '!target.switching':
Code:
# Change target to user of Follow Me (overrides Magic Coat
# because check for Magic Coat below uses this target)
if PBTargets.targetsOneOpponent?(thismove)
newtarget=nil; strength=100
for i in priority # use Pokémon latest in priority
next if !user.pbIsOpposing?(i.index)
if !i.fainted? && [email protected] && !target.switching && !i.effects[PBEffects::SkyDrop] &&
i.effects[PBEffects::FollowMe]>0 && i.effects[PBEffects::FollowMe]<strength
PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Follow Me")
newtarget=i; strength=i.effects[PBEffects::FollowMe]
changeeffect=0
end
end
target=newtarget if newtarget
end
Now, replace the code below '# Pokémon switching caused by U-Turn, Volt Switch, Eject Button' for:
Spoiler:
Code:
# Pokémon switching caused by U-Turn, Volt Switch, Eject Button
switched=[]
for i in 0...4
pursuit=false
if @battle.battlers[i].effects[PBEffects::Uturn]
@battle.battlers[i].switching=true
@battle.battlers[i].effects[PBEffects::Uturn]=false
@battle.battlers[i].effects[PBEffects::Roar]=false
if [email protected][i].fainted? && @battle.pbCanChooseNonActive?(i) &&
[email protected]?(@battle.pbOpposingParty(i))
# TODO: Pursuit should go here, and negate this effect if it KO's attacker
for j in @battle.pbPriority
next if [email protected][i].pbIsOpposing?(j.index)
next if pursuit
[email protected][j.index][1]
# if Pursuit and this target ("i") was chosen
if @battle.battlers[j.index].moves[oppmove].function==0x88 && !j.hasMovedThisRound? # Pursuit
if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
!j.effects[PBEffects::SkyDrop] && (!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
pursuit=true
@battle.choices[j.index][3][email protected][i].index # Make sure to target the switching Pokémon
j.pbUseMove(@battle.choices[j.index]) # This calls pbGainEXP as appropriate
j.effects[PBEffects::Pursuit]=true
return if @battle.decision>0
end
end
end
@battle.battlers[i].switching=false
break if @battle.battlers[i].fainted?
@battle.pbDisplay(_INTL("{1} went back to {2}!",@battle.battlers[i].pbThis,@battle.pbGetOwner(i).name))
newpoke=0
[email protected](i,true,false)
newpokename=newpoke
if isConst?(@battle.pbParty(i)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(i)
end
switched.push(i)
@battle.battlers[i].pbResetForm
@battle.pbRecallAndReplace(i,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
@battle.choices[i]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
end
end
end
for i in @battle.pbPriority
next if !switched.include?(i.index)
i.pbAbilitiesOnSwitchIn(true)
end
# Baton Pass
Finally, replace the function for Pursuit inside 'PokeBattle_MoveEffects' script:
Code:
################################################################################
# Power is doubled if a foe tries to switch out or use U-turn/Volt Switch/
# Parting Shot. (Pursuit)
# (Handled in Battle's pbAttackPhase): Makes this attack happen before switching.
################################################################################
class PokeBattle_Move_088 < PokeBattle_Move
def pbBaseDamage(basedmg,attacker,opponent)
if @battle.switching || opponent.switching
PBDebug.log("[Move Effect] #{attacker.pbThis} double Pursuit damage")
return basedmg*2
end
return basedmg
end
def pbAccuracyCheck(attacker,opponent)
return true if @battle.switching || opponent.switching
return super(attacker,opponent)
end
end
Wimp Out and Emergency Exit:
Spoiler:
In 'PokeBattle_Battler' script, look for 'def pbEffectsAfterHit(user,target,thismove,turneffects)' and replace Shell Bell's code:
Code:
# Shell Bell
if user.hasWorkingItem(:SHELLBELL) && user.effects[PBEffects::HealBlock]==0
PBDebug.log("[Item triggered] #{user.pbThis}'s Shell Bell (total damage=#{turneffects[PBEffects::TotalDamage]})")
previoushp=user.hp
hpgain=user.pbRecoverHP((turneffects[PBEffects::TotalDamage]/8).floor,true)
if hpgain>0
@battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!",user.pbThis,PBItems.getName(user.item)))
end
# Wimp Out/ Emergency Exit
if (user.hasWorkingAbility(:WIMPOUT) || user.hasWorkingAbility(:EMERGENCYEXIT)) && !user.fainted?
if hpgain>0 && (previoushp<=(user.totalhp/2).floor && user.hp>(user.totalhp/2).floor)
if [email protected]
pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled!",user.pbThis))
for i in 0...4; @battle.choices[@battle.battlers[i].index][0]=-1; end
@battle.decision=3
PBDebug.log("[Escape] #{user.pbThis} fled")
else
if @battle.pbCanSwitch?(user.index,-1,false) && @battle.pbCanChooseNonActive?(user.index)
newpoke=0
[email protected](user.index,true,false)
newpokename=newpoke
if isConst?(@battle.pbParty(user.index)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(user.index)
end
user.pbResetForm
@battle.pbRecallAndReplace(user.index,newpoke,newpokename) #,@battle.battlers[i].effects[PBEffects::BatonPass])
@battle.choices[user.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
user.pbAbilitiesOnSwitchIn(true)
end
end
end
end
end
# Life Orb
Also, I edited the codes for Red Card and Eject Button. If you want:
Spoiler:
Code:
def pbEffectsAfterHit(user,target,thismove,turneffects)
return if turneffects[PBEffects::TotalDamage]==0
if !(user.hasWorkingAbility(:SHEERFORCE) && thismove.addlEffect>0)
# Target's held items:
# Red Card
if target.hasWorkingItem(:REDCARD) && @battle.pbCanSwitch?(user.index,-1,false) &&
!user.fainted? && @battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("{1} held up its {2} against the {3}!",target.pbThis,PBItems.getName(target.item),user.pbThis(true)))
target.pbConsumeItem
choices=[]
[email protected](user.index)
for j in 0...party.length
choices.push(j) if @battle.pbCanSwitchLax?(user.index,j,false)
end
if choices.length>0
newpoke=choices[@battle.pbRandom(choices.length)]
newpokename=newpoke
if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(user.index)
end
user.pbResetForm
@battle.pbRecallAndReplace(user.index,newpoke,newpokename,false,
user.hasMoldBreaker || thismove.ignoresAbilities?)
@battle.pbDisplay(_INTL("{1} was dragged out!",user.pbThis))
@battle.choices[user.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
user.pbAbilitiesOnSwitchIn(true)
end
# Eject Button
elsif target.hasWorkingItem(:EJECTBUTTON) && @battle.pbCanChooseNonActive?(target.index)
@battle.pbDisplay(_INTL("{1} is switched out with the {2}!",target.pbThis,PBItems.getName(target.item)))
target.pbConsumeItem(false,true)
newpoke=0
[email protected](target.index,true,false)
newpokename=newpoke
if isConst?(@battle.pbParty(target.index)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(i)
end
@battle.battlers[target.index].pbResetForm
@battle.pbRecallAndReplace(target.index,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
@battle.choices[target.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
target.pbAbilitiesOnSwitchIn(true)
end
# User's held items:
# Shell Bell
Now, add the code for these abilities, below Color Change's code:
Code:
# Wimp Out/ Emergency Exit
if (target.hasWorkingAbility(:WIMPOUT) || target.hasWorkingAbility(:EMERGENCYEXIT)) &&
!target.effects[PBEffects::SkyDrop] && thismove.function!=0x0EC # Circle Throw, Dragon Tail
if target.hp+turneffects[PBEffects::TotalDamage]>(target.totalhp/2).floor &&
target.hp<=(target.totalhp/2).floor
PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
if [email protected]
pbSEPlay("Battle flee"); @battle.pbDisplay(_INTL("{1} fled!",target.pbThis))
for i in 0...4
@battle.choices[@battle.battlers[i].index][0]=-1
end
@battle.decision=3
PBDebug.log("[Escape] #{target.pbThis} fled")
else
if @battle.pbCanSwitch?(target.index,-1,false) &&@battle.pbCanChooseNonActive?(target.index)
newpoke=0
[email protected](target.index,true,false)
newpokename=newpoke
if isConst?(@battle.pbParty(target.index)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(target.index)
end
target.pbResetForm
@battle.pbRecallAndReplace(target.index,newpoke,newpokename)
@battle.choices[target.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
target.pbAbilitiesOnSwitchIn(true)
end
end
end
end
end
# Moxie
Then, we need add these abilities inside Stealth Rock and Spike code:
Spoiler:
Code:
# Spikes
if pkmn.pbOwnSide.effects[PBEffects::Spikes]>0 && !pkmn.isAirborne?(moldbreaker)
if !pkmn.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Spikes")
spikesdiv=[8,6,4][pkmn.pbOwnSide.effects[PBEffects::Spikes]-1]
@scene.pbDamageAnimation(pkmn,0)
currentHP=pkmn.hp
pkmn.pbReduceHP((pkmn.totalhp/spikesdiv).floor)
pbDisplayPaused(_INTL("{1} is hurt by the spikes!",pkmn.pbThis))
if (pkmn.hasWorkingAbility(:WIMPOUT) || pkmn.hasWorkingAbility(:EMERGENCYEXIT)) && !pkmn.fainted?
pkmn.pbBerryCureCheck(true)
if currentHP>=(pkmn.totalhp/2).floor && pkmn.hp<=(pkmn.totalhp/2).floor
PBDebug.log("[Ability triggered] #{pkmn.pbThis}'s #{PBAbilities.getName(pkmn.ability)}")
if !@opponent
pbSEPlay("Battle flee"); @battle.pbDisplay(_INTL("{1} fled!",pkmn.pbThis))
for i in 0...4; @battle.choices[@battle.battlers[i].index][0]=-1; end
@decision=3
PBDebug.log("[Escape] #{pkmn.pbThis} fled")
else
if pbCanSwitch?(pkmn.index,-1,false) && @battle.pbCanChooseNonActive?(pkmn.index)
newpoke=0
newpoke=pbSwitchInBetween(pkmn.index,true,false)
newpokename=newpoke
if isConst?(pbParty(pkmn.index)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(pkmn.index)
end
pkmn.pbResetForm
pbRecallAndReplace(pkmn.index,newpoke,newpokename)
@choices[pkmn.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
pkmn.pbAbilitiesOnSwitchIn(true)
end
end
end
end
end
end
pkmn.pbFaint if pkmn.fainted?
# Stealth Rock
if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
if !pkmn.hasWorkingAbility(:MAGICGUARD)
atype=getConst(PBTypes,:ROCK) || 0
eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
if eff>0
PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
@scene.pbDamageAnimation(pkmn,0)
currentHP=pkmn.hp
pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
if (pkmn.hasWorkingAbility(:WIMPOUT) || pkmn.hasWorkingAbility(:EMERGENCYEXIT)) && !pkmn.fainted?
pkmn.pbBerryCureCheck(true)
if currentHP>=(pkmn.totalhp/2).floor && pkmn.hp<=(pkmn.totalhp/2).floor
PBDebug.log("[Ability triggered] #{pkmn.pbThis}'s #{PBAbilities.getName(pkmn.ability)}")
if !@opponent
pbSEPlay("Battle flee"); @battle.pbDisplay(_INTL("{1} fled!",pkmn.pbThis))
for i in 0...4; @battle.choices[@battle.battlers[i].index][0]=-1; end
@decision=3
PBDebug.log("[Escape] #{pkmn.pbThis} fled")
else
if pbCanSwitch?(pkmn.index,-1,false) && @battle.pbCanChooseNonActive?(pkmn.index)
newpoke=0
newpoke=pbSwitchInBetween(pkmn.index,true,false)
newpokename=newpoke
if isConst?(pbParty(pkmn.index)[newpoke].ability,PBAbilities,:ILLUSION)
newpokename=pbGetLastPokeInTeam(pkmn.index)
end
pkmn.pbResetForm
pbRecallAndReplace(pkmn.index,newpoke,newpokename)
@choices[pkmn.index]=[0,0,nil,-1] # Replacement Pokémon does nothing this round
pkmn.pbAbilitiesOnSwitchIn(true)
end
end
end
end
end
end
end
pkmn.pbFaint if pkmn.fainted?
# Toxic Spikes
And finally, replace the code for the move, inside 'PokeBattle_MoveEffects':
Code:
################################################################################
# After inflicting damage, user switches out. Ignores trapping moves.
# (U-turn, Volt Switch)
# TODO: Pursuit should interrupt this move.
################################################################################
class PokeBattle_Move_0EE < PokeBattle_Move
def pbEffectAfterHit(attacker,opponent,turneffects)
if !attacker.fainted? && opponent.damagestate.calcdamage>0 &&
@battle.pbCanChooseNonActive?(attacker.index) && [email protected]?(@battle.pbParty(opponent.index))
if (opponent.hasWorkingAbility(:WIMPOUT) || opponent.hasWorkingAbility(:EMERGENCYEXIT)) &&
opponent.hp+turneffects[PBEffects::TotalDamage]>(opponent.totalhp/2).floor &&
opponent.hp<=(opponent.totalhp/2).floor
attacker.effects[PBEffects::Uturn]=false
else
attacker.effects[PBEffects::Uturn]=true
end
end
end
end
Hyperspace Hole:
Spoiler:
Code:
################################################################################
# Always hits. (Hyperspace Hole)
################################################################################
class PokeBattle_Move_147 < PokeBattle_Move
def pbAccuracyCheck(attacker,opponent)
return true
end
def pbEffectAfterHit(attacker,opponent,turneffects)
if !opponent.fainted? && opponent.damagestate.calcdamage>0
opponent.effects[PBEffects::Protect]=false
opponent.effects[PBEffects::KingsShield]=false
opponent.effects[PBEffects::SpikyShield]=false
opponent.effects[PBEffects::BanefulBunker]=false
opponent.pbOwnSide.effects[PBEffects::QuickGuard]=false
opponent.pbOwnSide.effects[PBEffects::WideGuard]=false
opponent.pbOwnSide.effects[PBEffects::CraftyShield]=false
opponent.pbOwnSide.effects[PBEffects::MatBlock]=false
end
end
end
Last edited: