private static WorldObject CreateJewelry(TreasureDeath profile, bool isMagical, bool mutate = true)
        {
            // 31% chance ring, 31% chance bracelet, 30% chance necklace 8% chance Trinket

            int jewelrySlot = ThreadSafeRandom.Next(1, 100);
            int jewelType;

            // Made this easier to read (switch -> if statement)
            if (jewelrySlot <= 31)
            {
                jewelType = LootTables.ringItems[ThreadSafeRandom.Next(0, LootTables.ringItems.Length - 1)];
            }
            else if (jewelrySlot <= 62)
            {
                jewelType = LootTables.braceletItems[ThreadSafeRandom.Next(0, LootTables.braceletItems.Length - 1)];
            }
            else if (jewelrySlot <= 92)
            {
                jewelType = LootTables.necklaceItems[ThreadSafeRandom.Next(0, LootTables.necklaceItems.Length - 1)];
            }
            else
            {
                jewelType = LootTables.trinketItems[ThreadSafeRandom.Next(0, LootTables.trinketItems.Length - 1)];
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)jewelType);

            if (wo != null && mutate)
            {
                MutateJewelry(wo, profile, isMagical);
            }

            return(wo);
        }
Example #2
0
        private static void AddWeeniesToInventoryX(Player player, IEnumerable <uint> weenieIds, ushort?stackSize = null)
        {
            foreach (uint weenieId in weenieIds)
            {
                var loot = WorldObjectFactory.CreateNewWorldObject(weenieId);

                if (loot == null) // weenie doesn't exist
                {
                    continue;
                }

                if (stackSize == null)
                {
                    stackSize = loot.MaxStackSize;
                }

                if (stackSize > 1)
                {
                    loot.SetStackSize(stackSize);
                }

                // Make sure the item is full of mana
                if (loot.ItemCurMana.HasValue)
                {
                    loot.ItemCurMana = loot.ItemMaxMana;
                }

                player.TryAddToInventory(loot);
            }
        }
        private static WorldObject CreateMundaneObjects(int tier)
        {
            uint id = 0;
            int chance;
            WorldObject wo;

            if (tier < 1) tier = 1;
            if (tier > 8) tier = 8;

            chance = ThreadSafeRandom.Next(0, 1);

            switch (chance)
            {
                case 0:
                    id = (uint)CreateFood();
                    break;
                default:
                    int mundaneLootMatrixIndex = tier - 1;
                    int upperLimit = LootTables.MundaneLootMatrix[mundaneLootMatrixIndex].Length - 1;

                    chance = ThreadSafeRandom.Next(0, upperLimit);
                    id = (uint)LootTables.MundaneLootMatrix[mundaneLootMatrixIndex][chance];
                    break;
            }

            if (id == 0)
                return null;

            wo = WorldObjectFactory.CreateNewWorldObject(id);
            wo = RandomizeColor(wo);
            return wo;
        }
Example #4
0
        /// <summary>
        /// Creates and optionally mutates a new MissileWeapon
        /// </summary>
        public static WorldObject CreateMissileWeapon(TreasureDeath profile, bool isMagical, bool mutate = true)
        {
            int weaponWeenie;

            int wieldDifficulty = RollWieldDifficulty(profile.Tier, TreasureWeaponType.MissileWeapon);

            // Changing based on wield, not tier. Refactored, less code, best results.  HarliQ 11/18/19
            if (wieldDifficulty < 315)
            {
                weaponWeenie = GetNonElementalMissileWeapon();
            }
            else
            {
                weaponWeenie = GetElementalMissileWeapon();
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)weaponWeenie);

            if (wo != null && mutate)
            {
                MutateMissileWeapon(wo, profile, isMagical, wieldDifficulty);
            }

            return(wo);
        }
Example #5
0
        private static void AddWeeniesToInventory(Player player, HashSet <uint> weenieIds, ushort?stackSize = null)
        {
            foreach (uint weenieId in weenieIds)
            {
                var loot = WorldObjectFactory.CreateNewWorldObject(weenieId);

                if (loot == null) // weenie doesn't exist
                {
                    continue;
                }

                if (stackSize == null)
                {
                    stackSize = loot.MaxStackSize;
                }

                if (stackSize > 1)
                {
                    loot.StackSize      = stackSize;
                    loot.EncumbranceVal = (loot.StackUnitEncumbrance ?? 0) * (stackSize ?? 1);
                    loot.Value          = (loot.StackUnitValue ?? 0) * (stackSize ?? 1);
                }

                player.TryAddToInventory(loot);
            }
        }
        private static WorldObject CreateDinnerware(int tier, bool mutate = true)
        {
            uint        id = 0;
            int         chance;
            WorldObject wo;

            if (tier < 1)
            {
                tier = 1;
            }
            if (tier > 8)
            {
                tier = 8;
            }

            int genericLootMatrixIndex = tier - 1;
            int upperLimit             = LootTables.DinnerwareLootMatrix.Length - 1;

            chance = ThreadSafeRandom.Next(0, upperLimit);
            id     = (uint)LootTables.DinnerwareLootMatrix[chance];

            wo = WorldObjectFactory.CreateNewWorldObject(id);

            if (wo != null && mutate)
            {
                MutateDinnerware(wo, tier);
            }

            return(wo);
        }
Example #7
0
        /// <summary>
        /// Creates a Melee weapon object.
        /// </summary>
        /// <param name="profile"></param><param name="isMagical"></param>
        /// <returns>Returns Melee Weapon WO</returns>
        public static WorldObject CreateMeleeWeapon(TreasureDeath profile, bool isMagical, int weaponType = -1, bool mutate = true)
        {
            int weaponWeenie = 0;
            int subtype      = 0;

            int eleType = ThreadSafeRandom.Next(0, 4);

            if (weaponType == -1)
            {
                weaponType = ThreadSafeRandom.Next(0, 3);
            }

            // Weapon Types
            // 0 = Heavy
            // 1 = Light
            // 2 = Finesse
            // default = Two Handed
            switch (weaponType)
            {
            case 0:
                // Heavy Weapons
                subtype      = ThreadSafeRandom.Next(0, LootTables.HeavyWeaponsMatrix.Length - 1);
                weaponWeenie = LootTables.HeavyWeaponsMatrix[subtype][eleType];
                break;

            case 1:
                // Light Weapons
                subtype      = ThreadSafeRandom.Next(0, LootTables.LightWeaponsMatrix.Length - 1);
                weaponWeenie = LootTables.LightWeaponsMatrix[subtype][eleType];
                break;

            case 2:
                // Finesse Weapons;
                subtype      = ThreadSafeRandom.Next(0, LootTables.FinesseWeaponsMatrix.Length - 1);
                weaponWeenie = LootTables.FinesseWeaponsMatrix[subtype][eleType];
                break;

            default:
                // Two handed
                subtype      = ThreadSafeRandom.Next(0, LootTables.TwoHandedWeaponsMatrix.Length - 1);
                weaponWeenie = LootTables.TwoHandedWeaponsMatrix[subtype][eleType];
                break;
            }

            var wo = WorldObjectFactory.CreateNewWorldObject((uint)weaponWeenie);

            if (wo != null && mutate)
            {
                if (!MutateMeleeWeapon(wo, profile, isMagical))
                {
                    log.Warn($"[LOOT] Missing needed melee weapon properties on loot item {wo.WeenieClassId} - {wo.Name} for mutations");
                    return(null);
                }
            }

            return(wo);
        }
Example #8
0
        private static void CreateIOU(Player player, uint missingWeenieId)
        {
            var book = (Book)WorldObjectFactory.CreateNewWorldObject("parchment");

            book.SetProperties("IOU", "An IOU for a missing database object.", "Sorry about that chief...", "ACEmulator", "prewritten");
            book.AddPage(player.Guid.Full, "ACEmulator", "prewritten", false, $"{missingWeenieId}\n\nSorry but the database does not have a weenie for weenieClassId #{missingWeenieId} so in lieu of that here is an IOU for that item.");

            player.TryAddToInventory(book);
        }
Example #9
0
        public static WorldObject CreateIOU(Player player, uint missingWeenieId)
        {
            var iou = (Book)WorldObjectFactory.CreateNewWorldObject("parchment");

            iou.SetProperties("IOU", "An IOU for a missing database object.", "Sorry about that chief...", "ACEmulator", "prewritten");
            iou.AddPage(player.Guid.Full, "ACEmulator", "prewritten", false, $"{missingWeenieId}\n\nSorry but the database does not have a weenie for weenieClassId #{missingWeenieId} so in lieu of that here is an IOU for that item.");

            return(iou);
        }
        private static WorldObject CreateGenericObjects(int tier)
        {
            int         chance;
            WorldObject wo;

            if (tier < 1)
            {
                tier = 1;
            }
            if (tier > 8)
            {
                tier = 8;
            }

            chance = ThreadSafeRandom.Next(1, 100);

            switch (chance)
            {
            case var rate when(rate < 2):
                wo = WorldObjectFactory.CreateNewWorldObject(49485);     // Encapsulated Spirit

                break;

            case var rate when(rate < 10):
                wo = CreateSummoningEssence(tier);

                break;

            case var rate when(rate < 28):
                wo = CreateRandomScroll(tier);

                break;

            case var rate when(rate < 57):
                wo = CreateFood();

                break;

            default:
                int genericLootMatrixIndex = tier - 1;
                int upperLimit             = LootTables.GenericLootMatrix[genericLootMatrixIndex].Length - 1;

                chance = ThreadSafeRandom.Next(0, upperLimit);
                uint id = (uint)LootTables.GenericLootMatrix[genericLootMatrixIndex][chance];

                if (id == 0)
                {
                    return(null);
                }

                wo = WorldObjectFactory.CreateNewWorldObject(id);
                break;
            }

            return(wo);
        }
        private static WorldObject CreateAetheria(int tier, bool mutate = true)
        {
            int  chance;
            uint aetheriaType;

            if (tier < 5)
            {
                return(null);
            }

            // TODO: drop percentage tweaks between types within a given tier, if needed
            switch (tier)
            {
            case 5:
                aetheriaType = Aetheria.AetheriaBlue;
                break;

            case 6:
                chance = ThreadSafeRandom.Next(1, 10);      // Example 50/50 split between color type
                if (chance <= 5)
                {
                    aetheriaType = Aetheria.AetheriaBlue;
                }
                else
                {
                    aetheriaType = Aetheria.AetheriaYellow;
                }
                break;

            default:
                chance = ThreadSafeRandom.Next(1, 9);     // Example 33% between color type
                if (chance <= 3)
                {
                    aetheriaType = Aetheria.AetheriaBlue;
                }
                else if (chance <= 6)
                {
                    aetheriaType = Aetheria.AetheriaYellow;
                }
                else
                {
                    aetheriaType = Aetheria.AetheriaRed;
                }
                break;
            }

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject(aetheriaType) as Gem;

            if (wo != null && mutate)
            {
                MutateAetheria(wo, tier);
            }

            return(wo);
        }
Example #12
0
        private static WorldObject CreateSummoningEssence(int tier, bool mutate = true)
        {
            uint id = 0;

            // Adding a spread of Pet Device levels for each tier - Level 200 pets should only be dropping in T8 Loot - HQ 2/29/2020
            // The spread is from Optim's Data
            // T5-T8 20/35/30/15% split
            // T8- 200,180,150,125
            // T7- 180,150,125,100
            // T6- 150,125,100,80
            // T5- 125,100,80,50
            // T4- 100,80,50
            // T3- 80,50
            // T2- 50
            // T1- 50

            // Tables are already 1-7, so removing them being Tier dependent

            int petLevel = 0;
            int chance   = ThreadSafeRandom.Next(1, 100);

            if (chance > 80)
            {
                petLevel = tier - 1;
            }
            else if (chance > 45)
            {
                petLevel = tier - 2;
            }
            else if (chance > 15)
            {
                petLevel = tier - 3;
            }
            else
            {
                petLevel = tier - 4;
            }
            if (petLevel < 2)
            {
                petLevel = 1;
            }

            int summoningEssenceIndex = ThreadSafeRandom.Next(0, LootTables.SummoningEssencesMatrix.Length - 1);

            id = (uint)LootTables.SummoningEssencesMatrix[summoningEssenceIndex][petLevel - 1];

            var petDevice = WorldObjectFactory.CreateNewWorldObject(id) as PetDevice;

            if (petDevice != null && mutate)
            {
                MutatePetDevice(petDevice, tier);
            }

            return(petDevice);
        }
        public static WorldObject TryCreateRare(int luck = 0)
        {
            var t1_chance = 2500; // 1 in 2,500 chance

            t1_chance = Math.Max(t1_chance - luck, 1);

            int tier = 0;

            if (ThreadSafeRandom.Next(1, t1_chance) == 1)   // 1 in 2,500 chance
            {
                tier = 1;
                if (ThreadSafeRandom.Next(1, 10) == 1)      // 1 in 25,000 chance
                {
                    tier = 2;
                }
                if (ThreadSafeRandom.Next(1, 100) == 1)     // 1 in 250,000 chance
                {
                    tier = 3;
                }
                if (ThreadSafeRandom.Next(1, 1250) == 1)    // 1 in 3,120,000 chance
                {
                    tier = 4;
                }
                if (ThreadSafeRandom.Next(1, 3017) == 1)    // 1 in 7,542,500 (wiki avg. 7,543,103)
                {
                    tier = 5;
                }
                if (ThreadSafeRandom.Next(1, 3500) == 1)    // 1 in 8,750,000 chance
                {
                    tier = 6;
                }
            }

            if (tier == 0)
            {
                return(null);
            }

            var tierRares = RareWCIDs[tier].ToList();

            var rng = ThreadSafeRandom.Next(0, tierRares.Count - 1);

            var rareWCID = tierRares[rng];

            var wo = WorldObjectFactory.CreateNewWorldObject((uint)rareWCID);

            if (wo == null)
            {
                log.Error($"LootGenerationFactory_Rare.CreateRare(): failed to generate rare wcid {rareWCID}");
            }

            return(wo);
        }
Example #14
0
        /// <summary>
        /// Creates a Melee weapon object.
        /// </summary>
        /// <param name="profile"></param><param name="isMagical"></param>
        /// <returns>Returns Melee Weapon WO</returns>
        public static WorldObject CreateMeleeWeapon(TreasureDeath profile, bool isMagical, int weaponType = -1, bool mutate = true)
        {
            int weaponWeenie = 0;
            int subtype      = 0;

            int eleType = ThreadSafeRandom.Next(0, 4);

            if (weaponType == -1)
            {
                weaponType = ThreadSafeRandom.Next(0, 3);
            }

            // Weapon Types
            // 0 = Heavy
            // 1 = Light
            // 2 = Finesse
            // default = Two Handed
            switch (weaponType)
            {
            case 0:
                // Heavy Weapons
                subtype      = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.HeavyWeaponsMatrix[subtype][eleType];
                break;

            case 1:
                // Light Weapons
                subtype      = ThreadSafeRandom.Next(0, 19);
                weaponWeenie = LootTables.LightWeaponsMatrix[subtype][eleType];
                break;

            case 2:
                // Finesse Weapons;
                subtype      = ThreadSafeRandom.Next(0, 22);
                weaponWeenie = LootTables.FinesseWeaponsMatrix[subtype][eleType];
                break;

            default:
                // Two handed
                subtype      = ThreadSafeRandom.Next(0, 11);
                weaponWeenie = LootTables.TwoHandedWeaponsMatrix[subtype][eleType];
                break;
            }

            var wo = WorldObjectFactory.CreateNewWorldObject((uint)weaponWeenie);

            if (wo != null && mutate)
            {
                MutateMeleeWeapon(wo, profile, isMagical, weaponType, subtype);
            }

            return(wo);
        }
        public static void CreateRandomTestWorldObjects(Player player, uint typeId, uint numItems)
        {
            var weenieList           = DatabaseManager.World.GetRandomWeeniesOfType(typeId, numItems);
            List <WorldObject> items = new List <WorldObject>();

            for (int i = 0; i < numItems; i++)
            {
                WorldObject wo = WorldObjectFactory.CreateNewWorldObject(weenieList[i].WeenieClassId);
                items.Add(wo);
            }
            player.HandleAddNewWorldObjectsToInventory(items);
        }
Example #16
0
        private static WorldObject CreateRandomScroll(int tier)
        {
            WorldObject wo;

            if (tier > 7)
            {
                int id = CreateLevel8SpellComp();
                wo = WorldObjectFactory.CreateNewWorldObject((uint)id);
                return(wo);
            }

            if (tier == 7)
            {
                // According to wiki, Tier 7 has a chance for level 8 spell components or level 7 spell scrolls
                // No indication of weighting in either direction, so assuming a 50/50 split
                int chance = ThreadSafeRandom.Next(1, 100);
                if (chance > 50)
                {
                    int id = CreateLevel8SpellComp();
                    wo = WorldObjectFactory.CreateNewWorldObject((uint)id);
                    return(wo);
                }
            }

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

            int scrollLootMatrixIndex = tier - 1;
            int minSpellLevel         = LootTables.ScrollLootMatrix[scrollLootMatrixIndex][0];
            int maxSpellLevel         = LootTables.ScrollLootMatrix[scrollLootMatrixIndex][1];

            int  scrollLootIndex = ThreadSafeRandom.Next(minSpellLevel, maxSpellLevel);
            uint spellID         = 0;

            while (spellID == 0)
            {
                spellID = (uint)LootTables.ScrollSpells[ThreadSafeRandom.Next(0, LootTables.ScrollSpells.Length - 1)][scrollLootIndex];
            }

            var weenie = DatabaseManager.World.GetScrollWeenie(spellID);

            if (weenie == null)
            {
                log.DebugFormat("CreateRandomScroll for tier {0} and spellID of {1} returned null from the database.", tier, spellID);
                return(null);
            }

            wo = WorldObjectFactory.CreateNewWorldObject(weenie.ClassId);
            return(wo);
        }
        private static WorldObject CreateAetheria_New(TreasureDeath profile, bool mutate = true)
        {
            var wcid = AetheriaWcids.Roll(profile.Tier);

            var wo = WorldObjectFactory.CreateNewWorldObject((uint)wcid);

            if (mutate)
            {
                MutateAetheria_New(wo, profile);
            }

            return(wo);
        }
        /// <summary>
        /// Creates and optionally mutates a new MeleeWeapon
        /// </summary>
        public static WorldObject CreateMeleeWeapon(TreasureDeath profile, bool isMagical, MeleeWeaponSkill weaponSkill = MeleeWeaponSkill.Undef, bool mutate = true)
        {
            var wcid       = 0;
            var weaponType = 0;

            var eleType = ThreadSafeRandom.Next(0, 4);

            if (weaponSkill == MeleeWeaponSkill.Undef)
            {
                weaponSkill = (MeleeWeaponSkill)ThreadSafeRandom.Next(1, 4);
            }

            switch (weaponSkill)
            {
            case MeleeWeaponSkill.HeavyWeapons:

                weaponType = ThreadSafeRandom.Next(0, LootTables.HeavyWeaponsMatrix.Length - 1);
                wcid       = LootTables.HeavyWeaponsMatrix[weaponType][eleType];
                break;

            case MeleeWeaponSkill.LightWeapons:

                weaponType = ThreadSafeRandom.Next(0, LootTables.LightWeaponsMatrix.Length - 1);
                wcid       = LootTables.LightWeaponsMatrix[weaponType][eleType];
                break;

            case MeleeWeaponSkill.FinesseWeapons:

                weaponType = ThreadSafeRandom.Next(0, LootTables.FinesseWeaponsMatrix.Length - 1);
                wcid       = LootTables.FinesseWeaponsMatrix[weaponType][eleType];
                break;

            case MeleeWeaponSkill.TwoHandedCombat:

                weaponType = ThreadSafeRandom.Next(0, LootTables.TwoHandedWeaponsMatrix.Length - 1);
                wcid       = LootTables.TwoHandedWeaponsMatrix[weaponType][eleType];
                break;
            }

            var wo = WorldObjectFactory.CreateNewWorldObject((uint)wcid);

            if (wo != null && mutate)
            {
                if (!MutateMeleeWeapon(wo, profile, isMagical))
                {
                    log.Warn($"[LOOT] {wo.WeenieClassId} - {wo.Name} is not a MeleeWeapon");
                    return(null);
                }
            }
            return(wo);
        }
        private static WorldObject CreateDinnerware(int tier)
        {
            uint        id = 0;
            int         chance;
            WorldObject wo;

            if (tier < 1)
            {
                tier = 1;
            }
            if (tier > 8)
            {
                tier = 8;
            }

            int genericLootMatrixIndex = tier - 1;
            int upperLimit             = LootTables.DinnerwareLootMatrix.Length - 1;

            chance = ThreadSafeRandom.Next(0, upperLimit);
            id     = (uint)LootTables.DinnerwareLootMatrix[chance];

            if (id == 0)
            {
                return(null);
            }

            wo = WorldObjectFactory.CreateNewWorldObject(id);

            // Dinnerware has all these options (plates, tankards, etc)
            // This is just a short-term fix until Loot is overhauled
            // TODO - Doesn't handle damage/speed/etc that the mutate engine should for these types of items.
            wo.SetProperty(PropertyInt.GemCount, ThreadSafeRandom.Next(1, 5));
            wo.SetProperty(PropertyInt.GemType, ThreadSafeRandom.Next(10, 50));

            wo.LongDesc = wo.Name;

            int materialType = GetMaterialType(wo, tier);

            wo.MaterialType = (MaterialType)materialType;
            int workmanship = GetWorkmanship(tier);

            wo.ItemWorkmanship = workmanship;

            wo = SetAppraisalLongDescDecoration(wo);

            wo = AssignValue(wo);

            wo = RandomizeColor(wo);

            return(wo);
        }
Example #20
0
        public static List <WorldObject> CreateRandomObjectsOfType(WeenieType type, int count)
        {
            var weenies = DatabaseManager.World.GetRandomWeeniesOfType((int)type, count);

            var worldObjects = new List <WorldObject>();

            foreach (var weenie in weenies)
            {
                var wo = WorldObjectFactory.CreateNewWorldObject(weenie.WeenieClassId);
                worldObjects.Add(wo);
            }

            return(worldObjects);
        }
Example #21
0
        public static WorldObject CreateIOU(uint missingWeenieId)
        {
            var iou = (Book)WorldObjectFactory.CreateNewWorldObject("parchment");

            iou.SetProperties("IOU", "An IOU for a missing database object.", "Sorry about that chief...", "ACEmulator", "prewritten");
            iou.AddPage(uint.MaxValue, "ACEmulator", "prewritten", false, $"{missingWeenieId}\n\nSorry but the database does not have a weenie for weenieClassId #{missingWeenieId} so in lieu of that here is an IOU for that item.");
            iou.Bonded         = (int)BondedStatus.Bonded;
            iou.Attuned        = (int)AttunedStatus.Attuned;
            iou.IsSellable     = false;
            iou.Value          = 0;
            iou.EncumbranceVal = 0;

            return(iou);
        }
        private static WorldObject CreateDinnerware(TreasureDeath profile, bool isMagical, bool mutate = true)
        {
            var rng = ThreadSafeRandom.Next(0, LootTables.DinnerwareLootMatrix.Length - 1);

            var wcid = (uint)LootTables.DinnerwareLootMatrix[rng];

            var wo = WorldObjectFactory.CreateNewWorldObject(wcid);

            if (wo != null && mutate)
            {
                MutateDinnerware(wo, profile, isMagical);
            }

            return(wo);
        }
Example #23
0
        private static WorldObject GetClothingObject(uint weenieClassId, uint palette, double shade)
        {
            var weenie = DatabaseManager.World.GetCachedWeenie(weenieClassId);

            if (weenie == null)
            {
                return(null);
            }

            var worldObject = (Clothing)WorldObjectFactory.CreateNewWorldObject(weenie);

            worldObject.SetProperties((int)palette, shade);

            return(worldObject);
        }
        /// <summary>
        /// creates a portal of the specified weenie at the position provided
        /// </summary>
        public static void SpawnPortal(PortalWcid weenieClassId, Position newPosition, float despawnTime)
        {
            WorldObject portal = WorldObjectFactory.CreateNewWorldObject((uint)weenieClassId);

            portal.Positions.Add(PositionType.Location, newPosition);

            LandblockManager.AddObject(portal);

            // Create portal decay
            ActionChain despawnChain = new ActionChain();

            despawnChain.AddDelaySeconds(despawnTime);
            despawnChain.AddAction(portal, () => portal.CurrentLandblock.RemoveWorldObject(portal.Guid, false));
            despawnChain.EnqueueChain();
        }
Example #25
0
        private static WorldObject CreateJewelry(int tier, bool isMagical)
        {
            // 35% chance ring, 35% chance bracelet, 30% chance necklace
            int ringPercent     = 35;
            int braceletPercent = 35;
            int necklacePercent = 30;

            int jewelrySlot = ThreadSafeRandom.Next(0, ringPercent + braceletPercent + necklacePercent);
            int jewelType;

            switch (jewelrySlot)
            {
            case int n when(n <= ringPercent):
                jewelType = LootTables.ringItems[ThreadSafeRandom.Next(0, LootTables.ringItems.Length - 1)];

                break;

            case int n when(n <= ringPercent + braceletPercent && n > ringPercent):
                jewelType = LootTables.braceletItems[ThreadSafeRandom.Next(0, LootTables.braceletItems.Length - 1)];

                break;

            case int n when(n <= ringPercent + braceletPercent + necklacePercent && n > ringPercent + braceletPercent):
                jewelType = LootTables.necklaceItems[ThreadSafeRandom.Next(0, LootTables.necklaceItems.Length - 1)];

                break;

            default:
                return(null);
            }

            //int rank = 0;
            //int skill_level_limit = 0;

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject((uint)jewelType);

            if (wo == null)
            {
                return(null);
            }

            wo.SetProperty(PropertyInt.AppraisalLongDescDecoration, 1);
            wo.SetProperty(PropertyString.LongDesc, wo.GetProperty(PropertyString.Name));
Example #26
0
        private static WorldObject CreateGenericObjects(TreasureDeath profile)
        {
            int         chance;
            WorldObject wo;

            chance = ThreadSafeRandom.Next(1, 100);

            switch (chance)
            {
            case var rate when(rate < 2):
                wo = WorldObjectFactory.CreateNewWorldObject(49485);     // Encapsulated Spirit

                break;

            case var rate when(rate < 10):
                wo = CreateSummoningEssence(profile.Tier);

                break;

            case var rate when(rate < 28):
                wo = CreateRandomScroll(profile);

                break;

            case var rate when(rate < 57):
                wo = CreateFood();

                break;

            default:
                int genericLootMatrixIndex = profile.Tier - 1;
                int upperLimit             = LootTables.GenericLootMatrix[genericLootMatrixIndex].Length - 1;

                chance = ThreadSafeRandom.Next(0, upperLimit);
                uint id = (uint)LootTables.GenericLootMatrix[genericLootMatrixIndex][chance];

                wo = WorldObjectFactory.CreateNewWorldObject(id);
                break;
            }

            return(wo);
        }
Example #27
0
        private static WorldObject CreateGem(int tier, bool isMagical, bool mutate = true)
        {
            int gemLootMatrixIndex = tier - 1;

            if (gemLootMatrixIndex > 4)
            {
                gemLootMatrixIndex = 4;
            }
            int upperLimit = LootTables.GemsMatrix[gemLootMatrixIndex].Length - 1;

            uint gemWCID = (uint)LootTables.GemsWCIDsMatrix[gemLootMatrixIndex][ThreadSafeRandom.Next(0, upperLimit)];

            WorldObject wo = WorldObjectFactory.CreateNewWorldObject(gemWCID) as Gem;

            if (wo != null && mutate)
            {
                MutateGem(wo, tier, isMagical);
            }

            return(wo);
        }
Example #28
0
        public static WorldObject CreateIOU(uint missingWeenieId)
        {
            if (!PropertyManager.GetBool("iou_trades").Item)
            {
                log.Warn($"CreateIOU: Skipping creation of IOU for missing weenie {missingWeenieId} because IOU system is disabled.");

                return(null);
            }

            var iou = (Book)WorldObjectFactory.CreateNewWorldObject("parchment");

            iou.SetProperties("IOU", "An IOU for a missing database object.", "Sorry about that chief...", "ACEmulator", "prewritten");
            iou.AddPage(uint.MaxValue, "ACEmulator", "prewritten", false, $"{missingWeenieId}\n\nSorry but the database does not have a weenie for weenieClassId #{missingWeenieId} so in lieu of that here is an IOU for that item.", out _);
            iou.Bonded         = BondedStatus.Bonded;
            iou.Attuned        = AttunedStatus.Attuned;
            iou.IsSellable     = false;
            iou.Value          = 0;
            iou.EncumbranceVal = 0;

            return(iou);
        }
        private static WorldObject CreateGem(TreasureDeath profile, bool isMagical, bool mutate = true)
        {
            var idx = profile.Tier - 1;

            if (idx > 4)
            {
                idx = 4;
            }

            var rng = ThreadSafeRandom.Next(0, LootTables.GemsMatrix[idx].Length - 1);

            var wcid = (uint)LootTables.GemsMatrix[idx][rng];

            var wo = WorldObjectFactory.CreateNewWorldObject(wcid) as Gem;

            if (wo != null && mutate)
            {
                MutateGem(wo, profile, isMagical);
            }

            return(wo);
        }
Example #30
0
        private static WorldObject CreateRandomScroll(int tier)
        {
            WorldObject wo;

            if (tier > 7)
            {
                int id = CreateLevel8SpellComp();
                wo = WorldObjectFactory.CreateNewWorldObject((uint)id);
                return(wo);
            }

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

            int scrollLootMatrixIndex = tier - 1;
            int minSpellLevel         = LootTables.ScrollLootMatrix[scrollLootMatrixIndex][0];
            int maxSpellLevel         = LootTables.ScrollLootMatrix[scrollLootMatrixIndex][1];

            int  scrollLootIndex = ThreadSafeRandom.Next(minSpellLevel, maxSpellLevel);
            uint spellID         = 0;

            while (spellID == 0)
            {
                spellID = (uint)LootTables.ScrollSpells[ThreadSafeRandom.Next(0, LootTables.ScrollSpells.Length - 1)][scrollLootIndex];
            }

            var weenie = DatabaseManager.World.GetScrollWeenie(spellID);

            if (weenie == null)
            {
                log.WarnFormat("CreateRandomScroll for tier {0} and spellID of {1} returned null from the database.", tier, spellID);
                return(null);
            }

            wo = WorldObjectFactory.CreateNewWorldObject(weenie.ClassId);
            return(wo);
        }