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


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Events?
Author Message
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #1
Random Events?

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

05-27-2011 10:55 PM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #2
RE: Random Events?

Random events are easy.

Example:
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
Find all posts by this user Quote this message in a reply
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #3
RE: Random Events?

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

Example:
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?:

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-28-2011 10:01 AM
Find all posts by this user Quote this message in a reply
jens Offline
Frictional Games

Posts: 4,095
Joined: Apr 2006
Reputation: 202
Post: #4
RE: Random Events?

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
Visit this user's website Find all posts by this user Quote this message in a reply
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #5
RE: Random Events?

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

05-28-2011 10:50 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #6
RE: Random Events?

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

05-28-2011 01:37 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)