コード例 #1
0
        /// <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);
        }
コード例 #2
0
        public async Task Remove(MobXLootTemplate template)
        {
            if (string.IsNullOrWhiteSpace(template.ObjectId))
            {
                return;
            }

            await Task.Run(() =>
            {
                DatabaseManager.Database
                .SelectObjects <LootTemplate>("`TemplateName` = @TemplateName",
                                              new QueryParameter("@TemplateName", template.LootTemplateName))
                .ToList()
                .ForEach(x => DatabaseManager.Database.DeleteObject(x));

                DatabaseManager.Database.DeleteObject(template);
            });
        }