/// <summary>
        /// Update armor values after equipping or unequipping a piece of armor.
        /// </summary>
        public void UpdateEquippedArmorValues(DaggerfallUnityItem armor, bool equipping)
        {
            if (armor.ItemGroup == ItemGroups.Armor ||
                (armor.ItemGroup == ItemGroups.MensClothing && armor.GroupIndex >= 6 && armor.GroupIndex <= 8) ||
                (armor.ItemGroup == ItemGroups.WomensClothing && armor.GroupIndex >= 4 && armor.GroupIndex <= 6)
                )
            {
                if (!armor.IsShield)
                {
                    // Get slot used by this armor
                    EquipSlots slot = ItemEquipTable.GetEquipSlot(armor);

                    // Get equip index with out of range check
                    int index = (int)DaggerfallUnityItem.GetBodyPartForEquipSlot(slot);
                    if (armorValues == null || index < 0 || index >= armorValues.Length)
                    {
                        return;
                    }

                    if (equipping)
                    {
                        armorValues[index] -= (sbyte)(armor.GetMaterialArmorValue() * 5);
                    }
                    else
                    {
                        armorValues[index] += (sbyte)(armor.GetMaterialArmorValue() * 5);
                    }
                }
                else
                {
                    // Shield armor values in classic are unaffected by their material type.
                    int[]       values             = { 0, 0, 0, 0, 0, 0, 0 }; // shield's effect on the 7 armor values
                    int         armorBonus         = armor.GetShieldArmorValue();
                    BodyParts[] protectedBodyParts = armor.GetShieldProtectedBodyParts();

                    foreach (var BodyPart in protectedBodyParts)
                    {
                        values[(int)BodyPart] = armorBonus;
                    }

                    for (int i = 0; i < armorValues.Length; i++)
                    {
                        if (equipping)
                        {
                            armorValues[i] -= (sbyte)(values[i] * 5);
                        }
                        else
                        {
                            armorValues[i] += (sbyte)(values[i] * 5);
                        }
                    }
                }
            }
        }
Exemple #2
0
        // Finds the material that an armor item is made from, then returns the multiplier that will be used later based on this material check.
        private static int ArmorMaterialModifierFinder(DaggerfallUnityItem armor)
        {
            if (!armor.IsShield)
            {
                int itemMat = armor.GetMaterialArmorValue();
                itemMat /= 2 - (int)0.5;
                return(itemMat);
            }
            else
            {
                int itemMat = armor.NativeMaterialValue;

                switch (itemMat)
                {
                case (int)ArmorMaterialTypes.Leather:
                    return(1);

                case (int)ArmorMaterialTypes.Chain:
                case (int)ArmorMaterialTypes.Chain2:
                    return(2);

                case (int)ArmorMaterialTypes.Iron:
                    return(3);

                case (int)ArmorMaterialTypes.Steel:
                case (int)ArmorMaterialTypes.Silver:
                    return(4);

                case (int)ArmorMaterialTypes.Elven:
                    return(5);

                case (int)ArmorMaterialTypes.Dwarven:
                    return(6);

                case (int)ArmorMaterialTypes.Mithril:
                case (int)ArmorMaterialTypes.Adamantium:
                    return(7);

                case (int)ArmorMaterialTypes.Ebony:
                    return(8);

                case (int)ArmorMaterialTypes.Orcish:
                    return(9);

                case (int)ArmorMaterialTypes.Daedric:
                    return(10);
                }
            }
            return(1);
        }
        /// <summary>
        /// Update armor values after equipping or unequipping a piece of armor.
        /// </summary>
        public void UpdateEquippedArmorValues(DaggerfallUnityItem armor, bool equipping)
        {
            if (!armor.IsShield)
            {
                // Get slot used by this armor
                EquipSlots slot = ItemEquipTable.GetEquipSlot(armor);

                // This array maps equip slots to the order of the 7 armor values
                EquipSlots[] equipSlots = { EquipSlots.Head,       EquipSlots.RightArm, EquipSlots.LeftArm,
                                            EquipSlots.ChestArmor, EquipSlots.Gloves,   EquipSlots.LegsArmor,
                                            EquipSlots.Feet };

                // Get the index for the correct armor value and update the armor value.
                // Armor value is 100 when no armor is equipped. For every point of armor as shown on the inventory screen, 5 is subtracted.
                int index = System.Array.IndexOf(equipSlots, slot);

                if (equipping)
                {
                    armorValues[index] -= (sbyte)(armor.GetMaterialArmorValue() * 5);
                }
                else
                {
                    armorValues[index] += (sbyte)(armor.GetMaterialArmorValue() * 5);
                }
            }
            else
            {
                // Shields armor values in classic are unaffected by their material type.
                int[] values = { 0, 0, 0, 0, 0, 0, 0 }; // shield's effect on the 7 armor values

                if (armor.TemplateIndex == (int)Armor.Buckler)
                {
                    values[2] = 1; // left arm
                    values[4] = 1; // gloves
                }
                else if (armor.TemplateIndex == (int)Armor.Round_Shield)
                {
                    values[2] = 2; // left arm
                    values[4] = 2; // gloves
                    values[5] = 2; // legs armor
                }
                else if (armor.TemplateIndex == (int)Armor.Kite_Shield)
                {
                    values[2] = 3; // left arm
                    values[4] = 3; // gloves
                    values[5] = 3; // legs armor
                }
                else if (armor.TemplateIndex == (int)Armor.Tower_Shield)
                {
                    values[0] = 4; // head
                    values[2] = 4; // left arm
                    values[4] = 4; // gloves
                    values[5] = 4; // legs armor
                }

                for (int i = 0; i < armorValues.Length; i++)
                {
                    if (equipping)
                    {
                        armorValues[i] -= (sbyte)(values[i] * 5);
                    }
                    else
                    {
                        armorValues[i] += (sbyte)(values[i] * 5);
                    }
                }
            }
        }