• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Changing Enemy Trainer's Pokemon Levels based on a switch?

  • 59
    Posts
    9
    Years
    • Seen Aug 9, 2020
    I've succesfully implemented an option in EncounterModifiers so that unlocking X switch, in my example, badges, will increase the Wild mon's levels. Cool. My issue starts when I try to do the same under PokeBattle_Battler.

    I changed def pbUpdate and it worked (adding rand5 to the Pokémon levels) but that also increased the level of the Player's Pokémon.

    Code:
    def pbUpdate(fullchange=false)
        if @pokemon
          @pokemon.calcStats
          if $game_switches[11]
          @level     = @pokemon.level + rand(5)
          else
            @level     = @pokemon.level
            end
          @hp        = @pokemon.hp
          @totalhp   = @pokemon.totalhp
          if !@effects[PBEffects::Transform]
            @attack    = @pokemon.attack
            @defense   = @pokemon.defense
            @speed     = @pokemon.speed
            @spatk     = @pokemon.spatk
            @spdef     = @pokemon.spdef
            if fullchange
              @ability = @pokemon.ability
              @type1   = @pokemon.type1
              @type2   = @pokemon.type2
            end

    I tried changing def pbInitPokemon(pkmn,pkmnIndex) and def pbInitBlank (if $game_switches[11] etc) but those did not work at all. Yeah, the switch is turned on.

    Code:
    def pbInitPokemon(pkmn,pkmnIndex)
        if pkmn.egg?
         raise _INTL("An EGG can't be an active POKéMON")
        end
        @name         = pkmn.name
        @species      = pkmn.species
        if $game_switches[11]
        @level        = pkmn.level + 20
        else @level        = pkmn.level
      end
    (...)
    end
      
       def pbInitBlank
        @name         = ""
        @species      = 0
        if $game_switches[11]
        @level        = 0 + 20
        else 
       @level        = 0
        end
        (...)
      end

    Can someone with more experience guide me? The best way to go around this would be separating player and enemy Pokémon levels as separate variables, but that seems extremely tedious and out of my reach.
     
    PokeBattle_Battler has to do with the Pokemon on the field - they're actually different than normal Pokemon, so that things like Protean don't change the actual Pokemon outside of battle.

    The code to do with enemy trainers is actually found in PTrainer_NPCTrainers.

    However, you can also do this, also in EncounterModifiers:

    Code:
    Events.onTrainerPartyLoad+=proc {|sender,e|
      if [COLOR="Red"]INSERT YOUR CONDITION HERE[/COLOR]
        if e[0] # Trainer data should exist to be loaded, but may not exist somehow
          trainer=e[0][0] # A PokeBattle_Trainer object of the loaded trainer
          items=e[0][1]   # An array of the trainer's items they can use
          party=e[0][2]   # An array of the trainer's Pokémon
          for poke in party
            [COLOR="red"]INSERT YOUR CODE TO ADJUST LEVELS HERE[/COLOR]
            poke.calcStats
          end
        end
      end
    }
     
    Thanks, Rot8er_ConeX. I found a way in PokemonTrainers, to avoid using it as Encounter Modifiers.

    What I did:
    In PokemonTrainers, find def pbLoadTrainer and simply find around line 42 and edit as you wish with whatever condition.
     
    Back
    Top