Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Completely Random event

Xyphien

Owner
Staff member
Administrator
Resource Team
Xy$
9.57
I'm about to make a simulator game, and need it so random people will enter the room and talk to you. For example:
8313

The guy in the suit is a salesman, he comes at random, walks in, and talks to you. How would you go about making it so random people come in and talk to you at random times. Not just the sales man, but if a plumber comes in, fireman, waitress, etc.
 
David Foxfire said:
  1. Create Common Event, this will be your overall event checker.
  2. Parallel Process it on each map to do the following:
  • Set timer to countdown starting at random time
  • After countdown, select random variable between 0 - X; X being the maximum number of possible events you can have happen on a certain map, in your case, 3
  • After it has chosen a number between 0 - 3, set that as your Global Event Variable.
3. Create all your events on that map and position them as you would. Have them set and activated by checking to see if the Global Event Variable is a certain value.

If it is 0 then loop the parallel process again and it will countdown at a different time and pick a different number. If it has selected 1 - 3, then the event will trigger. From here you could be doing this many ways. If you wish to continue random events even when one is currently running then you will need to check to see if your Global Event Variable has a value. If it does, then loop the random countdown once more but this time assign the value to a second Global Event Variable. This can continue forever. If you wish not to run another event when one is running then check the 1st Global Event Variable and if it contains a value, temporarily loop itself back again after a random countdown once more and continually check to see if the Global Event Variable has a value, when it no longer doesnt then replace it's value with a random one like you were from the very beginning.

This is the easiest and most flexible way to do it.
He mentioned this in a thread on here, if I recall. You could make it so the common event also deals with changing the sprite, and then just have it play in a parallel blank sprite or something.
 
Top