Example #1
0
        /// <summary>
        /// Returns the loot for the given Mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public static ItemTemplate[] GetLoot(GameNPC mob, GameObject killer)
        {
            LootList lootList   = null;
            IList    generators = GetLootGenerators(mob);

            foreach (ILootGenerator generator in generators)
            {
                try
                {
                    if (lootList == null)
                    {
                        lootList = generator.GenerateLoot(mob, killer);
                    }
                    else
                    {
                        lootList.AddAll(generator.GenerateLoot(mob, killer));
                    }
                }
                catch (Exception e)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("GetLoot", e);
                    }
                }
            }
            if (lootList != null)
            {
                return(lootList.GetLoot());
            }
            else
            {
                return(new ItemTemplate[0]);
            }
        }
Example #2
0
        public void GenerateROG(GamePlayer player, eObjectType objectType, eSlot slot)
        {
            player.RemoveBountyPoints(100);
            GameNPC mob = new GameNPC();

            mob.Name            = "Unique Object";
            mob.CurrentRegionID = 1;
            mob.Level           = (byte)(player.Level);
            if (mob.Level > 50)
            {
                mob.Level = 51;
            }

            LootList   lootlist = new LootList();
            ItemUnique item     = null;

            item             = new ItemUnique();
            item.Object_Type = (int)objectType;
            item.Item_Type   = (int)slot;

            mob.Level           = 60;
            mob.Name            = "TOA Mob";
            mob.CurrentRegionID = 30;
            mob.Z = 9999;
            lootlist.AddFixed(LootGeneratorUniqueObject.GenerateUniqueItem(mob, player, item), 1);
            foreach (ItemUnique unique in lootlist.GetLoot())
            {
                unique.Price = 0;
                GameServer.Database.AddObject(unique);
                InventoryItem invitem = GameInventoryItem.Create <ItemUnique>(unique);
                player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, invitem);
                player.Out.SendMessage("Generated: " + unique.Name, eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            int lvl = mob.Level + 1;

            if (lvl < 1)
            {
                lvl = 1;
            }
            int minLoot = 2 + ((lvl * lvl * lvl) >> 3);

            long moneyCount = minLoot + Util.Random(minLoot >> 1);

            moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);

            ItemTemplate money = new ItemTemplate();

            money.Model = 488;
            money.Name  = "bag of coins";
            money.Level = 0;

            money.Price = moneyCount;

            loot.AddFixed(money, 1);
            return(loot);
        }
Example #4
0
        /// <summary>
        /// Merges two list into one big list, containing items of both and having the bigger dropCount
        /// </summary>
        /// <param name="list"></param>
        public void AddAll(LootList list)
        {
            if (list.m_randomItemDrops != null)
            {
                m_randomItemDrops.AddRange(list.m_randomItemDrops);
            }

            if (list.m_fixedItemDrops != null)
            {
                m_fixedItemDrops.AddRange(list.m_fixedItemDrops);
            }

            if (list.DropCount > DropCount)
                DropCount = list.DropCount;
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            if (Util.Chance(10))
            {
                ItemTemplate[] itemTemplates = null;

                eRealm realm = mob.CurrentZone.Realm;

                if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
                {
                    realm = (eRealm)Util.Random((int)eRealm._FirstPlayerRealm, (int)eRealm._LastPlayerRealm);
                }

                switch (realm)
                {
                case eRealm.Albion:
                {
                    int index = Math.Min(m_itemTemplatesAlb.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesAlb[index];
                }
                break;

                case eRealm.Hibernia:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesHib[index];
                    break;
                }

                case eRealm.Midgard:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesMid[index];
                    break;
                }
                }

                if (itemTemplates != null && itemTemplates.Length > 0)
                {
                    ItemTemplate itemTemplate = itemTemplates[Util.Random(itemTemplates.Length - 1)];
                    loot.AddFixed(itemTemplate, 1);
                }
            }

            return(loot);
        }
Example #6
0
        /// <summary>
        /// Merges two list into one big list, containing items of both and having the bigger dropCount
        /// </summary>
        /// <param name="list"></param>
        public void AddAll(LootList list)
        {
            if (list.m_randomItemDrops != null)
            {
                m_randomItemDrops.AddRange(list.m_randomItemDrops);
            }

            if (list.m_fixedItemDrops != null)
            {
                m_fixedItemDrops.AddRange(list.m_fixedItemDrops);
            }

            if (list.DropCount > DropCount)
            {
                DropCount = list.DropCount;
            }
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot  = base.GenerateLoot(mob, killer);
            int      small = SMALLCHEST_CHANCE;
            int      large = LARGECHEST_CHANCE;

            if (Util.Chance(small))
            {
                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }

                int  minLoot    = ServerProperties.Properties.SMALLCHEST_MULTIPLIER * (lvl * lvl);
                long moneyCount = minLoot + Util.Random(minLoot >> 1);
                moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);
                ItemTemplate money = new ItemTemplate();
                money.Model = 488;
                money.Name  = "small chest";
                money.Level = 0;
                money.Price = moneyCount;
                loot.AddFixed(money, 1);
            }

            if (Util.Chance(large))
            {
                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }

                int  minLoot    = ServerProperties.Properties.LARGECHEST_MULTIPLIER * (lvl * lvl);
                long moneyCount = minLoot + Util.Random(minLoot >> 1);
                moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);
                ItemTemplate money = new ItemTemplate();
                money.Model = 488;
                money.Name  = "large chest";
                money.Level = 0;
                money.Price = moneyCount;
                loot.AddFixed(money, 1);
            }

            return(loot);
        }
Example #8
0
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }

                if (player == null)
                {
                    return(loot);
                }

                ItemTemplate token_many = new ItemTemplate(m_token_many);

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }

                int maxcount = Util.Random(1, 10);
                loot.AddFixed(m_token_many, maxcount);
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList       loot     = base.GenerateLoot(mob, killer);
            List <LootOTD> lootOTDs = null;

            try
            {
                if (m_mobOTDList.ContainsKey(mob.Name.ToLower()))
                {
                    lootOTDs = m_mobOTDList[mob.Name.ToLower()];
                }

                if (lootOTDs != null)
                {
                    foreach (GameObject gainer in mob.XPGainers.Keys)
                    {
                        GamePlayer player = null;

                        if (gainer is GamePlayer)
                        {
                            player = gainer as GamePlayer;
                        }
                        else if (gainer is GameNPC)
                        {
                            IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain;
                            if (brain != null)
                            {
                                player = brain.GetPlayerOwner();
                            }
                        }

                        if (player != null)
                        {
                            foreach (LootOTD drop in lootOTDs)
                            {
                                if (drop.MinLevel <= player.Level)
                                {
                                    CharacterXOneTimeDrop hasDrop = GameServer.Database.SelectObject <CharacterXOneTimeDrop>("CharacterID = '" + GameServer.Database.Escape(player.QuestPlayerID) + "' AND ItemTemplateID = '" + GameServer.Database.Escape(drop.ItemTemplateID) + "'");

                                    if (hasDrop == null)
                                    {
                                        ItemTemplate item = GameServer.Database.FindObjectByKey <ItemTemplate>(drop.ItemTemplateID);

                                        if (item != null)
                                        {
                                            if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, GameInventoryItem.Create <ItemTemplate>(item)))
                                            {
                                                CharacterXOneTimeDrop charXDrop = new CharacterXOneTimeDrop();
                                                charXDrop.CharacterID    = player.QuestPlayerID;
                                                charXDrop.ItemTemplateID = drop.ItemTemplateID;
                                                GameServer.Database.AddObject(charXDrop);

                                                player.Out.SendMessage(string.Format("You receive {0} from {1}!", item.GetName(1, false), mob.GetName(1, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                                                InventoryLogging.LogInventoryAction(mob, player, eInventoryActionType.Loot, item);
                                            }
                                            else
                                            {
                                                // do not drop, player will have to try again
                                                player.Out.SendMessage("Your inventory is full and a one time drop cannot be added!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                                                log.DebugFormat("OTD Failed, Inventory full: {0} from mob {1} for player {2}.", drop.ItemTemplateID, drop.MobName, player.Name);
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            log.ErrorFormat("Error trying to drop ItemTemplate {0} from {1}.  Item not found.", drop.ItemTemplateID, drop.MobName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("LootGeneratorOneTimeDrop exception for mob " + mob.Name + ":", ex);
            }

            return(loot);
        }
Example #10
0
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns>Lootlist with Aurulite drops</returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            // ItemTemplate aurulite = new ItemTemplate(m_aurulite);  Creating a new ItemTemplate throws an exception later
            ItemTemplate aurulite = GameServer.Database.FindObjectByKey <ItemTemplate>(m_aurulite.Id_nb);


            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }
                int maxcount = 1;

                //Switch pack size
                if (lvl > 0 && lvl < 10)
                {
                    //Aurulite only
                    maxcount = (int)Math.Floor((double)(lvl / 2)) + 1;
                }
                else if (lvl >= 10 && lvl < 20)
                {
                    //Aurulire Chip (x5)
                    aurulite.PackSize = 5;
                    maxcount          = (int)Math.Floor((double)((lvl - 10) / 2)) + 1;
                }
                else if (lvl >= 20 && lvl < 30)
                {
                    //Aurulite Fragment (x10)
                    aurulite.PackSize = 10;
                    maxcount          = (int)Math.Floor((double)((lvl - 20) / 2)) + 1;
                }
                else if (lvl >= 30 && lvl < 40)
                {
                    //Aurulite Shard (x20)
                    aurulite.PackSize = 20;
                    maxcount          = (int)Math.Floor((double)((lvl - 30) / 2)) + 1;
                }
                else if (lvl >= 40 && lvl < 50)
                {
                    //Aurulite Cluster (x30)
                    aurulite.PackSize = 30;
                    maxcount          = (int)Math.Floor((double)((lvl - 40) / 2)) + 1;
                }
                else
                {
                    //Aurulite Cache (x40)
                    aurulite.PackSize = 40;
                    maxcount          = (int)Math.Round((double)(lvl / 10));
                }

                if (!mob.Name.ToLower().Equals(mob.Name))
                {
                    //Named mob, more cash !
                    maxcount = (int)Math.Round(maxcount * ServerProperties.Properties.LOOTGENERATOR_AURULITE_NAMED_COUNT);
                }

                // add to loot
                if (maxcount > 0 && Util.Chance(ServerProperties.Properties.LOOTGENERATOR_AURULITE_BASE_CHANCE + Math.Max(10, killedcon)))
                {
                    // Add to fixed to prevent overrides with loottemplate
                    loot.AddFixed(aurulite, (int)Math.Ceiling(maxcount * ServerProperties.Properties.LOOTGENERATOR_AURULITE_AMOUNT_RATIO));
                }
            }
            catch
            {
                // Prevent displaying errors
                return(loot);
            }

            return(loot);
        }
        /// <summary>
        /// Add all loot templates specified in MobDropTemplate for an entry in DropTemplateXItemTemplate
        /// If the item has a 100% drop chance add it as a fixed drop to the loot list.
        /// </summary>
        /// <param name="mobXLootTemplate">Entry in MobDropTemplate.</param>
        /// <param name="lootTemplates">List of all itemtemplates this mob can drop and the chance to drop</param>
        /// <param name="lootList">List to hold loot.</param>
        /// <param name="player">Player used to determine realm</param>
        /// <returns>lootList (for readability)</returns>
        private static LootList GenerateLootFromMobXLootTemplates(MobDropTemplate mobXLootTemplates, List <DropTemplateXItemTemplate> lootTemplates, LootList lootList, GamePlayer player)
        {
            if (mobXLootTemplates == null || lootTemplates == null || player == null)
            {
                return(lootList);
            }

            Dictionary <string, DropTemplateXItemTemplate> templateList = null;

            if (m_lootTemplates.ContainsKey(mobXLootTemplates.LootTemplateName.ToLower()))
            {
                templateList = m_lootTemplates[mobXLootTemplates.LootTemplateName.ToLower()];
            }

            if (templateList != null)
            {
                foreach (DropTemplateXItemTemplate lootTemplate in templateList.Values)
                {
                    ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                    if (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems)
                    {
                        if (lootTemplate.Chance == 100)
                        {
                            lootList.AddFixed(drop, lootTemplate.Count);
                        }
                        else
                        {
                            lootTemplates.Add(lootTemplate);
                        }
                    }
                }
            }

            return(lootList);
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                // allow the leader to decide the loot realm
                if (player.Group != null)
                {
                    player = player.Group.Leader;
                }

                List <MobDropTemplate> killedMobXLootTemplates;
                // MobDropTemplate contains a loot template name and the max number of drops allowed for that template.
                // We don't need an entry in MobDropTemplate in order to drop loot, only to control the max number of drops.

                // DropTemplateXItemTemplate contains a template name and an itemtemplateid (id_nb).
                // TemplateName usually equals Mob name, so if you want to know what drops for a mob:
                // select * from DropTemplateXItemTemplate where templatename = 'mob name';
                // It is possible to have TemplateName != MobName but this works only if there is an entry in MobDropTemplate for the MobName.
                if (!m_mobXLootTemplates.TryGetValue(mob.Name.ToLower(), out killedMobXLootTemplates))
                {
                    Dictionary <string, DropTemplateXItemTemplate> lootTemplatesToDrop;
                    // We can use DropTemplateXItemTemplate.Count to determine how many of a item can drop
                    if (m_lootTemplates.TryGetValue(mob.Name.ToLower(), out lootTemplatesToDrop))
                    {
                        foreach (DropTemplateXItemTemplate lootTemplate in lootTemplatesToDrop.Values)
                        {
                            ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                            if (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems)
                            {
                                if (lootTemplate.Chance == 100)
                                {
                                    loot.AddFixed(drop, lootTemplate.Count);
                                }
                                else
                                {
                                    loot.AddRandom(lootTemplate.Chance, drop, lootTemplate.Count);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // MobDropTemplate exists and tells us the max number of items that can drop.
                    // Because we are restricting the max number of items to drop we need to traverse the list
                    // and add every 100% chance items to the loots Fixed list and add the rest to the Random list
                    // due to the fact that 100% items always drop regardless of the drop limit
                    List <DropTemplateXItemTemplate> lootTemplatesToDrop = new List <DropTemplateXItemTemplate>();
                    foreach (MobDropTemplate mobXLootTemplate in killedMobXLootTemplates)
                    {
                        loot           = GenerateLootFromMobXLootTemplates(mobXLootTemplate, lootTemplatesToDrop, loot, player);
                        loot.DropCount = Math.Max(mobXLootTemplate.DropCount, loot.DropCount);
                        foreach (DropTemplateXItemTemplate lootTemplate in lootTemplatesToDrop)
                        {
                            ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                            if (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems)
                            {
                                loot.AddRandom(lootTemplate.Chance, drop, lootTemplate.Count);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Error in LootGeneratorTemplate for mob {0}.  Exception: {1}", mob.Name, ex.Message);
            }

            return(loot);
        }
Example #13
0
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
			LootList lootList = new LootList();

			// check to see if we are in ToA
			if (mob.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis && killer.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis)
			{
				if (mob.Level >= 45 && Util.Chance(ServerProperties.Properties.SCROLL_DROP_RATE))
				{
					List<Artifact> artifacts = new List<Artifact>();

					if (mob.CurrentRegion.IsDungeon && Util.Chance((int)(ServerProperties.Properties.SCROLL_DROP_RATE * 1.5)))
					{
						artifacts = ArtifactMgr.GetArtifacts();
					}
					else
					{
						switch (mob.CurrentZone.Description)
						{
							case "Oceanus Hesperos":
							case "Mesothalassa":
							case "Oceanus Notos":
							case "Oceanus Boreal":
							case "Oceanus Anatole":
								artifacts = ArtifactMgr.GetArtifacts("Oceanus");
								break;
							case "Stygian Delta":
							case "Land of Atum":
								artifacts = ArtifactMgr.GetArtifacts("Stygia");
								break;
							case "Arbor Glen":
							case "Green Glades":
								artifacts = ArtifactMgr.GetArtifacts("Aerus");
								break;
							case "Typhon's Reach":
							case "Ashen Isles":
								artifacts = ArtifactMgr.GetArtifacts("Volcanus");
								break;
						}
					}

					if (artifacts.Count > 0)
					{
						String artifactID = (artifacts[Util.Random(artifacts.Count - 1)]).ArtifactID;
						int pageNumber;

						ItemTemplate loot = new ItemTemplate();
						loot.AllowAdd = false;

						if (mob.Level > 55)
						{
							pageNumber = 3;
						}
						else if (mob.Level >= 51)
						{
							pageNumber = 2;
						}
						else
						{
							pageNumber = 1;
						}

						loot.Model = 488;
						loot.Name = "scroll|" + artifactID + "|" + pageNumber;
						loot.Level = 35;

						lootList.AddFixed(loot, 1);
					}
				}
			}

            return lootList;
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                // Certain epic mobs have a 100% drop chance of 10 seals at once
                switch (mob.Brain.ToString().ToLower())
                {
                case "dragonbrain":
                case "lord":
                    loot.AddFixed(m_DreadedSeal, 10);
                    break;

                default:
                    if (mob.Name.ToLower() == "lord agramon")     // Another 10 seal dropper
                    {
                        loot.AddFixed(m_DreadedSeal, 10);
                    }
                    else
                    {
                        if (mob.Level < ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                        {
                            return(loot);
                        }

                        int iPercentDrop = (mob.Level - ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                                           * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_DROP_CHANCE_PER_LEVEL
                                           + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_BASE_CHANCE;

                        if (!mob.Name.ToLower().Equals(mob.Name))     // Named mobs are more likely to drop a seal
                        {
                            iPercentDrop = (int)Math.Round(iPercentDrop * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_NAMED_CHANCE);
                        }

                        int iRandom = m_rnd.Next(10000);

                        if (iRandom < iPercentDrop)
                        {
                            // ItemTemplate dragonscales = new ItemTemplate(m_dragonscales); Creating a new ItemTemplate like this throws an exception later
                            loot.AddFixed(m_DreadedSeal, 1);
                        }

                        /*log.Error("LootGeneratorDreadedSeal Calculations: " + "Mob level " + mob.Level.ToString()
                         + ", Starting Level=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL.ToString()
                         + ", Base chance=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_BASE_CHANCE
                         + ", Chance per level=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_DROP_CHANCE_PER_LEVEL
                         + ", " + (iPercentDrop / 100).ToString()
                         + "% drop chance, rolled "
                         + (iRandom / 100).ToString());*/
                    }    // else
                    break;
                }//switch
            }//try
            catch (Exception e)
            {
                log.Error(e.Message);
                return(loot);
            }

            return(loot);
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public virtual LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = new LootList();

            return(loot);
        }
        /// <summary>
        /// Add all loot templates specified in MobXLootTemplate for an entry in LootTemplates
        /// If the item has a 100% drop chance add it as a fixed drop to the loot list.
        /// </summary>
        /// <param name="mobXLootTemplate">Entry in MobXLootTemplate.</param>
        /// <param name="lootTemplates">List of all itemtemplates this mob can drop and the chance to drop</param>
        /// <param name="lootList">List to hold loot.</param>
        /// <param name="player">Player used to determine realm</param>
        /// <returns>lootList (for readability)</returns>
        private LootList GenerateLootFromMobXLootTemplates(MobXLootTemplate mobXLootTemplates, List <LootTemplate> lootTemplates, LootList lootList, GamePlayer player)
        {
            if (mobXLootTemplates == null || lootTemplates == null || player == null)
            {
                return(lootList);
            }

            // Using Name + Realm (if ALLOW_CROSS_REALM_ITEMS) for the key to try and prevent duplicate drops
            Dictionary <string, LootTemplate> templateList = null;

            if (m_lootTemplates.ContainsKey(mobXLootTemplates.LootTemplateName.ToLower()))
            {
                templateList = m_lootTemplates[mobXLootTemplates.LootTemplateName.ToLower()];
            }

            if (templateList != null)
            {
                foreach (LootTemplate lootTemplate in templateList.Values)
                {
                    ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                    if (drop != null && (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems))
                    {
                        if (lootTemplate.Chance == 100)
                        {
                            // Added support for specifying drop count in LootTemplate rather than relying on MobXLootTemplate DropCount
                            if (lootTemplate.Count > 0)
                            {
                                lootList.AddFixed(drop, lootTemplate.Count);
                            }
                            else
                            {
                                lootList.AddFixed(drop, mobXLootTemplates.DropCount);
                            }
                        }
                        else
                        {
                            lootTemplates.Add(lootTemplate);
                            lootList.DropCount = Math.Max(lootList.DropCount, mobXLootTemplates.DropCount);
                        }
                    }
                }
            }

            return(lootList);
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int iScaleCount = 0;

                switch (mob.Name.ToLower())
                {
                // Epic dragons
                case "cuuldurach the glimmer king":
                case "gjalpinulva":
                case "golestandt":
                case "myrddraxis":
                case "nosdoden":
                case "xanxicar":
                    iScaleCount = 10 * ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_NAMED_COUNT;
                    break;

                // Named Dragons
                case "asiintath":
                case "ghorvensath":
                case "iasentinth":
                case "neureksath":
                case "dyronith":
                case "elinkueth":
                case "jarkkonith":
                case "ljoridkorith":
                case "preniceth":
                case "runicaath":
                case "tollabarth":
                case "varrkorith":
                    iScaleCount = 5 * ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_NAMED_COUNT;
                    break;

                // Dragon Spawn
                case "glimmer dragon spawn":
                case "stone dragon spawn":
                case "wolf dragon spawn":
                    iScaleCount = 1;
                    break;

                default:
                    // Mobs range from 55 to 75, and we want an up to 10% bonus to drop chance based on that
                    // I dislike losing accuracy rounding things, and it's a lot faster to do this in 1/10ths
                    //	of a percent than to convert to doubles and to multiply rather than divide.
                    if (Util.Random(1000) < (10 * ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_BASE_CHANCE
                                             + 5 * (mob.Level - 55)))
                    {
                        if (mob.Name.ToLower() != mob.Name)
                        {
                            // Named critter
                            iScaleCount = ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_NAMED_COUNT;
                        }
                        else
                        {
                            iScaleCount = 1;
                        }
                    }
                    break;
                }

                if (iScaleCount > 0)
                {
                    loot.AddFixed(m_dragonscales, iScaleCount);
                }
            }
            catch (Exception e)
            {
                log.Error("LootGeneratorDragonscales.GenerateLoot()", e);
                return(loot);
            }

            return(loot);
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList lootList = new LootList();

            // check to see if we are in ToA
            if (mob.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis && killer.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis)
            {
                if (mob.Level >= 45 && Util.Chance(ServerProperties.Properties.SCROLL_DROP_RATE))
                {
                    List <Artifact> artifacts = new List <Artifact>();

                    if (mob.CurrentRegion.IsDungeon && Util.Chance((int)(ServerProperties.Properties.SCROLL_DROP_RATE * 1.5)))
                    {
                        artifacts = ArtifactMgr.GetArtifacts();
                    }
                    else
                    {
                        switch (mob.CurrentZone.Description)
                        {
                        case "Oceanus Hesperos":
                        case "Mesothalassa":
                        case "Oceanus Notos":
                        case "Oceanus Boreal":
                        case "Oceanus Anatole":
                            artifacts = ArtifactMgr.GetArtifacts("Oceanus");
                            break;

                        case "Stygian Delta":
                        case "Land of Atum":
                            artifacts = ArtifactMgr.GetArtifacts("Stygia");
                            break;

                        case "Arbor Glen":
                        case "Green Glades":
                            artifacts = ArtifactMgr.GetArtifacts("Aerus");
                            break;

                        case "Typhon's Reach":
                        case "Ashen Isles":
                            artifacts = ArtifactMgr.GetArtifacts("Volcanus");
                            break;
                        }
                    }

                    if (artifacts.Count > 0)
                    {
                        string artifactID = artifacts[Util.Random(artifacts.Count - 1)].ArtifactID;
                        int    pageNumber;

                        ItemTemplate loot = new ItemTemplate();
                        loot.AllowAdd = false;

                        if (mob.Level > 55)
                        {
                            pageNumber = 3;
                        }
                        else if (mob.Level >= 51)
                        {
                            pageNumber = 2;
                        }
                        else
                        {
                            pageNumber = 1;
                        }

                        loot.Model = 488;
                        loot.Name  = "scroll|" + artifactID + "|" + pageNumber;
                        loot.Level = 35;

                        lootList.AddFixed(loot, 1);
                    }
                }
            }

            return(lootList);
        }
Example #19
0
		/// <summary>
		/// Generate loot for given mob
		/// </summary>
		/// <param name="mob"></param>
		/// <param name="killer"></param>
		/// <returns></returns>
		public virtual LootList GenerateLoot(GameNPC mob, GameObject killer)
		{
			LootList loot = new LootList();
			return loot;
		}
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                switch (mob)
                {
                // Certain mobs have a 100% drop chance of multiple seals at once
                case GuardLord lord:
                    if (lord.IsTowerGuard)
                    {
                        loot.AddFixed(m_DreadedSeal, 1);      // Guaranteed drop, but towers only merit 1 seal.
                    }
                    else
                    {
                        loot.AddFixed(m_DreadedSeal, 10);
                    }
                    break;

                case GameDragon dragon:
                    loot.AddFixed(m_DreadedSeal, 10);
                    break;

                default:
                    if (mob.Name.ToLower() == "lord agramon")
                    {
                        loot.AddFixed(m_DreadedSeal, 10);
                    }

                    if (mob.Level < ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                    {
                        return(loot);
                    }

                    int iPercentDrop = (mob.Level - ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                                       * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_DROP_CHANCE_PER_LEVEL
                                       + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_BASE_CHANCE;

                    if (!mob.Name.ToLower().Equals(mob.Name))     // Named mobs are more likely to drop a seal
                    {
                        iPercentDrop = (int)Math.Round(iPercentDrop * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_NAMED_CHANCE);
                    }

                    int iRandom = Util.Random(9999);

                    if (iRandom < iPercentDrop)
                    {
                        loot.AddFixed(m_DreadedSeal, 1);
                    }

                    /*log.Error("LootGeneratorDreadedSeal Calculations: " + "Mob level " + mob.Level.ToString()
                     + ", Starting Level=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL.ToString()
                     + ", Base chance=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_BASE_CHANCE
                     + ", Chance per level=" + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_DROP_CHANCE_PER_LEVEL
                     + ", " + (iPercentDrop / 100).ToString()
                     + "% drop chance, rolled "
                     + (iRandom / 100).ToString());*/

                    break;
                }                // else
            }//try
            catch (Exception e)
            {
                log.Error(e.Message);
            }

            return(loot);
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);


            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                // allow the leader to decide the loot realm
                if (player.Group != null)
                {
                    player = player.Group.Leader;
                }

                double killedCon = player.GetConLevel(mob);

                //grey don't loot RoG
                if (killedCon <= -3)
                {
                    return(loot);
                }

                // chance to get a RoG Item
                int chance = BASE_ROG_CHANCE + ((int)killedCon + 3) * 2;
                // toa item
                bool toachance = Util.Chance(BASE_TOA_CHANCE);

                if (IsMobInTOA(mob) && mob.Name.ToLower() != mob.Name && mob.Level >= 50)
                {
                    // ToA named mobs have good chance to drop unique loot
                    chance   += NAMED_ROG_CHANCE + NAMED_TOA_CHANCE;
                    toachance = true;
                }
                else if (IsMobInTOA(mob))
                {
                    toachance = true;
                }
                else if (mob.Name.ToLower() != mob.Name)
                {
                    chance += NAMED_ROG_CHANCE;
                }

                GeneratedUniqueItem item = new GeneratedUniqueItem(toachance, player.Realm, (byte)Math.Min(mob.Level + 1, 51));
                item.AllowAdd = true;
                item.GenerateItemQuality(killedCon);

                if (player.Realm != 0)
                {
                    loot.AddRandom(chance, item, 1);
                }
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
		/// <summary>
		/// Add all loot templates specified in MobDropTemplate for an entry in DropTemplateXItemTemplate
		/// If the item has a 100% drop chance add it as a fixed drop to the loot list.  
		/// </summary>
		/// <param name="mobXLootTemplate">Entry in MobDropTemplate.</param>
		/// <param name="lootTemplates">List of all itemtemplates this mob can drop and the chance to drop</param>
		/// <param name="lootList">List to hold loot.</param>
		/// <param name="player">Player used to determine realm</param>
		/// <returns>lootList (for readability)</returns>
		private static LootList GenerateLootFromMobXLootTemplates(MobDropTemplate mobXLootTemplates, List<DropTemplateXItemTemplate> lootTemplates, LootList lootList, GamePlayer player)
		{
			if (mobXLootTemplates == null || lootTemplates == null || player == null)
				return lootList;

			Dictionary<string, DropTemplateXItemTemplate> templateList = null;
			if (m_lootTemplates.ContainsKey(mobXLootTemplates.LootTemplateName.ToLower()))
				templateList = m_lootTemplates[mobXLootTemplates.LootTemplateName.ToLower()];

			if (templateList != null)
			{
				foreach (DropTemplateXItemTemplate lootTemplate in templateList.Values)
				{
					ItemTemplate drop = GameServer.Database.FindObjectByKey<ItemTemplate>(lootTemplate.ItemTemplateID);

					if (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems)
					{
						if (lootTemplate.Chance == 100)
							lootList.AddFixed(drop, lootTemplate.Count);
						else
							lootTemplates.Add(lootTemplate);
					}
				}
			}

			return lootList;
		}
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }


                ItemTemplate atlanteanGlass = new ItemTemplate(m_atlanteanglass);

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }
                int maxcount = 1;

                //Switch pack size
                if (lvl > 0 && lvl < 10)
                {
                    //Single AtlanteanGlass
                    maxcount = (int)Math.Floor((double)(lvl / 2)) + 1;
                }
                else if (lvl >= 10 && lvl < 20)
                {
                    //Double
                    atlanteanGlass.PackSize = 2;
                    maxcount = (int)Math.Floor((double)((lvl - 10) / 2)) + 1;
                }
                else if (lvl >= 20 && lvl < 30)
                {
                    //Triple
                    atlanteanGlass.PackSize = 3;
                    maxcount = (int)Math.Floor((double)((lvl - 20) / 2)) + 1;
                }
                else if (lvl >= 30 && lvl < 40)
                {
                    //Quad
                    atlanteanGlass.PackSize = 4;
                    maxcount = (int)Math.Floor((double)((lvl - 30) / 2)) + 1;
                }
                else if (lvl >= 40 && lvl < 50)
                {
                    //Quint
                    atlanteanGlass.PackSize = 5;
                    maxcount = (int)Math.Floor((double)((lvl - 40) / 2)) + 1;
                }
                else
                {
                    //Cache (x10)
                    atlanteanGlass.PackSize = 10;
                    maxcount = (int)Math.Round((double)(lvl / 10));
                }

                if (!mob.Name.ToLower().Equals(mob.Name))
                {
                    //Named mob, more cash !
                    maxcount = (int)Math.Round(maxcount * ServerProperties.Properties.LOOTGENERATOR_ATLANTEANGLASS_NAMED_COUNT);
                }

                if (maxcount > 0 && Util.Chance(ServerProperties.Properties.LOOTGENERATOR_ATLANTEANGLASS_BASE_CHANCE + Math.Max(10, killedcon)))
                {
                    loot.AddFixed(atlanteanGlass, maxcount);
                }
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                switch (mob)
                {
                // Certain mobs have a 100% drop chance of multiple seals at once
                case GuardLord lord:
                    if (lord.IsTowerGuard || lord.Component.AbstractKeep.BaseLevel < 50)
                    {
                        loot.AddFixed(m_SanguineDreadedSeal, 1);      // Guaranteed drop, but towers and BGs only merit 1 seal.
                    }
                    else
                    {
                        loot.AddFixed(m_SanguineDreadedSeal, 5 * lord.Component.Keep.Level);
                    }
                    break;

                default:
                    if (mob.Name.ToUpper() == "LORD AGRAMON")
                    {
                        loot.AddFixed(m_SanguineDreadedSeal, 10);
                    }
                    else if (mob.Level >= ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                    {
                        int iPercentDrop = (mob.Level - ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_STARTING_LEVEL)
                                           * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_DROP_CHANCE_PER_LEVEL
                                           + ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_BASE_CHANCE;

                        if (!mob.Name.ToLower().Equals(mob.Name)) // Named mobs are more likely to drop a seal
                        {
                            iPercentDrop = (int)Math.Round(iPercentDrop * ServerProperties.Properties.LOOTGENERATOR_DREADEDSEALS_NAMED_CHANCE);
                        }

                        if (Util.Random(9999) < iPercentDrop)
                        {
                            loot.AddFixed(m_GlowingDreadedSeal, 1);
                        }
                    }
                    break;
                }    // switch
            }//try
            catch (Exception e)
            {
                log.Error(e.Message);
            }

            return(loot);
        }
		/// <summary>
		/// Add all loot templates specified in MobXLootTemplate for an entry in LootTemplates
		/// If the item has a 100% drop chance add it as a fixed drop to the loot list.
		/// </summary>
		/// <param name="mobXLootTemplate">Entry in MobXLootTemplate.</param>
		/// <param name="lootTemplates">List of all itemtemplates this mob can drop and the chance to drop</param>
		/// <param name="lootList">List to hold loot.</param>
		/// <param name="player">Player used to determine realm</param>
		/// <returns>lootList (for readability)</returns>
		private LootList GenerateLootFromMobXLootTemplates(MobXLootTemplate mobXLootTemplates, List<LootTemplate> lootTemplates, LootList lootList, GamePlayer player)
		{
			if (mobXLootTemplates == null || lootTemplates == null || player == null)
				return lootList;

			// Using Name + Realm (if ALLOW_CROSS_REALM_ITEMS) for the key to try and prevent duplicate drops

			Dictionary<string, LootTemplate> templateList = null;

			if (m_lootTemplates.ContainsKey(mobXLootTemplates.LootTemplateName.ToLower()))
			{
				templateList = m_lootTemplates[mobXLootTemplates.LootTemplateName.ToLower()];
			}

			if (templateList != null)
			{
				foreach (LootTemplate lootTemplate in templateList.Values)
				{
					ItemTemplate drop = GameServer.Database.FindObjectByKey<ItemTemplate>(lootTemplate.ItemTemplateID);

					if (drop != null && (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems))
					{
						if (lootTemplate.Chance == 100)
						{
							// Added support for specifying drop count in LootTemplate rather than relying on MobXLootTemplate DropCount
							if (lootTemplate.Count > 0)
								lootList.AddFixed(drop, lootTemplate.Count);
							else
								lootList.AddFixed(drop, mobXLootTemplates.DropCount);
						}
						else
						{
							lootTemplates.Add(lootTemplate);
							lootList.DropCount = Math.Max(lootList.DropCount, mobXLootTemplates.DropCount);
						}
					}
				}
			}

			return lootList;
		}
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = null;

                if (killer is GamePlayer)
                {
                    player = killer as GamePlayer;
                }
                else if (killer is GameNPC && (killer as GameNPC).Brain is IControlledBrain)
                {
                    player = ((killer as GameNPC).Brain as ControlledNpcBrain).GetPlayerOwner();
                }

                // allow the leader to decide the loot realm
                if (player != null && player.Group != null)
                {
                    player = player.Group.Leader;
                }

                if (player != null)
                {
                    List <MobXLootTemplate> killedMobXLootTemplates = null;

                    // Graveen: we first privilegiate the loottemplate named 'templateid' if it exists
                    if (mob.NPCTemplate != null && m_mobXLootTemplates.ContainsKey(mob.NPCTemplate.TemplateId.ToString()))
                    {
                        killedMobXLootTemplates = m_mobXLootTemplates[mob.NPCTemplate.TemplateId.ToString()];
                    }

                    // else we are choosing the loottemplate named 'mob name'
                    // this is easily allowing us to affect different level choosen loots to different level choosen mobs
                    // with identical names
                    else if (m_mobXLootTemplates.ContainsKey(mob.Name.ToLower()))
                    {
                        killedMobXLootTemplates = m_mobXLootTemplates[mob.Name.ToLower()];
                    }

                    // MobXLootTemplate contains a loot template name and the max number of drops allowed for that template.
                    // We don't need an entry in MobXLootTemplate in order to drop loot, only to control the max number of drops.

                    // LootTemplate contains a template name and an itemtemplateid (id_nb).
                    // TemplateName usually equals Mob name, so if you want to know what drops for a mob:
                    // select * from LootTemplate where templatename = 'mob name';
                    // It is possible to have TemplateName != MobName but this works only if there is an entry in MobXLootTemplate for the MobName.
                    if (killedMobXLootTemplates == null)
                    {
                        // If there is no MobXLootTemplate entry then every item in this mobs LootTemplate can drop.
                        // In addition, we can use LootTemplate.Count to determine how many of a fixed (100% chance) item can drop
                        if (m_lootTemplates.ContainsKey(mob.Name.ToLower()))
                        {
                            Dictionary <string, LootTemplate> lootTemplatesToDrop = m_lootTemplates[mob.Name.ToLower()];

                            if (lootTemplatesToDrop != null)
                            {
                                foreach (LootTemplate lootTemplate in lootTemplatesToDrop.Values)
                                {
                                    ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                                    if (drop != null && (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems))
                                    {
                                        if (lootTemplate.Chance == 100)
                                        {
                                            loot.AddFixed(drop, lootTemplate.Count);
                                        }
                                        else
                                        {
                                            loot.AddRandom(lootTemplate.Chance, drop, 1);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // MobXLootTemplate exists and tells us the max number of items that can drop.
                        // Because we are restricting the max number of items to drop we need to traverse the list
                        // and add every 100% chance items to the loots Fixed list and add the rest to the Random list
                        // due to the fact that 100% items always drop regardless of the drop limit
                        List <LootTemplate> lootTemplatesToDrop = new List <LootTemplate>();
                        foreach (MobXLootTemplate mobXLootTemplate in killedMobXLootTemplates)
                        {
                            loot = GenerateLootFromMobXLootTemplates(mobXLootTemplate, lootTemplatesToDrop, loot, player);

                            if (lootTemplatesToDrop != null)
                            {
                                foreach (LootTemplate lootTemplate in lootTemplatesToDrop)
                                {
                                    ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(lootTemplate.ItemTemplateID);

                                    if (drop != null && (drop.Realm == (int)player.Realm || drop.Realm == 0 || player.CanUseCrossRealmItems))
                                    {
                                        loot.AddRandom(lootTemplate.Chance, drop, 1);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Error in LootGeneratorTemplate for mob {0}.  Exception: {1} {2}", mob.Name, ex.Message, ex.StackTrace);
            }

            return(loot);
        }