I want to disable an NPC’s combat AI entirely, so that he only takes actions added to his queue via script. This plot NPC is normally hostile and I want him to continue with his scripted actions, even if he takes damage from PCs. I don’t want anything interrupting his script. I don’t want to change his faction, because there are other hostiles nearby and I don’t want him to attack them or be attacked by them. As I understand it, even merchant and commoner factions will attack hostile faction creatures nearby. And, I would like this to be work via scripting on an otherwise normal creature, rather than creating a custom creature with a custom faction, etc.
Is there a constant or something that will accomplish this? Seems like there would be an easy way to do this, but I don’t know it.
BTW, I have tried SetAILevel(oNPC, AI_LEVEL_VERY_LOW), but apparently that slows down OnPerception handling to the point where he isn’t aware the PCs are even there, which is trouble since an OnPerception event triggers what he needs to do.
I have also tried clearing the NPC’s OnAttacked event using SetEventScript(oNPC, EVENT_SCRIPT_CREATURE_ON_MELEE_ATTACKED, ""), but it looks like that either doesn’t do what I think or it is ignored if the replacement script name is an empty string.
commoner is not good they run when attacked instead
I was assuming this is pre-placed npc in area so you can edit it directly if it is not then you will need to use custom blueprint to guarantee that because normally if npc spawns in vision of another creature which she considers enemy she starts attacking or doing other AI actions, and this happens basicalyy at same time as OnSpawn
but yes give it a try, in OnSpawn cancel all actions and set all events to **** might work
By setting events to **** do you literally mean setting them to a string of four asterisks? E.g. SetEventScript(oNPC, "****")? I ask because when I tried setting them to an empty string, it seemed to ignore SetEventScript. Hmm, I suppose the **** (or any non-existing script name) may work, since it will try and fail to run a script it can’t find…
i don’t think you even need to use nwnx, you should be able to accomplish what you want w/just basic scripting. in essence, you’d do a comparison of the creature’s tag right at the beginning of the script[s] controlling the actions you want to bypass, and just return from the script immediately if the condition matches.
for example, suppose the npc in question is the stock duergar cleric from hotu. its tag is NW_DUECLER001. and suppose you want to make it so the cleric won’t respond at all if it’s damaged in combat. you could add the following right at the beginning of nw_c2_default6.nss :
if (GetTag(OBJECT_SELF) == "NW_DUECLER001")
you could do the same thing for the on-spell-cast-at event (nw_c2_defaultb.nss), on-combat-round-end (nw_c2_default3.nss), etc. in essence, you’re suppressing the script entirely because this is the first statement executed.
obviously this approach will become painful the more creatures you want to apply it to, but if it’s just this one creature…
also, this approach will fail if you use multiple creatures w/the same tag and you want only one of the creatures to behave this way.
a bit of detail: DetermineCombatRound() checks if a custom script has been set, if so it runs it with an ExecuteScript() call, and if that script sets the round as finished, DCR aborts without doing anything.
It might be worth a try. The script could be written to run your custom actions (but only during combat).
Thank you, everyone, for these suggestions. It turns out that setting the various event scripts (OnAttacked, OnSpellCastAt, OnHeartbeat, etc.) to **** works fine. Admittedly, this is an EE-only option, but I am doing this for an EE module, so that’s okay here.