Post feature RSS Designing enemy spawn mechanic

How do you go about designing an enemy that spawns only when the player is greedy, and how do you make it feel "right" with the other game mechanics, and how do you make it feel fair?

Posted by on

What you need to know about the game

For this article to make sense, a short explanation of the game is required: Necken is a tile based game that is very mechanically driven. The game focuses on strategy and tries to stay away from "action based skills". Each decision you make is based on strategy.

The game has two currencies: Wood and Stone. They are gathered from any Wood tile or Stone tile. Each of these tiles have charges that recharge differently. Wood recharges each tick - each "turn", while stone only recharges once the tile is completely depleted.

What I'm trying to build

The resource gathering is quite dull, and to make it more interesting, there will be a risk added to it.

The idea is to incorporate this: "When the player is greedy, the forest will defend itself". This will involve spawning a new set of enemies based on each resource - a wooden maiden and a stone troll.

This means that the level will defend itself by creating enemies when the player gathers resources, without feeling unfair, unbalanced or too flat. The ideal approach is to increase the difficulty over time. If the player stays too long, the difficulty will increase, so that the player doesn't want to stay longer than necessary.

The problem to be fixed

The first one I mentioned already, the gathering is quite dull. The second reason is that the players have the possibility to gather a large sum of resources, and never have to worry about it for the rest of the level.

One obvious way to solve this is to add a maximum cap - "the player can only hold 20 wood and 20 stone". This could however be solved in a more interesting way.

The components needed are these:

* When does a resource based enemy spawn?
* Where does it spawn?
* How do this increase over time?
* How do this tie into greed?

When to spawn #1 - Time based spawn

Each second is called a 'tick' in the game. A new turn. Enemies spawn and move based on ticks, resources recharges based on tick etc.

"For every x ticks, a resource enemy will spawn".

To make this a bit more tied with the questions above, let's evolve this.

"For every x ticks, a resource enemy have a chance to spawn, based on the resources the player is carrying".

With this, a system could work like this: If the player is above a 'safe threshold' (let's say 10) of resources, there's a slight chance an enemy will spawn. The more resources the player is gathering, the higher the chance. But, we also need something to monitor the fact that an enemy has spawned. If the player have 50 resources ("high chance"), and an enemy will spawn - what happens the next time? Equal chance for another spawn? Or, less chance, since the last enemy "used up" the already high probability?

If the chance is the same, this will spawn a lot of enemies when the chance is high enough.
If the chance is lowered each time an enemy is spawned, the player can gather a lot of resources still.

It could work something like this:

"Each x tick,
If the player have above 10 resources,
There's a chance of 1% per resource above 10 resources, minus 5 for each spawned and alive enemy."

Each time the player kills a resource based enemy, the offset will be lowered. The right call is to avoid killing them. This approach will be very affected by where the enemy is spawned, that will be mentioned later in this article.

When to spawn #2 - Collecting based spawn

A collecting based spawn would trigger each time the player gathers a resource instead of every tick. An approach could work something like this:

"Each time a player gathers x resources, an enemy spawns"

This is very static and very easy to see through. Every 20 resources, an enemy spawns. It does work, and it does tie into the greed part, but it doesn't feel very satisfactory, it feels too simple. Let's elaborate it a bit:

"Each time a player gathers a resource, there's a chance that an enemy spawns, based on the current held resources."

It's the same idea, but it adds risk into the mix, something that players will most likely enjoy more than a static "every x". If the player is greedy, there's an added chance for an enemy to spawn.

Let's say that each time you gather a resource, there's a +1% chance that an enemy will spawn. Do we reset this each time we spawn like before? Or, do we keep the percentage just as high? The player can come to a state where an enemy is spawned each time a resource is gathered. We can imagine that the player has been kind of greedy at that point. A good thing, yes?

Saving the highest chance as a separate variable, each time the player gathers a resource makes sense. When the player is greedy but lucky enough to not trigger a spawn, the whole purpose of the system is wasted. Instead, if we are saving the highest chance we can use this to trigger at least some enemies from time to time.

Imagine that the player have 20 resources - 10 above the threshold. This would mean 10% chance to spawn. If the player uses the resources, he will be below the threshold again, and is safe from spawning. But, if we save the chance, and only lower it once an enemy spawns, we ensure that some enemies will enter the game due to greed at least.

Implementing a small drop-off, like 5 units per spawn, will result in something like this: If the player have 20 resources and then wastes them, there's still a 10% "saved" chance to spawn an enemy each time a resource is gathered. When we eventually spawn an enemy, we lower the saved chance by 5 units, so it's 5% chance. If another spawn triggers, we lower it again and the player is "safe" again.

Even though I personally like this approach, the player should always be aware that an enemy has spawned because of the greed. This needs to be telegraphed (if the enemy doesn't spawn right next to the player of course). This approach is also very affected by the way we actually spawn an enemy now that we have calculated that we will indeed spawn an enemy.

Where to spawn #1 - Directly

When an enemy is about to be spawned, let's just spawn it right next to the player, or actually, right next to the tile that is being gathered. In the gif above, the enemy is spawned next to the tree, defending it.

If we are using a time based spawn evaluation, there's no connection between the greed and the tile the player is near. It will look like a random enemy from nowhere.

If we instead use the collecting based spawn, the enemy will pop right out from the tile that the player is gathering from. This will be a more obvious way to show the player that greed is being punished.

But, this puts the player in a tough spot. If the game is about strategical choices, would the player have gathered from this tree if a spawn was supposed to happen? Shouldn't the player get to decide that for himself?

How will this affect difficulty over time? It won't. Or, actually, indirectly. If the player gets slowed down, it will take longer to reach a powerful state.

Imagine that the birds aren't there..

Where to spawn #2 - Indirectly

In the gif above (which is from an old prototype version of Necken), the birds show the player that an enemy hides in the tile. The player can still choose to gather resources from it, with the enemy popping out when the player gathers it's resources.

An indirect spawn would instead of spawning the enemy directly, pick a resource tile near the player, and put a bird on top of it. This will tell the player that if you gather resources from this tile, there will spawn an enemy to defend it. The player suddenly have a choice - either continue the greed, or find another tile to gather from. This doesn't really make the player less greedy automatically, but the player will be punished for it, but still maintaining the choice of actually spawning the enemy. The player might as well find a nearby tree and continue. But, since the tiles take some time to recharge, the player might eventually have to gather from a tile with a bird on it.

How will this affect difficulty over time? Let's say that the player has beed greedy enough to spawn 5 birds (guaranteed enemy spawns), but only discovered 2 of them. The other 3 are hidden deeper in the level. When the player reaches them, they will already be full of birds, so they will not be as "cheap" as the previous resources.

Let's also assume that the birds can stack. If a random tile gets chosen twice, it will contain two birds. This will show the player that an even more powerful foe is hidden there, because of a mix between "bad random luck" and the player's own greed.

Above is a bird in the tree, which means there's an enemy waiting to attack there.


There's a lot more to think about than just spawning enemies to make the game harder. There are a couple of easy ways to solve the problem, but are they really adding quality to the game, or will the player feel like it's a cheap way to solve it? Adding more choices to the player instead of using numbers for max capacity, spawn time and "greed", will probably make the player feel like it's his own "fault" that they attacked him, rather than the feeling of random enemies thrown in the face from time to time.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.