public static int GetTotalValueOfKit(CLRScriptBase script, uint Character)
        {
            int lootValue = 0;
            foreach (uint item in script.GetItemsInInventory(Character))
            {
                lootValue += script.GetGoldPieceValue(item);
            }
            lootValue += script.GetGold(Character);

            for (int slot = 0; slot < 14; slot++)
            {
                uint equip = script.GetItemInSlot(slot, Character);
                if (script.GetIsObjectValid(equip) == CLRScriptBase.TRUE)
                {
                    lootValue += script.GetGoldPieceValue(equip);
                }
            }

            if (pChestAccess.ContainsKey(Character))
            {
                foreach (string chest in pChestAccess[Character])
                {
                    lootValue += pChestValues[chest];
                }
            }
            return lootValue;
        }
        public static int GetWealthMultiplierInt(CLRScriptBase script, uint Character, bool CombatDrop)
        {
            if (script.GetIsPC(Character) == CLRScriptBase.FALSE) return 0;

            int lootValue = GetTotalValueOfKit(script, Character);
            int level = GetEffectiveLevel(script, Character);

            int retVal = 4000; // very poor level 20. No multiplier should be more than this.
            
            if (recentlyDroppedItems.ContainsKey(Character))
            {
                List<uint> checkedPCs = new List<uint>();
                List<uint> removedItems = new List<uint>();
                checkedPCs.Add(Character); // We already checked the PC outside of this loop.
                uint partyMate = script.GetFirstFactionMember(Character, CLRScriptBase.TRUE);
                while (script.GetIsObjectValid(partyMate) == CLRScriptBase.TRUE)
                {
                    if(!checkedPCs.Contains(partyMate))
                    {
                        checkedPCs.Add(partyMate);
                        int tempMult = WealthToMultiplier(GetTotalValueOfKit(script, partyMate), GetEffectiveLevel(script, partyMate), CombatDrop);
                        if (tempMult < retVal) retVal = tempMult;
                    }
                    partyMate = script.GetNextFactionMember(Character, CLRScriptBase.TRUE);
                }
                foreach (uint Item in recentlyDroppedItems[Character])
                {
                    if (script.GetIsObjectValid(Item) == CLRScriptBase.TRUE) 
                    {
                        if(!checkedPCs.Contains(script.GetItemPossessor(Item)))
                        {
                            uint itemOwner = script.GetItemPossessor(Item);
                            if (script.GetIsObjectValid(itemOwner) != CLRScriptBase.FALSE)
                            {
                                // Remember that this might be OBJECT_INVALID, if it's just on the 
                                // ground.
                                checkedPCs.Add(itemOwner);
                            }
                            if(script.GetIsPC(itemOwner) != CLRScriptBase.FALSE)
                            {
                                int tempMult = WealthToMultiplier(GetTotalValueOfKit(script, itemOwner), GetEffectiveLevel(script, itemOwner), CombatDrop);
                                if (tempMult < retVal) retVal = tempMult;
                            }
                            else if(script.GetObjectType(itemOwner) != CLRScriptBase.OBJECT_TYPE_STORE)
                            {
                                lootValue += script.GetGoldPieceValue(Item);
                            }
                        }
                    }
                    else
                    {
                        removedItems.Add(Item);
                    }
                }
                foreach(uint Item in removedItems)
                {
                    recentlyDroppedItems[Character].Remove(Item);
                }
            }

            int chaMult = WealthToMultiplier(lootValue, level, CombatDrop);
            if (chaMult < retVal) retVal = chaMult;

            return retVal;
        }
        public static void CalculatePrice(CLRScriptBase script, uint target)
        {
            #region Reject to Price Objects Which Can't or Shouldn't be Priced
            if (script.GetObjectType(target) != OBJECT_TYPE_ITEM)
            {
                return;
            }

            int itemType = script.GetBaseItemType(target);
            if (GetIsOOCItem(itemType))
            {
                return;
            }
            #endregion

            #region Find out What the Item Should be Worth
            int targetValue = 0;
            if (GetIsWeapon(itemType) || GetIsAmmunition(itemType))
            {
                targetValue = GetWeaponPrice(script, target);
            }
            else if (GetIsArmor(itemType))
            {
                targetValue = GetArmorPrice(script, target);
            }
            else
            {
                targetValue = GetWonderousPrice(script, target);
            }
            #endregion

            #region Early Return for Illegal and Custom-Scripted Items
            if (targetValue == -1)
            {
                // We can't price this item, because it's illegal.
                script.SetFirstName(target, "(Illegal) " + script.GetName(target));
                return;
            }
            else if (targetValue == -2)
            {
                return;
            }
            #endregion

            #region Determine if the Item Requires Adjustment, and Adjust if Necessary
            bool isPlot = false;
            bool isUnidentified = false;
            if (script.GetLocalInt(target, localVarName) == pricingVersion)
            {
                // We've already used this logic to price this item. We have nothing to add.
                return;
            }
            if (script.GetPlotFlag(target) == TRUE)
            {
                script.SetPlotFlag(target, FALSE);
                isPlot = true;
            }
            if (script.GetIdentified(target) == FALSE)
            {
                script.SetIdentified(target, TRUE);
                isUnidentified = true;
            }
            int currentValue = script.GetGoldPieceValue(target);
            if (script.GetItemStackSize(target) > 1)
            {
                currentValue /= script.GetItemStackSize(target);
            }
            if (currentValue != targetValue)
            {
                script.StoreCampaignObject(ItemChangeDBName, PriceChangeVarName, target, script.OBJECT_SELF);
                if (ALFA.Shared.Modules.InfoStore.ModifiedGff.Keys.Contains(PriceChangeVarName))
                {
                    if (ALFA.Shared.Modules.InfoStore.ModifiedGff[PriceChangeVarName].TopLevelStruct["ModifyCost"].ValueInt == 0 ||
                        targetValue > currentValue ||
                        script.GetLocalInt(target, localVarName) != 0)
                    {
                        // We only want to adjust the price if either a) no effort to control the item's price has been made or
                        // b) the item is actually less valuable than the current price reads. Artificial inflations of price are
                        // legal in ALFA.

                        // Also, if this item was priced automatically, we want to be able to correct it.
                        script.SetLocalInt(target, localVarName, pricingVersion);
                        AdjustPrice(script, target, targetValue - currentValue);
                    }
                }
            }
            if (isPlot)
            {
                script.SetPlotFlag(target, TRUE);
            }
            if (isUnidentified)
            {
                script.SetIdentified(target, FALSE);
            }
            #endregion
        }