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

New (Better) Trainer and Wild Pokemon Move Generation Script

286
Posts
5
Years
    • Seen May 15, 2024
    I have already been working on this on a different thread, but now that this script is pretty much complete (I have done a decent amount of testing with it), I thought I'd share it in the scripts section and explain how to implement it (should work for v17.2 but haven't tested it with other versions). These scripts change the way movesets are generated to include a bit more variability. It can be annoying to have to use heart scales to get moves that you missed at earlier levels, but these scripts provide the possibility of Pokemon spawning with these moves. Also, there will be a little more randomness when fighting trainers who don't have their movesets already defined for them. The part that controls all this is def resetMoves in Pokebattle_Pokemon. There are a few ways you can include this in your game. In my game, I'm using separate moveset generation for trainer move generation and wild move generation, but you can keep it the same for both.

    It is important to note that normally, a Pokemon's moveset will be determined as the last 4 moves before and up to the Pokemon's current level as defined in pokemon.txt. There are 3 variations that I made:

    Generate moves as a random 4 out of all the moves the Pokemon learns up to its current level by leveling up (removes duplicate moves so that moves that appear twice in a Pokemon's levelup moves don't have a higher chance of being chosen):
    Spoiler:

    Generate moves as a random 4 out of all the moves the Pokemon learns up to its current level by leveling up (removes duplicate moves so that moves that appear twice in a Pokemon's levelup moves don't have a higher chance of being chosen) but guarantees the first move slot to be occupied by a random STAB move present in its move list (if possible):
    Spoiler:

    Generate moves as a random 4 out of all the moves the Pokemon learns up to its current level by leveling up (removes duplicate moves so that moves that appear twice in a Pokemon's levelup moves don't have a higher chance of being chosen) but guarantees the first move slot to be occupied by a random damaging move present in its move list (if possible):
    Spoiler:

    If you want to add TM and/or Egg moves to the move pool:
    Spoiler:

    If you want movesets to be generated the same for all Pokemon, just replace everything in def resetMoves (in Pokebattle_Pokemon) with whichever version you want to use.

    If you want movesets to be generated differently between wild and trainer Pokemon (I like to guarantee at least 1 damaging move for wild Pokemon and 1 STAB move for trainer Pokemon), you'll need to do a little more:
    Spoiler:

    You might also consider using switches to turn these on and off, but it's not at all necessary.

    I hope some of you find this useful, and please let me know if you find any problems or have any questions about it. Also, if you have suggestions for other variations of this (like guaranteeing the strongest STAB move as part of the moveset), let me know that as well and I'll consider making the code for it. Feel free to give me credit if you use this, but I don't require it.
     
    Last edited:
    22
    Posts
    7
    Years
    • Seen May 15, 2023
    This is really interesting! just, i have a question:
    It is possible to make it work with forms specific move sets?
     
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    This is really interesting! just, i have a question:
    It is possible to make it work with forms specific move sets?

    The script should work automatically with forms as well, and I just verified this with wild and trainer battles. Is it not working for you?
     
    If you want movesets to be generated differently between wild and trainer Pokemon (I like to guarantee at least 1 damaging move for wild Pokemon and 1 STAB move for trainer Pokemon), you'll need (at least) 2 different methods for this:
    Spoiler:

    You might also consider using switches to turn these on and off, but it's not at all necessary.

    Can you type the script how you achieved this. I am a beginner in Programming.
     
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    Can you type the script how you achieved this. I am a beginner in Programming.

    Yeah, sorry, I know it's a little bit complicated the way I explained it. I'll replace my old explanation.

    So first you'll want to copy the 2 out of the 3 code sections that you want to use. Find "def resetMoves" in Pokebattle_Pokemon and paste both of these sections between "def resetMoves" and "def pbLearnMove(move)". You'll notice how the 2 pasted sections also start with "def resetMoves". In order to distinguish them from the original, replace "def resetMoves" (just that line) in the ones that you pasted with "def trainerResetMoves" and "def wildResetMoves", respectively. Use trainerResetMoves for the one that you want to have activate for trainer battles and use wildResetMoves for the one that you want to have activate for wild battles.

    Next, for wild battles, you'll need to go to PField_EncounterModifiers and replace all instances of "pokemon.resetMoves" with "pokemon.wildResetMoves" (there should be 2 places to do this). Then, go to Pokebattle_Pokemon and replace "self.resetMoves" with "self.wildResetMoves" (1 place to do this).

    Next, for trainer battles, you'll need to go to PTrainer_NPCTrainers and replace "pokemon.resetMoves" with "pokemon.trainerResetMoves" (1 place to do this).

    This should be all the extra stuff you need to do if you're using 2 versions of move generation.
     
    22
    Posts
    7
    Years
    • Seen May 15, 2023
    ---------------------------
    Error
    ---------------------------
    Script '[PokeBattle_Pokemon]' line 505: NoMethodError occurred.

    undefined method `isDamaging?' for #<PBMove:0x10c15940 @pp=25, @id=146, @ppup=0>

    from 'PokeBattle_Pokemon' line 505 in `wildResetMoves'
    from 'PokeBattle_Pokemon' line 503 in `each'
    from 'PokeBattle_Pokemon' line 503 in `wildResetMoves'
    from 'PokeBattle_Pokemon' line 1065 in `__mf_initialize'
    from 'Pokemon_Forms' line 43 in `birthsign_initialize'
    from 'Birthsign' line 1207 in `initialize'
    from 'Birthsign' line 4754 in `new'
    from 'Birthsign' line 4754 in `pbGenerateWildPokemon'
    from 'PokemonSalvajesVisuales' line 669 in `pbWildBattle_ebs'
    from 'EliteBattle_6' line 221 in `pbWildBattle'
    from 'Phenomenom' line 224
    from 'Phenomenom' line 191 in `call'
    ---------------------------
    Aceptar
    ---------------------------

    Got this.
    And where u say "replace all instances of "pokemon.resetMoves" with "pokemon.wildResetMoves" (there should be 2 places to do this)" i only found one place, i have 17.2.

    I have some other scripts installed:

    EBS, Birthsign, WildOverworldSprites, Following Pokemon, etc.

    Edit: Using the first of the three script for the wild pokemons, seems to work fine.
     
    Last edited:
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    ---------------------------
    Error
    ---------------------------
    Script '[PokeBattle_Pokemon]' line 505: NoMethodError occurred.

    undefined method `isDamaging?' for #<PBMove:0x10c15940 @pp=25, @id=146, @ppup=0>

    from 'PokeBattle_Pokemon' line 505 in `wildResetMoves'
    from 'PokeBattle_Pokemon' line 503 in `each'
    from 'PokeBattle_Pokemon' line 503 in `wildResetMoves'
    from 'PokeBattle_Pokemon' line 1065 in `__mf_initialize'
    from 'Pokemon_Forms' line 43 in `birthsign_initialize'
    from 'Birthsign' line 1207 in `initialize'
    from 'Birthsign' line 4754 in `new'
    from 'Birthsign' line 4754 in `pbGenerateWildPokemon'
    from 'PokemonSalvajesVisuales' line 669 in `pbWildBattle_ebs'
    from 'EliteBattle_6' line 221 in `pbWildBattle'
    from 'Phenomenom' line 224
    from 'Phenomenom' line 191 in `call'
    ---------------------------
    Aceptar
    ---------------------------

    Got this.
    And where u say "replace all instances of "pokemon.resetMoves" with "pokemon.wildResetMoves" (there should be 2 places to do this)" i only found one place, i have 17.2.

    I have some other scripts installed:

    EBS, Birthsign, WildOverworldSprites, Following Pokemon, etc.

    Edit: Using the first of the three script for the wild pokemons, seems to work fine.

    You're absolutely right. For some reason, it seems like I had some extra things in my game that aren't in vanilla essentials (I really don't remember adding these things, but I guess I did at some point). For this to work, you just need to add the following code segment above "# Gets the maximum PP for this move." in the PBMove script:
    Code:
      def isDamaging?
        movedata = PBMoveData.new(@id)
        return movedata.category!=2
      end

    You're also right that you only need to replace "pokemon.resetMoves" in 1 place.

    I'll update my original post, and let me know if there are any other problems.
     
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    I just edited the main post to be more clear and easier to implement. There are now fewer things to do if you want to separate moveset generation between trainers and wild Pokemon, and you don't need to add the "def isDamaging?" part anymore. Note that if you already did everything the old way that this doesn't actually change the mechanics and you don't need to change anything. The changes were only to make this easier to put into your game. I tested this new implementation with an unmodified version of essentials (17.2), but let me know if any problems arise.
     
    29
    Posts
    5
    Years
    • Seen Feb 27, 2023
    Nice script. Is there a way to add egg moves and moves learnt from TMs or tutor to the random pool? Thanks in advance
     
    286
    Posts
    5
    Years
    • Seen May 15, 2024
    Nice script. Is there a way to add egg moves and moves learnt from TMs or tutor to the random pool? Thanks in advance

    I got it working with Egg moves and TM moves. It was unfortunately way too slow for practical use when I tried including tutor moves as well, and it's even noticeably a bit slower at generating trainer teams just with Egg/TM moves (though it's not that bad just with these). If anyone has any ideas for making this more efficient/working with tutor moves, I can include this in the main post.

    Anyway, here's what you'll need to do to add this:
    Spoiler:
     
    Last edited:
    Back
    Top