Example #1
0
        // Create stack of gold pieces
        DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh)
        {
            // Get amount
            int amount = 0;

            if (rangeLow == -1 || rangeHigh == -1)
            {
                Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

                int    playerMod  = (playerEntity.Level / 2) + 1;
                int    factionMod = 50;
                IGuild guild      = null;
                if (ParentQuest.FactionId != 0)
                {
                    guild = GameManager.Instance.GuildManager.GetGuild(ParentQuest.FactionId);
                    if (guild != null && !(guild is NonMemberGuild))
                    {
                        // If this is a faction quest, playerMod is (player factionrank + 1) rather than level
                        playerMod = guild.Rank + 1;

                        // If this is a faction quest, factionMod = faction.power rather than 50
                        FactionFile.FactionData factionData;
                        if (playerEntity.FactionData.GetFactionData(ParentQuest.FactionId, out factionData))
                        {
                            factionMod = factionData.power;
                        }
                    }
                }
                if (playerMod > 10)
                {
                    playerMod = 10;
                }

                PlayerGPS gps            = GameManager.Instance.PlayerGPS;
                int       regionPriceMod = playerEntity.RegionData[gps.CurrentRegionIndex].PriceAdjustment / 2;
                amount = UnityEngine.Random.Range(150 * playerMod, (200 * playerMod) + 1) * (regionPriceMod + 500) / 1000 * (factionMod + 50) / 100;

                if (guild != null)
                {
                    amount = guild.AlterReward(amount);
                }
            }
            else
            {
                amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1);
            }

            if (amount < 1)
            {
                amount = 1;
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0);

            result.stackCount = amount;
            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }
Example #2
0
        // Create by item class and subclass
        DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass)
        {
            // Validate
            if (itemClass == -1)
            {
                throw new Exception(string.Format("Tried to create Item with class {0}", itemClass));
            }

            // Handle random magic item by redirecting itemClass to one of several supported types
            // Currently unknown how many types this supports - will expand later
            // May also need to account for gender if offering clothing
            // Item should have a world texture as may be placed in world by quest
            // Only goal currently to have more variety than "ruby" for everything
            bool isMagicItem = false;

            if (itemClass == (int)ItemGroups.MagicItems && itemSubClass == -1)
            {
                ItemGroups[] randomMagicGroups = new ItemGroups[]
                {
                    ItemGroups.Armor,
                    ItemGroups.Weapons,
                    ItemGroups.ReligiousItems,
                    ItemGroups.Gems,
                };
                itemClass   = UnityEngine.Random.Range(0, randomMagicGroups.Length);
                isMagicItem = true;
            }

            // Handle random subclass
            if (itemSubClass == -1)
            {
                Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass);
                itemSubClass = UnityEngine.Random.Range(0, enumArray.Length);
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass);

            // Assign dummy magic effects so item becomes enchanted
            // This will need to be ported to real magic system in future
            if (isMagicItem)
            {
                result.legacyMagic          = new DaggerfallEnchantment[1];
                result.legacyMagic[0].type  = EnchantmentTypes.CastWhenHeld;
                result.legacyMagic[0].param = 87;
            }

            // Link item to quest
            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }
Example #3
0
        // Create stack of gold pieces
        DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh)
        {
            // Get amount
            int amount = 0;

            if (rangeLow == -1 || rangeHigh == -1)
            {
                Entity.PlayerEntity player = GameManager.Instance.PlayerEntity;

                // TODO: If this is a faction quest, playerMod is (player factionrank + 1) rather than level
                int playerMod = (player.Level / 2) + 1;
                if (playerMod > 10)
                {
                    playerMod = 10;
                }

                // TODO: If this is a faction quest, factionMod = faction.power rather than 50
                int factionMod = 50;

                PlayerGPS gps            = GameManager.Instance.PlayerGPS;
                int       regionPriceMod = player.RegionData[gps.CurrentRegionIndex].PriceAdjustment / 2;
                amount = UnityEngine.Random.Range(150 * playerMod, (200 * playerMod) + 1) * (regionPriceMod + 500) / 1000 * (factionMod + 50) / 100;
            }
            else
            {
                amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1);
            }

            if (amount < 1)
            {
                amount = 1;
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0);

            result.stackCount = amount;
            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }
Example #4
0
        // Create stack of gold pieces
        DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh)
        {
            // Get amount
            int amount = 0;

            if (rangeLow == -1 || rangeHigh == -1)
            {
                amount = GameManager.Instance.PlayerEntity.Level * UnityEngine.Random.Range(90, 110);
            }
            else
            {
                amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1);
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0);

            result.stackCount = amount;
            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }
Example #5
0
        // Create by item class and subclass
        DaggerfallUnityItem CreateItem(int itemClass, int itemSubClass)
        {
            // Validate
            if (itemClass == -1)
            {
                throw new Exception(string.Format("Tried to create Item with class {0}", itemClass));
            }

            // Handle random subclass
            if (itemSubClass == -1)
            {
                Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray((ItemGroups)itemClass);
                itemSubClass = UnityEngine.Random.Range(0, enumArray.Length);
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem((ItemGroups)itemClass, itemSubClass);

            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }