• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Scripting Question] Check species AND level

  • 3
    Posts
    8
    Years
    • Seen Jun 14, 2016
    Hey everybody,

    how can I check if the player has a Hitmonchan with Level 40 or more in his Team?
    And can I evolve a Pokemon with an event?
     
    Last edited by a moderator:
    how can I check if the player has a Hitmonchan with Level 40 or more in his Team?

    Essentials has a function pbHasSpecies? which you can use to check if the player has a specific pokemon species. We can copy and modify that for your needs. (Put the following in a script section above main.)

    Code:
    def pbHasSpeciesAtLevel?(species, level)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.species==species && pokemon.level>=level
      end
      return false
    end
    Then, you would simply be able to call pbHasSpeciesAtLevel?(:HITMONCHAN,40) from your condition.

    Note: I have not tested the above code.
     
    Essentials has a function pbHasSpecies? which you can use to check if the player has a specific pokemon species. We can copy and modify that for your needs. (Put the following in a script section above main.)

    Code:
    def pbHasSpeciesAtLevel?(species, level)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.species==species && pokemon.level>=level
      end
      return false
    end
    Then, you would simply be able to call pbHasSpeciesAtLevel?(:HITMONCHAN,40) from your condition.

    Note: I have not tested the above code.

    Thanks a lot! It works perfectly!!
    Do you even know how I can start a evolution of this pokemon, when this condition came true?
     
    You can change Pokemon evolution methods in the pokemon.txt. No need to use scripts to do it.
     
    Hey, I'm new to Pokemon Essentials as well as pokecommunity. Could you tell me where exactly I paste this code and would I need to give you credit?
     
    Back
    Top