First I want to define the terminology used in this series:
skeleton of a level - minimal spanning tree
section of a level - a (small) portion of a level in which the player can walk freely around, these are the nodes of our graph
gate - a connection between two sections, these are the edges of our graph
goal - a certain section which has to be reached
critical path - a path from the entry point of the level to a goal
backbone - all edges which are used to reach atleast one goal
Well, this time I want to create goal chains. A goal chain is a collection of more than two goals, which must be reached in the correct order. A simple example are the red,blue,green keys in older FPS. Find the red key to gain access to an other part of the level to find the blue key and so on. This simple key-gate->goal principle is found very often in modern games, but the keys and gates are more sophisticated. In fact you have to do something before you are able to progress to your final goal, which is just a key. I.e. kill a boss, recover a stolen item, activate a secret button, disarm a trap.
The problem with generated goal chains is, that you must ensure that you don't add barriers (gates) which can't be overcome, because a key which is needed earlier is behind the barrier. This is some kind of gamelogic deadlock. Think about a red and blue door and the according keys. If you put the red key behind the blue door and the blue key behind the red door the game is in fact unsolvable, and even more frustrating.
In this installment I will show you how to divide your level into islands of sections. One or more of these islands define a quest space in which you can safely place a key without the danger of deadlocks.
As we seen in part I you choose a goal on the skeleton, calculate the unique critical path to this goal and you can place a gate on this path as barrier. This time will we take the gate and subdivide the skeleton into two islands by removing the gate-edge. The island, which still contains our level-entry will be used for the next iteration. The next iteration is simple doing the same,
choose a goal, find the critical path, place a gate and remove the gate-edge. Each goal, except the last one, should contain the key to the next gate. Take a look at figure 1. Once we have finished this process we add all edges which lead to a goal, to the set of backbone-edges.
As you can see in the final graph version, almost all edges are backbone-edges, just two are not used in any critical path to a goal. This can be utilized to extend the chain of goals, or to start a new one.
For a new chain of goals we can repeat the whole procedure with one limitation. We start with the same skeleton, without any islands, but we keep the backbone set of edges from the previous run. The limitation is to don't add any gate to an edge which is already contained in the backbone set. This implies that any new goal-node is not part of any critical path to a goal defined in the previous run. The reason is that we don't want to block the "main" quest with a barrier from a "sub" quest.
In this part we worked out how to add chains of goals without blocking other more or less independent goals. In one of the next installments we will discuss fleshing out tge quest.