• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Question] Need help with a Trainer Team Generator System

PokePrinny

Project VS
  • 4
    Posts
    4
    Years
    • He/Him
    • USA
    • Seen Jun 20, 2022
    I feel like there's something already in the scripts I can use for this but I'm having trouble putting it together so here goes:

    In my game each gym is essentially it's own Battle Tower Facility (meaning they are all "battle towers" but each has its own trainer/pokemon pool). I have tried to mirror the battle tower scripts as best as I could but there isn't much guidance on the section. I can put most of the event together through conditional branches and loops but the one issue I can't overcome is getting the system to generate trainers from my own challenge type.

    So my question is this:
    How do I create a battle challenge, or multiple, that can generate a set of trainers similar to the Battle Tower scripts?

    From my tests, I know that the below script is what generates the teams:

    pbBattleChallenge.set("towersingle",7,
    pbBattleTowerRules(false,false))


    I can change the 7 to modify the number of trainers in the set and I was also able to create my own Challenge in trainerlists.txt along with the corresponding tr/pm files, but i think this is where I'm getting stuck:
    pbBattleTowerRules

    This is my current attempt at creating my own "Rules"

    def pbBlueGymRules(double,openlevel)
    ret=PokemonChallengeRules.new
    if openlevel
    ret.setLevelAdjustment(OpenLevelAdjustment.new(60))
    else
    ret.setLevelAdjustment(CappedLevelAdjustment.new(50))
    end
    ret.addPokemonRule(StandardRestriction.new)
    ret.addTeamRule(SpeciesClause.new)
    ret.addTeamRule(ItemClause.new)
    ret.addBattleRule(SoulDewBattleClause.new)
    ret.setDoubleBattle(double)
    return ret
    end


    But that's about as far as I have been able to figure out. I looked at it with a friend and he mentioned the "pbGenerateBattleTrainer" script but I can't completely understand the section (it's located in OrgBattle section of the scripts). Maybe a breakdown of this section or just how to modify the generator logic to work for each gym would suffice?

    Any help is appreciated! Sorry if the post is long-winded, I've just really put thought and time into it :)
    *version 18.1*
     
    I must admit, I don't understand the way the Battle Tower works in Pokémon Essentials. The rules / challenges and such seem very obscure to me. This bothered me because I also wanted to generate battles like you do.
    Also, the way the function pbTrainerBattle function works makes it really hard to do a battle against a generated team, because pbTrainerBattle can only look for a trainer that is in the PBS file trainers.txt, so that's another thing to consider.
    As for the rules, if you understand how it works, keep them, but I coudn't. I suggest you check and use the function setBattleRules instead.
    Besides, the database of Pokémons (btpokemon.txt) does not allow you to set IVs / EVs.

    My guess: the whole Battle Facility code is probably deprecated, and seeing how it's not commented, it's probably just a draft at this point.

    So, what I did was:
    • Make a database of movesets for Pokémons. I suggest you take the same structure as the file trainers.txt, except you put only Pokémon movesets, no trainer data. This is the database of the movesets to pick from.
    • Create your own compiler.
      NB: for Pokémon Essentials, a compiler is a function that reads a PBS file, and turns its text into a hash of constants of the game, which are easily accessible in game.
      Ok that sounds hard, it will take you a month or two maybe, but after you're done, it's clean. As I am advising you to take inspiration on trainers.txt, you should take inspiration on its compiler too (pbCompileTrainers). Basically remove the parts that handle the trainer data.
    • I also suggest you make a decompiler to go with the compiler, because it's a good way to see where you screwed up in your compiler. Again, take inspiration on pbSaveTrainerBattles.
    • Note that you will also need a function to load the database.
    • Ok, now that the database, compiler and decompilers are ready, you need a way to generate teams. A random choice should be enough, but you can refine it with handmake filters.
    • Modify the function pbLoadTrainer, so that the argument trainerPartyID of the function pbTrainerBattle can be an actual Pokémon team (ie. an array of 1-6 instances of PokeBattle_Pokemon).
    • As for the battle rules. I suggest you check and use the function setBattleRules instead of the Battle Facility thing that I don't understand XD You will have to code your own "level-balancing" function though, but it's pretty easy. And if you know that all gym battles will have the same rules and such, you should make a function pbGymBattle for example.

    I hope that helps. Unfortunately, what you ask is not what Pokémon Essentials was thought for, hence the length of this post and the number of functions you have to code yourself.
    However, it's perfectly doable, but it'll take time.

    Spoiler:
     
    Last edited:
    you can use pokemon team builder to make pokemon teams.
    Pokemon Team Builder is an exclusive tool that is used to plan and make your team before starting the game. It is a simple tool that contains all pokemon data simply click on your favorite pokemon image to add it to your pokemon team list. Since your childhood, you are listening to pokemon games and cartoons. Might be possible you are used to playing that game. In the game, there are several pokemons like Pikachu, jiggly puff, and many more other characters that have specific powers, strengths & weaknesses. You can build up your own pokemon team by selecting your favorite pokemon and compete for the best result.
     
    Thank you so much! This was very helpful and confirms what I was afraid of with the Tower Scripts. If this is doable through the above method, I think I found something to work on for the essentials community :)

    I have definitely being using setBattleRule("setStyle") for Gym Battles. I also created switches for Thor348's level scaling and No use of items from Bag. Would it be cleaner to put those in my setBattleRule("Gyms")?

    It seems I should expand on that and create a pbGymBattle like you proposed. This would replace pbTrainerBattle scripts in gyms if I am understanding correctly?
    For example:
    Conditional Branch: Script: pbGymbattle(:GYMLEADER1,"Name")

    This is all assuming I would complete it before your game xD So I'll be keeping an eye out for your game now!

    Cheers :)
     
    Back
    Top