Custom Encounter creatures takes too long to attack
fot1
Member Posts: 74
I'm working on a custom encounter system and I could use some tips. I've noticed that when using the default encounter system, the enemies start to attack the PC right away, and when I do spawn those, it take some time (one turn maybe?) for them to attack.
At first I just dropped a
And at first it worked. However, it seems that even if my pc is invisible the creatures will jump on him instantly.
Then I tried
But then it seems that the pc is not seen. Can I somehow update the perception table from my just spawn creatures prior calling this? Or is there a better way to achieve this?
At first I just dropped a
AssignCommand(creature, DetermineCombatRound(pc));
And at first it worked. However, it seems that even if my pc is invisible the creatures will jump on him instantly.
Then I tried
if(GetObjectSeen(pc, creature)) { AssignCommand(creature, DetermineCombatRound(pc)); }
But then it seems that the pc is not seen. Can I somehow update the perception table from my just spawn creatures prior calling this? Or is there a better way to achieve this?
0
Comments
Since also acount for stealth. But of course is not ideal
I think assigning DetermineCombatRound() isn't any different than when they just spawn. (i.e. the default scripts do their thing and call DetermineCombatRound() based on things like if they see an enemy, or an enemy vanished, or they are attacked/spell cast at, etc)
Try i.e. omitting the PC. This lets the creature select its own target. If that doesn't work in your particular script, a 1 second delay may help, to give time for OnPerception to fire.
ActionCommand indeed make wizards to run to attack the PC, which is terrible decision making with their d4 life :-)
I was really hopeful that DetermineCombatRound without parameters would work, but unfortunately it doesn't. I also tried to add some delay, but even after 1.5 secs there is no response.
I've improved my code a little bit in the meantime, making it to target the PC only if the spawn is nearby and the PC is not invisible, which is not ideal yet, but for the time being, it will have to do:
But essentially I would love a function `UpdatePerceptionTable` or something on those lines, which I could call immediately before the DetermineCombatRound without parameters.
I have found that changing faction to hostile, immediately followed by DetermineCombatRound() with no target, causes members of a neutral faction to attack immediately, but I don't use the encounter system much.
Here is almost the full code. The idea is quite simple actually, it uses a custom trigger `on_enter`, which calls `encounterSpawn`. And when creatures die, in the default7 script, I call `decrementLivingCreatures`.
The code here does not contains the code in which select which creatures will spawn (enc_inc_npcs, through the function call selectNPCs) and the code on where those will spawn (enc_inc_location, through the function call selectLocation), since those portions of the code are the biggest and are actually in other file, it shouldn't make much difference, since those return only a string with the resrefs, and a location to the creatures be spawn in the code presented here.
Ah, the SL functions are String List functions, that is a list of strings serialized in only one string. It provides methods to access the nth element (SL_at), the length of the list, and etc. Also please consider that the `inc_log` functions are either `PrintString` or `timestampedPrintStringWithLongAndHardToRememberName`.
Looking at similar code in my own module, spawning visuals take around 2 seconds, after which attack occurs in 3-4 seconds. This concurs with the Lexicon comments about the OnPerception event:
Personally, I can live with that delay, as it gives the player a moment to react.
If you're finding that the official encounter system reacts faster, perhaps it's an engine feature that can't be reproduced with scripting?
Probably best to ask at the Vault forum as others know a lot more than I do.