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

Clone Trainer

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • Thanks to Rot8er_ConeX
    original post : http://www.pokecommunity.com/showthread.php?t=355236

    -------------------------------------------------------------------------------------------------------------------------------------

    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:

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    I think this tutorial should use the Events.onTrainerPartyLoad procedure rather than editing PTrainer_NPCTrainers. That's what it's for, and it's easier to distinguish from the base Essentials code.
     
    Back
    Top