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

Opponent Trainer copying the Player's Trainer Sprite and Party?

Snooper16

The Bionic Man
  • 134
    Posts
    11
    Years
    As the title says, I'm wondering if there's a way I can have a computer-controlled trainer have the same Pokemon party and spriteset (Male and Female trainer) as the player character. The final boss would vary from player to player, depending on the team they have with them at the time of speaking with the final boss. I would really like to see this idea in a game. However, with little to no scripting knowledge, I'm not sure how I would pull that off.

    Also, bonus points if there's a way to copy the player's party's details as well, like moves, ability, and everything else that can be defined in trainers.txt. If anyone can help me with this, that'd be great, and you will be added to the credits. :)

    Also, there's an example on Youtube of this idea in action. I would envision it like this (just with Pokemon, not Moemon):
    https://www.youtube.com/watch?v=lKmHaXRiFSc
     
    I'm going to bed at the moment, but this idea intrigues me. I'll try to figure it out tomorrow.

    Also, I doubt him having your bag would be possible, and if he did, him having access to it would probably make the battle a little too hard. Those 87 Max Revives you've saved up throughout the entire game just for the final boss? Guess what, he has them, too.
     
    I'm going to bed at the moment, but this idea intrigues me. I'll try to figure it out tomorrow.

    Also, I doubt him having your bag would be possible, and if he did, him having access to it would probably make the battle a little too hard. Those 87 Max Revives you've saved up throughout the entire game just for the final boss? Guess what, he has them, too.

    I don't need the bag items to be copied. Just the Pokemon, their properties, and the trainer's sprite. Sorry if I wasn't clear on that. xD
     
    Okay, just got it working. (It was a lot easier than I thought it would be)

    Step 1
    Enter your game's PBS folder and find trainertypes.txt At the very bottom of it, add:
    76,DARKPLAYER,Dark Player
    The number at the beginning should be one higher than the number right above it.

    Step 2
    In trainers.txt , add the following to the bottom:
    Code:
    #-------------------
    DARKPLAYER
    Rorrim
    1,FULLRESTORE,FULLRESTORE
    GEODUDE,12
    The only actual bit of code that is important is the line that reads DARKPLAYER. Everything else will be overwritten by the code segment I'm going to add in step 3, but needs to be in the text file so that the game doesn't ignore this trainer. The two Full Restores are items the "Dark Player" will have, so you can edit those to be what you want it to be able to use.

    Step 3
    In RPG Maker XP, open up your game and press F11. This should open up the Script Editor. To the left side, find "PTrainer_NPCTrainers".
    Around line 120, you should find the following code. Add in the red stuff:
    Code:
          pokemon.ballused=poke[TPBALL]
          pokemon.calcStats
          party.push(pokemon)
        end
        success=true
        break
      end[COLOR="red"]
      if isConst?(trainerid,PBTrainers,:DARKPLAYER)
        partytoload=$Trainer.party
        party=[]
        for i in partytoload
          j=i.clone
          j.iv=i.iv.clone
          j.ev=i.ev.clone
          j.hp=j.totalhp
          j.status=0
          for k in j.moves
            k.pp=k.totalpp
          end
          j.calcStats
          party.push(j)
        end
        opponent=PokeBattle_Trainer.new($Trainer.name,$Trainer.metaID)
        success=true
      end[/COLOR]
      return success ? [opponent,items,party] : nil
    end
    Now, any trainers in the Dark Player class will ignore their own party and have a fully-healed version of the player's party. They will also ignore the image of the Dark Player class and use the player's own sprite and name. However, this means that if you want epic final boss music, you have to define it as playing for the player classes, not the Dark Player class, which depending on how you have the Rivals working may mess with the rivals' battle music. (If you have it set up like RSE where the player you didn't choose is your rival, then it will mess with the rival music. If you have it set up like RBY where the rival is predefined and the player you didn't choose is nowhere to be found, then it'll be fine.)

    Step 4
    Set the event up like you would for any other trainer battle, of which many can be found in Essentials' example maps. The relevant line of code for the battle itself (which is couched in a conditional branch) should read as follows:
    Code:
    pbTrainerBattle(PBTrainers::DARKPLAYER,"Rorrim",_I("You really are strong, you beat me when I was using your own tactics!"))

    (If you'll notice, the name - that the players will never see because it'll get overwritten by their own name - I gave the Dark Player is "mirror" spelled backwards.)
     
    Last edited:
    Thanks! After a little tinkering around with the script and error messages that came up, it's working! I've added you to the credits for the game. Again, thanks a bundle! :)
     
    Okay, just got it working. (It was a lot easier than I thought it would be)

    Step 1
    Enter your game's PBS folder and find trainertypes.txt At the very bottom of it, add:
    76,DARKPLAYER,Dark Player
    The number at the beginning should be one higher than the number right above it.

    Step 2
    In trainers.txt , add the following to the bottom:
    Code:
    #-------------------
    DARKPLAYER
    Rorrim
    1,FULLRESTORE,FULLRESTORE
    GEODUDE,12
    The only actual bit of code that is important is the line that reads DARKPLAYER. Everything else will be overwritten by the code segment I'm going to add in step 3, but needs to be in the text file so that the game doesn't ignore this trainer. The two Full Restores are items the "Dark Player" will have, so you can edit those to be what you want it to be able to use.

    Step 3
    In RPG Maker XP, open up your game and press F11. This should open up the Script Editor. To the left side, find "PTrainer_NPCTrainers".
    Around line 120, you should find the following code. Add in the red stuff:
    Code:
          pokemon.ballused=poke[TPBALL]
          pokemon.calcStats
          party.push(pokemon)
        end
        success=true
        break
      end[COLOR="red"]
      if isConst?(trainerid,PBTrainers,:DARKPLAYER)
        partytoload=$Trainer.party
        party=[]
        for i in partytoload
          j=i.clone
          j.iv=i.iv.clone
          j.ev=i.ev.clone
          j.hp=j.totalhp
          j.status=0
          for k in j.moves
            k.pp=k.totalpp
          end
          j.calcStats
          party.push(j)
        end
        opponent=PokeBattle_Trainer.new($Trainer.name,$Trainer.metaID)
        success=true
      end[/COLOR]
      return success ? [opponent,items,party] : nil
    end
    Now, any trainers in the Dark Player class will ignore their own party and have a fully-healed version of the player's party. They will also ignore the image of the Dark Player class and use the player's own sprite and name. However, this means that if you want epic final boss music, you have to define it as playing for the player classes, not the Dark Player class, which depending on how you have the Rivals working may mess with the rivals' battle music. (If you have it set up like RSE where the player you didn't choose is your rival, then it will mess with the rival music. If you have it set up like RBY where the rival is predefined and the player you didn't choose is nowhere to be found, then it'll be fine.)

    Step 4
    Set the event up like you would for any other trainer battle, of which many can be found in Essentials' example maps. The relevant line of code for the battle itself (which is couched in a conditional branch) should read as follows:
    Code:
    pbTrainerBattle(PBTrainers::DARKPLAYER,"Rorrim",_I("You really are strong, you beat me when I was using your own tactics!"))

    (If you'll notice, the name - that the players will never see because it'll get overwritten by their own name - I gave the Dark Player is "mirror" spelled backwards.)
    Hi. I found this today and am trying to implement it in my game. But I think the code is outdated?

    Is there anyway you can provide an updated version? Or help me figure out what I'm doing wrong? Thanks
     
    Back
    Top