Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Events?
NylePudding Offline
Member

Posts: 77
Threads: 23
Joined: Apr 2011
Reputation: 0
#1
Random Events?

How would you make it so then if you walked into a ScriptArea, there was a chance 3 different individual things would happen?

Would you have a variable for instance called: "RandomEvent" and basically say:

RandomEvent = 3

AddEntityCollideCallback("Player" , "ScriptArea_1" , "BodyFunc1" , true , 1);

RandomEventFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("corpse_male_1" , true);
AddTimer("tut03", 10, "Timer02");
RandomNumber(3) = RandomEvent ;
}

if RandomNumber == 0
{
Spawn Monster
}

if RandomNumber == 1
{
Put out candles
}

if RandomNumber == 2
{
An Evil Donkey of mass destruction kills you
}


I know a lot of that wasn't actually C++, but if actual functions were used would that work?

Also what would those functions be? Tongue
(This post was last modified: 05-01-2011, 02:45 PM by NylePudding.)
05-01-2011, 02:44 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: Random Events?

Something like that. You could do like:

int Random = RandInt(1,3)

...

if (Random==1)...
if (Random==2)...
if (Random==3)...
05-01-2011, 02:57 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#3
RE: Random Events?

This is what it could look like:

OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Function01", true, 1);
}
void Function01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1,3);
if (x == 1)
{
[spawn monster]
return;
}
else if (x == 2)
{
[put out candles]
return;
}
else if (x == 3)
{
[an evil donkey of mass descruction kills you]
return;
}
}

I would usually indent the lines correctly, but the post doesn't like it. Smile

(This post was last modified: 05-01-2011, 03:13 PM by Kyle.)
05-01-2011, 03:12 PM
Find




Users browsing this thread: 1 Guest(s)