Refresh creature perception table

I’ve came to notice that for both my and other encounter systems, the spawned creatures react pretty slow in comparison with the vanilla encounter system. I wonder if there is a way to make the creatures to react to the encounter faster?

Right now, the best script I came up with is the following:

if(GetDistanceBetween(creature, pc) > ATTACK_DISTANCE) return;
if(InvisibleTrue(pc)) return;

AssignCommand(creature, DetermineCombatRound(pc));

Used alone, the DetermineCombatRound makes the creatures to attack pcs which they can’t see, like for instance invisible ones. This is where the InvisibleTrue came from, which returns TRUE if the PC is either invisible or stealth. And then there is a distance check to make sure that the creature will not dash 2km in the direction of the player when it is spawn.

If I use DetermineCombatRound without sending the player as parameter, this does nothing, since the creature have not perceived the player yet.

Of course this is less than ideal. Ideally the code would look like this, but I’m not sure if the first function exists:

RefreshPerceptionTable(creature);
DetermineCombatRound(creature);

Is there a RefreshPerceptionTable function? If this can’t be triggered manually, do you have suggestion on how to improve the code I’m currently using?

I’m using NWNEE.

Thanks for your time!

I think that the only real difference is that the spawn itself is a bit slower. There is visible delay when spawning the creature using CreateObject compared to her appearing from vanilla encounter.

As for the npcs not reacting immediately, vanilla npcs sometimes does that too, althought you are right that mostly they don’t especially when spawned into face. The reason for this is that for the creature spawned by CreateObject, it will take a while before her perception starts working. She simply doesn’t see anything by the time she is spawned so she cannot attack.

You can force her to attack with ActionAttack, perhaps even with DetermineCombatRound but I think that won’t work. Still that is just a workaround and not suitable for npcs that should start the round with casting - you cannot cast on the target you don’t see (this was the core issue for someone else’s problem with cutscene that was discussed on these forums a while ago).

There is not a function that would trigger perception I am afraid, the best option is spawn npcs in advance so that they have time to adjust to the area they are spawned into and then trigger OnPerception event properly when player character appears in their vision.

If you are coding PW and use nwnx, then you should ask for this on their discord, they might be able to make a solution, but in vanilla there is no other way I am afraid.

1 Like