How to make random events?

New releases and general discussions.

Post » Sat Dec 13, 2014 7:50 am

I'm making a game which is set in space in the near future and like space traveling is a thing, so I want it to have conditions like, "If you are this far in the story, these random events can happen." Any ideas?
B
2
S
1
Posts: 4
Reputation: 308

Post » Sat Dec 13, 2014 8:04 am

global constant number AT_THE_START = 1
global constant number NOT_VERY_FAR = 2
global constant number QUITE_FAR = 3
global number HowFarInStory = 0

System: At start of layout
System: Set HowFarInStory to AT_THE_START

<if certain conditions>
System: Add 1 to HowFarInStory
<etc>

System: HowFarInStory = NOT_VERY_FAR
Function: Call choose("DoNotVeryFarThing1", "DoNotVeryFarThing2", "DoNotVeryFarThing3")()
System: Once while true
else
System: HowFarInStory = QUITE_FAR
Function: Call choose("DoQuiteFarThing1", "DoQuiteFarThing2", "DoQuiteFarThing3")()
System: Once while true
else
...
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Dec 13, 2014 9:14 am

Thanks man, but what do you mean by HowFarInStory = 0 ?
EDIT - Oh I understood it, I'm gonna try it out after sometime. I would understand a lot more if you could show me a small example. BTW thanks. :D
B
2
S
1
Posts: 4
Reputation: 308

Post » Sat Dec 13, 2014 9:27 am

Well, your question was kind of vague... :) So I gave you a pretty generic sample. It pretty much translates into C2 code...

HowFarInStory is a variable tracking your progress in the game.
I set it to 0 as a way of saying "has no value" because you can't use variables when setting another variable's initial value in properties. That's done later in 'on start of layout'
The constants are just a nice way to keep track of special values. Makes your code readable.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Dec 13, 2014 9:37 am

K Thanks! :D
B
2
S
1
Posts: 4
Reputation: 308


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests