Random counter

Hi all,

I'm making a game at the moment. In this game there's an enemy that follows you around the house. But it only spawns when i click on a certain object. What i want to do is make it spawn randomly whenever i enter a room(like ano oni), but I don't know how to do this. Could anyone help me with that?

Thanks in advance!
The pinned topic for this forum starts 

This forum is meant for discussing the Maker series as well as other programs and utilities that may help with game creation.
It is not a "how do I do this?" forum.  For this sort of question you go to the Support forum for the engine that you are using.

Assuming that you are using Ace, as it says under your avatar, I shall ask to have this moved to VXAce Support forum.
By randomly, do you mean at a random time in a specific location, or in a random location at a specific time? Both are fairly easy to accomplish.
Random time with specific location. Like there are 10 rooms and everytime I enter a room i want there to be a change of spawning the monster.
Here's a quick tutorial: (25% chance that the monster will appear.)

On your monster event's page conditions, have it require a variable to be equal to or greater than 4.

Give your monster event an additional blank page, preferably the last page.

Create a new event at the entrance to the room. Set the trigger to player touch or event touch.

Inside of this event, set a variable(the same variable you used for your monster) to be equal to a random number between 1 and 4.

Whenever the player steps on this event, they're a 1 and 4 (25%) chance that the monster's page condition will be met, causing it to appear in the room.

Repeat for other rooms.

Now, there are other ways to go about this. You could use the same monster event for each room by changing its location x, y location for example. I can post some sceenshots in demonstration, but not until I get home.

Edit: On second thought, since this is for 10 rooms, there's a better way to do this. If someone hasn't answered this already, I'll post some screenshots when I get home.

Edit (Alright I'm home)

I cheated a little and used a script call to get the player's location.
random_spawn01.PNGrandom_spawn02.PNGrandom_spawn03.PNG

This is if the rooms are on the same map. If you want the monster to spawn upon entering a new map, this becomes even easier. I went ahead got did more difficult of the two just in case.

For entering a new map: use an autorun, roll a random number, check for a number within the range using a conditional branch, if true, flip the monster switch...
Hi ribobi,

Thanks for the response! It works now when i enter a room but when i go out of the room the monster doesn't follow me anymore which it did before. I used this tutorial, i made it almost the exact same. Could you help me combine that turoial and yours? Thanks for helping me out already this much! (Tutorial link: http://www.rpgmakervxace.net/topic/26992-how-to-make-a-chasing-monster-like-ao-oni/
This is one of those rare occasions where erase event actually comes in handy.

This event works pretty well when transferring from room to room while something's chasing the player. Some assembly required.

random_spawn04.PNGrandom_spawn05.PNGrandom_spawn06.PNG
Thank you very much! It works now!

Original thread: https://forums.rpgmakerweb.com/threads/random-counter.51584/