Frictional Games Forum (read-only)

Full Version: Random Events?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I was wondering how you make random events. If you could post the script that would be great Big Grin
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;
     }
}
(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;
}
}


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.
(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 :/
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