Make an NPC use an item
sarevok57
Member Posts: 6,002
so i can't figure out how to make an NPC wear an item that the player has given them
so far everything else works, the quest completes, the NPC gets the outfit, but i dont know how to make it so the NPC puts the outfit on after the quest completes
anyone have some insight?
so far everything else works, the quest completes, the NPC gets the outfit, but i dont know how to make it so the NPC puts the outfit on after the quest completes
anyone have some insight?
0
Comments
The delay isn't always necessary, but can help if the item or the NPC are recently spawned.
As with all NPC actions, there is a risk that it might be cancelled by AI, especially if the NPC is an associate.
That can be prevented using SetCommandable (see Example Note 2).
and what would i EXACTLY need to type into the script field for this to work?
NPC tag: NW_ELFMAGE005
item tag: NW_CLOTH003
i tried putting in:
void main()
{
DelayCommand(0.5, AssignCommand(NW_ELFMAGE005, ActionEquipItem(NW_CLOTH003, INVENTORY_SLOT_CHEST)));
}
but that didn't work it says:
2019-07-05 3:15:57 AM: Error. 'leena009' did not compile.
leena009.nss(3): ERROR: VARIABLE DEFINED WITHOUT TYPE
I'd recommend doing a scripting primer, maybe the one in the Lexicon and/or Tarot Redhand's tutorials on the Vault.
In essence, your script is failing because you're using constants (tags) where nwscript expects to see object variables.
One approach in conversation with the NPC is as follows:
The delay and assigned command in the last line might be redundant in this special case.
Equally, if the NPC were not speaking to the PC, you'd have to use GetObjectByTag to set oNPC, and assign the ActionTakeItem to them.