- 1
- Posts
- 5
- Years
- Seen Apr 1, 2020
So, I know very little about scripting. I've only read a very basic introduction to Ruby, and tried to study the scripts that come with essentials, so I might be way off here, but hopefully what I want to do is doable. What I'm trying to do is make it so that opposing trainers more frequently switch out their pokemon if they have a better one. This is more in line with how Pokemon is played competitively, and would, I believe, make the battles more strategic.
My thinking was that the best way to go about doing this would be to check if the best pokemon against the player's was a different one than the active pokemon, and if so switch it out a certain percent of the time (65%).
![[PokeCommunity.com] Changing the frequency of battle AI switching [PokeCommunity.com] Changing the frequency of battle AI switching](https://data.pokecommunity.com/attachments/11/11631-2e9027ba99a3bf514327e2001d950edb.jpg)
![[PokeCommunity.com] Changing the frequency of battle AI switching [PokeCommunity.com] Changing the frequency of battle AI switching](https://data.pokecommunity.com/attachments/11/11632-498b5af14bfdc05762abf2576c26dd2b.jpg)
I defined a new method pbBetterPokemon which is identical to pbChooseBestNewEnemy except for what's marked with red, as I find the AI does a good job finding the best new enemy when one has fainted. I set the method to be true if best pokemon is different than active pokemon, and false if else (at least I hope that's what I've done).
Then I added a couple of lines to pbEnemyShouldWithdrawEx? where I say that if there is a better pokemon available, and a random number generator is below 65 out of a hundred then shouldswitch=true.
The good news is that opposing pokemon do switch out about 65% of the time. The bad news is that they don't switch to the best available pokemon, and if they do they will swap that one out as well even though no other pokemon are better. So what am I doing wrong here? Any help would be highly appreciated :)
My thinking was that the best way to go about doing this would be to check if the best pokemon against the player's was a different one than the active pokemon, and if so switch it out a certain percent of the time (65%).
![[PokeCommunity.com] Changing the frequency of battle AI switching [PokeCommunity.com] Changing the frequency of battle AI switching](https://data.pokecommunity.com/attachments/11/11631-2e9027ba99a3bf514327e2001d950edb.jpg)
![[PokeCommunity.com] Changing the frequency of battle AI switching [PokeCommunity.com] Changing the frequency of battle AI switching](https://data.pokecommunity.com/attachments/11/11632-498b5af14bfdc05762abf2576c26dd2b.jpg)
I defined a new method pbBetterPokemon which is identical to pbChooseBestNewEnemy except for what's marked with red, as I find the AI does a good job finding the best new enemy when one has fainted. I set the method to be true if best pokemon is different than active pokemon, and false if else (at least I hope that's what I've done).
Then I added a couple of lines to pbEnemyShouldWithdrawEx? where I say that if there is a better pokemon available, and a random number generator is below 65 out of a hundred then shouldswitch=true.
The good news is that opposing pokemon do switch out about 65% of the time. The bad news is that they don't switch to the best available pokemon, and if they do they will swap that one out as well even though no other pokemon are better. So what am I doing wrong here? Any help would be highly appreciated :)
Last edited: