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

Calling a non-player trainer's party

  • 15
    Posts
    10
    Years
    • Seen Dec 24, 2020
    If there's the array $Trainer.party for the player, is there anything equivalent for an opponent?

    (And by the way, where is $trainer.party created anyways? Searched the scripts to no avail)
     
    Just call the party method on the opponent. All opponents are of the Trainer class. It just so happens to be that $Trainer is assigned to the player's trainer.
     
    $trainer.party is created when PokeBattle_Trainer is created, set to be an empty array in the 'def initialize'
    of the class PokeBattle_Trainer.

    This is only when you're starting a new game, though. When you're loading the game, the trainer is loaded
    via Marshal.load, together with party and everything else.
     
    Thanks for the feedback!
    Am I supposed to do something like that? $opponent = PokeBattle_Trainer(John,PERSON)
    And then using $opponent.party to call its party? I'm still quite noobish at scripting, so I'm sure I'm missing something.
     
    Thanks for the feedback!
    Am I supposed to do something like that? $opponent = PokeBattle_Trainer(John,PERSON)
    And then using $opponent.party to call its party? I'm still quite noobish at scripting, so I'm sure I'm missing something.

    It depends on what you want to do. If you're interested in your opponent's party you
    could take a look at the method pbTrainerBattle. (search for def pbTrainerBattle). There
    you'll find a line that says something like trainer=pbLoadTrainer ... Now if you want to
    meddle with opponent's party, trainer[2] will contain it after the call to pbLoadTrainer.

    If you want to create a new trainer (although that's probably not what you want to do)
    you would say; opponent = PokeBattle_Trainer.new(name, trainerid)

    I could help you better if I knew what is it that you want to do exactly. Why do you
    need your opponent's party?
     
    I need a non-player 'version' of $trainer.party, made of the opponent's party instead of the player's. That's for a 'replica' of the Pokémon menu (this one)

    [PokeCommunity.com] Calling a non-player trainer's party


    But with the referred trainer's party instead of the player's. Since the Pokémon menu calls $trainer.party, I need to call an equivalent (or learn how to build it, if needed)
     
    Okay, I think I get what you need.
    Look at the line 334 in PokemonTrainers script. It should say,

    Code:
    trainer=pbLoadTrainer...

    Now, after that line, assign trainer's party to a global variable called whatever you like,
    but let's call it $OpponentParty

    Code:
    $OpponentParty = trainer[2]

    You now have global access to the opponent's party that you can use in your menu.
    Hope this helps! : )
     
    Back
    Top