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

Forcing a trainer to use a specific last pokémon

KillerMapper

Helix Follower
200
Posts
9
Years
Hello !

I would like to know if it's possible to force a trainer (in my case, a gym leader, with better AI than regular trainers) to use a specific pokémon of his team as his last pokémon. I would like to have the strongest pokémon (which have custom IVs, movesets...) at the end of the battle, but the trainer will use it before the other (and less powerful) pokémons if the players use a strong pokémon.

Does PE have an option for that, or does it need some scripting anywhere ?

Thanks.
 
14
Posts
9
Years
  • Age 36
  • Seen Jun 1, 2016
In Pokebattle around 3990

override

Code:
  def pbDefaultChooseNewEnemy(index,party)
    enemies=[]
    for i in 0..party.length-1
      if pbCanSwitchLax?(index,i,false)
        enemies.push(i)
      end
    end
    if enemies.length>0
      return pbChooseBestNewEnemy(index,party,enemies)
    end
    return -1
  end
with (XXX - your switch ID; this is untested)

Code:
  def pbDefaultChooseNewEnemy(index,party)
    enemies=[]
    length = party.length-1
    for i in 0..length
        if pbCanSwitchLax?(index,i,false)
            if i == length && $game_switches[xxx]
                if  enemies.length == 0
                    enemies.push(i)
                end
            else
                enemies.push(i)
            end
        end
    end
    if enemies.length>0
      return pbChooseBestNewEnemy(index,party,enemies)
    end
    return -1
  end
 
Last edited:

KillerMapper

Helix Follower
200
Posts
9
Years
Thanks, it's working !

Do you think it's possible to let the trainer choose the best pokémon except for the last one ?
 
14
Posts
9
Years
  • Age 36
  • Seen Jun 1, 2016
It actually does that. (It calls pbChooseBestNewEnemy)

If you are not satisfied with the criteria, you have to work with the function.

It is around line ~4000

Code:
  def pbChooseBestNewEnemy(index,party,enemies)
    return -1 if !enemies || enemies.length==0
    $PokemonTemp=PokemonTemp.new if !$PokemonTemp
    o1=@battlers[index].pbOpposing1
    o2=@battlers[index].pbOpposing2
    o1=nil if o1 && o1.isFainted?
    o2=nil if o2 && o2.isFainted?
    best=-1
    bestSum=0
    for e in enemies
      pkmn=party[e]
      sum=0
      for move in pkmn.moves
        next if move.id==0
        md=PBMoveData.new(move.id)
        next if md.basedamage==0
        if o1
          sum+=PBTypes.getCombinedEffectiveness(md.type,o1.type1,o1.type2)
        end
        if o2
          sum+=PBTypes.getCombinedEffectiveness(md.type,o2.type1,o2.type2)
        end
      end
      if best==-1 || sum>bestSum
        best=e
        bestSum=sum
      end
    end
    return best
  end

Things you could work around with:
-Pokemon base stats, expecting type damage
-Pokemon defensive capabilities (physical, spezial, KP)

"known" moves (this could be tricky, if you don't want to cheat)
 

Florio

Pokemon Crimson Skies Owner
391
Posts
15
Years
I needed this to, I'm going to try it.
Also is there a way to get the opponent to show his sprite when he sends out said last Pokemon, just like it does in the games? Like for example when you face Galactic Boss Cyrus in Platinum, when he sends out his last Pokemon his sprite pops out for a second and he says, "I admit you have pushed me to this extreme."
 

KillerMapper

Helix Follower
200
Posts
9
Years
Ok. Trainer just used the order defined in the txt, maybe I wasn't lucky. I'll try more battles then. Thanks for your help.
 
69
Posts
14
Years
  • Seen Sep 26, 2016
In Pokebattle around 3990

override

Code:
  def pbDefaultChooseNewEnemy(index,party)
    enemies=[]
    for i in 0..party.length-1
      if pbCanSwitchLax?(index,i,false)
        enemies.push(i)
      end
    end
    if enemies.length>0
      return pbChooseBestNewEnemy(index,party,enemies)
    end
    return -1
  end
with (XXX - your switch ID; this is untested)

Code:
  def pbDefaultChooseNewEnemy(index,party)
    enemies=[]
    length = party.length-1
    for i in 0..length
        if pbCanSwitchLax?(index,i,false)
            if i == length && $game_switches[xxx]
                if  enemies.length == 0
                    enemies.push(i)
                end
            else
                enemies.push(i)
            end
        end
    end
    if enemies.length>0
      return pbChooseBestNewEnemy(index,party,enemies)
    end
    return -1
  end

Sorry for asking.
How should i define the ID and how do I use it in the Event?
 
Back
Top