Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.
The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games. Don't forget to come back September 21st to vote for your favorites!
Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
Can someone help me with writing some scripts to improve trainer AI?
I want the enemy pokemon holding light clay prefer using a screen move and the pokemon holding a flame orb use protect on turn 1.
is that possible to achieve?
Or have Zorua prefer using statusmoves while still in illusion!
In order to help you understand the AI system better, let me explain how you can find the answers to your questions.
First, you wanted to create a script that would encourage a trainer to prefer using a screen move while their Pokemon is holding a Light Clay. AI move preferences are mostly handled by their function codes. So:
Step 1) Open up your moves PBS file, move.txt.
Step 2) Find one of the moves whose behavior you'd like to affect, perhaps Light Screen.
Step 3) Look at Light Screen's function code: "StartWeakenSpecialDamageAgainstUserSide"
Step 4) Open up the Pokemon Essentials scripts.
Step 5) Search for "StartWeakenSpecialDamageAgainstUserSide" within the AI sections.
If you do that, you will find a block that looks like this:
Every function code that the AI "knows about" has one of these blocks that starts with Battle:: AI ::Handlers::MoveEffectScore.add(...), which contains the scoring process to run for moves with that function code. And if you look inside the block for this function code, you'll see the following:
Ruby:
score += 5 if user.has_active_item?(:LIGHTCLAY)
So, in fact, the AI already does exactly what you were hoping for, in this case.
Now, let's talk about the next capability you were hoping to add. You wanted to update the AI scripts to prefer moves like Protect when a Pokemon is holding an item like Flame Orb. Well, follow the steps I mentioned above. For each move you want to prefer, find its function code in the moves.txt file. Then, find its Battle:: AI ::Handlers::MoveEffectScore.add(...) block in the scripts. Then, add a line like the one above that increases the move's score if the user is holding one of the items you'd like to consider.
The same could apply to your last use case, but it's very broad, so you may want to explore the AI scripts on your own to figure out whether there's a different way to implement it that doesn't involve looking up every single status move function code.