Flexible wave/spawn system - best practices?

0 favourites
  • 10 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • 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 <img src="smileys/smiley1.gif" border="0" align="middle" />) 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!

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

  • Good to hear that! Would you mind sharing some of your ideas already?

  • 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? :)

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

    <img src="http://i.imgur.com/XhzcucSl.jpg" border="0" />

    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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have never saw trigger once! FOR CHRIST!

  • Thanks a lot for the input, 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 :)

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

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

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

    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!

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