ok, I seem to have been able to fix it (I tested this a few times). It was just a matter of comparing the tag of the equipped item to the tag of the item for the given activity. Fortunately, both the current item and the item for the activity were already recorded by the original script :-)
Here is the corrected script. I removed
if (oCheck != OBJECT_INVALID) {return;}
because it was no longer needed.
//Call before activities that need right hand item with no armor
void NpcEquipItemRight(object oNpc)
{
object oArmor = GetItemInSlot (1, oNpc); //slot 1 is chest
object oCheck = GetItemInSlot (4, oNpc); //slot 4 is right hand
int nAct = GetLocalInt(oNpc, "nCurrentActivity");
string sItem = GetItemString (oNpc, nAct);
if (GetTag(oCheck) != sItem) //has wrong item, disarm. kamal
{
NpcDisarm (oNpc);
SetLocalInt (oNpc, "armed", 0);
EquipNewItem(oNpc, sItem, 4);
DelayCommand (0.4, EquipNewItem(oNpc, sItem, 4, FALSE));
SetLocalInt (oNpc, "equipcounter",1);
SetLocalInt (oNpc, "armed", 1);
}
if (oArmor != OBJECT_INVALID) {NpcDisarm (oNpc);}
if (oCheck == OBJECT_INVALID) {SetLocalInt (oNpc, "armed", 0);}
int nArmed = GetLocalInt (oNpc,"armed");
int nEquip = GetLocalInt (oNpc, "equipcounter");
{switch (nArmed)
{
case 0:
{switch (nEquip)
{
default:
{
ClearFlags (oNpc);
EquipNewItem(oNpc, sItem, 4);
DelayCommand (0.4, EquipNewItem(oNpc, sItem, 4, FALSE));
SetLocalInt (oNpc, "equipcounter",1);
SetLocalInt (oNpc, "armed", 1);
break;
}
case 1:
{
ClearFlags (oNpc);
EquipNewItem(oNpc, sItem, 4);
DelayCommand (0.4, EquipNewItem(oNpc, sItem, 4, FALSE));
SetLocalInt (oNpc, "equipcounter",2);
SetLocalInt (oNpc, "armed", 1);
break;
}
case 2:
{
ClearFlags (oNpc);
CreateItemOnObject(sItem, oNpc, 1);
ActionEquipMostDamagingMelee();
SetLocalInt (oNpc, "equipcounter",3);
SetLocalInt (oNpc, "armed", 1);
break;
}
case 3:
{
break;
}
}
}
break;
default:
break;
}
}
}
Modifié par kamal_, 25 mars 2012 - 11:17 .