void Update()
        {
            if (!dfUnity.IsReady || !playerEnterExit || !PlayerTorch || playerEntity == null || GameManager.IsGamePaused)
            {
                return;
            }

            bool enableTorch = false;

            if (DaggerfallUnity.Settings.PlayerTorchFromItems)
            {
                DaggerfallUnityItem lightSource = playerEntity.LightSource;
                if (lightSource != null)
                {
                    enableTorch      = true;
                    torchLight.range = lightSource.ItemTemplate.capacityOrTarget;
                    // Consume durability / fuel
                    if (Time.realtimeSinceStartup > lastTickTime + tickTimeInterval)
                    {
                        lastTickTime = Time.realtimeSinceStartup;
                        if (lightSource.currentCondition > 0)
                        {
                            lightSource.currentCondition--;
                        }

                        if (lightSource.currentCondition == 0 && DaggerfallUnityItem.CompareItems(playerEntity.LightSource, lightSource))
                        {
                            DaggerfallUI.AddHUDText(TextManager.Instance.GetLocalizedText("lightDies").Replace("%it", lightSource.ItemName));
                            enableTorch = false;
                            playerEntity.LightSource = null;
                            if (!lightSource.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Lantern))
                            {
                                playerEntity.Items.RemoveItem(lightSource);
                            }
                        }
                    }

                    if (lightSource.currentCondition < 3)
                    {
                        // Give warning signs if running low of fuel
                        intensityMod = 0.6f + (Mathf.Cos(guttering) * 0.2f);
                        guttering   += Random.Range(-0.02f, 0.06f);
                    }
                    else
                    {
                        intensityMod = 1;
                        guttering    = 0;
                    }
                }
            }
            else
            {
                enableTorch = (!playerEnterExit.IsPlayerInside && dfUnity.WorldTime.Now.IsCityLightsOn) || playerEnterExit.IsPlayerInsideDungeon;
            }
            if (torchLight)
            {
                torchLight.intensity = torchIntensity * DaggerfallUnity.Settings.PlayerTorchLightScale * intensityMod;
            }

            PlayerTorch.SetActive(enableTorch);
        }
Esempio n. 2
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;
            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 = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup);
                        for (int j = 0; j < enumArray.Length; ++j)
                        {
                            DaggerfallConnect.FallExe.ItemTemplate itemTemplate = DaggerfallUnity.Instance.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, ItemBuilder.RandomMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, j + Armor.Cuirass, ItemBuilder.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
                                    {
                                        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public static bool IsItemStackable(DaggerfallUnityItem item)
 {
     return(item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Bandage));
 }