HOW-TO: Create a monster encounter

Time to add some of Geralt’s best friends to our world. Monsters!

If you are completing our tutorials in order, by now you should have your own world and in it a very basic quest structure set up with Roach spawning in the middle of the level. Now we will add some more creatures to our world. These will however not be as friendly as our loyal steed.


Encounters vs Communities

Both Encounters and Communities are valid ways to spawn NPCs, but they each have their own strengths and weaknesses.

  • Encounters - used for larger groups of NPCs (humans, animals and monsters). Encounters are bound to an area that you define within a single world. They are great for setting up city crowds, village communities, herds of animals/monsters nests, patrols and quest group fights.

  • Communities - used for Quest related NPCs (humans, animals and monsters). Communities are not bound to a single world. They are great for setting up Quest important NPCs with many different phases, smaller groups of enemies.


1. Create a new group and layers

Open your test World level from the previous tutorial or load an other existing world. In the Scene Explorer make sure to load in all the files: right click on World icon and Load all in group. You can also use just the living_world folder.

The folders which you selected should change their colour to signify that files have been loaded.

92433687-07b1-4669-baef-0e24941974f2.png

Before you can set up an encounter, first you need to create a new layer in the world.

In the Scene Explorer, right click on the folder you want the layer to belong to (in our example living_world group > monsters) and choose Add layer. Enter a name for the layer and select a Quest or Communities Build Tag and a Non-static (dynamic entitities) Type.

To create a new “group” (folder) in the Scene Explorer, right click on the parent folder and choose Add group to create it.


2. Add Encounter Area

You need to let the game know where the encounter should take place. This can be done by adding an Encounter Area.

First select your encounter layer in the Scene Explorer. Now right click on the main editor screen and from the context menu choose Gameplay > Area > Add Encounter Area.

A blue rectangle should appear on the level.

As previously seen with the Spawn Area, you can now Move, Rotate or Scale the Encounter Area. Use the Scale tool to make the area larger.

The NPCs spawned by the encounter will spawn when the player enters the area. Make sure the area is big enough if you do not want to see the NPCs spawning right in front of you and just as you set foot in the Encounter Area.


3. Encounter properties

The encounter needs a tag by which you can easily reference it later.

Select the Encounter layer in the Scene Explorer, go to its Properties column and open the CNode. In the tags add a name for your encounter. Since we’re planning a wolf encounter, we went with enc_wolves.


4. Open the Encounter Editor

There’s two ways in which you can open the Encounter Editor.

Either Right clicking the Encounter and choose Edit Spawn Tree or find the spawnTree in Properties, select it and then press the little tree icon () on the right side. This will open the Encounter Graph.

This will open the Encounter Editor.

As you can see, the enc_wolves tag is there, but the Encounter Graph (green area) is empty.


5. Edit the Encounter Graph

Right click on the green graph area and choose Add SelectPhase. Now press the three dots which will generate the basic start for the encounter: a Default Phase. By right clicking on the Default Phase None node you will see there are many available options.

For the purpose of this tutorial we are going with the Include File option.

(If you want to have more than one phase for the encounter, it’s recommended to rename the Phase. You can drag additional phases from the SelectPhase nodes output.)

  • Include File - this node will use a previously made Spawn Tree inside the Encounter. This is a simple way to quickly create encounters based on templates that have been set up by the game’s developers. You can find some commonly used ones in living_world\event_templates\encounters\aproved_templates.

    Please note that you cannot edit the setting of that Spawn Tree inside this encounter, so you will have to use the same tags in your Spawn Points, Guard Areas, etc. (the Encounter only checks Spawn Points and Guard Areas within its area so there shouldn’t be issues with duplicated tags - as long as you don’t overlap many encounters with the same exact included spawn trees).

You can find definitions of some of the other options below:

  • Condition - will only continue the signal if the conditions such as facts, daytime and more are met.

 

  • Parallel - activates all branches of the encounter which you add simultaneously.

     

  • Random - randomly chooses between multiple child branches. You can change how often it re-rolls the random branch.


6. Include an existing Spawn Tree

Let’s include an Existing Spawn Tree by using Add Include File and choosing this file:

  • living_world\event_templates\encounters\aproved_templates\wolves\wolves_level_5_alpha_level_5.spawntree

You need to find it in the Asset Browser and then press the icon in the Encounter Editor.

Once the Spawn Tree is loaded you can see all its elements.

Notice that is has a TopInitializerList - this allows us to add different properties to this particular branch of the encounter, the blue nodes. The SpawnEntries (green nodes) on the other hand spawns the specified NPCs.


7. Adding NPCs

As you can see at the bottom of the graph, there are two different green NPC Entry nodes (Entry alfa wolf_level1 and Entry wolf_level1).

Both need to be added to the Encounter. Click the icon at the bottom of the Encounter Editor to add a new entry and fill out their names according to what the names in the existing nodes.

 

Once we have the NPCs name copied correctly, it’s time to add an Entity templates in the next column. We can use the two different types of wolves found in the characters\npc_entities\monsters\ folder.

  • characters\npc_entities\monsters\wolf_lvl1__alpha.w2ent

  • characters\npc_entities\monsters\wolf_lvl1.w2ent

Once you find these two files in the Asset Browser, select them and then click the green arrow back in the Encounter Editor / Entity Template box.


8. Adding Guard Area and Spawner

The graph and Initializers suggest you need to add a Guard Area and at least one Spawner to your level.

First, create a Guard Area on the level.

Select your Encounter layer in the Scene Explorer. Now right click on the main editor screen and from the context menu choose Gameplay > Area > Add Guard Area. Once it’s on the level, scale it and add a Tag - it should be the same exact tag that is set in the “Guard Area by Tag” node in the encounter graph.

Now, in the same way as with Guard Areas, let’s add some Spawn Points (Gameplay > SpawnPoint > Add Spawn Point).


9. Done!

You should be all set. Go back to the Editor and start the level. Once in the game, the wolves will spawn and guard the areas you created!

Remember that an Encounter begins once you enter the area.

Good luck!


Controlling Encounters

You can also control the encounter via the Quest graph and the Gameplay > Encounter Manager node. This is only needed if you want to dynamically enable/disable the encounter or change its phases.


Further editing Encounter properties

If you want more control over the settings in your encounter, then you need to create the nodes by yourself. The Include File method, as we mentioned before, has limited edit options for existing templates.

However you can still use Include File option, load an existing graph and create your own Encounter Graph in parallel with any settings you like. When you are done, simply delete the Include File. As always, the best way to learn is to search for some existing examples from the game.


Spawn & Wander Points, Guard Areas

There are different types of points which are useful for encounters.

1. Spawn Points

Spawn Points should be always placed inside of their Encounter Area.

There are three types of spawn points:

  • Party Spawn Point: for a party of enemies (enemies that are defined as a party within their spawn tree) used for encounters.

  • Living World Spawn Point: for one type of entity used for living world encounters.

  • Spawn Point: for a single type of entity used for encounters


2. Wander Points

Wander points give a path to an entity to wander. This can be achieved with Wanderpoints Smart AI and Wander and Work Smart AI Entries. Both need wander point group tags, to identify which wander points can be used by the specified entity.

Wandering can be achieved without wander points too, in which case, the entity wanders around its designated spawn point. How far off it goes can be limited by setting a maximum wander distance (named wanderMaxDistance in the node’s properties). This can be achieved with AreaWander Smart AI and Idle AI.

 


3. Guard Areas

Guard areas can be created by selecting the layer you’d like your spawn point to be on and then right click the place you’d like the middle of your area to be in. Then go to Gameplay→Area→Add Guard Area.

Always create a Guard Area when spawning hostile Entities in an Encounter. Create a Guard Area and custom Spawn Points for every Group of Monsters to prevent interaction between spawned Entities. While an Encounter Area is a Guard and Pursuit Area, additional/custom Guard Areas should be created.

How does it work? Enemies will only engage in combat, when you are in close range of (4m) or inside the guard area.

  • If you are in range when combat starts, Enemies will chase you.

  • If you are not in range, Enemies will return to the Guard Area and remain there taunting as long as they can sense you.

  • If no Pursuit Range value is set, Enemies will stop attacking the Player once they leave the Guard Area.

 

By now you should have already finished these tutorials:

Table of contents:

______________________________________
The Witcher 3: Wild Hunt Complete Edition © 2024 CD PROJEKT S.A. Published by CD PROJEKT S.A. Developed by CD PROJEKT RED. CD PROJEKT®, The Witcher®, REDengine® are registered trademarks of CD PROJEKT Capital Group. All rights reserved. The Witcher game is set in the universe created by Andrzej Sapkowski in his series of books. All rights reserved.