SetEncounterDifficulty(int, object)

From NWN Lexicon
Revision as of 11:00, 30 September 2020 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Sets the difficulty level of an encounter.

void SetEncounterDifficulty(
    int nEncounterDifficulty,
    object oEncounter = OBJECT_SELF


ENCOUNTER_DIFFICULTY_* constant or a line from encdifficulty.2da
The encounter to change the difficulty. (Default: OBJECT_SELF)


Sets the difficulty level of oEncounter.

This uses an ID line from encdifficulty.2da, the default ones are provided as ENCOUNTER_DIFFICULTY_* constants.


The spawn-part of an encounter fires BEFORE the encounter's OnEnter does. Thus, if you call this in the OnEnter event, it will not have any effect on the group being spawned. You can draw a trigger around the encounter and call this function from OnEnter of that trigger instead as a workaround, or use the areas OnEnter.

Note: GetEncounterDifficulty returns the difficulty "value" column from the 2da not the line ID, so storing the ID value using a local may be recommended for more easily matching it up if this is used.

Known Bugs

Red bug icon.png Warning: This function has a known bug and may not work as expected in some situations. See Known Bugs for details.

Known to exist in base game and NWN:EE. If you use this on an encounter and the game is saved, then loaded, the encounters difficulty gets reset to 0 or VERY_EASY difficulty, regardless of what the original difficulty was or what it was set to.



See Also





 author: Tom Cassiotis, editor: Lilac Soul