Maxam - Introduction To Encounters

Introduction


In NWN, there are three ways to place creatures in your module: firstly by selecting them from the creature palette and painting them directly into an area, secondly by setting up an encounter trigger which will "spawn" or create the creatures when a player enters it, thirdly, by writing a script to place the creatures when certain conditions are met.


This tutorial is concerned with the second method.


We will be using two terms frequently, which will be briefly explained here.


Firstly the term 'spawn.' Spawn is used to refer to any object being created by the NWN engine while a game is running. This could be an object (e.g., a chest or door), but is more likely to be a creature or NPC which is what we will be concerned with in this tutorial. When a creature is 'spawned,' it will run a script, called an 'OnSpawn' script, and we will be discussing this also.


Secondly, the term 'lag.' Lag is when, for whatever reason (and there are many), the NWN engine 'chokes' or 'stutters' and is unable to deliver the optimal silky-smooth gameplay experience we would all like to enjoy. Some lag can be caused by creatures spawning - usually by an encounter and we will be looking at this.


Why use an Encounter?


At first glance, placing creatures directly from the palette may seem to be the best method for populating a module - after all, creatures are placed and positioned precisely to your liking. Also, building this way closely resembles the way a traditional PnP module would be prepared.


However, there are several key reasons why the use of an encounter is a superior solution to the use of placed creatures:


Creating an Encounter


In order to create an encounter, you must first select one from the 'Encounter Palette', either from the 'Standard' or 'Custom' list.


Ideally choose an encounter that is as similar to what you want in terms of creatures and difficulty level as possible. Whilst you can change the encounters properties to achieve the same results, you might as well save yourself a bit of work.


Once you have done this, you create an 'Encounter Trigger', by drawing a trigger polygon (multiple sided 'area') where you would like the PC to activate the encounter.


This is done by clicking once with the left mouse button for each corner of the polygon, except the last one, which you must double-click. This will tell NWN to close the area, ie join the last corner and the first corner.


The encounter trigger can be any size or shape you care to make it - the main thing is to make sure that the players are able to enter it.


If your trigger is not quite the right shape, or you find later that you need to change it, you can do so by right-clicking on it and choosing 'Redraw Polygon' from the menu that pops up. Then place the new trigger area in the same way as you placed the old one.


While the trigger is still highlighted, right click at the location where you would like the trigger to spawn its creatures, and choose 'Add Spawn Point.'


Right clicking on the encounter and choosing 'Properties' will let you change various settings for the encounter, including the quantity and type of creatures that will appear. We will look at all of the settings you can change under properties in a later section.


Some Important Points

There are some important things to keep in mind when painting encounters in an area:


Encounter Properties


In this chapter, we will examine all of the properties available for an encounter, looking at each tab in sequence.


Basic Tab


Name and Tag

Like everything in NWN, encounters have a 'Name' and a 'Tag'. The 'Name' is used to describe this encounter in the 'Encounter Palette', the 'Tag' is used to describe the encounter in the 'Module Contents' panel. The 'Tag' is also how you would refer to the encounter in a script.


Difficulty

This determines how difficult the encounter will be, constrained only by the creatures you have put in the 'Creature List'. For example, when an encounter is triggered, NWN will weigh up the challenge rating of the creatures in its 'Creature List' and the combined level of the PC's, then spawn in an appropriate amount of creatures in an attempt to match the difficulty level you have set. Obviously it will not always be able to do this - if you have only entered creatures with a challenge rating of 6 to 9 in the creature list, setting the encounter to 'Very Easy' will never make it possible for level 1 characters, nor will setting it to 'Impossible' make it challenging for characters of level 30.


If the level of players in your module is likely to cover a wide range (definitely the case if it is a PW), you will need to make sure that the creatures the encounter spawns cover a broad spectrum of difficulty ('Challenge Rating') - see the Creature List section below for an in depth explanation.


Maximum and Minimum Creatures

This is where you set the limits for the 'Maximum Creatures' and 'Minimum Creatures' generated by the encounter. The greater the range set here, the easier it is for NWN to scale the difficulty of the encounter.


Spawn Option

There are two settings here - 'Single Shot' and 'Continuous'. 'Single Shot' means the encounter will trigger once and once only. 'Continuous' means that it can be triggered more than once, although you will need to set additional options in the 'Advanced' tab to make it work properly, see below.


Category (For Custom Encounters Only)

'Category' is only available for 'Custom Encounters' or when you add a 'Standard Encounter' to the 'Custom Encounter Palette'. It simply indicates where the encounter will be found in the palette, ie in the 'Hard' section, 'Impossible' section or whatever. Note that this is for your reference only - it has no effect on the actual difficulty of the encounter.


Creature List Tab

The 'Creature List' is where you select what monsters or NPCs the encounter will spawn. As mentioned in the Difficulty section above, if the level of players in your module is likely to vary greatly, you need to take care when populating the 'Creature List', otherwise NWN will not be able to provide a challenge for the players appropriate to the difficulty level you have set.


For example - let's say you have an encounter which you would like to spawn a scaled mob of ordinary Humanoids (i.e. no Chieftains, Shamans or Champions). At the most basic level, you could place a Goblin, an Orc, a Bugbear and an Ogre in the creature list - for a low level party or PC the encounter would probably spawn just Goblins, adding Orcs, Bugbears and Ogres to the mix for higher level parties, until eventually just spawning all Ogres.


Another more advanced method involves making several new creature blueprints with varying difficulty settings of the same creature. For example in the encounter above you could have a normal Goblin (CR .25), a tough Goblin (CR .5), a normal Orc, a tough Orc, etc.


The bottom line is that the greater the variety you give the encounter in terms of Challenge Ratings of the monsters, the easier it will be for NWN to scale the encounter properly.


The 'Unique' check box in the list forces NWN to make only one instance of this creature appear (if the difficulty of the encounter warrants its appearance that is!) - this is useful for spawning boss creatures leading groups, or making sure that only one spell caster is spawned in a group of warriors.


However, mixing unique and non-unique creatures in the same encounter can limit the scalability of that encounter. Why? Simply put, placing three 'leaders' of varying difficulty all set to unique, will not guarantee that only one them will appear. Depending on the level of the players, the encounter may well spawn all of the 'unique' leaders. For example, in the case of the Humanoid mob discussed above, if you wanted a unique leader to appear for the group, you would either have to have a single unique leader that couldn't scale, or you would have to handle the leader with a separate encounter, refer to the section on Case Studies below.


Finally, it might be a good idea to think about how 'realistic' your encounter is, (a loosely defined term in a fantasy RPG,) when populating your 'Creature List'. Although you could have an encounter spawn a wide range of creatures from Kobolds to Balors (with Giants, Trolls, Umber Hulks and more in between), bear in mind that NWN will not spawn a group entirely made of creatures of one type - it will invariably mix it up as best it can. This being the case, it may not be logical in the context of your area or module for such a varied selection of creatures to appear.


Scripts Tab

An encounter has five event handlers that will fire a script - four of which are standard ('OnEnter', 'OnExit', 'OnHeartbeat' and 'OnUserDefined'), and one which is unique to encounters ('OnExhausted'). An 'OnExhausted' event is fired when the last creature spawned by the encounter is slain. This can be used to trigger an event such as the opening of a gate, or a cut scene once the encounter group has been defeated.


Advanced Tab


Faction

Like creatures, encounters have a faction. It is important to note that the faction of the encounter in no way determines or changes the faction of the creatures spawned. It only controls whether or not the encounter will spawn when a PC or other creature walks over it.


In order for the encounter to trigger properly the player must be hostile to the faction of the trigger - the creatures spawned could be hostile, neutral or even friendly. For this reason most triggers will be set to the 'Hostile' faction.


Its worth noting that encounters set to the standard npc factions, (commoner, merchant and defender,) don't seem to trigger for npc's that are hostile to these factions, they only trigger for PC's and members of their party. However using a custom faction on the encounter, set up with similar likes and dislikes, should work as expected.


So for example you could set a number of encounters, with a faction of 'Commoner', around a village. When triggered, these encounters would spawn groups of guards to deal with the attackers. These encounters will not be triggered when players wander around the village unless the players have been attacking villagers, thus becoming hostile to the villagers ('Commoner') faction.


Active

Simply put, this needs to be checked for the encounter to work. Possible reasons for setting this to unchecked would be for encounters you wanted to remain dormant until a certain time, and then make active with a script - for example, graveyard encounters that only become active when night falls.


Encounter Respawns

If you have set the 'Spawn Option' on the 'Basic Tab' to 'Continuous', the 'Encounter Respawns' options will be available. Here you will be able to set how frequently the encounter respawns and how often (a limited or infinite number of times).


Note that the 'Respawn Time' represents (in seconds) the amount of time NWN takes to make the encounter active again from when the last creature spawned by the encounter is killed.


It is also important to note that, if you set the respawn time to 0 seconds and the triggering PC remains standing within the trigger, it will retrigger immediately once only, after which it needs to be 're-entered' to trigger again. Refer to the Continuously spawning encounters case study below.


Player Triggered Only

When set, only players can trigger the encounter - otherwise henchmen, familiars and occasionally npc's can also trigger it. Obviously the latter for the most part is preferable and more realistic although there will be times when it will be more convenient or necessary to set it otherwise.


Comments Tab

This tab usually contains a short description of the encounters purpose or usage. It has no effect on the operation of the encounter.


Encounter Lag Issues


Even those with the most powerful PCs will notice the tell-tale judder or 'lag' that signifies the activation of an encounter trigger. The severity of this can range from a slight hiccup to a lengthy spate of shuddering - apart from the obvious irritation of the delay, it's even more annoying because it gives the player an indication that they are about to be set upon by foes.


While it can never be removed completely, there are certainly ways to lessen it, or even in some cases hide it from players. However, in order to address this issue we must understand what causes it.


There are two main things that cause encounter lag - placing creatures (ie when NWN determines where to place them in an area) and spawning creatures (that is, running their 'OnSpawn' script as they are placed in the area).


Placing Creatures

There are some key points to bear in mind if you wish to lessen the lag caused by an encounter triggering:


Spawning Creatures

When each creature is placed in NWN, whether by an encounter or a script or when the module first loads (for manually placed creatures), they execute an 'OnSpawn' script. The execution of spawn scripts causes lag, although for manually placed creatures this happens when the module first loads and is rarely noticed by the player.


There are ways to minimize the lag caused by spawn scripts:


Case Studies


Here we will look at some examples of specific things that you may want to do in a module, and explain how they may be done with encounters.


Spawning a group of creatures with a unique leader, and having the abilities of the leader scale to the level of the PCs

The solution is to have two separate encounters, one for the main group and one for the leader. Ideally you would make the two trigger areas overlap and place the spawn points for both encounters together.


For the group encounter you would need a range of creatures of varying difficulty (e.g. Goblin, Hobgoblin and Bugbear) and varying quantities, (e.g. 4 - 8).


For the boss encounter, create two or more creature blueprints of the leader with increasing levels of toughness (e.g. a Hobgoblin Champion of CR 3, 6 and 9) and place them in the creature list with each one set to unique. Then make sure that the maximum and minimum creatures are both set to one.


Then when the triggers are crossed you will get both a scaled group and a scaled leader spawned in.


Continuously spawning encounters

An example of a continuously spawning encounter would be to have the guardian of a portal respawn after a certain amount of time, say 10 minutes after it is slain. On the surface, it would appear that the solution to this problem would be to have an encounter trigger covering the whole area, set to continuous and infinite, with a respawn time of 600 seconds. You would expect that as the PCs are present within the trigger, (they must be unless they leave the level,) the trigger will fire as soon as the respawn time is met. There is however a problem with this, as mentioned earlier (Encounter Respawns, above), an encounter will only respawn once if the PCs remain within the trigger area. After that the PCs must exit and re-enter the trigger area for it to fire again.


The solution is to stick with an area-wide trigger, but shaped in such a way that the PCs cannot avoid constantly moving in and out of it as they wander around. By necessity, the shape of the trigger will vary depending on the design of your area, but one of the more common ways to do it (particularly in open areas) would be to 'stripe' the level with the trigger, i.e. shape the trigger like a comb - the teeth stretching across the area.


Permanent wandering monsters

To create wandering monsters that are always present in an area, begin by creating one or more creature blueprints for the wandering monster(s) that either have mobile animations set in their OnSpawn script or have a set of way-points to follow.


Next create the encounter and paint an area-wide trigger in a similar fashion to the trigger discussed in Continuously spawning encounters above. Then set up at least two spawn points that are a reasonable distance apart (near a way-point path if you are using them) and set the encounter to continuous and infinite with a respawn time of 0 seconds.


Take care when drawing the trigger that it does not stray too close to any entrances to the area to avoid scaling issues as discussed in the Creating an Encounter section (under Trigger Placement) above.


Troubleshooting


Here we will look at some common problems people come across when using encounters and address them.


An encounter does nothing when PCs enter it

This is a common problem, and usually indicates that the player is not hostile to the faction of the encounter. Setting the encounter faction to 'Hostile' should solve this problem.


Creatures spawned by an encounter do not face the direction of the spawn point arrow

With older versions of NWN, there was a problem of creature spawns always facing east. This has been fixed in more recent versions. Note also that if a creature spawns close enough to a PC, it will appear facing the PC regardless of the direction of its spawn point.


An encounter does not spawn an appropriate amount or type of creature for the party's level

The encounter trigger may be too close to the entrance of the area. When an encounter trigger fires, it checks the levels of all the members of the party which the triggering PC belongs to, however, it only looks at party members currently in the same area.


So, if a trigger is too close to the entrance of an area, chances are it will only end up firing based on the one or two members of a party who ran ahead and entered an area before the rest of their team mates.


Alternatively, you may need to specify a bigger range of creatures in the 'Creature List', (different 'Challenge Ratings etc,) to enable the encounter to better match the strength of the party.





 author: Maxam, editor: Grimlar