• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - 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] How can I change the wild Pokemon's AI?

  • 85
    Posts
    7
    Years
    • Seen Nov 24, 2023
    I tried looking through the script editor for ways to change it, but I couldn't find any.

    Does anyone know how to do this?
     
    You have to check the file AI_Move, and more precisely the function pbRegisterMoveWild.
    In Pokemon Essentials v18.dev (and probably in any other version of Essentials), the code of this function is:
    Code:
      # Wild Pokémon choose their moves randomly.
      def pbRegisterMoveWild(_user,idxMove,choices)
        choices.push([idxMove,100,-1])   # Move index, score, target
      end
    Basically it gives a 100 score to any move the Pokémon has (the higher the score, the more likely it will be chosen). You need to alter the evaluation of the moves, just like in pbRegisterMoveTrainer (which gets the move score from pbGetMoveScore()).
     
    You have to check the file AI_Move, and more precisely the function pbRegisterMoveWild.
    In Pokemon Essentials v18.dev (and probably in any other version of Essentials), the code of this function is:
    Code:
      # Wild Pokémon choose their moves randomly.
      def pbRegisterMoveWild(_user,idxMove,choices)
        choices.push([idxMove,100,-1])   # Move index, score, target
      end
    Basically it gives a 100 score to any move the Pokémon has (the higher the score, the more likely it will be chosen). You need to alter the evaluation of the moves, just like in pbRegisterMoveTrainer (which gets the move score from pbGetMoveScore()).

    I'm using version 17.2, not 18. pbRegisterMoveWild doesn't exist in it. There is pbRegisterMove, but that's in PokeBattle_Battle, and it has nothing to do with score.

    This is its code:
    Code:
    def pbRegisterMove(idxPokemon,idxMove,showMessages=true)
        thispkmn=@battlers[idxPokemon]
        thismove=thispkmn.moves[idxMove]
        return false if !pbCanChooseMove?(idxPokemon,idxMove,showMessages)
        @choices[idxPokemon][0]=1         # "Use move"
        @choices[idxPokemon][1]=idxMove   # Index of move to be used
        @choices[idxPokemon][2]=thismove  # PokeBattle_Move object of the move
        @choices[idxPokemon][3]=-1        # No target chosen yet
        return true
      end
     
    Back
    Top