SetEncounterDifficulty(int, object)

From NWN Lexicon
Jump to navigationJump to search

Sets the difficulty level of an encounter.

void SetEncounterDifficulty(
    int nEncounterDifficulty,
    object oEncounter = OBJECT_SELF
);

Parameters

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

Description

Sets the difficulty level of oEncounter.

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

Remarks

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.

Version

1.61

See Also

functions:

GetEncounterDifficulty

constants: 

ENCOUNTER_DIFFICULTY_* Constants



 author: Tom Cassiotis, editor: Lilac Soul