Pokemon Encounters - RMXP Tutorial

Jeff_PKLight

RMXP User
  • 535
    Posts
    20
    Years
    Well, if you wondered how to make pokemon encounters in RMXP, here's one way.

    First, go to your Script Editor. Open up Game_Player, and on line 269 (or around there), you'll find this script:

    Code:
    if last_moving

    Right after that code, insert this code:

    Code:
    # START OF EDIT
            
            @terrainid = $game_map.terrain_tag(@x, @y) #Grabs the ID of the terrain
            if @terrainid != 0 #0 means no encounters will happen, any other number and it'll make checks.
              @encounterchance = rand(30) #Sets the chance to a random number between 0 and 30
              if @encounterchance > 24 #If the number is 25+ an encounter will occur
                @monstertype = rand(3) #Sets a variable to a random number between 1 and 3, this essentially means that there are 3 types of pokemon you can find in each type of terrain ID (if you want to change this you have to change the next 3 as well
                if @terrainid > 1
                  @monstertype += 3*@terrainid #This sets the enemy troop based on the terrain ID.. Essentially, TerrainID 1 will pull one of the first 3 monster groups from the database, ID 2 will pull one of the next 3  (4-6) and ID 3 will pull 7-9 and so forth. Problem here occurs with the fact that there are only 8 terrain ids (0-7) so you'd have to figure out another way of doing it.
                end
                $game_variables[10] = @monstertype
                $game_switches[34] = true
              end
            end
            
            # END OF EDIT

    That means you'll need to set the pokemon encounter tile to a terrain. Open up your database and go to the tileset with the tile that you want pokemon to only occur in (ex: grass). Set the terrain to a number, probably 1.

    For the next part, you'll need to change the script numbers 10 and 34:

    Code:
    $game_variables[10] = @monstertype
                $game_switches[34] = true

    ....to the one you assign the switches/variables below.

    Now, go to the 'Common Events' section of the database. Create a new common event entitled "Battle", set to Auto Start, and then trigger the switch for 'Battlestarter'.

    Create a Conditional Branch when Variable Monster Group equals 3 (Here's the trick. Take the terrain number and multiply by 3 to get the variable you need to make that pokemon appear). Under the Conditional Branch, set an 'Enemy Encounter' and choose an enemy.

    That's it! Simple, huh? Well....only problem is, you can't do a lot of pokemon with this method. This should only be used if you want a pokemon encounter script temporarily.

    ------------Credit goes to Prexus first, and then me----------------

    Enjoy

    ~~~Jeff

    (This was my script I wrote on the BSP Forums. I just took the one I wrote there and placed it here so more people can use it.)
     
    Jeff_PKLight said:
    Well, if you wondered how to make pokemon encounters in RMXP, here's one way.

    First, go to your Script Editor. Open up Game_Player, and on line 269 (or around there), you'll find this script:

    Code:
    if last_moving

    Right after that code, insert this code:

    Code:
    # START OF EDIT
            
            @terrainid = $game_map.terrain_tag(@x, @y) #Grabs the ID of the terrain
            if @terrainid != 0 #0 means no encounters will happen, any other number and it'll make checks.
              @encounterchance = rand(30) #Sets the chance to a random number between 0 and 30
              if @encounterchance > 24 #If the number is 25+ an encounter will occur
                @monstertype = rand(3) #Sets a variable to a random number between 1 and 3, this essentially means that there are 3 types of pokemon you can find in each type of terrain ID (if you want to change this you have to change the next 3 as well
                if @terrainid > 1
                  @monstertype += 3*@terrainid #This sets the enemy troop based on the terrain ID.. Essentially, TerrainID 1 will pull one of the first 3 monster groups from the database, ID 2 will pull one of the next 3  (4-6) and ID 3 will pull 7-9 and so forth. Problem here occurs with the fact that there are only 8 terrain ids (0-7) so you'd have to figure out another way of doing it.
                end
                $game_variables[10] = @monstertype
                $game_switches[34] = true
              end
            end
            
            # END OF EDIT

    That means you'll need to set the pokemon encounter tile to a terrain. Open up your database and go to the tileset with the tile that you want pokemon to only occur in (ex: grass). Set the terrain to a number, probably 1.

    For the next part, you'll need to change the script numbers 10 and 34:

    Code:
    $game_variables[10] = @monstertype
                $game_switches[34] = true

    ....to the one you assign the switches/variables below.

    Now, go to the 'Common Events' section of the database. Create a new common event entitled "Battle", set to Auto Start, and then trigger the switch for 'Battlestarter'.

    Create a Conditional Branch when Variable Monster Group equals 3 (Here's the trick. Take the terrain number and multiply by 3 to get the variable you need to make that pokemon appear). Under the Conditional Branch, set an 'Enemy Encounter' and choose an enemy.

    That's it! Simple, huh? Well....only problem is, you can't do a lot of pokemon with this method. This should only be used if you want a pokemon encounter script temporarily.

    ------------Credit goes to Prexus first, and then me----------------

    Enjoy

    ~~~Jeff

    (This was my script I wrote on the BSP Forums. I just took the one I wrote there and placed it here so more people can use it.)

    Do you leave:
    Code:
    # START OF EDIT

    and

    Code:
    # END OF EDIT

    In there?
     
    Yes. Anything that has the # symbol before text means that it's a comment (so it doesn't count towards the real script). :)
     
    Can I see a screen of this working
     
    My DBS is being fixed (the encounter and all), so I can't get a screen of it. Though someone could get one... :\
     
    datriot said:
    if you edit the script, will the script that has been edited be edited even if you make another game?

    What are you trying to say? :\ If you mean the comments after #, you can edit that. You can also edit the switch number, variable number, and some other numbers.
     

    I think he means if you edit the script for a pokemon game, but then make a new project for a diffrent type of game (Non-Pokemon) will the script still be edited for will it be default.
     
    Oh, okay. Well datriot, it'll work still. :)

    ~Jeff
     
    BlackCharizard, perhaps you didn't make the terrain number or possibly you didn't set up your pokemon to be encountered.
     
    Well, maybe I'll figure it out later on. BTW, does any1 know hwt the hell is going on with all the images on PC today???
     
    Back
    Top