コード例 #1
0
        void Awake()
        {
            //Unleveled gold and daedra drops
            FormulaHelper.RegisterOverride(mod, "ModifyFoundLootItems", (Func <DaggerfallUnityItem[], int>)UnleveledGoldLootPiles);
            EnemyDeath.OnEnemyDeath += UnlevelDroppedLoot_OnEnemyDeath;

            PlayerEnterExit.OnPreTransition      += SetDungeon_OnPreTransition;
            PlayerEnterExit.OnTransitionExterior += ClearData_OnTransitionExterior;

            //Override of material mechanics.
            FormulaHelper.RegisterOverride <Func <int, WeaponMaterialTypes> >(mod, "RandomMaterial", (player) =>
            {
                luckMod = GameManager.Instance.PlayerEntity.Stats.LiveLuck / 10;
                matRoll = UnityEngine.Random.Range(0, 92) + luckMod;
                WeaponMaterialTypes material = WpnMatSelector();
                return(material);
            });
            FormulaHelper.RegisterOverride <Func <int, ArmorMaterialTypes> >(mod, "RandomArmorMaterial", (player) =>
            {
                luckMod = GameManager.Instance.PlayerEntity.Stats.LiveLuck / 10;
                matRoll = UnityEngine.Random.Range(0, 92) + luckMod;
                ArmorMaterialTypes material = ArmMatSelector();
                return(material);
            });


            mod.IsReady = true;
        }
コード例 #2
0
        /// <summary>
        /// Resolves full item name using parameters like %it and material type.
        /// </summary>
        public string ResolveItemName(DaggerfallUnityItem item)
        {
            // Start with base name
            string result = item.shortName;

            // Get item template
            ItemTemplate template = item.ItemTemplate;

            // Resolve %it parameter
            result = result.Replace("%it", template.name);

            // Resolve weapon material
            if (item.ItemGroup == ItemGroups.Weapons)
            {
                WeaponMaterialTypes weaponMaterial = (WeaponMaterialTypes)item.nativeMaterialValue;
                string materialName = DaggerfallUnity.Instance.TextProvider.GetWeaponMaterialName(weaponMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            // Resolve armor material
            if (item.ItemGroup == ItemGroups.Armor)
            {
                ArmorMaterialTypes armorMaterial = (ArmorMaterialTypes)item.nativeMaterialValue;
                string             materialName  = DaggerfallUnity.Instance.TextProvider.GetArmorMaterialName(armorMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Creates random weapon.
        /// </summary>
        /// <param name="playerLevel">Player level for material type.</param>
        /// <returns>DaggerfallUnityItem</returns>
        public static DaggerfallUnityItem CreateRandomWeapon(int playerLevel)
        {
            // Create a random weapon type, including any custom items registered as weapons
            ItemHelper itemHelper = DaggerfallUnity.Instance.ItemHelper;
            Array      enumArray  = itemHelper.GetEnumArray(ItemGroups.Weapons);

            int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(ItemGroups.Weapons);

            int groupIndex = UnityEngine.Random.Range(0, enumArray.Length + customItemTemplates.Length);
            DaggerfallUnityItem newItem;

            if (groupIndex < enumArray.Length)
            {
                newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);
            }
            else
            {
                newItem = CreateItem(ItemGroups.Weapons, customItemTemplates[groupIndex - enumArray.Length]);
            }

            // Random weapon material
            WeaponMaterialTypes material = FormulaHelper.RandomMaterial(playerLevel);

            ApplyWeaponMaterial(newItem, material);

            // Handle arrows
            if (groupIndex == 18)
            {
                newItem.stackCount          = UnityEngine.Random.Range(1, 20 + 1);
                newItem.currentCondition    = 0; // not sure if this is necessary, but classic does it
                newItem.nativeMaterialValue = 0; // Arrows don't have a material
            }

            return(newItem);
        }
コード例 #4
0
        private static ArmorMaterialTypes ArmMatSelector()
        {
            ArmorMaterialTypes armorMaterial = ArmorMaterialTypes.Leather;
            int rollMod = 0;
            int armRoll = UnityEngine.Random.Range(1, 91) + luckMod;

            if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop)
            {
                rollMod += GameManager.Instance.PlayerEnterExit.Interior.BuildingData.Quality * 6;
            }
            else if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon)
            {
                rollMod += dungeonQuality();
            }
            if (armRoll + rollMod > 50)
            {
                if (armRoll + rollMod > 80)
                {
                    WeaponMaterialTypes material = WpnMatSelector();
                    armorMaterial = (ArmorMaterialTypes)(0x0200 + material);
                }
                else
                {
                    armorMaterial = ArmorMaterialTypes.Chain;
                }
            }
            return(armorMaterial);
        }
コード例 #5
0
        /// <summary>
        /// Resolves full item name using parameters like %it and material type.
        /// </summary>
        public string ResolveItemLongName(DaggerfallUnityItem item)
        {
            string result = ResolveItemName(item);

            // Return result without material prefix if item is unidentified or an Artifact.
            if (!item.IsIdentified || item.IsArtifact)
            {
                return(result);
            }

            // Resolve weapon material
            if (item.ItemGroup == ItemGroups.Weapons && item.TemplateIndex != (int)Weapons.Arrow)
            {
                WeaponMaterialTypes weaponMaterial = (WeaponMaterialTypes)item.nativeMaterialValue;
                string materialName = DaggerfallUnity.Instance.TextProvider.GetWeaponMaterialName(weaponMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            // Resolve armor material
            if (item.ItemGroup == ItemGroups.Armor && !item.IsShield && item.TemplateIndex != (int)Armor.Helm)
            {
                ArmorMaterialTypes armorMaterial = (ArmorMaterialTypes)item.nativeMaterialValue;
                string             materialName  = DaggerfallUnity.Instance.TextProvider.GetArmorMaterialName(armorMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Resolves full item name using parameters like %it and material type.
        /// </summary>
        public string ResolveItemLongName(DaggerfallUnityItem item)
        {
            string result = ResolveItemName(item);

            // Return result without material prefix if item is unidentified or an Artifact.
            if (!item.IsIdentified || item.IsArtifact)
            {
                return(result);
            }

            // Resolve weapon material
            if (item.ItemGroup == ItemGroups.Weapons && item.TemplateIndex != (int)Weapons.Arrow)
            {
                WeaponMaterialTypes weaponMaterial = (WeaponMaterialTypes)item.nativeMaterialValue;
                string materialName = DaggerfallUnity.Instance.TextProvider.GetWeaponMaterialName(weaponMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            // Resolve armor material
            if (item.ItemGroup == ItemGroups.Armor && ArmorShouldShowMaterial(item))
            {
                ArmorMaterialTypes armorMaterial = (ArmorMaterialTypes)item.nativeMaterialValue;
                string             materialName  = DaggerfallUnity.Instance.TextProvider.GetArmorMaterialName(armorMaterial);
                result = string.Format("{0} {1}", materialName, result);
            }

            // Resolve potion names
            if (item.ItemGroup == ItemGroups.UselessItems1 && item.TemplateIndex == (int)UselessItems1.Glass_Bottle)
            {
                return(MacroHelper.GetValue("%po", item));
            }

            return(result);
        }
コード例 #7
0
        static float CalculateWeightForMaterial(DaggerfallUnityItem item, WeaponMaterialTypes material)
        {
            int   quarterKgs    = (int)(item.weightInKg * 4);
            float matQuarterKgs = (float)(quarterKgs * weightMultipliersByMaterial[(int)material]) / 4;

            return(Mathf.Round(matQuarterKgs) / 4);
        }
コード例 #8
0
        private static WeaponMaterialTypes RandomHighTier()
        {
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Mithril;

            int roll = UnityEngine.Random.Range(0, 201);

            if (roll > 199)
            {
                weaponMaterial = WeaponMaterialTypes.Daedric;
            }
            else if (roll > 192)
            {
                weaponMaterial = WeaponMaterialTypes.Orcish;
            }
            else if (roll > 180)
            {
                weaponMaterial = WeaponMaterialTypes.Ebony;
            }
            else if (roll > 100)
            {
                weaponMaterial = WeaponMaterialTypes.Adamantium;
            }


            return(weaponMaterial);
        }
コード例 #9
0
        /// <summary>
        /// Creates random weapon.
        /// </summary>
        /// <param name="playerLevel">Player level for material type.</param>
        /// <returns>DaggerfallUnityItem</returns>
        public static DaggerfallUnityItem CreateRandomWeapon(int playerLevel)
        {
            // Create random weapon type
            Array enumArray             = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(ItemGroups.Weapons);
            int   groupIndex            = UnityEngine.Random.Range(0, enumArray.Length);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            // Random weapon material
            WeaponMaterialTypes material = RandomMaterial(playerLevel);

            newItem.nativeMaterialValue = (int)material;

            newItem          = SetItemPropertiesByMaterial(newItem, material);
            newItem.dyeColor = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);

            // Handle arrows
            if (groupIndex == 18)
            {
                newItem.stackCount          = UnityEngine.Random.Range(1, 20 + 1);
                newItem.currentCondition    = 0; // not sure if this is necessary, but classic does it
                newItem.nativeMaterialValue = 0; // Arrows don't have a material
            }

            return(newItem);
        }
コード例 #10
0
        /// <summary>
        /// Generates a random armor material.
        /// </summary>
        /// <param name="minMaterial">Lowest quality of material.</param>
        /// <param name="maxMaterial">Highest quality of material.</param>
        /// <returns>WeaponMaterialTypes</returns>
        public static WeaponMaterialTypes RandomWeaponMaterial(
            WeaponMaterialTypes minMaterial = WeaponMaterialTypes.Iron,
            WeaponMaterialTypes maxMaterial = WeaponMaterialTypes.Daedric)
        {
            Array materialValues = Enum.GetValues(typeof(WeaponMaterialTypes));
            int   index          = UnityEngine.Random.Range((int)minMaterial, (int)maxMaterial);

            return((WeaponMaterialTypes)materialValues.GetValue(index));
        }
コード例 #11
0
        /// <summary>
        /// Generates a weapon.
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="material"></param>
        /// <returns></returns>
        public static DaggerfallUnityItem CreateWeapon(Weapons weapon, WeaponMaterialTypes material)
        {
            // Create item
            int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(ItemGroups.Weapons, (int)weapon);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            // Adjust material
            newItem.nativeMaterialValue = (int)material;
            newItem.dyeColor            = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);

            return(newItem);
        }
コード例 #12
0
        /// <summary>Set material and adjust weapon stats accordingly</summary>
        public static void ApplyWeaponMaterial(DaggerfallUnityItem weapon, WeaponMaterialTypes material)
        {
            weapon.nativeMaterialValue = (int)material;
            weapon          = SetItemPropertiesByMaterial(weapon, material);
            weapon.dyeColor = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);

            // Female characters use archive - 1 (i.e. 233 rather than 234) for weapons
            if (GameManager.Instance.PlayerEntity.Gender == Genders.Female)
            {
                weapon.PlayerTextureArchive -= 1;
            }
        }
コード例 #13
0
        private static WeaponMaterialTypes randomMat()
        {
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Iron;

            if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon)
            {
                matRoll = (matRoll - 15) + dungeonQuality();
            }
            else
            {
                matRoll -= UnityEngine.Random.Range(10, 20);
            }
            //increased chance of orcish when in orsinium or an orc stronghold
            if (Dice100.SuccessRoll(luckMod * 2))
            {
                if ((region == (int)DaggerfallRegions.OrsiniumArea || dungeon == (int)DFRegion.DungeonTypes.OrcStronghold) && Dice100.SuccessRoll(luckMod))
                {
                    return(WeaponMaterialTypes.Orcish);
                }
                else
                {
                    matRoll += luckMod * 4;
                }
            }
            if (matRoll > 90)
            {
                if (Dice100.SuccessRoll(luckMod * 3))
                {
                    weaponMaterial = RandomHighTier();
                }
                else
                {
                    weaponMaterial = WeaponMaterialTypes.Dwarven;
                }
            }
            else if (matRoll > 83)
            {
                weaponMaterial = WeaponMaterialTypes.Elven;
            }
            else if (matRoll > 75)
            {
                weaponMaterial = WeaponMaterialTypes.Silver;
            }
            else if (matRoll > 35)
            {
                weaponMaterial = WeaponMaterialTypes.Steel;
            }
            return(weaponMaterial);
        }
コード例 #14
0
        /// <summary>
        /// Creates random weapon.
        /// </summary>
        /// <param name="playerLevel">Player level for material type.</param>
        /// <returns>DaggerfallUnityItem</returns>
        public static DaggerfallUnityItem CreateRandomWeapon(int playerLevel)
        {
            // Create random weapon type (excluding bows and arrows for now)
            Array enumArray             = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(ItemGroups.Weapons);
            int   groupIndex            = UnityEngine.Random.Range(0, enumArray.Length - 3);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            // Random weapon material
            WeaponMaterialTypes material = RandomWeaponMaterial(playerLevel);

            newItem.nativeMaterialValue = (int)material;
            newItem.dyeColor            = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);

            return(newItem);
        }
コード例 #15
0
        private static WeaponMaterialTypes WpnMatSelector()
        {
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Iron;

            if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop)
            {
                weaponMaterial = shopMat();
            }
            else
            {
                weaponMaterial = randomMat();
            }

            return(weaponMaterial);
        }
コード例 #16
0
        private static WeaponMaterialTypes shopMat()
        {
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Steel;
            int region      = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
            int shopQuality = GameManager.Instance.PlayerEnterExit.Interior.BuildingData.Quality;

            matRoll = (matRoll - 35) + (shopQuality * 2);

            //increased chance of orcish when in orsinium
            if ((region == (int)DaggerfallRegions.OrsiniumArea) && (matRoll) > 70)
            {
                int roll = UnityEngine.Random.Range(0, 90) + luckMod;
                if (roll > 90)
                {
                    return(WeaponMaterialTypes.Orcish);
                }
            }

            if (matRoll > 99)
            {
                weaponMaterial = WeaponMaterialTypes.Ebony;
            }
            else if (matRoll > 97)
            {
                weaponMaterial = WeaponMaterialTypes.Adamantium;
            }
            else if (matRoll > 94)
            {
                weaponMaterial = WeaponMaterialTypes.Mithril;
            }
            else if (matRoll > 88)
            {
                weaponMaterial = WeaponMaterialTypes.Dwarven;
            }
            else if (matRoll > 80)
            {
                weaponMaterial = WeaponMaterialTypes.Elven;
            }
            else if (matRoll > 70)
            {
                weaponMaterial = WeaponMaterialTypes.Silver;
            }
            else if (matRoll < 10)
            {
                weaponMaterial = WeaponMaterialTypes.Iron;
            }
            return(weaponMaterial);
        }
コード例 #17
0
        /// <summary>
        /// Generates a weapon.
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="material">Ignored for arrows</param>
        /// <returns></returns>
        public static DaggerfallUnityItem CreateWeapon(Weapons weapon, WeaponMaterialTypes material)
        {
            // Create item
            int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(ItemGroups.Weapons, (int)weapon);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            if (weapon == Weapons.Arrow)
            {                                 // Handle arrows
                newItem.stackCount       = UnityEngine.Random.Range(1, 20 + 1);
                newItem.currentCondition = 0; // not sure if this is necessary, but classic does it
            }
            else
            {
                ApplyWeaponMaterial(newItem, material);
            }
            return(newItem);
        }
コード例 #18
0
        /// <summary>
        /// Generates a weapon.
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="material">Ignored for arrows</param>
        /// <returns></returns>
        public static DaggerfallUnityItem CreateWeapon(Weapons weapon, WeaponMaterialTypes material)
        {
            // Create item
            int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(ItemGroups.Weapons, (int)weapon);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            if (weapon == Weapons.Arrow)
            {                                 // Handle arrows
                newItem.stackCount       = UnityEngine.Random.Range(1, 21);
                newItem.currentCondition = 0; // not sure if this is necessary, but classic does it
            }
            else
            {   // Adjust material
                newItem.nativeMaterialValue = (int)material;
                newItem          = SetItemPropertiesByMaterial(newItem, material);
                newItem.dyeColor = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);
            }
            return(newItem);
        }
コード例 #19
0
        /// <summary>
        /// Gets a random armor material based on player level.
        /// </summary>
        /// <param name="playerLevel">Player level.</param>
        /// <returns>ArmorMaterialTypes.</returns>
        public static ArmorMaterialTypes RandomArmorMaterial(int playerLevel)
        {
            // Random armor material
            int random = UnityEngine.Random.Range(1, 101);

            if (random >= 70)
            {
                if (random >= 90)
                {
                    WeaponMaterialTypes plateMaterial = RandomMaterial(playerLevel);
                    return((ArmorMaterialTypes)(0x0200 + plateMaterial));
                }
                else
                {
                    return(ArmorMaterialTypes.Chain);
                }
            }
            else
            {
                return(ArmorMaterialTypes.Leather);
            }
        }
コード例 #20
0
        /// <summary>
        /// Gets a random armor material based on player level.
        /// </summary>
        /// <param name="playerLevel">Player level.</param>
        /// <returns>ArmorMaterialTypes.</returns>
        public static ArmorMaterialTypes RandomArmorMaterial(int playerLevel)
        {
            // Random armor material
            int roll = Dice100.Roll();

            if (roll >= 70)
            {
                if (roll >= 90)
                {
                    WeaponMaterialTypes plateMaterial = RandomMaterial(playerLevel);
                    return((ArmorMaterialTypes)(0x0200 + plateMaterial));
                }
                else
                {
                    return(ArmorMaterialTypes.Chain);
                }
            }
            else
            {
                return(ArmorMaterialTypes.Leather);
            }
        }
コード例 #21
0
        public string GetWeaponMaterialName(WeaponMaterialTypes material)
        {
            switch (material)
            {
            case WeaponMaterialTypes.Iron:
                return("Iron");

            case WeaponMaterialTypes.Steel:
                return("Steel");

            case WeaponMaterialTypes.Silver:
                return("Silver");

            case WeaponMaterialTypes.Elven:
                return("Elven");

            case WeaponMaterialTypes.Dwarven:
                return("Dwarven");

            case WeaponMaterialTypes.Mithril:
                return("Mithril");

            case WeaponMaterialTypes.Adamantium:
                return("Adamantium");

            case WeaponMaterialTypes.Ebony:
                return("Ebony");

            case WeaponMaterialTypes.Orcish:
                return("Orcish");

            case WeaponMaterialTypes.Daedric:
                return("Daedric");

            default:
                return(string.Empty);
            }
        }
コード例 #22
0
        public string GetWeaponMaterialName(WeaponMaterialTypes material)
        {
            switch (material)
            {
            case WeaponMaterialTypes.Iron:
                return(TextManager.Instance.GetLocalizedText("iron"));

            case WeaponMaterialTypes.Steel:
                return(TextManager.Instance.GetLocalizedText("steel"));

            case WeaponMaterialTypes.Silver:
                return(TextManager.Instance.GetLocalizedText("silver"));

            case WeaponMaterialTypes.Elven:
                return(TextManager.Instance.GetLocalizedText("elven"));

            case WeaponMaterialTypes.Dwarven:
                return(TextManager.Instance.GetLocalizedText("dwarven"));

            case WeaponMaterialTypes.Mithril:
                return(TextManager.Instance.GetLocalizedText("mithril"));

            case WeaponMaterialTypes.Adamantium:
                return(TextManager.Instance.GetLocalizedText("adamantium"));

            case WeaponMaterialTypes.Ebony:
                return(TextManager.Instance.GetLocalizedText("ebony"));

            case WeaponMaterialTypes.Orcish:
                return(TextManager.Instance.GetLocalizedText("orcish"));

            case WeaponMaterialTypes.Daedric:
                return(TextManager.Instance.GetLocalizedText("daedric"));

            default:
                return(string.Empty);
            }
        }
コード例 #23
0
        private static ArmorMaterialTypes WeaponToArmorMaterialType(WeaponMaterialTypes materialType)
        {
            switch (materialType)
            {
            case WeaponMaterialTypes.Iron:
                return(ArmorMaterialTypes.Iron);

            case WeaponMaterialTypes.Steel:
                return(ArmorMaterialTypes.Steel);

            case WeaponMaterialTypes.Silver:
                return(ArmorMaterialTypes.Silver);

            case WeaponMaterialTypes.Elven:
                return(ArmorMaterialTypes.Elven);

            case WeaponMaterialTypes.Dwarven:
                return(ArmorMaterialTypes.Dwarven);

            case WeaponMaterialTypes.Mithril:
                return(ArmorMaterialTypes.Mithril);

            case WeaponMaterialTypes.Adamantium:
                return(ArmorMaterialTypes.Adamantium);

            case WeaponMaterialTypes.Ebony:
                return(ArmorMaterialTypes.Ebony);

            case WeaponMaterialTypes.Orcish:
                return(ArmorMaterialTypes.Orcish);

            case WeaponMaterialTypes.Daedric:
                return(ArmorMaterialTypes.Daedric);

            default:
                return(ArmorMaterialTypes.None);
            }
        }
コード例 #24
0
        /// <summary>
        /// Converts weapon material to appropriate dye colour.
        /// </summary>
        /// <param name="material">WeaponMaterialTypes.</param>
        /// <returns>DyeColors.</returns>
        public DyeColors GetWeaponDyeColor(WeaponMaterialTypes material)
        {
            switch (material)
            {
            case WeaponMaterialTypes.Iron:
                return(DyeColors.Iron);

            case WeaponMaterialTypes.Steel:
                return(DyeColors.Steel);

            case WeaponMaterialTypes.Silver:
            case WeaponMaterialTypes.Elven:
                return(DyeColors.SilverOrElven);

            case WeaponMaterialTypes.Dwarven:
                return(DyeColors.Dwarven);

            case WeaponMaterialTypes.Mithril:
                return(DyeColors.Mithril);

            case WeaponMaterialTypes.Adamantium:
                return(DyeColors.Adamantium);

            case WeaponMaterialTypes.Ebony:
                return(DyeColors.Ebony);

            case WeaponMaterialTypes.Orcish:
                return(DyeColors.Orcish);

            case WeaponMaterialTypes.Daedric:
                return(DyeColors.Daedric);

            default:
                return(DyeColors.Unchanged);
            }
        }
コード例 #25
0
 public string GetWeaponMaterialName(WeaponMaterialTypes material)
 {
     switch(material)
     {
         case WeaponMaterialTypes.Iron:
             return "Iron";
         case WeaponMaterialTypes.Steel:
             return "Steel";
         case WeaponMaterialTypes.Silver:
             return "Silver";
         case WeaponMaterialTypes.Elven:
             return "Elven";
         case WeaponMaterialTypes.Dwarven:
             return "Dwarven";
         case WeaponMaterialTypes.Mithril:
             return "Mithril";
         case WeaponMaterialTypes.Adamantium:
             return "Adamantium";
         case WeaponMaterialTypes.Ebony:
             return "Ebony";
         case WeaponMaterialTypes.Orcish:
             return "Orcish";
         case WeaponMaterialTypes.Daedric:
             return "Daedric";
         default:
             return string.Empty;
     }
 }
コード例 #26
0
        static void AssignSkillItems(PlayerEntity playerEntity, DFCareer.Skills skill)
        {
            ItemCollection items  = playerEntity.Items;
            Genders        gender = playerEntity.Gender;
            Races          race   = playerEntity.Race;

            bool upgrade = Dice100.SuccessRoll(playerEntity.Career.Luck / (playerEntity.Career.Luck < 56 ? 2 : 1));
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Iron;

            if ((upgrade && !playerEntity.Career.IsMaterialForbidden(DFCareer.MaterialFlags.Steel)) || playerEntity.Career.IsMaterialForbidden(DFCareer.MaterialFlags.Iron))
            {
                weaponMaterial = WeaponMaterialTypes.Steel;
            }
            ArmorMaterialTypes armorMaterial = ArmorMaterialTypes.Leather;

            if ((upgrade && !playerEntity.Career.IsArmorForbidden(DFCareer.ArmorFlags.Chain)) || playerEntity.Career.IsArmorForbidden(DFCareer.ArmorFlags.Leather))
            {
                armorMaterial = ArmorMaterialTypes.Chain;
            }

            switch (skill)
            {
            case DFCareer.Skills.Archery:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Weapons.Short_Bow, weaponMaterial));
                DaggerfallUnityItem arrowPile = ItemBuilder.CreateWeapon(Weapons.Arrow, WeaponMaterialTypes.Iron);
                arrowPile.stackCount = 30;
                items.AddItem(arrowPile);
                return;

            case DFCareer.Skills.Axe:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Battle_Axe : Weapons.War_Axe, weaponMaterial)); return;

            case DFCareer.Skills.Backstabbing:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Right_Pauldron, armorMaterial)); return;

            case DFCareer.Skills.BluntWeapon:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Mace : Weapons.Flail, weaponMaterial)); return;

            case DFCareer.Skills.Climbing:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Helm, armorMaterial, -1)); return;

            case DFCareer.Skills.CriticalStrike:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Greaves, armorMaterial)); return;

            case DFCareer.Skills.Dodging:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Casual_cloak, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Casual_cloak, race)); return;

            case DFCareer.Skills.Etiquette:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Formal_tunic, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Evening_gown, race)); return;

            case DFCareer.Skills.HandToHand:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Gauntlets, armorMaterial)); return;

            case DFCareer.Skills.Jumping:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Boots, armorMaterial)); return;

            case DFCareer.Skills.Lockpicking:
                items.AddItem(ItemBuilder.CreateRandomPotion()); return;

            case DFCareer.Skills.LongBlade:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Saber : Weapons.Broadsword, weaponMaterial)); return;

            case DFCareer.Skills.Medical:
                DaggerfallUnityItem bandages = ItemBuilder.CreateItem(ItemGroups.UselessItems2, (int)UselessItems2.Bandage);
                bandages.stackCount = 4;
                items.AddItem(bandages);
                return;

            case DFCareer.Skills.Mercantile:
                items.AddItem(ItemBuilder.CreateGoldPieces(UnityEngine.Random.Range(playerEntity.Career.Luck, playerEntity.Career.Luck * 4))); return;

            case DFCareer.Skills.Pickpocket:
                items.AddItem(ItemBuilder.CreateRandomGem()); return;

            case DFCareer.Skills.Running:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Shoes, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Shoes, race)); return;

            case DFCareer.Skills.ShortBlade:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Shortsword : Weapons.Tanto, weaponMaterial)); return;

            case DFCareer.Skills.Stealth:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Khajiit_suit, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Khajiit_suit, race)); return;

            case DFCareer.Skills.Streetwise:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Cuirass, armorMaterial)); return;

            case DFCareer.Skills.Swimming:
                items.AddItem((gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Loincloth, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Loincloth, race)); return;

            case DFCareer.Skills.Daedric:
            case DFCareer.Skills.Dragonish:
            case DFCareer.Skills.Giantish:
            case DFCareer.Skills.Harpy:
            case DFCareer.Skills.Impish:
            case DFCareer.Skills.Orcish:
                items.AddItem(ItemBuilder.CreateRandomBook());
                for (int i = 0; i < 4; i++)
                {
                    items.AddItem(ItemBuilder.CreateRandomIngredient(ItemGroups.CreatureIngredients1));
                }
                return;

            case DFCareer.Skills.Centaurian:
            case DFCareer.Skills.Nymph:
            case DFCareer.Skills.Spriggan:
                items.AddItem(ItemBuilder.CreateRandomBook());
                for (int i = 0; i < 4; i++)
                {
                    items.AddItem(ItemBuilder.CreateRandomIngredient(ItemGroups.PlantIngredients1));
                }
                return;
            }
        }
コード例 #27
0
        /// <summary>
        /// Sets properties for a weapon or piece of armor based on its material.
        /// </summary>
        /// <param name="item">Item to have its properties modified.</param>
        /// <param name="material">Material to use to apply properties.</param>
        /// <returns>DaggerfallUnityItem</returns>
        public static DaggerfallUnityItem SetItemPropertiesByMaterial(DaggerfallUnityItem item, WeaponMaterialTypes material)
        {
            item.value             *= 3 * valueMultipliersByMaterial[(int)material];
            item.weightInKg         = CalculateWeightForMaterial(item, material);
            item.maxCondition      *= conditionMultipliersByMaterial[(int)material] / 4;
            item.currentCondition   = item.maxCondition;
            item.enchantmentPoints *= enchantmentPointMultipliersByMaterial[(int)material] / 4;

            return(item);
        }
コード例 #28
0
        /// <summary>
        /// Generates a weapon.
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="material"></param>
        /// <returns></returns>
        public static DaggerfallUnityItem CreateWeapon(Weapons weapon, WeaponMaterialTypes material)
        {
            // Create item
            int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(ItemGroups.Weapons, (int)weapon);
            DaggerfallUnityItem newItem = new DaggerfallUnityItem(ItemGroups.Weapons, groupIndex);

            // Adjust material
            newItem.nativeMaterialValue = (int)material;
            newItem.dyeColor = DaggerfallUnity.Instance.ItemHelper.GetWeaponDyeColor(material);

            return newItem;
        }
コード例 #29
0
        public void StockShopShelf(PlayerGPS.DiscoveredBuilding buildingData)
        {
            stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now);
            items.Clear();

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;
            int shopQuality = buildingData.quality;

            Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
            int        playerLuck = playerEntity.Stats.LiveLuck;
            ItemHelper itemHelper = DaggerfallUnity.Instance.ItemHelper;

            byte[] itemGroups   = { 0 };
            int[]  discrimItems = new int[] { };

            switch (buildingType)
            {
            case DFLocation.BuildingTypes.Alchemist:
                float alchChance    = 60;
                float alchChanceMod = 0.75f;
                while (Dice100.SuccessRoll((int)alchChance))
                {
                    RandomlyAddPotion(100, items);
                    alchChance *= alchChanceMod;
                }
                alchChance = 40;
                while (Dice100.SuccessRoll((int)alchChance))
                {
                    RandomlyAddPotionRecipe(100, items);
                    alchChance *= alchChanceMod;
                }
                itemGroups = DaggerfallLootDataTables.itemGroupsAlchemist;
                break;

            case DFLocation.BuildingTypes.Armorer:
                itemGroups   = DaggerfallLootDataTables.itemGroupsArmorer;
                discrimItems = new int[] { (int)Repair_Tools.Charging_Powder, (int)Repair_Tools.Epoxy_Glue, (int)Repair_Tools.Whetstone };
                break;

            case DFLocation.BuildingTypes.Bookseller:
                itemGroups = DaggerfallLootDataTables.itemGroupsBookseller;
                break;

            case DFLocation.BuildingTypes.ClothingStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsClothingStore;
                break;

            case DFLocation.BuildingTypes.GemStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGemStore;
                break;

            case DFLocation.BuildingTypes.GeneralStore:
                if (Dice100.SuccessRoll(20))
                {
                    items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Horse));
                }
                if (Dice100.SuccessRoll(30))
                {
                    items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart));
                }
                itemGroups   = DaggerfallLootDataTables.itemGroupsGeneralStore;
                discrimItems = new int[] { (int)Containers.Barrel, (int)Containers.Lockbox, (int)Liquid_Containers.Gem_Encrusted_Gold_Goblet, (int)Liquid_Containers.Gem_Encrusted_Silver_Goblet, (int)Liquid_Containers.Gold_Goblet, (int)Liquid_Containers.Silver_Goblet };
                break;

            case DFLocation.BuildingTypes.PawnShop:
                itemGroups   = DaggerfallLootDataTables.itemGroupsPawnShop;
                discrimItems = new int[] { (int)Containers.Barrel, (int)Containers.Bucket, (int)Containers.Urn, (int)Containers.Urn, (int)Containers.Snuff_Box, (int)Containers.Quiver, (int)Liquid_Containers.Empty_Bottle, (int)Liquid_Containers.Wooden_Cup, (int)Liquid_Containers.Tin_Goblet };
                break;

            case DFLocation.BuildingTypes.WeaponSmith:
                itemGroups   = DaggerfallLootDataTables.itemGroupsWeaponSmith;
                discrimItems = new int[] { (int)Repair_Tools.Charging_Powder, (int)Repair_Tools.Armorers_Hammer, (int)Repair_Tools.Jewelers_Pliers, (int)Repair_Tools.Sewing_Kit };
                break;
            }

            for (int i = 0; i < itemGroups.Length; i += 2) // Alright, that makes more sense to me now at least, from what it seems at least. Odd values are the itemGroup, Even are the chance for that itemGroup, makes much more sense.
            {
                ItemGroups itemGroup = (ItemGroups)itemGroups[i];
                float      chance    = itemGroups[i + 1];
                float      chanceMod = 0.45f;

                if (itemGroup != ItemGroups.Furniture && itemGroup != ItemGroups.UselessItems1)
                {
                    while (Dice100.SuccessRoll((int)chance))                      // I think order will be, roll if item of group is generated, then actually pick the item of said group randomly and then continue from there until loop roll fails.
                    {
                        DaggerfallUnityItem item = null;                          // Don't forget to have weapons and armor and such have variable condition values depending on the quality of the store they were bought/generated in.
                        chanceMod = Mathf.Clamp(chanceMod + 0.05f, 0.10f, 0.85f); // Will likely have to tweak this around and see how the results are. Possibly have shop quality modify these chance values as well.
                        if (itemGroup == ItemGroups.Weapons)
                        {
                            item = ItemBuilder.CreateWeapon((Weapons)Random.Range((int)Weapons.Dagger, (int)Weapons.Arrow + 1), FormulaHelper.RandomMaterial(-1, shopQuality, playerLuck)); // May rework and give weapons different rarity values later.
                        }
                        else if (itemGroup == ItemGroups.Armor)
                        {
                            item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, (Armor)Random.Range((int)Armor.Cuirass, (int)Armor.Tower_Shield + 1), FormulaHelper.RandomArmorMaterial(-1, shopQuality, playerLuck));
                        }
                        else if (itemGroup == ItemGroups.MensClothing)
                        {
                            item          = ItemBuilder.CreateMensClothing((MensClothing)Random.Range((int)MensClothing.Straps, (int)MensClothing.Champion_straps + 1), playerEntity.Race);
                            item.dyeColor = ItemBuilder.RandomClothingDye();
                        }
                        else if (itemGroup == ItemGroups.WomensClothing)
                        {
                            item          = ItemBuilder.CreateWomensClothing((WomensClothing)Random.Range((int)WomensClothing.Brassier, (int)WomensClothing.Vest + 1), playerEntity.Race);
                            item.dyeColor = ItemBuilder.RandomClothingDye();
                        }
                        else if (itemGroup == ItemGroups.Books)
                        {
                            item = ItemBuilder.CreateRandomBookOfRandomSubject(-1, shopQuality, playerLuck);
                        }
                        else if (itemGroup == ItemGroups.MagicItems)
                        {
                            item = ItemBuilder.CreateRandomMagicItem(playerEntity.Gender, playerEntity.Race, -1, shopQuality, playerLuck);
                        }
                        else if ((int)itemGroup == (int)ItemGroups.Jewellery || ((int)itemGroup >= (int)ItemGroups.Tiara_Jewelry && (int)itemGroup <= (int)ItemGroups.Bracelet_Jewelry))
                        {
                            item = ItemBuilder.CreateRandomJewelryOfRandomSlot(-1, shopQuality, playerLuck, discrimItems);
                        }
                        else
                        {
                            item = ItemBuilder.CreateRandomItemOfItemgroup(itemGroup, -1, shopQuality, playerLuck, discrimItems); // For filter could make a method to populate the discrimItem para values and just change them based on shop types, maybe.
                            if (item != null && DaggerfallUnity.Settings.PlayerTorchFromItems && item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Oil))
                            {
                                item.stackCount = Random.Range(5, 20 + 1);  // Shops stock 5-20 bottles
                            }
                        }
                        items.AddItem(item);

                        chance *= chanceMod; // Likely determine chanceMod by the itemGroup being currently ran.
                    }

                    // Add any modded items registered in applicable groups
                    int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(itemGroup);
                    for (int j = 0; j < customItemTemplates.Length; j++)
                    {
                        ItemTemplate itemTemplate = itemHelper.GetItemTemplate(itemGroup, customItemTemplates[j]);
                        if (itemTemplate.rarity <= shopQuality)
                        {
                            int stockChance = (int)Mathf.Round(chance * 5 * (21 - itemTemplate.rarity) / 100);
                            if (Dice100.SuccessRoll(stockChance))
                            {
                                DaggerfallUnityItem item = ItemBuilder.CreateItem(itemGroup, customItemTemplates[j]);

                                // Setup specific group stats
                                if (itemGroup == ItemGroups.Weapons)
                                {
                                    WeaponMaterialTypes material = FormulaHelper.RandomMaterial(-1, shopQuality, playerLuck);
                                    ItemBuilder.ApplyWeaponMaterial(item, material);
                                }
                                else if (itemGroup == ItemGroups.Armor)
                                {
                                    ArmorMaterialTypes material = FormulaHelper.RandomArmorMaterial(-1, shopQuality, playerLuck);
                                    ItemBuilder.ApplyArmorSettings(item, playerEntity.Gender, playerEntity.Race, material);
                                }
                                else if (item.TemplateIndex == 810)
                                {
                                    WeaponMaterialTypes material = FormulaHelper.RandomMaterial(-1, shopQuality, playerLuck);
                                    ItemBuilder.ApplyIngotMaterial(item, material);
                                }

                                items.AddItem(item);
                            }
                        }
                    }
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Converts weapon material to appropriate dye colour.
        /// </summary>
        /// <param name="material">WeaponMaterialTypes.</param>
        /// <returns>DyeColors.</returns>
        public DyeColors GetWeaponDyeColor(WeaponMaterialTypes material)
        {
            switch (material)
            {
                case WeaponMaterialTypes.Iron:
                    return DyeColors.Iron;
                case WeaponMaterialTypes.Steel:
                    return DyeColors.Steel;
                case WeaponMaterialTypes.Silver:
                case WeaponMaterialTypes.Elven:
                    return DyeColors.SilverOrElven;
                case WeaponMaterialTypes.Dwarven:
                    return DyeColors.Dwarven;
                case WeaponMaterialTypes.Mithril:
                    return DyeColors.Mithril;
                case WeaponMaterialTypes.Adamantium:
                    return DyeColors.Adamantium;
                case WeaponMaterialTypes.Ebony:
                    return DyeColors.Ebony;
                case WeaponMaterialTypes.Orcish:
                    return DyeColors.Orcish;
                case WeaponMaterialTypes.Daedric:
                    return DyeColors.Daedric;
                default:
                    return DyeColors.Unchanged;

            }
        }
コード例 #31
0
        /// <summary>
        /// Converts native Daggerfall weapon and armor material types to generic Daggerfall Unity MetalType.
        /// The old metal type enum may be retired as true materials become better integrated.
        /// </summary>
        /// <param name="item">Item to convert material to metal type.</param>
        /// <returns>MetalTypes.</returns>
        public MetalTypes ConvertItemMaterialToAPIMetalType(DaggerfallUnityItem item)
        {
            // Determine metal type
            if (item.ItemGroup == ItemGroups.Weapons)
            {
                WeaponMaterialTypes weaponMaterial = (WeaponMaterialTypes)item.nativeMaterialValue;
                switch (weaponMaterial)
                {
                case WeaponMaterialTypes.Iron:
                    return(MetalTypes.Iron);

                case WeaponMaterialTypes.Steel:
                    return(MetalTypes.Steel);

                case WeaponMaterialTypes.Silver:
                    return(MetalTypes.Silver);

                case WeaponMaterialTypes.Elven:
                    return(MetalTypes.Elven);

                case WeaponMaterialTypes.Dwarven:
                    return(MetalTypes.Dwarven);

                case WeaponMaterialTypes.Mithril:
                    return(MetalTypes.Mithril);

                case WeaponMaterialTypes.Adamantium:
                    return(MetalTypes.Adamantium);

                case WeaponMaterialTypes.Ebony:
                    return(MetalTypes.Ebony);

                case WeaponMaterialTypes.Orcish:
                    return(MetalTypes.Orcish);

                case WeaponMaterialTypes.Daedric:
                    return(MetalTypes.Daedric);

                default:
                    return(MetalTypes.None);
                }
            }
            else if (item.ItemGroup == ItemGroups.Armor)
            {
                ArmorMaterialTypes armorMaterial = (ArmorMaterialTypes)item.nativeMaterialValue;
                switch (armorMaterial)
                {
                case ArmorMaterialTypes.Iron:
                    return(MetalTypes.Iron);

                case ArmorMaterialTypes.Steel:
                    return(MetalTypes.Steel);

                case ArmorMaterialTypes.Chain:
                case ArmorMaterialTypes.Chain2:
                    return(MetalTypes.Chain);

                case ArmorMaterialTypes.Silver:
                    return(MetalTypes.Silver);

                case ArmorMaterialTypes.Elven:
                    return(MetalTypes.Elven);

                case ArmorMaterialTypes.Dwarven:
                    return(MetalTypes.Dwarven);

                case ArmorMaterialTypes.Mithril:
                    return(MetalTypes.Mithril);

                case ArmorMaterialTypes.Adamantium:
                    return(MetalTypes.Adamantium);

                case ArmorMaterialTypes.Ebony:
                    return(MetalTypes.Ebony);

                case ArmorMaterialTypes.Orcish:
                    return(MetalTypes.Orcish);

                case ArmorMaterialTypes.Daedric:
                    return(MetalTypes.Daedric);

                default:
                    return(MetalTypes.None);
                }
            }
            else
            {
                return(MetalTypes.None);
            }
        }
コード例 #32
0
 /// <summary>
 /// Gets name of weapon material type.
 /// </summary>
 /// <param name="material">Material type of weapon.</param>
 /// <returns>String for weapon material name.</returns>
 public virtual string GetWeaponMaterialName(WeaponMaterialTypes material)
 {
     return(fallback.GetWeaponMaterialName(material));
 }
コード例 #33
0
        public void StockShopShelf(PlayerGPS.DiscoveredBuilding buildingData)
        {
            stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now);
            items.Clear();

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;
            int shopQuality = buildingData.quality;

            Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
            ItemHelper itemHelper = DaggerfallUnity.Instance.ItemHelper;

            byte[] itemGroups = { 0 };

            switch (buildingType)
            {
            case DFLocation.BuildingTypes.Alchemist:
                itemGroups = DaggerfallLootDataTables.itemGroupsAlchemist;
                RandomlyAddPotionRecipe(25, items);
                break;

            case DFLocation.BuildingTypes.Armorer:
                itemGroups = DaggerfallLootDataTables.itemGroupsArmorer;
                break;

            case DFLocation.BuildingTypes.Bookseller:
                itemGroups = DaggerfallLootDataTables.itemGroupsBookseller;
                break;

            case DFLocation.BuildingTypes.ClothingStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsClothingStore;
                break;

            case DFLocation.BuildingTypes.GemStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGemStore;
                break;

            case DFLocation.BuildingTypes.GeneralStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGeneralStore;
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Horse));
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart));
                break;

            case DFLocation.BuildingTypes.PawnShop:
                itemGroups = DaggerfallLootDataTables.itemGroupsPawnShop;
                break;

            case DFLocation.BuildingTypes.WeaponSmith:
                itemGroups = DaggerfallLootDataTables.itemGroupsWeaponSmith;
                break;
            }

            for (int i = 0; i < itemGroups.Length; i += 2)
            {
                ItemGroups itemGroup = (ItemGroups)itemGroups[i];
                int        chanceMod = itemGroups[i + 1];
                if (itemGroup == ItemGroups.MensClothing && playerEntity.Gender == Game.Entity.Genders.Female)
                {
                    itemGroup = ItemGroups.WomensClothing;
                }
                if (itemGroup == ItemGroups.WomensClothing && playerEntity.Gender == Game.Entity.Genders.Male)
                {
                    itemGroup = ItemGroups.MensClothing;
                }

                if (itemGroup != ItemGroups.Furniture && itemGroup != ItemGroups.UselessItems1)
                {
                    if (itemGroup == ItemGroups.Books)
                    {
                        int qualityMod = (shopQuality + 3) / 5;
                        if (qualityMod >= 4)
                        {
                            --qualityMod;
                        }
                        qualityMod++;
                        for (int j = 0; j <= qualityMod; ++j)
                        {
                            items.AddItem(ItemBuilder.CreateRandomBook());
                        }
                    }
                    else
                    {
                        System.Array enumArray = itemHelper.GetEnumArray(itemGroup);
                        for (int j = 0; j < enumArray.Length; ++j)
                        {
                            ItemTemplate itemTemplate = itemHelper.GetItemTemplate(itemGroup, j);
                            if (itemTemplate.rarity <= shopQuality)
                            {
                                int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100;
                                if (Dice100.SuccessRoll(stockChance))
                                {
                                    DaggerfallUnityItem item = null;
                                    if (itemGroup == ItemGroups.Weapons)
                                    {
                                        item = ItemBuilder.CreateWeapon(j + Weapons.Dagger, FormulaHelper.RandomMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, j + Armor.Cuirass, FormulaHelper.RandomArmorMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.MensClothing)
                                    {
                                        item          = ItemBuilder.CreateMensClothing(j + MensClothing.Straps, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.WomensClothing)
                                    {
                                        item          = ItemBuilder.CreateWomensClothing(j + WomensClothing.Brassier, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.MagicItems)
                                    {
                                        item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race);
                                    }
                                    else
                                    {
                                        item = new DaggerfallUnityItem(itemGroup, j);
                                        if (DaggerfallUnity.Settings.PlayerTorchFromItems && item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Oil))
                                        {
                                            item.stackCount = Random.Range(5, 20 + 1);  // Shops stock 5-20 bottles
                                        }
                                    }
                                    items.AddItem(item);
                                }
                            }
                        }
                        // Add any modded items registered in applicable groups
                        int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(itemGroup);
                        for (int j = 0; j < customItemTemplates.Length; j++)
                        {
                            ItemTemplate itemTemplate = itemHelper.GetItemTemplate(itemGroup, customItemTemplates[j]);
                            if (itemTemplate.rarity <= shopQuality)
                            {
                                int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100;
                                if (Dice100.SuccessRoll(stockChance))
                                {
                                    DaggerfallUnityItem item = ItemBuilder.CreateItem(itemGroup, customItemTemplates[j]);

                                    // Setup specific group stats
                                    if (itemGroup == ItemGroups.Weapons)
                                    {
                                        WeaponMaterialTypes material = FormulaHelper.RandomMaterial(playerEntity.Level);
                                        ItemBuilder.ApplyWeaponMaterial(item, material);
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        ArmorMaterialTypes material = FormulaHelper.RandomArmorMaterial(playerEntity.Level);
                                        ItemBuilder.ApplyArmorSettings(item, playerEntity.Gender, playerEntity.Race, material);
                                    }

                                    items.AddItem(item);
                                }
                            }
                        }
                    }
                }
            }
        }