Recurring encounter

I think thats the right term, I want to create an encounter that will randomly generate hostiles to attack the PC and party or even random npc.

The best example would be during the Quest 3: Sweeping the Docks Clean

Having random groups of thugs popup and attack is more fun. As long as the quest is not complete, groups of thugs continue to appear to harass the player party.

http://www.nwn2toolset.dayjo.org/ToolsetTuts/blueprints/encounters/createencounters.html

I got the hang of that one, but how to make a script to randomly trigger until the quest is complete.

like any scripting, it depends on the details of what you want,

here’s an idea though

Areas have heartbeat scripts. Journals have a state (or range of state). In any area that the party should encounter the threat, if the journal-state is TRUE, and a fitting chance is rolled by the RNG, create the creatures at a fitting distance from the party (or perhaps at any of several pre-placed waypoints).

basically, this is done in SoZ on the overland map (for plot-encounters and special-encounters). The OL-area HB-scripts check journal state if a plot-enc should be spawned, or they simply roll the RNG to see if a special-enc should spawn.

 
it is non-trivial, it is a challenge, you’ll get intimate with scripts … but the events that trigger a spawn don’t have to be OnHeartbeat – an area’s OnClientEnter could be the trigger eg. And the condition doesn’t have to be journal-state, it could be party-possession of a particular item, etc etc

 
ps. what I said above isn’t about what the toolset calls “encounters”. Those aren’t as flexible as CreateObject() – though you might not want/need that flexibility … etc

1 Like

Looking around I thought this might help;

But it seems to be referring to nwn1 instead since I cannot find an infinite option in the toolset.

Encounters in nwn2 are very substantially enhanced since nwn1 – try “Auto-Reset?” true

But then you also need to set auto reset count, which would eventually run out… although I should try setting it at -1?

I know there is REE but you need to set variables for all the conversation encounters else every encounter will be looped which would be rather funny.

Encounters won’t deal with that by themselves … something needs to be scripted.

Thats the part I still cant figure out. To make the encounters continuously fire until the quest is completed.

void main()
{
    object oEnc = GetObjectByTag("tag_of_encountertrigger");

    int iJournal = GetJournalEntry("tag_of_quest", GetFirstPC());
    if (iJournal == 25) // enc will be active iff quest-state is @ 25
    {
        SetEncounterActive(TRUE, oEnc);
    }
    else
        SetEncounterActive(FALSE, oEnc);
}

something like that can fire from the OnHeartbeat event of an area. First get your encounter-trigger to fire infinitely. Then compile that script and assign it to the area’s HB event-slot. Use the correct tag/state of your quest, and the correct tag of the enc-trigger. All things being equal … the script will check every 6 seconds for the PC’s current quest-state, and if it matches what you’ve set in the script, should toggle itself on/off

(note that a range of values can be checked against if need be)

1 Like

Hmm, ironic, recently I’ve kept experiencing a bug(?) while playing where enemies keep respawning every time I re-enter an area or reload. Eg: the Sokol Keep undead in Pool of Radiance module, enemies in Fort Tremagne module. I don’t know if it’s an intentional effect or not.

Right thanks. I’ll have to try it.

ook so this script goes into the onheartbeat of the encounter.

need another script to infinite loop it?

===========

Alrite let me try to sum up what I need;

the encounter must have spawn once false, then reset count 1

this

void main()
{
    object oEnc = GetObjectByTag("tag_of_encountertrigger");

    int iJournal = GetJournalEntry("tag_of_quest", GetFirstPC());
    if (iJournal == 25) // enc will be active iff quest-state is @ 25
    {
        SetEncounterActive(TRUE, oEnc);
    }
    else
        SetEncounterActive(FALSE, oEnc);
}

goes into the onheartbeat of the encounter

did I get that right so far?

==========

then a loop script to keep everything going, or is there a way to set SetEncounterSpawnsMax to infinite?

the heartbeat loops automatically.

I don’t know what the settings for the encounter-trigger should be, sry.

 
ps. the script won’t work as it is, you will have to change it

Change the proper tags right?

y, the two tags, plus the journal ID

ps. don’t know if it actually works …

made some changes and it works;

/*
infinite repeat encounter
*/

void main()
{
//SpawnScriptDebugger();
object oEnc = GetObjectByTag(“encounter1”);

int iJournal = GetJournalEntry("Waterdeep Emissary", GetFirstPC());
while (iJournal < 1350)
{
    SetEncounterActive(TRUE, oEnc);
	    //object oEncounter1;
SetEncounterSpawnsMax(1, oEnc);	
}

/*if (iJournal < 1350) // enc will be active if quest-state 
{
    SetEncounterActive(TRUE, oEnc);
	    object oEncounter1;
SetEncounterSpawnsMax(1, oEncounter1 = OBJECT_SELF);
}
else
    SetEncounterActive(FALSE, oEnc);
	*/

}

encounter1 = the encounter tag
then theres the journal tag

Thanks for helping.

3 Likes