Flexible wave/spawn system - best practices?

Get help using Construct 2

Post » Wed Jun 05, 2013 3:28 pm

Hi all!

The forum contains a lot of great information on many things but I believe one topic is lacking that many other than me could benefit from: how to create a flexible wave system that can control multiple enemies and differences in both waves and maps. All posts on the topics (that I could find) seem to only refer to waves with only 1 type of creature and with the same increment from wave to wave (e.g. 5 more monsters per wave).

First of all, let me clarify what I mean by a flexible wave system. In most defense games (TD, BD) and games like Orcs Must Die and Dungeon Defenders, there is a spawner system which controls which enemies spawn at what time and how many of each. It is such a wave system that I'm trying to figure out how to go about in Construct 2. I have been unable to find any information about this on the forums, but please let me know if I've missed any! If someone has already made a system I hope they will share some of their ideas :)

Let's say we have a game with 5 levels each containing 5 waves. The game also includes 3 different monsters. In level 1, wave 1 I want 5 monsters of type 1 to spawn. In wave 2, I want 5 monsters of type 1 and 3 monsters of type 2. In wave 3, perhaps 10 monsters of type 1, 5 monsters of type 2 and 1 of type 3. The number of monsters will be different in the next levels as well. This quickly becomes very difficult for me to deal with in an efficient way.

What I've tried so far. The first example has random spawning - not fixed, which is what I would prefer.
1) In this system, I have a list (a dictionary, really) containing what monster types that are allowed to spawn in a given level. I also have an array which holds the number of monsters to spawn in a given wave. What I then do is when the monster is spawned I randomly make it one of the types that is allowed in that level. So, lets say wave 1 spawns 10 monsters that can be of either type 1 or 2. The function will then spawn 10 monsters with random types, e.g. 4 of type 1 and 6 of type 2. This actually works quite well and is relatively easy to scale from wave to wave and level to level. However, this is random spawning which really isn't what I want.

2) This system is what I'm trying to implement now but it just seems full of hassle. This would be done with arrays and the ability to count instances. Let's say we are in wave 1 of level 1 and want 8 enemies of type 1 and 2 of type 2. What I could do is make an array which would hold the wave number and the monsters to spawn. One way I could think off would be this: (1,1,1,1,1,1,1,1,2,2). I could then, when spawning enemies, use the count to set the monster type, e.g. when monster count is 3 it would choose monster type from index 3 (or 2 with zero-based but let's just ignore that for now to avoid confusion ) which would be 1. And when monster count became 9 it would spawn a monster of type 2. I haven't tried this system yet but I believe it would work. The problem is, if I end up having a total of hundreds of waves each spawning dozens of enemies it quickly becomes extremely messy.

Does anyone have any ideas how to go about it? I was hoping that by posting here, we could together come up with a good way to create a flexible spawning system which makes it easy to control what monsters to spawn in what wave. I'm sure that this would help anyone who is trying to create e.g. a tower defense game and be a great resource to the community.

Cheers!
B
16
S
4
G
4
Posts: 13
Reputation: 4,266

Post » Thu Jun 06, 2013 4:11 am

We are working on functionality very similar to this right now. I will be sure and post here anything we work out that can help propel this topic forward. It may be awhile though, so don't expect a post tomorrow or anything. ;)
B
6
S
1
Posts: 62
Reputation: 532

Post » Thu Jun 06, 2013 7:53 pm

Good to hear that! Would you mind sharing some of your ideas already?
B
16
S
4
G
4
Posts: 13
Reputation: 4,266

Post » Fri Jun 07, 2013 7:20 pm

Does anyone else feel like contributing towards making a good spawn system? I'll update when I've done more progress myself but had hoped to hear from more - surely others must have had the same challenge? :)
B
16
S
4
G
4
Posts: 13
Reputation: 4,266

Post » Fri Jun 07, 2013 7:33 pm

i got a simple algorithm for my wave system. But i do not have multiple monsters at this point.


What you can do is always spawn round(currentwave/3) and spawn that amount of each monster or something. You can get far with a bit of math. And maybe start that when currentwave > 10 or something.

i also do monster -> set HP = currentwave*5
mrPeanut2013-06-07 19:34:30
B
9
S
3
G
3
Posts: 70
Reputation: 1,990

Post » Fri Jun 07, 2013 10:41 pm

I have never saw trigger once! FOR CHRIST!
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

Post » Mon Jun 10, 2013 3:39 pm

Thanks a lot for the input, @mrPeanut. It's a good suggestion with the currentwave/x to differ between the monsters! I'll post in this thread when I've done more work on it. More suggestions are very welcome as well :)
B
16
S
4
G
4
Posts: 13
Reputation: 4,266

Post » Mon Jun 10, 2013 3:51 pm

You could store the information about what you want to spawn (type, spawn spot and amount) in array. Then have couple of variables (wave, level) that basically index that array. At start of every wave you call a spawn function, which looks at data the array has defined for the wave/level array. Spawn stuff based on values in indexed array positions.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Mon Jun 10, 2013 5:09 pm

Here is a quick example how system I described could work:

Spawner example

It's very basic, but expanding it should not be too hard.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Tue Jun 11, 2013 5:34 pm

[QUOTE=vee41] Here is a quick example how system I described could work:

Spawner example

It's very basic, but expanding it should not be too hard.[/QUOTE]

This is so awesome! Thank you so much @vee41 :D This looks very promising and much better than anything I could come up with. I obviously still have a long way to go with construct :D And great you included several spawning locations - that only makes it even more flexible!
B
16
S
4
G
4
Posts: 13
Reputation: 4,266

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests