Just wrote an article about how to spawn enemies based on player greed that will be implemented in the game shortly. Here'a short cut from the article plus the link to the whole thing.
What you need to know about the gameNecken 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 possible.
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 spawnEach 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 will spawn 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.
...
Read the full article herehttp://jocce.com/post/159635140760/designing-enemy-spawn-mechanics