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

[Essentials Tutorial] Changing An Opponent's Trainer Class Temporarily

311
Posts
4
Years
  • Let's say for example, you have a trainer class, an Ace Trainer, that you'd like to change into a Cooltrainer, but only for one battle. Instead of creating an entirely new trainer class, in trainertypes.txt, you can simply alter the output name defined in the scripts.

    Do a global search for
    Code:
    def fullname
    Once there, you'll see this
    Code:
    def fullname
       return _INTL("{1} {2}",self.trainerTypeName,@name)
    end
    Going with the previous example up above, we're going to change an Ace Trainer into a Cooltrainer. You'll want to set aside a variable to use. In this case we'll use variable # 70, so replace that with whatever else you'd like.
    Replace the above code with this:
    Code:
    def fullname
        case $game_variables[70]
          when 0
            return _INTL("{1} {2}",self.trainerTypeName,@name)
          when 1
            return _INTL("Cooltrainer Jeff")
          when 2
            return _INTL("Other filler")
          end
        end
      end
    So when the variable #70 is equal to 1, it'll change the name of the trainer to be whatever you write there. Note you must also write the trainer's name.
    You can have multiple occasions, as I showed, so you can continue having more and more instances of this.

    So now, to actually apply the code. When you write the trainer, use the same as you would without the script. Still write ACETRAINER as the trainer class. Then, right before the battle, you'll set the variable 70 to be 1. And then of course don't forget to set the variable back to zero after the battle, otherwise all your trainers will become Cooltrainer Jeff.

    I hope this guide was helpful, and could save you a slot in your trainers.txt.
     

    #Not Important

    All hail the wishmaker
    910
    Posts
    4
    Years
  • It should be about the same, just an array for mons:
    Code:
    return [PBSpecies::PIKACHU, PBSpecies::WEEDLE]
     
    311
    Posts
    4
    Years
  • I'm not sure that would work, since fullname returns the opponent's name, not their team.

    You can still do this, it's just in a different location. In PTrainer_NPCTrainers, after the line
    Code:
    TPDEFAULTS = [0,10,0,0,0,0,0,nil,nil,0,false,nil,10,70,nil,false,0]
    You can add something similar to this:
    Code:
    def changeForVariable(pkmn)
      if $game_variables[70]!=0
        changedName=false
        case pkmn.species
          when PBSpecies::RATTATA
            pkmn.species=PBSpecies::RATICATE
            pkmn.resetMoves
            changedName=true
        end
      end
      pkmn.calcStats
      if changedName
        pkmn.name=PBSpecies.getName(pkmn.species
      end
      return pkmn
    end
    Then search for party.push(pokemon) and add this on the line above it:
    Code:
    pokemon=changeForVariable(pokemon)
    Essentially this will change all Rattatas into Raticates, so long as the code is active. I'm not quite sure this is what you wanted, but if you wanted the trainer to have a different team, that's when you should make a new trainer. As for altering the sprite, the variable holding the sprite is in trainerfile. I'm not quite sure what to edit for this one, but doing a global search would certainly get you one step closer.
     
    Last edited:

    #Not Important

    All hail the wishmaker
    910
    Posts
    4
    Years
  • You used the wrong slash, / is the right one
    [B]Bold[/B] [CODE] Code[/CODE]
    And I meant in the defenition of the trainers pokémon
     
    311
    Posts
    4
    Years
  • Yeah thanks, I fixed the slashes. I'm still not quite sure what you mean by the definition of the trainers pokemon. That should still be handled in the trainers.txt. The script is mostly just for flavor, in case you want a slightly different trainer class to be displayed.
     
    Back
    Top