Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.


Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#B3D4FF

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 and load all files in 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). The . You can also use just the living_world folder which we were previously using for our Roach spawn area should change its .

The folders which you selected should change their colour to signify that files have been loaded - you can now also see the spawn area in the editor screen.

Image Removed

Select the living_world group and right click the monsters folder .

92433687-07b1-4669-baef-0e24941974f2.pngImage Added

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 orCommunities Build Tag and a Non-static (dynamic entitities) Type.

Info
(If the monsters group doesn’t exist in your project, don’t worry, right click living world

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

)

.

Image RemovedImage Added

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.

Image RemovedImage Added

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.

Image Removed

3. Add Spawn Point

In the Scene Explorer select the monsters folder. Right click and Add layer.

Let’s name it foglings and select the Non-static layer type.

Image Removed

Now select the new foglings layer. In the Editor main screen, inside the Spawn Area, right click to open the context menu. Choose Gameplay > SpawnPoint > Add Spawn Point.

A new Spawn Point, the spot where monsters will spawn and start roaming the Spawn Area, should now be visible. It’s automatically named spawnpoint0.

Image Removed

Select spawnpoint0 in the foglings folder in the Scene Explorer and go to its Properties tab.

Find the CNode and in tags enter a name: fogling_sp_1. We will refer to it in just a moment so copy (CTRL+C) the tag name.

Image Removed

4. Encounter Editor

Encounters also use graphs which consist of many Spawn Trees.

To open the Encounter Editor: right click on the encounter0 (CEnounter) file (in the encounter layer folder) and choose Edit Spawn Tree. Spawn Trees use a table in which we need enter information about the entities which will be spawned during the encounter.

Image Removed
Note

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.

Note

Move the Encounter area a few meters underground so that you do not see the bottom borders above the ground anymore. The Encounter Area checks the height of all actors within it: if SpawnPoints or Guard Areas happen to be slightly below it the bottom of the blue Encounter Area, it might disregard them.

Note

All Spawn Points and Guard Areas etc. that is referenced inside the encounter graph must be also located inside the Encounter Area in the level. You cannot have spawn points outside of the Encounters Area.

00854154-14f2-432a-a4f5-146b52165f67.pngImage Added

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.

2024-04-23_12-36.pngImage Added

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 Treeor find the spawnTree inProperties, select it and then press the little tree icon (🎄) on the right side. This will open the Encounter Graph.

Info

Spawn Trees specify what is supposed to spawned and whereat which location.

To add a Spawn Tree table press the (plus) icon and let’s start filling it with information. First: Definition name: fogling_lvl3.

Image Removed

Now we need to find an Entity Template in the Asset Browser. Search for fogling in the top-right corner and among the search results choose fogling_lvl3_willowisp Entity Template.

After selecting the file click on the green arrow () in the Encounter Editor to import the file.

Image Removed

5. Insert a Spawn Tree

Now let’s move to the Spaw Tree’s graph which is built in a similar fashion to the Quest Editor’s graph: be connected different types of nodes.

Right-click on the graph and AddSelectPhase. Then click the three dots which will add a DefaultPhaseNone - this where the encounter will be enabled. Right click on the new Default Phase None node and choose Add Condition.

Info

Phases and encounters are initiated in the main quest graph.

Image Removed

Now right click the Condition node and Add Include File.

It will turn up a new Include EMPTY node, but worry not. We will solve this problem by using an existing, defined spawn tree.

Image Removed

Find the foglings_level_25 Spawn Tree in the Asset Browser and select the file.

Back in the Encounter Editor, choose the Include EMPTY node and look to the top-left corner to see it’s properties. Go to spawnTree (CSpawnTreeIncludeTreeNode) to import an existing Spawn Tree file.

As usual, select a file in the Asset Browser (like: fogling_level_25 Spawn Tree) and press the green arrow icon () to import the ready Spawn Tree.

Image RemovedImage Removed

The node previously name Include EMPTY will change its name.

Press the three dots to see the complete Spawn Tree which we will use (without going into too much detail).

Image Removed

6. Edit the Spawn Tree

Guard areas and spawn points are referenced by tags.

To see how it works, select the node at the top of the Spawn Tree (TopInitizersList) and look to its properties. The guardAreaTag is lw_ga_foglings_group1. Now select the Entry fogling_lvl3 (1-2) node and notice how the tags are referenced in the baseSpawner property.

We will change this tag at its source.

Image Removed

Go back to the Asset Browser.

Find and open the Spawn Tree file (fogling_level_25) which we used earlier. This will open the Spawn Tree Editor.

Info

The foglings_level 25 Spawn Tree needs to be unlocked by either copying the Spawn Tree file to a different location or by right clicking the file in the Asset Browser and selecting the „Checkout” option.

Image Removed

Now select the Entry fogling_lvl3 (1-2) node and find its baseSpawner property. Open it and change tags (from lw_ga_foglings_group1) to our previously created fogling_sp_1 Spawn Point. Save your changes.

Image Removed

7. Add a phase setter to the quest graph

Okay. We have our encounter’s area and monster spawning set up. Now we need to add another node to our world’s main quest file.

Let’s find it in the Asset Browser (should in our world’s main folder) and open it.

Info

We will continue to edit the Quest Graph built in the previous tutorial. If you haven’t yet completed it, please take a look at HOW-TO: Make a new world come alive.

Image Removed

In the Quest Editor this is how our Quest Graph should look up to this point.

Right click on the background to add a new node: Gameplay > Story phase setter which will reference a community file.

Image Removed

Connect the new node (Story phase setter) to the Pause node’s socket.

Select the Story phase setter node, go to its properties and in the CQuestStoryPhaseSetterBlock category find spawnsets and add a new one.

In your new spawnset (“0”), expand the list of classes (🔻) and select the CActivateStoryPhase class.

Image Removed

After selecting the class for our spawnset, we can import an existing community file.

Find the q402_folings02 community file in the Asset Browser, select it and click the green arrow to import it.

Image Removed

8. Edit the Community file

As we choose to use an already defined Community file we need to make slight alterations so it fits our quest and references to correct tags. This will establish a connection between our quest graph and the encounter graph.

Open the q402_folings02 community file from the Asset Browser. This will launch the Community Editor. We need to define two main values in the Spawnset table.

Image Removed

First, the Story Phase Name of the phase in which we want our foglings to spawn.

We can use the name Default.

Image Removed

Now take a look back in the Quest Editor.

Select the Story phase setter node so you can check which phase is defined by this node. It should load the name which you entered just a moment ago in the Community Editor Story Name Phase field (“Default”).

Image Removed

Now we need to set the spawn point tags which define where the NPC will appear.

First go back to the main Editor and find the spawnpoint0 on the file/layer list in the Scene Explorer. Go to properties and check the name of the tag in CNode - which in this tutorial should be fogling_sp_1.

Copy the name and paste it in Community Editor, in the Spawn Point Tags column.

Image Removed9. Test the encounter

enc_tree.pngImage Added

This will open the Encounter Editor.

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

2024-04-23_12-49.pngImage Added

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.)

selectphase.pngImage Added25b31f1bc-5535-41d2-a272-88018ff9e0cc.pngImage Added
  • 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:

Expand
titleAdd Condition, Add Parralel, Add Random - expand to read more.
  • Condition - will only continue the signal if the conditions such as facts, daytime and more are met.

    image - 2024-04-23T133159.096.pngImage Added

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

    image - 2024-04-23T132434.909.pngImage Added

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

    2024-04-23_13-28.pngImage Added
Info

All of these options can also be mixed with each other to create more complex graphs.


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.

2024-04-23_15-42.pngImage Added

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.

image - 2024-04-23T133538.337.pngImage Added

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 (plus) 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.

add11.pngImage Added
Note

Please note that the “alfa wolf_entry1” has a space after the first word. The names need to exactly match the names on the nodes in the graph.

2024-04-23_14-11.pngImage Added

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.

add_entit.pngImage Added

8. Adding Guard Area and Spawner

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

image - 2024-04-23T142737.731.pngImage Added

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.

image-20240422-194550.pngImage Added
Note

Make sure to add the tag to BOTH of the CNodes - tags properties, not just the top one. This is something to keep in mind universally while working with REDkit: always add tags to both of the tags fields.

image-20240422-194550 (1).pngImage Added

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

Note

Remember to add the same exact Tags to SpawnPoints as you did in the Encounter Graph.

Info

In order to see SpawnPoints you need to have enable the Waypoints debug filter. Find out how, here: HOW-TO: Change display settings.

4afbe707-ef05-4dfa-9e08-3bcf460c1da6.pngImage Added

9. Done!

You should be all set. Go back to the main editor, make sure to choose the correct game definition file and then press the Play the game from game definition button (🕹️ ).

Image Removed

When the game loads, you should see the Foglings in the distance.

When you approach them the true “encounter” begins - good luck fighting your enemies!

Image Removed

You can now try following the same steps from this tutorial but with slight alterations: adding different monsters, more Spawn Areas etc.

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!

wolves.jpgImage Added
Info

If fighting monsters or wolves is slowing down your work on a new quest and you want to get rid of your opponents quickly, you can eliminated them quicker by using the Marauder’s Map tool!

Image Removed


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.

b717a194-3e59-4036-aad2-c1ff8c16a613.pngImage Added

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

Info

When an Encounter Area contains different Monster Groups, e.g. Wolf Packs, use unique Tags for each group of Spawn Points. Using the same Tag for all Spawn Points will mix Entities on spawn.

2024-06-18_11-08.pngImage Added


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.

2024-06-18_11-10.pngImage Added


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.

9c3215fc-5943-4bc6-b7a8-7c736609ae24.pngImage Added

By now you should have already finished these tutorials:

Table of contents:

Table of Contents
minLevel3
maxLevel6
outlinefalse
typelist
printablefalse