NPC checks that a PC has an item equipped
From NWNWiki
This is a basic OnPerceived script which will check for an item and make the NPC hostile if the PC does not have it equipped:
// Goes in the OnPercieved of an NPC
// Checks a PC has the correct item equipped in a specific inventory slot
void main()
{
object oPC = GetLastPerceived();
object oDisguise = GetObjectByTag("disguise");
// Insert the correct item tag
if (GetIsPC(oPC))
{
object oTarget = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
// Change the inventory slot as required
if (oTarget != oDisguise)
{
// Uncomment the appropriate lines or add your own custom code
// AdjustFactionReputation(oPC,OBJECT_SELF,-100);//This would make the NPC's whole faction hostile
// SetIsTemporaryEnemy(oPC);//This is for just this NPC
// ActionAttack(oPC);// Ensures the NPC will attack immediately
}
}
}
