Adding Weight Reduction to Items?

Hopefully the script is somewhat self-explanatory. If there is a ‘rookfeather’ and a bottle of ‘mojo’ in the chest, then add the weight reduction item property to the oItem not equal to the rookfeather or mojo.

It runs, the rookfeather and mojo do get deleted, but the item does not get the property. What am I missing?

 if ( GetItemPossessedBy(oTarget, "rookfeather") != OBJECT_INVALID && GetItemPossessedBy(oTarget, "mojo") != OBJECT_INVALID)
      {


          while(GetIsObjectValid(oItem) == TRUE && GetTag(oItem) != "rookfeather" && GetTag(oItem) != "mojo")
          {
              itemproperty ipAdd;
              oItem = GetNextItemInInventory(oTarget);
              ipAdd = ItemPropertyWeightReduction(IP_CONST_REDUCEDWEIGHT_40_PERCENT);
              IPSafeAddItemProperty(oItem, ipAdd,0.0);
              AssignCommand(oPC, SpeakString("kNotez hEavi-oH!"));

              DestroyObject(GetItemPossessedBy(oTarget, "rookfeather"));
              DestroyObject(GetItemPossessedBy(oTarget, "mojo"));

              //Do some Effects..
            effect eVFX;

            // Apply some visual effects.
            eVFX = EffectVisualEffect(SPELLABILITY_BOLT_LIGHTNING);
            oTarget = GetObjectByTag("EnchantingCauldron");
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oTarget);
            eVFX = SupernaturalEffect(EffectVisualEffect(VFX_DUR_GLOW_LIGHT_PURPLE));
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oTarget, 3.0);
         }

The problem in your script is that you test oItem but add the property to the next item in the inventory (which might be the rookfeather, the mojo or invalid but definitely not the item you want to add the property to.

I would probably try something like this (done without toolset so it might have errors):

object oFeather = GetItemPossessedBy(oTarget, "rookfeather");
object oMojo = GetItemPossessedBy(oTarget, "mojo");

if (GetIsObjectValid(oFeather) && (GetIsObjectValid(oMojo))
{
   object oItem = GetFirstItemInInventory(oTarget);
   while (GetIsObjectValid(oItem))
   {
      string sTag = GetTag(oItem);
      if ((sTag!="rookfeather") && (sTag!="mojo"))
      {
         itemproperty ipAdd = ItemPropertyWeightReduction(IP_CONST_REDUCEDWEIGHT_40_PERCENT);
         IPSafeAddItemProperty(oItem, ipAdd,0.0);
         AssignCommand(oPC, SpeakString("kNotez hEavi-oH!"));
         DestroyObject(oFeather);
         DestroyObject(oMojo);

         // Do some Effects...
         // ...
 
         break;
     }
     oItem = GetNextItemInventory(oTarget);
}

HA! I see it right there. I’m a dumbo Head. Thanks Kamiryn!