How to make random events?

This forum is currently in read-only mode.
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

    ...

  • 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.

  • 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.

  • K Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)