Frictional Games Forum (read-only)
Random Events? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Random Events? (/thread-7731.html)



Random Events? - NylePudding - 05-01-2011

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


RE: Random Events? - MrBigzy - 05-01-2011

Something like that. You could do like:

int Random = RandInt(1,3)

...

if (Random==1)...
if (Random==2)...
if (Random==3)...


RE: Random Events? - Kyle - 05-01-2011

This is what it could look like:

Code:
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