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

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

                switch (mob.CurrentZone.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.AddRandom(100, itemTemplate, 1);
                }
            }

            return(loot);
        }
        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);
        }
        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);
        }
        /// <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);
        }