Getting NPCs into stealth on spawn

Trying to force some rogue-ish opponents to be in stealth before the PC encounters them. I’m using the X2_def event scripts and pstemarie’s userdefined event script with the following uncommented out:
SetSpawnInCondition(NW_FLAG_STEALTH);
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);
SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);
SetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)
SetCombatCondition(X0_COMBAT_FLAG_AMBUSHER)

if have the variable X2_USERDEFINED_ONSPAWN_EVENTS = 2 on them.
Nothing in the specific events portion.

Whether I spawn them in or place them in the area, they are always plainly visible when the PC walks up. I think I see them leave combat and try to go into stealth (the ones with HIPS that is) but it’s hard to tell. They don’t appear to do ambient animations either. They also don’t sneak attack, even when clearly flanking the PC.

Is there another flag I’m missing somewhere? I saw a recent thread with Andgalf, ramonsebas and pstemarie on ambient anims, which made me think maybe pstemarie’s script might not have all the functionality in NWN2 (it’s worked

In that particular case it was just a stupid mistake of mine. I had downloaded and used a prefab area and with that area came a version of the stock scripts that overwrote the original stock script. When I removed that new version of the script everything worked as usual again.

I did it, I used the same way Obsidian did in the OC with the house full of thiev if you side with the watch.

I don’t remember the specific, but you should check the Merchant quarter module of the OC and that house full of thieves and see how they did it.

1 Like

Said thieves use this as their OnPerception event:

//::///////////////////////////////////////////////////////////////////////////
//::
//::	10b_sneaky_percep
//::
//::	OnPercieved event handler for sneaky sneaky thugs.
//::
//::///////////////////////////////////////////////////////////////////////////
//  DBR 1/16/06


#include "nw_i0_generic"

void main()
{
	//ExecuteScript("nw_c2_default2",OBJECT_SELF);

	
	object oPercept=GetLastPerceived();
	if (GetIsInCombat())
		return;
	//if (GetNumActions(OBJECT_SELF)>0)
		//return;
	if (GetIsEnemy(oPercept))
	{
		ClearAllActions();
		SetActionMode(OBJECT_SELF,ACTION_MODE_STEALTH,TRUE);
		ActionMoveToObject(oPercept);
		ActionDoCommand(DetermineCombatRound(oPercept));
		SetEventHandler(OBJECT_SELF,CREATURE_SCRIPT_ON_NOTICE,"nw_c2_default2");
	}
}
3 Likes