Male
Seen April 10th, 2020
Posted January 13th, 2017
15 posts
4.3 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:


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

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 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:


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.

################################################################################
# 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
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
Male
Seen April 10th, 2020
Posted January 13th, 2017
15 posts
4.3 Years
Spectral Thief doesn't copy all stat changes. It actually steals positive stat changes.

################################################################################
# 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[i]=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.
Female
Seen 2 Days Ago
Posted February 20th, 2018
186 posts
12.3 Years
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.

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
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!;)
Male
Seen April 10th, 2020
Posted January 13th, 2017
15 posts
4.3 Years
I'd be interested to check it out!;)
I said it is awfully long and probably overcomplicated, right?
But here's what I got:

################################################################################
# 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

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
I said it is awfully long and probably overcomplicated, right?
But here's what I got:

################################################################################
# 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.

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 Years
I said it is awfully long and probably overcomplicated, right?
But here's what I got:

################################################################################
# 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".

################################################################################
# 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.
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
How would I make a move like Revelation Dance that checks for the user's first type and change the move's type to match it? This is what I made out of it, but it doesn't work.

class PokeBattle_Move_CF25 < PokeBattle_Move
  def pbModifyType(type,attacker,opponent)
    type=getConst(attacker.type1)
    return type
  end
end

rigbycwts

Hmm, hmm.

Male
Seen February 22nd, 2019
Posted September 27th, 2017
98 posts
7.7 Years
Tried coding the ability Dancer. First, this goes in PokeBattle_Move, below the isBombMove function block:
  def isDanceMove?
    return isConst?(@id,PBMoves,:QUIVERDANCE) ||
           isConst?(@id,PBMoves,:DRAGONDANCE) ||
           isConst?(@id,PBMoves,:FIERYDANCE) ||
           isConst?(@id,PBMoves,:FEATHERDANCE) ||
           isConst?(@id,PBMoves,:PETALDANCE) ||
           isConst?(@id,PBMoves,:SWORDSDANCE) ||
           isConst?(@id,PBMoves,:TEETERDANCE) ||
           isConst?(@id,PBMoves,:LUNARDANCE) ||
           isConst?(@id,PBMoves,:RAINDANCE) ||
           isConst?(@id,PBMoves,:REVELATIONDANCE)
  end
Then this goes in PokeBattle_Battler above Intimidate:
    # Dancer. Kinda buggy.
    if self.hasWorkingAbility(:DANCER)
      user=self
      targetIndex=0
      hasMoved=false
      for i in 0...4       
        targetLastMoveUsed = PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(@battle.battlers[i].lastMoveUsed))
        if targetLastMoveUsed.isDanceMove?
          target = @battle.battlers[i]
          targetIndex=i
          moveToCopy = targetLastMoveUsed
          moveIDToCopy = @battle.battlers[i].lastMoveUsed
        end
      end
      if moveToCopy && moveToCopy.isDanceMove?
        PBDebug.log("[Ability triggered] #{pbThis}'s Dancer")
        @battle.pbDisplay(_INTL("Dancer copied {1}!",moveToCopy))
        user.pbUseMoveSimple(moveIDToCopy,-1,pbOppositeOpposing)
      end
    end
I don't know what causes the user, Oricorio in this case, to repeat this ability over and over. If any other Pokemon use a move like Swords Dance for example, then this Ability activates, it goes to an infinite loop. The infinite loop also happens when Oricorio is under the effects of Taunt and any other Pokemon uses a status move that is a dance move, such as Dragon Dance.
Coming soon: Pokemon Collective and Mercantile Versions.

My college-life-advice blog.

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 Years
Mutant Yoshi and I got Dancer to work. Lemme look at the code we used:

    if thismove.isDanceMove? && !specialusage
      for battler in @battle.battlers
        if battler.hasWorkingAbility(:DANCER) && battler.index != user.index
          @battle.pbDisplayEffect(battler)
          movedalready=battler.lastRoundMoved*1
          battler.pbUseMoveSimple(thismove.id,-1,user.index)
          battler.lastRoundMoved=movedalready*1
        end
      end
    end
This goes in PokeBattle_Battler, above line 3770 which is in the middle of the game recording which move was just moved.
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
Mutant Yoshi and I got Dancer to work. Lemme look at the code we used:

    if thismove.isDanceMove? && !specialusage
      for battler in @battle.battlers
        if battler.hasWorkingAbility(:DANCER) && battler.index != user.index
          @battle.pbDisplayEffect(battler)
          movedalready=battler.lastRoundMoved*1
          battler.pbUseMoveSimple(thismove.id,-1,user.index)
          battler.lastRoundMoved=movedalready*1
        end
      end
    end
This goes in PokeBattle_Battler, above line 3770 which is in the middle of the game recording which move was just moved.
PokeBattle_Battler naturally only has 3355 lines, could you specify a line it's below or above? I tried a few things but they didn't work.

rigbycwts

Hmm, hmm.

Male
Seen February 22nd, 2019
Posted September 27th, 2017
98 posts
7.7 Years
PokeBattle_Battler naturally only has 3355 lines, could you specify a line it's below or above? I tried a few things but they didn't work.
If you are using Essentials 16.2, try checking the function def pbProcessTurn(choice). Possibly it's this function.
Coming soon: Pokemon Collective and Mercantile Versions.

My college-life-advice blog.

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 Years
PokeBattle_Battler naturally only has 3355 lines, could you specify a line it's below or above? I tried a few things but they didn't work.
Okay, I looked at a clean version of 16.2. The code you need to paste it under is found on lines 3233-3238 of PokeBattle_Battler.
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
Male
Seen October 1st, 2020
Posted July 10th, 2018
294 posts
5 Years
I'm trying to code Core Enforcer but it does nothing when it goes lost even if I gave it 85 base power.

################################################################################
# If used after the target Attacks, the target's ability is removed. (Core Enforcer)
################################################################################

class PokeBattle_Move_15A < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    if @battle.choices[opponent.index][0]!=1 || # Didn't choose a move
       opponent.hasMovedThisRound? # Used a move already
      return pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    opponent.effects[PBEffects::GastroAcid]=true
    end
    return basedmg
  end
end

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
I'm trying to code Core Enforcer but it does nothing when it goes lost even if I gave it 85 base power.

################################################################################
# If used after the target Attacks, the target's ability is removed. (Core Enforcer)
################################################################################

class PokeBattle_Move_15A < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    if @battle.choices[opponent.index][0]!=1 || # Didn't choose a move
       opponent.hasMovedThisRound? # Used a move already
      return pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
    opponent.effects[PBEffects::GastroAcid]=true
    end
    return basedmg
  end
end
I'm not sure if I had this fully functional yet, but this is what I once made:
################################################################################
# Deals damage. If target has already moved, its ability will be supressed.
# (Core Enforcer)
################################################################################
class PokeBattle_Move_CF21 < PokeBattle_Move
  def pbEffectAfterHit(attacker,opponent,turneffects)
    if opponent.hasMovedThisRound?
      if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
        @battle.pbDisplay(_INTL("But it failed!"))  
        return -1
      end
      if isConst?(opponent.ability,PBAbilities,:MULTITYPE) ||
         isConst?(opponent.ability,PBAbilities,:STANCECHANGE) ||
         isConst?(opponent.ability,PBAbilities,:SCHOOLING) ||
         isConst?(opponent.ability,PBAbilities,:COMATOSE) ||
         isConst?(opponent.ability,PBAbilities,:SHIELDSDOWN) ||
         isConst?(opponent.ability,PBAbilities,:DISGUISE) ||
         isConst?(opponent.ability,PBAbilities,:RKSSYSTEM) ||
         isConst?(opponent.ability,PBAbilities,:BATTLEBOND) ||
         isConst?(opponent.ability,PBAbilities,:POWERCONSTRUCT)
        return -1
      end
      pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
      oldabil=opponent.ability
      opponent.effects[PBEffects::GastroAcid]=true
      opponent.effects[PBEffects::Truant]=false
      @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",opponent.pbThis)) 
      if opponent.effects[PBEffects::Illusion] && isConst?(oldabil,PBAbilities,:ILLUSION)
        PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Illusion ended")    
        opponent.effects[PBEffects::Illusion]=nil
        @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
        @battle.pbDisplay(_INTL("{1}'s {2} wore off!",opponent.pbThis,PBAbilities.getName(oldabil)))
      end
      return 0
    end
  end
end

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 Years
I'm not sure if I had this fully functional yet, but this is what I once made:
################################################################################
# Deals damage. If target has already moved, its ability will be supressed.
# (Core Enforcer)
################################################################################
class PokeBattle_Move_CF21 < PokeBattle_Move
  def pbEffectAfterHit(attacker,opponent,turneffects)
    if opponent.hasMovedThisRound?
      if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
        return -1
      end
      if isConst?(opponent.ability,PBAbilities,:MULTITYPE) ||
         isConst?(opponent.ability,PBAbilities,:STANCECHANGE) ||
         isConst?(opponent.ability,PBAbilities,:SCHOOLING) ||
         isConst?(opponent.ability,PBAbilities,:COMATOSE) ||
         isConst?(opponent.ability,PBAbilities,:SHIELDSDOWN) ||
         isConst?(opponent.ability,PBAbilities,:DISGUISE) ||
         isConst?(opponent.ability,PBAbilities,:RKSSYSTEM) ||
         isConst?(opponent.ability,PBAbilities,:BATTLEBOND) ||
         isConst?(opponent.ability,PBAbilities,:POWERCONSTRUCT)
        return -1
      end
      pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
      oldabil=opponent.ability
      opponent.effects[PBEffects::GastroAcid]=true
      opponent.effects[PBEffects::Truant]=false
      @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",opponent.pbThis)) 
      if opponent.effects[PBEffects::Illusion] && isConst?(oldabil,PBAbilities,:ILLUSION)
        PBDebug.log("[Ability triggered] #{opponent.pbThis}'s Illusion ended")    
        opponent.effects[PBEffects::Illusion]=nil
        @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
        @battle.pbDisplay(_INTL("{1}'s {2} wore off!",opponent.pbThis,PBAbilities.getName(oldabil)))
      end
      return 0
    end
  end
end
Fixed your code. It doesn't say "but it failed!" since the move does do damage.

Also, here's a version of the move written for v15 where the "effects after hit" function doesn't exist.

################################################################################
# If the target has already moved this round, supresses target's ability
################################################################################
class PokeBattle_Move_1B8 < PokeBattle_Move
  def pbAdditionalEffect(attacker,opponent)
    if !(opponent.hasMovedThisRound? && opponent.lastMoveUsed<=0)
      return false
    end
    if isConst?(opponent.ability,PBAbilities,:MULTITYPE) ||
       isConst?(opponent.ability,PBAbilities,:STANCECHANGE) ||
       isConst?(opponent.ability,PBAbilities,:DELTASTREAM) ||
       isConst?(opponent.ability,PBAbilities,:PRIMORDIALSEA) ||
       isConst?(opponent.ability,PBAbilities,:DESOLATELAND) ||
       isConst?(opponent.ability,PBAbilities,:SCHOOLING) ||
       isConst?(opponent.ability,PBAbilities,:COMATOSE) ||
       isConst?(opponent.ability,PBAbilities,:SHIELDSDOWN) ||
       isConst?(opponent.ability,PBAbilities,:DISGUISE) ||
       isConst?(opponent.ability,PBAbilities,:RKSSYSTEM) ||
       isConst?(opponent.ability,PBAbilities,:BATTLEBOND) ||
       isConst?(opponent.ability,PBAbilities,:POWERCONSTRUCT)
      return false
    end
    opponent.effects[PBEffects::GastroAcid]=true
    opponent.effects[PBEffects::Truant]=false
    @battle.pbDisplay(_INTL("{1}'s ability was suppressed!",opponent.pbThis)) 
    if opponent.effects[PBEffects::Illusion]!=nil #ILLUSION
      # Animation should go here
      # Break the illusion
      opponent.effects[PBEffects::Illusion]=nil
      @battle.pbDisplayEffect(opponent)
      @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
      @battle.pbDisplay(_INTL("{1}'s {2} wore off!",opponent.pbThis,
          PBAbilities.getName(opponent.ability)))
    end #ILLUSION
    return true
  end
end
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
Fixed your code. It doesn't say "but it failed!" since the move does do damage.

Also, here's a version of the move written for v15 where the "effects after hit" function doesn't exist.

################################################################################
# If the target has already moved this round, supresses target's ability
################################################################################
class PokeBattle_Move_1B8 < PokeBattle_Move
  def pbAdditionalEffect(attacker,opponent)
    if !(opponent.hasMovedThisRound? && opponent.lastMoveUsed<=0)
      return false
    end
    if isConst?(opponent.ability,PBAbilities,:MULTITYPE) ||
       isConst?(opponent.ability,PBAbilities,:STANCECHANGE) ||
       isConst?(opponent.ability,PBAbilities,:DELTASTREAM) ||
       isConst?(opponent.ability,PBAbilities,:PRIMORDIALSEA) ||
       isConst?(opponent.ability,PBAbilities,:DESOLATELAND) ||
       isConst?(opponent.ability,PBAbilities,:SCHOOLING) ||
       isConst?(opponent.ability,PBAbilities,:COMATOSE) ||
       isConst?(opponent.ability,PBAbilities,:SHIELDSDOWN) ||
       isConst?(opponent.ability,PBAbilities,:DISGUISE) ||
       isConst?(opponent.ability,PBAbilities,:RKSSYSTEM) ||
       isConst?(opponent.ability,PBAbilities,:BATTLEBOND) ||
       isConst?(opponent.ability,PBAbilities,:POWERCONSTRUCT)
      return false
    end
    opponent.effects[PBEffects::GastroAcid]=true
    opponent.effects[PBEffects::Truant]=false
    @battle.pbDisplay(_INTL("{1}'s ability was suppressed!",opponent.pbThis)) 
    if opponent.effects[PBEffects::Illusion]!=nil #ILLUSION
      # Animation should go here
      # Break the illusion
      opponent.effects[PBEffects::Illusion]=nil
      @battle.pbDisplayEffect(opponent)
      @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
      @battle.pbDisplay(_INTL("{1}'s {2} wore off!",opponent.pbThis,
          PBAbilities.getName(opponent.ability)))
    end #ILLUSION
    return true
  end
end
Glad you could work what wasn't working, I didn't know if it was already or not.

By the way, I see you added Desolate Land and stuff, but this is a quote from Bulbapedia:
The target's Ability will not be suppressed if it is Multitype, Stance Change, Schooling, Comatose, Shields Down, Disguise, RKS System, Battle Bond, or Power Construct.
I always use Bulbapedia for my information, but maybe it's not true. Who knows.

Rot8er_ConeX

Male
The Dissa Region
Seen February 22nd, 2018
Posted May 8th, 2017
822 posts
5.5 Years
Glad you could work what wasn't working, I didn't know if it was already or not.

By the way, I see you added Desolate Land and stuff, but this is a quote from Bulbapedia:

I always use Bulbapedia for my information, but maybe it's not true. Who knows.
I think I copied the abilities list from another move that has a lot of abilities that are immune to it - probably Gastro Acid.

So if Bulbapedia says that the Primal abilities aren't immune to Zygarde, go ahead.
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
Male
Seen December 27th, 2018
Posted April 22nd, 2017
2 posts
9.8 Years
Here are some move abilities that I have added to the Pokebattle_MoveEffects. If someone wants to test and verify these I would appreciate it! It seems they are working fine for me but I have been hacking away at some codes left and right so Idk if it will work for a standard version. :p

Spoiler:
################################################################################
# Heals user by an amount depending on the weather. (Shore Up)
################################################################################
class PokeBattle_Move_159 < PokeBattle_Move
def isHealingMove?
return true
end

def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if attacker.hp==attacker.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
return -1
end
hpgain=0
if @battle.pbWeather==PBWeather::SANDSTORM
hpgain=(attacker.totalhp*2/3).floor
elsif @battle.pbWeather!=0
hpgain=(attacker.totalhp/4).floor
else
hpgain=(attacker.totalhp/2).floor
end
pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
attacker.pbRecoverHP(hpgain,true)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
return 0
end
end


Spoiler:
################################################################################
# Heals a burn if the target is burned. (Sparkling Aria)
################################################################################
class PokeBattle_Move_15B < PokeBattle_Move
def pbEffectAfterHit(attacker,opponent,turneffects)
if !opponent.isFainted? && opponent.damagestate.calcdamage>0 &&
!opponent.damagestate.substitute && opponent.status==PBStatuses::BURN
opponent.pbCureStatus
@battle.pbDisplay(_INTL("{1}'s burn was cured.",opponent.pbThis))
end
end
end


I saw that someone already posted this one, but here is a corrected one that you can just "copy and paste" without changing.

Spoiler:
################################################################################
# Fails if this isn't the user's first turn. (First Impression)
################################################################################
class PokeBattle_Move_15A < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return (attacker.turncount>1)
end
end



All of the other effects have been a huge help, and I will post anymore that I figure out on here for everyone to see/use! Great forum!

Marin

Age 18
Male
Seen 1 Week Ago
Posted 4 Weeks Ago
959 posts
4 Years
I only have one question , Are these moves and abilities working in v16.2 too?
That is the latest version and I assume everyone here was as wise as to use that, so yes.