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-8286.html)



Random Events? - Henriksen - 05-27-2011

Hi, I was wondering how you make random events. If you could post the script that would be great Big Grin


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

Random events are easy.

Example:
Code:
void OnStart()
{
     AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     int x = RandInt(1, 3);
     if (x == 1)
     {
          [Whatever happens if the number it picked is 1 (1 is least, 3 is greatest)]
          return;
     }
     if (x == 2)
     {
          [Whatever happens if the number it picked is 2 (1 is least, 3 is greatest)]
          return;
     }
     if (x == 3)
     {
          [Whatever happens if the number it picked is 3 (1 is least, 3 is greatest)]
          return;
     }
}



RE: Random Events? - Henriksen - 05-28-2011

(05-27-2011, 11:04 PM)Kyle Wrote: Random events are easy.

Example:
Code:
void OnStart()
{
     AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     int x = RandInt(1, 3);
     if (x == 1)
     {
          [Whatever happens if the number it picked is 1 (1 is least, 3 is greatest)]
          return;
     }
     if (x == 2)
     {
          [Whatever happens if the number it picked is 2 (1 is least, 3 is greatest)]
          return;
     }
     if (x == 3)
     {
          [Whatever happens if the number it picked is 3 (1 is least, 3 is greatest)]
          return;
     }
}

Ahh thanks but one more thing. Would it mess up the script if i redo it so it looks like this?:

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}

void Func01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1, 3);
if (x == 1)
{
[Whatever happens if the number it picked is 1 (1 is least, 3 is greatest)]
return;
}
if (x == 2)
{
[Whatever happens if the number it picked is 2 (1 is least, 3 is greatest)]
return;
}
if (x == 3)
{
[Whatever happens if the number it picked is 3 (1 is least, 3 is greatest)]
return;
}
}





RE: Random Events? - jens - 05-28-2011

What's the difference? That you removed the tab layout? If so then no that will not break it, but it is harder to read.


RE: Random Events? - Henriksen - 05-28-2011

(05-28-2011, 10:49 AM)jens Wrote: What's the difference? That you removed the tab layout? If so then no that will not break it, but it is harder to read.

Yeah that was the "difference", still it doesnt work ingame :/


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

If it doesn't work ingame, did you:

-Make sure the ScriptArea matches up with the name of it in the script?

-Make sure you filled out all the scenarios?

-Make sure the scenarios will actually be noticable?

If you checked it already, then it is best to repost your script with the scenarios you added.

Note: Please use [cod*e] and [/cod*e] (Without asterisks) between your code to make it look neater. Smile