Aller au contenu

Photo

Change clothes/armor of NPC through dialogue


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Mistraven

Mistraven
  • Members
  • 14 messages

I just can't seem to figure this out, and could use a little bit of help.

What I have done so far is to setup a dialogue, and then I wrote a small conversation action script to switch armor. No matter how I try I can't get the script work for my NPC though, although it does work for the player, if the player has the specified armor in inventory. 

 

The NPC targeted by the script is standing right next to the player, and there are no other creatures in the area. Any ideas?
 

// make NPC with sNpcTag equip armor with sArmorTag
#include "ginc_param_const"

void main(string sArmorTag)
{
   object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());
   object oNpc = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC, oPC);
   object oArmor = GetItemPossessedBy(oNpc, sArmorTag);

   // Do stuff here
   if(GetIsObjectValid(oArmor)){
      AssignCommand(oNpc, ClearAllActions());
      AssignCommand(oNpc, ActionEquipItem(oArmor, INVENTORY_SLOT_CHEST));
   }
}


#2
rjshae

rjshae
  • Members
  • 4 478 messages

Are the oArmor and oNpc variables showing as valid when the script runs?



#3
Mistraven

Mistraven
  • Members
  • 14 messages

Yep they are, and I found the error, it was just a small typo when adding the parameter to the script in the conversation, now i'm feeling a bit stupid! Haha! :)