Create random events

Get help using Construct 2

Post » Fri Mar 30, 2012 2:09 pm

I have been building a tower defence game, but to make my game a little more unique and replayable I am trying to build the waves so that when a wave is completed the next wave is randomily chosen from a selection of wave events.

So I would create various wave events e.g. spawn this many ships of this type etc 5 seconds apart for 10 seconds etc. And group them somehow.

That way i can have say 500 different potential waves. And everytime one is completed the game randomily chooses another wave to begin. Some waves might have set requirements e.g. a certain score or energy level etc.

Can anyone advise if this is possible and if it is if they can point me towards how i would begin building something like this within the game so i can push forward myself. (p.s. ideally i wouldnt want the layout to change between waves, more a continuous game with short pauses between waves for the player to catch their breath.

thank you for any responses and thoughts.
B
25
S
7
G
5
Posts: 185
Reputation: 5,056

Post » Fri Mar 30, 2012 2:28 pm

Use groups.
Make them deactivated by default and name them something like "Wave0", "Wave1", "Wave2", etc...

Then let's say we are in "Wave0" group (the group is activated) and the wave is finished and it's time to pick another one.

The conditions of the event depends how you want to set it (change after a certain amount of time, of mobs spawnt, etc...) but the actions will look something like :
system - group "Wave0" (the current group) deactivate
system - group "Wave" & int(random(NbMaxWave)) activate

Where NbMaxWave is a global variable that holds the highest number of wave you have programmed.
The expression will pick a random number between 0 and the max number of waves (for example 500) and concatenate it to form a string that is the name of the next group that will be activated. (From "Wave0" to "Wave25" for example).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Mar 30, 2012 2:52 pm

wow thanks.. that is exactly what i was looking for. I thought groups would be the best way but werent sure how to randomise the selection process.

Thank you for your help :)
B
25
S
7
G
5
Posts: 185
Reputation: 5,056

Post » Mon Apr 09, 2012 11:13 am

Hi, I am having some issues getting the next group and event sequence to activate... Could you take a look at my current capx file to see if you can point out where i am going wrong?

I was trying to set it so that at present when 100 enemies have spawned, enemies stop spawning and the group deactivates and a random other group (as described above) activates. Then when all the current enemies are destroyed the new group begins.

But when ever i test it, the first group works but a new group does not proceed and i am not sure why...?

Capx file:
http://www.tilleydesign.co.uk/capx/EnergyFlux.capxAJTilley2012-04-09 11:17:24
B
25
S
7
G
5
Posts: 185
Reputation: 5,056


Return to How do I....?

Who is online

Users browsing this forum: Magistross, zatyka and 24 guests