Goblin Camp is a fantasy city-building game inspired by Finnish mythology. Deep simulation mechanics capture the unique challenges of surviving the harsh winters and carving a thriving settlement out of the northern forest. Lead your goblins to greatness!
Hello, this is the first Goblin Camp devlog. We'll post these devlogs every now and then to highlight some of the work we've been doing lately.
In this post I'll be going through what I've spent most of last month programming.
Farming is a critical activity for our little goblins, it's one of the main ways to provide food for your village. The fertility of the soil determines how much food you get out of a farm plot, so boosting fertility means boosting food output. Slash-and-burn agriculture is an effective and exciting way to do so.
[h3]Slashing, establishing a swidden[/h3]
[i]An area of land that has been cleared by cutting the vegetation and burning it; slash and burn.[/i]
First the player selects a rectangular area on the map to make into a swidden:
All of the flora (trees, bushes and the like) within the swidden are marked for clearing and the goblins get to work. They'll grab axes to fell trees or just use their hands if they need to clear bushes and smaller plants.
For each tree we take the approximate center of the swidden and record a 'preferred fall direction' that points towards the center. The goblins use this information when they decide which side of a tree to be on while chopping it with an axe, the goal being to minimize the amount of branches and logs that fall outside of the swidden.
Any burnable items that make their way into the swidden one way or another are reserved by the swidden to prevent other jobs from trying to use the branches and logs within. For example, any branches inside a swidden should not be used by the carpenter to make digging sticks out of.
A two tile wide perimeter is established around the swidden as a firebreak. Any items within the firebreak get moved closer to the center of the swidden.
Once everything is in place the player can open the slash and burn dialog and enable fires.
Goblins will equip branches and station themselves within the firebreak. If there are no active fires they will start new ones, based off of wind direction so that the fires are started upwind. This ensures that the fires spread in approximately the right direction.
As an aside, this required me to write code to differentiate between "wild fires" and "swidden fires". We already had existing code that told goblins to put out any fires that were threatening their village so when swidden fires were started other goblins would rush in with buckets and put them out immediately.
Whenever fires spread into the firebreak goblins will go there and put out the fire with their branches.
Selecting a fire is not done strictly by selecting the nearest one, this would lead to goblins clumping up when there are few fires and they would consequently all go to the same fires as a group. Instead random fires are selected for each goblin so that they tend to spread out. If a goblin encounters a new fire while moving they will stop and put that fire out as well as any other adjacent ones, which minimizes the chances that they foolishly run past fires to put out far away ones.
This cycle of igniting fires and putting them out is carried on until all tiles and burnable items within the swidden have been burned.
At that point the swidden is automatically removed and the firewatcher goblins freed to do other work. This is the point where the player can then create a farm plot over the now much more fertile ground. Tilling the new farm plot will incorporate the ashes into the soil and increase crop yields.
This was a very interesting feature to get done, it required quite a bit of coordination between various elements in our game. Combining a chaotic element like fire with intelligent behaviour of goblins can easily lead to things happening in game that look "dumb" to the player even if the code is technically doing the right thing. The end result here is satisfying, it's fun to watch the goblins scramble to contain a fire they started themselves.