I'm trying to create a function that creates a bite/claw for a subrace PC, but am banging my head against a wall trying to figure out why it's not working.
Can anyone review the below and see if I've done anything glaring? It's my understanding that PCs can be granted this feat/wield creature weapons.
Essentially, there's a check to see if an item is currently equipped in the creature right-hand weapon.
If the correct item is not found, it unequips items in the PCs hands and checks for the creature weapon proficiency
If the PC does not have the proficiency, it gives it to him/her.
If the PC does not have the item in its inventory, it creates the item on the PC and adds subrace abilities.
It then attempts to equip the item.
Finally, there's a follow-up call to this function again as a fail-safe to ensure the item is equipped.
SendMessageToAllDMs("DEBUG: Firing");
object oItem= GetItemInSlot(INVENTORY_SLOT_CWEAPON_R,oPC);
string sTag = GetTag (oItem);
//RH does not have item
if (sTag!="sItem")
{
SendMessageToAllDMs("DEBUG: Equip: CWEAPON_R does not have item");
//unequip items
AssignCommand (oPC, ClearAllActions());
AssignCommand (oPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC)));
AssignCommand (oPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC)));
SendMessageToAllDMs("DEBUG: Equip: Check for proficiency");
if(!GetHasFeat (FEAT_WEAPON_PROFICIENCY_CREATURE, oPC))
{
SendMessageToAllDMs("DEBUG: Equip: PC does not have weapon proficiency");
NWNXFuncs_AddFeat (oPC, FEAT_WEAPON_PROFICIENCY_CREATURE);
}
//nor is it in inventory, so start from scratch
if (GetItemPossessedBy(oPC, "item")==OBJECT_INVALID)
{
SendMessageToAllDMs("DEBUG: Equip: item not in inventory");
oItem = CreateItemOnObject ("item", oPC);
ApplyProperties (oItem, oPC);
}
//item in inventory, but not equpped
DelayCommand(4.0, AssignCommand (oPC, ActionEquipItem(oItem, INVENTORY_SLOT_CWEAPON_R)));
DelayCommand(6.0, ItemEquip (oPC)); //pseudo-hb to ensure item gets equipped
SendMessageToAllDMs("DEBUG: Equip: End of function reached");
}
What actually happens is that there is a never-ending loop of the item not being in the CWEAPON_R slot, but it is in inventory. The PC does have the proficiency, but never equips the item.
I do have a custom ILR in place that I thought might have been preventing it, but I set the value of the item to 0 in the ApplyProperties function, so it shouldn't trip the ILR. Plus, there's no message to the PC that they can't equip the item due to a level requirement.
Any thoughts about what I'm doing wrong?