• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

v20.1 Trainer modifier (part 1) 1.0

This resource pertains to version 20.1 of Pokémon Essentials.
Pokémon Essentials Version
v20.1 ➖
With a trainer modifier script, you can change the attributes of any trainer in your game. You can paste it anywhere above main or make it a plugin. A trainer modifier script looks like this:

Code:
Expand Collapse Copy
EventHandlers.add(:on_trainer_load, :nameofthemodifier,
  proc { |trainer|
   if trainer   # check if you are facing a  trainer
     if Condition
           do what you want
     end
   end
  }
)

The Condition is here to determine which trainer will be affected. If you don't put anything, it applies to every trainer in your game.
It can be something like trainer.name=="Joey" (every trainer called Joey), trainer.trainer_type_name==("Gym Leader")
(every gym leader), it can be triggered by a switch (if [imath]game_switches[50]), a variable (if[/imath]game_variables[50]>0 ), the id of the map ([imath]game_map.map_id), the number of badges you have ([/imath]Trainer.badge_count) or by whatever you could imagine.
Then you can edit the trainer's team in the code. You can use any method that is on the Wiki.

Here is a small example of what can be done, explanations are below:
Code:
Expand Collapse Copy
Difficulty=50
EventHandlers.add(:on_trainer_load, :gymleader,
  proc { |trainer|
    if trainer
      if trainer.trainer_type_name==("Gym Leader")
        if trainer.name==("Brock")
            trainer.party[0].hp/=2
            pkmn1 = Pokemon.new(:VULPIX, 12)
            trainer.party.push(pkmn1) if $game_variables[Difficulty]>0
            for pkmn in trainer.party
                pkmn.iv[:DEFENSE] = 31
            end
        end
        for pkmn in trainer.party
            pkmn.level+= $game_variables[Difficulty]*2
            pkmn.reset_moves
            pkmn.calc_stats
        end
        if trainer.name==("Brock")
                trainer.party[1].learn_move(:EARTHQUAKE) if !trainer.party[1].hasMove?(:EARTHQUAKE)
        end
      end
    end
    }
)

WARNING: In v18 and below trainer.party is replaced by trainer[0][2] and some synthax might have changed.

Imagine I'm a bit lazy (that's the easy part). I want to setup a difficulty mode that change only gym leaders, depending of the game variable 50 (in the intro event, I asked which level of difficulty the player was wanting, then I changed this variable depending on the answer). That's my Condition.

Here I'm adding extra things only to Brock because why not.
As he used it in the last fight, his Geodude has only half of its HP left.
The 2 next lines add a Vulpix to his team only if you are not in easy mode.
Then as we are in a rock gym, why not giving perfect defense IVs to all his pokémons?
End of Brock modifier

Now let's add some levels. It's as simple as adding the content of the variable to the level of every pokemon in their team then reset their moves (it gives them moves they would have by default at the new level).
If you want to teach a new move to a pokemon, you need to write it after this line, as you can see in the next if Brock part.

Finally, you always need to add a calc_stats to apply those changes.

If you have any question feel free to ask it in the thread.
In part 2, I will teach you how to make your custom manual level scaling script.
See you there!
Credits
No credits required
Author
grogro
Views
2,513
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from grogro

Back
Top