Random Encounter Events

This script allows you to run a common event when you encounter an enemy through “random encounter”.

When the common event finishes executing, the random encounter battle will begin.

In this common event, you have the opportunity to run some extra logic before the battle occurs. The enemy troop that you will battle is available, and you can use this information in your event. For example, you may choose to display a message if a certain troop is encountered.

This script provides a special command that allows you to “cancel” the encounter, allowing you to create mechanics that allow players to skip encounters if they do not wish to battle.


Script: download here


In the script editor, place this script below Materials and above Main


In the configuration, you can choose a variable that you will use to determine which common event to run. This allows you to change the common event during the game if necessary.

The enemy troop that is encountered can be accessed using script calls by referencing


If you would like to cancel the random encounter, use the script call


And the encounter will be canceled.

You may also like...

17 Responses

  1. KimoVoid says:

    Hey, i know this is old, but you can explain better how to use it?

  2. Shinryoku says:

    Love your works! I have a Question, and its about those cool emoji that pops up like when a character is angry, surprised, shocked etc. Do you know of any tutorial that shows how to add those to the events/character? Been trying for a while to find anything about it. XD

  3. Kris says:

    I am using VX/ACE, I have double and triple checked my commen event ID and have made sure there are no conflicts with other pre-written scripts I am using. The only thing in the event is a “show_text.” I am also using Yanfly’s Ace Battle Engine, but there doesn’t seem to be any conflicts in the script. When there is a random encounter, the common event is just ignored.

    • Kris says:

      Nevermind… I figured it out

      In case anyone else is confused by this, Variable (in the script) is a game_variable which contains the ID of the common event.

      • Kris says:

        okay… nevermind again. I’ve got the event working, but cancel_encounter does not work. I’ve tried to find the definition for the cancel_enounter method and have not been able to do so; nor have I found how to write my own. What am I doing wrong? In the event page I have added a “script” with the contents, “cancel_encounters” but I am given a error message saying, “Undefined local variable or method cancel_encounter

        • Hime says:

          That’s strange…I just lookd at the script and found that it’s not there.

          The script in my project has it though. I may have forgotten to copy it over.

          I have updated the script with the script call.

  4. mjshi says:

    How would you use $game_troop in a conditional to check if the incoming troop is a certain ID? (say, for example, the player will say a certain line before being attacked by slimes (troop id 1))

  5. wall says:

    I can’t get it to work.

    changed the number to 8, and made this commen event 8:

    Show animation: Wind 1 (wait)
    Script: $game_troop

    I want to play an animation before any random encounter, but it doesn’t work.

    • Hime says:

      I don’t think show animation works in a common event by default. Try changing it to “show text” to test whether it works or not.

  6. Bearsmith says:

    You could even use this to make an Etrian Odyssey type encounter warning. Have a meter that displays a variable that counts up each time the event is triggered and cancels the battle unless the variable is high enough.

    Could also use this to have a mechanic where you can deplete the population of monsters in an area. Every won battle decreases a variable, and when that variable is 0 this event doesn’t let battles run anymore.

    Overall a great script for adding variety to random encounters. Very awesome.

    • Hime says:

      Those are great ideas. Maybe I’ll put up some video demos to show how easy it is to add your own unique encounter systems.

  7. Grounded says:

    This is brilliant 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *