Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jury_Rigged107 on Sat 22/08/2015 20:31:03

Title: how to make random stuff happen?
Post by: Jury_Rigged107 on Sat 22/08/2015 20:31:03
I am not sure if this simple or not
but I want a effect of when you enter a room it might be the room it might be some random other place.
kind of like the insanity effect in trilby's note.
also how do you switch playable characters?
Title: Re: how to make random stuff happen?
Post by: Grok on Wed 26/08/2015 17:44:41
If you use the Help function at the top of the editor you will find the answers to many question of this sort. :)
---------------------------
Random
Random (int max)

Returns a random number between 0 and MAX. This could be useful to do various effects in your game.
NOTE: The range returned is inclusive - ie. if you do Random(3); then it can return 0, 1, 2 or 3.

Example:

int ran=Random(2);
if (ran==0) cEgo.ChangeRoom(1);
else if (ran==1) cEgo.ChangeRoom(2);
else cEgo.ChangeRoom(3);

will change the current room to room 1,2 or 3 depending on a random result.


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

cMan.SetAsPlayer();