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

Gen VII Scripts (Z-Moves, Abilities and Moves,)

58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Much appreciated. :-)

I've not yet figured out how to add Psychic Terrain. How would I do that?
 
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Okay, so I tested Merciless on clean Essentials V16, and I get these errors:

(Merciless script pasted on line 534, under Lucky Chant in PokeBattle_Move.)

---------------------------
Pokemon Essentials
---------------------------
Exception: NoMethodError

Message: private method `gsub' called for true:TrueClass

DrawText:215:in `toUnformattedText'

DrawText:225:in `unformattedTextLength'

SpriteWindow:3558:in `setText'

SpriteWindow:3531:in `text='

PokeBattle_Scene:1422:in `pbDisplayMessage'

PokeBattle_Battle:2422:in `pbDisplay'

PokeBattle_BattlerEffects:208:in `pbPoison'

PokeBattle_MoveEffects:230:in `pbEffect'

PokeBattle_Battler:2705:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:2661:in `each'


---------------------------
Pokemon Essentials
---------------------------
Exception: NameError

Message: uninitialized constant PokeBattle_Move::PBStatus

PokeBattle_Move:534:in `pbIsCritical?'

PokeBattle_Move:584:in `pbCalcDamage'

PokeBattle_Move:1265:in `pbEffect'

PokeBattle_Battler:2705:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:2661:in `each'

PokeBattle_Battler:2661:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:3151:in `pbUseMove'

PokeBattle_Battler:3131:in `loop'

PokeBattle_Battler:3154:in `pbUseMove'

PokeBattle_Battler:3350:in `pbProcessTurn'


I did the following:

1) Used Beedrill against one of the trainer characters.
2) Used Toxic on opponent.
3) Get 1st error.
4) Toxic repeats once.
5) Used Pursuit
6) Get 2nd error.
7) Battle loops continually.
8) Retry.
9) Used Twineddle
10) Get 2nd error.
11) Battle loops continually.
 
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Why are you treating a Boolean as a string? Is there a change since 16.2 that makes the Critical hit function return a string instead of a Boolean?

All I did was copy and paste the Merciless code (along with the PBS stuff). I didn't change anything else from the clean Essentials. If the program is running strangely, it's not because of anything that I've modified.

Clean V16.2 does the same thing.
 
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
I tested Stamina, and it gives me an error too.

Code:
Exception: NameErrorMessage: undefined local variable or method `target' for
#<PokeBattle_Battle:0x883a6b8>PokeBattle_Battle:3480:in
`__clauses__pbEndOfRoundPhase'PokeBattle_Clauses:42:in
`pbEndOfRoundPhase'PokeBattle_Battle:2591:in
`pbStartBattleCore'PokeBattle_Battle:2590:in `logonerr'PokeBattle_Battle:2590:in
`pbStartBattleCore'PokeBattle_Battle:2572:in `loop'PokeBattle_Battle:2595:in
`pbStartBattleCore'PokeBattle_Battle:2395:in `pbStartBattle'PTrainer_NPCTrainers:345:in
`pbTrainerBattle'PTrainer_NPCTrainers:344:in `pbSceneStandby'
 
Last edited:
824
Posts
8
Years
I tested Stamina, and it gives me an error too.

Code:
Exception: NameErrorMessage: undefined local variable or method `target' for
#<PokeBattle_Battle:0x883a6b8>PokeBattle_Battle:3480:in
`__clauses__pbEndOfRoundPhase'PokeBattle_Clauses:42:in
`pbEndOfRoundPhase'PokeBattle_Battle:2591:in
`pbStartBattleCore'PokeBattle_Battle:2590:in `logonerr'PokeBattle_Battle:2590:in
`pbStartBattleCore'PokeBattle_Battle:2572:in `loop'PokeBattle_Battle:2595:in
`pbStartBattleCore'PokeBattle_Battle:2395:in `pbStartBattle'PTrainer_NPCTrainers:345:in
`pbTrainerBattle'PTrainer_NPCTrainers:344:in `pbSceneStandby'

Assuming you put my code in the right place, the variable "target" should be defined. Unless, again, this is something in v16 that I'm unaware of.
 
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Assuming you put my code in the right place, the variable "target" should be defined. Unless, again, this is something in v16 that I'm unaware of.

I managed to make Stamina function in V16.2 by modifying the script for Justified. Placing this code above the Justified script in PokeBattle_Battler seemed to work for me:

Code:
if target.hasWorkingAbility(:STAMINA)
          if target.pbIncreaseStatWithCause(PBStats::DEFENSE,1,target,PBAbilities.getName(target.ability))
            PBDebug.log("[Ability triggered] #{target.pbThis}'s Stamina")
          end
        end

I reloaded a clean Essentials V16.2, and Merciless still doesn't function for whatever reason. The aforementioned errors continue to pop up. I don't know if it makes any difference, but I noticed that in the code that you provided for Merciless, you have Frost Breath in that section. In V16.2, that bit of code for Frost Breath is not present there, but the move still works perfectly fine. (I'm a coding noob, so I don't know if that little detail makes any difference. I just figured that I would point it out.)
 
Last edited:
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Shell Trap doesn't work for me. I've tried fiddling around with it as much as I can, but the move always fails.

When the provided code is copied directly into V16.2, I get this error:


Code:
Exception: ArgumentError

Message: wrong number of arguments(3 for 1)

PokeBattle_Battler:1279:in `pbIsPhysical?'

PokeBattle_Battler:1279:in `pbEffectsOnDealingDamage'

PokeBattle_Battler:2780:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:2699:in `each'

PokeBattle_Battler:2699:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:3175:in `pbUseMove'

PokeBattle_Battler:3155:in `loop'

PokeBattle_Battler:3178:in `pbUseMove'

PokeBattle_Battler:3376:in `pbProcessTurn'

PokeBattle_Battler:3375:in `logonerr'

I can edit the code so that the error does not appear, but, again, the move still fails.

For the Move_Effects section, could one use a modified Counter code (minus the "fixed damage" line)?

Edit:

I overlooked the fact that one user above already tried to set up Shell Trap as a modified Counter. Shell Trap isn't a fixed 150 damage though, is it? Rather, I thought that the move had 150 base power? If you listen closely to the Turtonator reveal video, when it uses Shell Trap against a Torkoal and a Carracosta, there is a "Not Very Effective" sound.
 
Last edited:
58
Posts
8
Years
  • Age 32
  • Seen Oct 6, 2019
Floral Healing, Shore Up, and Burn Up function properly, but I'm having issues with Toxic Thread and Speed Swap.

For the provided Toxic Thread code, when I use it, I get this error:


Code:
Exception: NoMethodError

Message: undefined method `index' for true:TrueClass

PokeBattle_BattlerEffects:747:in `pbCanReduceStatStage?'

PokeBattle_MoveEffects:1592:in `pbEffect'

PokeBattle_Battler:2881:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:2837:in `each'

PokeBattle_Battler:2837:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:3313:in `pbUseMove'

PokeBattle_Battler:3293:in `loop'

PokeBattle_Battler:3316:in `pbUseMove'

PokeBattle_Battler:3514:in `pbProcessTurn'

PokeBattle_Battler:3513:in `logonerr'

For Speed Swap: in double battles, when the move is used on an ally, the teammates' Speed stats revert back to normal when the opponent sends in a replacement Pokemon after a K.O. I tested with an Aggron (fully divested of Speed) and a Beedrill (fully invested) on a team, and their stats remained switched until I KO'd any of the opponent's 'mons, at which point Aggron became slower again.
 
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
I haven't done Pollen Puff yet, but here's Spectral Thief:

Code:
################################################################################
# Steals target's stat boosts, then attacks
################################################################################
class PokeBattle_Move_1A1 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.stages[1]>0 || opponent.stages[2]>0 || opponent.stages[3]>0 ||
       opponent.stages[4]>0 || opponent.stages[5]>0 || opponent.stages[6]>0 ||
       opponent.stages[7]>0
      stolenstats=[0,0,0,0,0,0,0,0]
      for i in 0...8
        stolenstats[i]=opponent.stages[i]*1 if opponent.stages[i]>0
        opponent.stages[i]=0 if opponent.stages[i]>0
      end
      @battle.pbDisplay(_INTL("{1} stole {2}'s stat boosts!",attacker.pbThis,opponent.pbThis(true)))
      showanim=true
      for i in 0...6
        if attacker.pbCanIncreaseStatStage?(i,true,attacker) && stolenstats[i]>0
          attacker.pbIncreaseStat(i,stolenstats[i],true,showanim,attacker)
          showanim=false
        end
      end
    end
    # actually attack now
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret
  end
end

I'm not so sure how relevant this is, but this script isn't working for me. I've been trying desperately to make something myself, but don't have any luck. Your script tells me it doesn't understand ">".
 
15
Posts
7
Years
  • Age 36
  • Seen Apr 21, 2023
I tried to create a Spectral Thief, since I'm also having trouble with that code. Could you guys
check if it is working properly? Here it is:


Code:
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,
              PBStats::SPATK,PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
      attacker.stages[i]=opponent.stages[i]
      opponent.stages[i]=0
    end
    @battle.pbDisplay(_INTL("{1} copied {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret    
  end  
end
 
824
Posts
8
Years
I tried to create a Spectral Thief, since I'm also having trouble with that code. Could you guys
check if it is working properly? Here it is:


Code:
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,
              PBStats::SPATK,PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
      attacker.stages[i]=opponent.stages[i]
      opponent.stages[i]=0
    end
    @battle.pbDisplay(_INTL("{1} copied {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret    
  end  
end

Spectral Thief doesn't copy all stat changes. It actually steals positive stat changes.

Code:
################################################################################
# Steals target's stat boosts, then attacks
################################################################################
class PokeBattle_Move_1A1 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.stages[1]>0 || opponent.stages[2]>0 || opponent.stages[3]>0 ||
       opponent.stages[4]>0 || opponent.stages[5]>0 || opponent.stages[6]>0 ||
       opponent.stages[7]>0
      stolenstats=[0,0,0,0,0,0,0,0]
      for i in 0...8
        stolenstats[i]=opponent.stages[i]*1 if opponent.stages[i]>0
        opponent.stages[i]=0 if opponent.stages[i]>0
      end
      @battle.pbDisplay(_INTL("{1} stole {2}'s stat boosts!",attacker.pbThis,opponent.pbThis(true)))
      showanim=true
      for i in 0...6
        if attacker.pbCanIncreaseStatStage?(i,true,attacker) && stolenstats[i]>0
          attacker.pbIncreaseStat(i,stolenstats[i],true,showanim,attacker)
          showanim=false
        end
      end
    end
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret
  end
end
 
15
Posts
7
Years
  • Age 36
  • Seen Apr 21, 2023
Spectral Thief doesn't copy all stat changes. It actually steals positive stat changes.

Code:
################################################################################
# Steals target's stat boosts, then attacks
################################################################################
class PokeBattle_Move_1A1 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.stages[1]>0 || opponent.stages[2]>0 || opponent.stages[3]>0 ||
       opponent.stages[4]>0 || opponent.stages[5]>0 || opponent.stages[6]>0 ||
       opponent.stages[7]>0
      stolenstats=[0,0,0,0,0,0,0,0]
      for i in 0...8
        stolenstats[i]=opponent.stages[i]*1 if opponent.stages[i]>0
        opponent.stages[i]=0 if opponent.stages[i]>0
      end
      @battle.pbDisplay(_INTL("{1} stole {2}'s stat boosts!",attacker.pbThis,opponent.pbThis(true)))
      showanim=true
      for i in 0...6
        if attacker.pbCanIncreaseStatStage?(i,true,attacker) && stolenstats[i]>0
          attacker.pbIncreaseStat(i,stolenstats[i],true,showanim,attacker)
          showanim=false
        end
      end
    end
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret
  end
end

Thanks for your swift answer! I thought the line "opponent.stages=0" after would reset the foe's stat changes to 0, which would be the same as "steal" it. However, I guess if the opponent uses Swords Dance on turn 1, and then Bulk Up on turn 2, "my" Spectral Thief would end with +1 from Bulk Up and would discard the +2 from the Swords Dance, correct?
Anyway, there seems to be a problem with your code. Everytime I use the move it doesn't work, and the error message says something about the ">". Undefined value or method, I don't remember.
 
15
Posts
7
Years
  • Age 36
  • Seen Apr 21, 2023
Well, after the correction from Rot8er_Conex I managed to create a new code for Spectral Thief.
It's horribly ugly, incredibly long and far, far - really far - from elegant, since I can't script, but it
does seems to be working so far.
If there's anybody interested, just post on this thread that I'll put it here.
 

Guest123123

Guest
0
Posts
I need help with First Impression.

To add it, I created a new Move Effect which copies the part of Fake Out's code that fails if it isn't the first turn, but didn't copy the part about flinching since First Impression doesn't make the target flinch unlike Fake Out. I assumed this should work, but I'm getting a Syntax Error on the line where First Impression's move effect ends.

This is the part of Fake Out that I copied (15D being the code for the new First Impression move effect):

lass PokeBattle_Move_15D < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return (attacker.turncount>1)
end

If this works for Fake Out, why wouldn't it work for First Impression?

EDIT: Never mind, I figured it out. I had to add another "end" before the end at the end, I assume for spacing reasons.
 
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
Well, after the correction from Rot8er_Conex I managed to create a new code for Spectral Thief.
It's horribly ugly, incredibly long and far, far - really far - from elegant, since I can't script, but it
does seems to be working so far.
If there's anybody interested, just post on this thread that I'll put it here.

I'd be interested to check it out!;)
 
15
Posts
7
Years
  • Age 36
  • Seen Apr 21, 2023
I'd be interested to check it out!;)

I said it is awfully long and probably overcomplicated, right?
But here's what I got:

Code:
################################################################################
# Spectral Thief
################################################################################
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    if opponent.stages[PBStats::ATTACK]==0
      attacker.pbIncreaseStat(PBStats::ATTACK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==1
      attacker.pbIncreaseStat(PBStats::ATTACK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==2
      attacker.pbIncreaseStat(PBStats::ATTACK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==3
      attacker.pbIncreaseStat(PBStats::ATTACK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==4
      attacker.pbIncreaseStat(PBStats::ATTACK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==5
      attacker.pbIncreaseStat(PBStats::ATTACK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==6
      attacker.pbIncreaseStat(PBStats::ATTACK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    end
    if opponent.stages[PBStats::DEFENSE]==0
      attacker.pbIncreaseStat(PBStats::DEFENSE,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==1
      attacker.pbIncreaseStat(PBStats::DEFENSE,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==2
      attacker.pbIncreaseStat(PBStats::DEFENSE,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==3
      attacker.pbIncreaseStat(PBStats::DEFENSE,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==4
      attacker.pbIncreaseStat(PBStats::DEFENSE,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==5
      attacker.pbIncreaseStat(PBStats::DEFENSE,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==6
      attacker.pbIncreaseStat(PBStats::DEFENSE,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    end
    if opponent.stages[PBStats::SPEED]==0
      attacker.pbIncreaseStat(PBStats::SPEED,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==1
      attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==2
      attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==3
      attacker.pbIncreaseStat(PBStats::SPEED,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==4
      attacker.pbIncreaseStat(PBStats::SPEED,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==5
      attacker.pbIncreaseStat(PBStats::SPEED,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==6
      attacker.pbIncreaseStat(PBStats::SPEED,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    end
    if opponent.stages[PBStats::SPATK]==0
      attacker.pbIncreaseStat(PBStats::SPATK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==1
      attacker.pbIncreaseStat(PBStats::SPATK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==2
      attacker.pbIncreaseStat(PBStats::SPATK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==3
      attacker.pbIncreaseStat(PBStats::SPATK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==4
      attacker.pbIncreaseStat(PBStats::SPATK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==5
      attacker.pbIncreaseStat(PBStats::SPATK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==6
      attacker.pbIncreaseStat(PBStats::SPATK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    end
    if opponent.stages[PBStats::SPDEF]==0
      attacker.pbIncreaseStat(PBStats::SPDEF,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==1
      attacker.pbIncreaseStat(PBStats::SPDEF,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==2
      attacker.pbIncreaseStat(PBStats::SPDEF,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==3
      attacker.pbIncreaseStat(PBStats::SPDEF,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==4
      attacker.pbIncreaseStat(PBStats::SPDEF,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)  
    elsif opponent.stages[PBStats::SPDEF]==5
      attacker.pbIncreaseStat(PBStats::SPDEF,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==6
      attacker.pbIncreaseStat(PBStats::SPDEF,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    end
    if opponent.stages[PBStats::ACCURACY]==0
      attacker.pbIncreaseStat(PBStats::ACCURACY,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==1
      attacker.pbIncreaseStat(PBStats::ACCURACY,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==2
      attacker.pbIncreaseStat(PBStats::ACCURACY,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)  
    elsif opponent.stages[PBStats::ACCURACY]==3
      attacker.pbIncreaseStat(PBStats::ACCURACY,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==4
      attacker.pbIncreaseStat(PBStats::ACCURACY,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==5
      attacker.pbIncreaseStat(PBStats::ACCURACY,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==6
      attacker.pbIncreaseStat(PBStats::ACCURACY,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    end
    if opponent.stages[PBStats::EVASION]==0
      attacker.pbIncreaseStat(PBStats::EVASION,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==1
      attacker.pbIncreaseStat(PBStats::EVASION,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==2
      attacker.pbIncreaseStat(PBStats::EVASION,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==3
      attacker.pbIncreaseStat(PBStats::EVASION,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==4
      attacker.pbIncreaseStat(PBStats::EVASION,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==5
      attacker.pbIncreaseStat(PBStats::EVASION,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==6
      attacker.pbIncreaseStat(PBStats::EVASION,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    end  
    @battle.pbDisplay(_INTL("{1} stole {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret    
  end  
end
 
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
I said it is awfully long and probably overcomplicated, right?
But here's what I got:

Code:
################################################################################
# Spectral Thief
################################################################################
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    if opponent.stages[PBStats::ATTACK]==0
      attacker.pbIncreaseStat(PBStats::ATTACK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==1
      attacker.pbIncreaseStat(PBStats::ATTACK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==2
      attacker.pbIncreaseStat(PBStats::ATTACK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==3
      attacker.pbIncreaseStat(PBStats::ATTACK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==4
      attacker.pbIncreaseStat(PBStats::ATTACK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==5
      attacker.pbIncreaseStat(PBStats::ATTACK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==6
      attacker.pbIncreaseStat(PBStats::ATTACK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    end
    if opponent.stages[PBStats::DEFENSE]==0
      attacker.pbIncreaseStat(PBStats::DEFENSE,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==1
      attacker.pbIncreaseStat(PBStats::DEFENSE,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==2
      attacker.pbIncreaseStat(PBStats::DEFENSE,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==3
      attacker.pbIncreaseStat(PBStats::DEFENSE,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==4
      attacker.pbIncreaseStat(PBStats::DEFENSE,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==5
      attacker.pbIncreaseStat(PBStats::DEFENSE,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==6
      attacker.pbIncreaseStat(PBStats::DEFENSE,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    end
    if opponent.stages[PBStats::SPEED]==0
      attacker.pbIncreaseStat(PBStats::SPEED,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==1
      attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==2
      attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==3
      attacker.pbIncreaseStat(PBStats::SPEED,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==4
      attacker.pbIncreaseStat(PBStats::SPEED,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==5
      attacker.pbIncreaseStat(PBStats::SPEED,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==6
      attacker.pbIncreaseStat(PBStats::SPEED,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    end
    if opponent.stages[PBStats::SPATK]==0
      attacker.pbIncreaseStat(PBStats::SPATK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==1
      attacker.pbIncreaseStat(PBStats::SPATK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==2
      attacker.pbIncreaseStat(PBStats::SPATK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==3
      attacker.pbIncreaseStat(PBStats::SPATK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==4
      attacker.pbIncreaseStat(PBStats::SPATK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==5
      attacker.pbIncreaseStat(PBStats::SPATK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==6
      attacker.pbIncreaseStat(PBStats::SPATK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    end
    if opponent.stages[PBStats::SPDEF]==0
      attacker.pbIncreaseStat(PBStats::SPDEF,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==1
      attacker.pbIncreaseStat(PBStats::SPDEF,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==2
      attacker.pbIncreaseStat(PBStats::SPDEF,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==3
      attacker.pbIncreaseStat(PBStats::SPDEF,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==4
      attacker.pbIncreaseStat(PBStats::SPDEF,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)  
    elsif opponent.stages[PBStats::SPDEF]==5
      attacker.pbIncreaseStat(PBStats::SPDEF,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==6
      attacker.pbIncreaseStat(PBStats::SPDEF,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    end
    if opponent.stages[PBStats::ACCURACY]==0
      attacker.pbIncreaseStat(PBStats::ACCURACY,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==1
      attacker.pbIncreaseStat(PBStats::ACCURACY,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==2
      attacker.pbIncreaseStat(PBStats::ACCURACY,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)  
    elsif opponent.stages[PBStats::ACCURACY]==3
      attacker.pbIncreaseStat(PBStats::ACCURACY,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==4
      attacker.pbIncreaseStat(PBStats::ACCURACY,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==5
      attacker.pbIncreaseStat(PBStats::ACCURACY,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==6
      attacker.pbIncreaseStat(PBStats::ACCURACY,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    end
    if opponent.stages[PBStats::EVASION]==0
      attacker.pbIncreaseStat(PBStats::EVASION,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==1
      attacker.pbIncreaseStat(PBStats::EVASION,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==2
      attacker.pbIncreaseStat(PBStats::EVASION,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==3
      attacker.pbIncreaseStat(PBStats::EVASION,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==4
      attacker.pbIncreaseStat(PBStats::EVASION,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==5
      attacker.pbIncreaseStat(PBStats::EVASION,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==6
      attacker.pbIncreaseStat(PBStats::EVASION,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    end  
    @battle.pbDisplay(_INTL("{1} stole {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret    
  end  
end

I tested it out real quick and it appears to be working as described on Bulbapedia. I haven't really stresstested it though, since I'm lacking time. Even though it's massive, it worked well, which is what matters. Other Spectral Thief's I tested didn't work for me, so this one ends up being the best one for me.
 
824
Posts
8
Years
I said it is awfully long and probably overcomplicated, right?
But here's what I got:

Code:
################################################################################
# Spectral Thief
################################################################################
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    if opponent.stages[PBStats::ATTACK]==0
      attacker.pbIncreaseStat(PBStats::ATTACK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==1
      attacker.pbIncreaseStat(PBStats::ATTACK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==2
      attacker.pbIncreaseStat(PBStats::ATTACK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==3
      attacker.pbIncreaseStat(PBStats::ATTACK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==4
      attacker.pbIncreaseStat(PBStats::ATTACK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==5
      attacker.pbIncreaseStat(PBStats::ATTACK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    elsif opponent.stages[PBStats::ATTACK]==6
      attacker.pbIncreaseStat(PBStats::ATTACK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.pbReduceStat(PBStats::ATTACK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
    end
    if opponent.stages[PBStats::DEFENSE]==0
      attacker.pbIncreaseStat(PBStats::DEFENSE,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==1
      attacker.pbIncreaseStat(PBStats::DEFENSE,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==2
      attacker.pbIncreaseStat(PBStats::DEFENSE,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==3
      attacker.pbIncreaseStat(PBStats::DEFENSE,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==4
      attacker.pbIncreaseStat(PBStats::DEFENSE,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==5
      attacker.pbIncreaseStat(PBStats::DEFENSE,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    elsif opponent.stages[PBStats::DEFENSE]==6
      attacker.pbIncreaseStat(PBStats::DEFENSE,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.pbReduceStat(PBStats::DEFENSE,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
    end
    if opponent.stages[PBStats::SPEED]==0
      attacker.pbIncreaseStat(PBStats::SPEED,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==1
      attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==2
      attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==3
      attacker.pbIncreaseStat(PBStats::SPEED,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==4
      attacker.pbIncreaseStat(PBStats::SPEED,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==5
      attacker.pbIncreaseStat(PBStats::SPEED,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    elsif opponent.stages[PBStats::SPEED]==6
      attacker.pbIncreaseStat(PBStats::SPEED,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPEED,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
    end
    if opponent.stages[PBStats::SPATK]==0
      attacker.pbIncreaseStat(PBStats::SPATK,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==1
      attacker.pbIncreaseStat(PBStats::SPATK,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==2
      attacker.pbIncreaseStat(PBStats::SPATK,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==3
      attacker.pbIncreaseStat(PBStats::SPATK,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==4
      attacker.pbIncreaseStat(PBStats::SPATK,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==5
      attacker.pbIncreaseStat(PBStats::SPATK,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    elsif opponent.stages[PBStats::SPATK]==6
      attacker.pbIncreaseStat(PBStats::SPATK,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPATK,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
    end
    if opponent.stages[PBStats::SPDEF]==0
      attacker.pbIncreaseStat(PBStats::SPDEF,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==1
      attacker.pbIncreaseStat(PBStats::SPDEF,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==2
      attacker.pbIncreaseStat(PBStats::SPDEF,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==3
      attacker.pbIncreaseStat(PBStats::SPDEF,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==4
      attacker.pbIncreaseStat(PBStats::SPDEF,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)  
    elsif opponent.stages[PBStats::SPDEF]==5
      attacker.pbIncreaseStat(PBStats::SPDEF,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    elsif opponent.stages[PBStats::SPDEF]==6
      attacker.pbIncreaseStat(PBStats::SPDEF,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.pbReduceStat(PBStats::SPDEF,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
    end
    if opponent.stages[PBStats::ACCURACY]==0
      attacker.pbIncreaseStat(PBStats::ACCURACY,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==1
      attacker.pbIncreaseStat(PBStats::ACCURACY,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==2
      attacker.pbIncreaseStat(PBStats::ACCURACY,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)  
    elsif opponent.stages[PBStats::ACCURACY]==3
      attacker.pbIncreaseStat(PBStats::ACCURACY,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==4
      attacker.pbIncreaseStat(PBStats::ACCURACY,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==5
      attacker.pbIncreaseStat(PBStats::ACCURACY,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    elsif opponent.stages[PBStats::ACCURACY]==6
      attacker.pbIncreaseStat(PBStats::ACCURACY,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.pbReduceStat(PBStats::ACCURACY,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
    end
    if opponent.stages[PBStats::EVASION]==0
      attacker.pbIncreaseStat(PBStats::EVASION,0,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,0,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==1
      attacker.pbIncreaseStat(PBStats::EVASION,1,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,1,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==2
      attacker.pbIncreaseStat(PBStats::EVASION,2,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,2,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==3
      attacker.pbIncreaseStat(PBStats::EVASION,3,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,3,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==4
      attacker.pbIncreaseStat(PBStats::EVASION,4,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,4,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==5
      attacker.pbIncreaseStat(PBStats::EVASION,5,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,5,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    elsif opponent.stages[PBStats::EVASION]==6
      attacker.pbIncreaseStat(PBStats::EVASION,6,attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.pbReduceStat(PBStats::EVASION,6,attacker,false,self) if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
    end  
    @battle.pbDisplay(_INTL("{1} stole {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret    
  end  
end

1.) If a stat stage is 0, nothing happens. No need to raise attacker by 0 and lower opponent by 0.

2.) As shown by this video, the stats do not get lowered, they get reset. There's no animation.

3.) Rather than doing "if x==1, f(1), elsif x==2, f(2), elsif x==3, f(3), etc.", this can be all combined into "f(x) if x>0".

Code:
################################################################################
# Spectral Thief
################################################################################
class PokeBattle_Move_167 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if opponent.pbOwnSide.effects[PBEffects::CraftyShield]
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    @battle.pbDisplay(_INTL("{1} stole {2}'s stat changes!",attacker.pbThis,opponent.pbThis(true)))
    if opponent.stages[PBStats::ATTACK]>0
      attacker.pbIncreaseStat(PBStats::ATTACK,opponent.stages[PBStats::ATTACK],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
      opponent.stages[PBStats::ATTACK]=0
    end
    if opponent.stages[PBStats::DEFENSE]>0
      attacker.pbIncreaseStat(PBStats::DEFENSE,opponent.stages[PBStats::DEFENSE],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
      opponent.stages[PBStats::DEFENSE]=0
    end
    if opponent.stages[PBStats::SPATK]>0
      attacker.pbIncreaseStat(PBStats::SPATK,opponent.stages[PBStats::SPATK],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
      opponent.stages[PBStats::SPATK]=0
    end
    if opponent.stages[PBStats::SPDEF]>0
      attacker.pbIncreaseStat(PBStats::SPDEF,opponent.stages[PBStats::SPDEF],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
      opponent.stages[PBStats::SPDEF]=0
    end
    if opponent.stages[PBStats::SPEED]>0
      attacker.pbIncreaseStat(PBStats::SPEED,opponent.stages[PBStats::SPEED],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
      opponent.stages[PBStats::SPEED]=0
    end
    if opponent.stages[PBStats::ACCURACY]>0
      attacker.pbIncreaseStat(PBStats::ACCURACY,opponent.stages[PBStats::ACCURACY],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,attacker,false,self)
      opponent.stages[PBStats::ACCURACY]=0
    end
    if opponent.stages[PBStats::EVASION]>0
      attacker.pbIncreaseStat(PBStats::EVASION,opponent.stages[PBStats::EVASION],attacker,false,self) if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
      opponent.stages[PBStats::EVASION]=0
    end
    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
    return ret
  end  
end

Optimization. It's a thing.
 
Back
Top