Beispiel #1
0
        public static string CreatureTemplateAddon(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template_addon))
            {
                return(string.Empty);
            }

            CreatureTemplateAddon templateAddonDefault = null;

            if (Settings.DBEnabled && Settings.SkipRowsWithFallbackValues)
            {
                templateAddonDefault = SQLUtil.GetDefaultObject <CreatureTemplateAddon>();
            }

            var dbFields = SQLUtil.GetDBFields <CreatureTemplateAddon>(false);
            var addons   = new DataBag <CreatureTemplateAddon>();

            foreach (var unit in units)
            {
                var npc = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(npc.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                var auras        = string.Empty;
                var commentAuras = string.Empty;
                if (npc.Auras != null && npc.Auras.Count != 0)
                {
                    foreach (var aura in npc.Auras.Where(aura =>
                                                         aura != null &&
                                                         (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ?
                                                          aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) :
                                                          aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster))))
                    {
                        auras        += aura.SpellId + " ";
                        commentAuras += StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", ";
                    }
                    auras        = auras.TrimEnd(' ');
                    commentAuras = commentAuras.TrimEnd(',', ' ');
                }

                var addon = new CreatureTemplateAddon
                {
                    Entry           = unit.Key.GetEntry(),
                    PathID          = 0,
                    MountID         = (uint)npc.UnitData.MountDisplayID,
                    Bytes1          = npc.Bytes1,
                    Bytes2          = npc.Bytes2,
                    Emote           = 0,
                    AIAnimKit       = npc.AIAnimKit.GetValueOrDefault(0),
                    MovementAnimKit = npc.MovementAnimKit.GetValueOrDefault(0),
                    MeleeAnimKit    = npc.MeleeAnimKit.GetValueOrDefault(0),
                    Auras           = auras,
                    CommentAuras    = commentAuras
                };

                if (templateAddonDefault != null && SQLUtil.AreDBFieldsEqual(addon, templateAddonDefault, dbFields))
                {
                    continue;
                }

                if (addons.ContainsKey(addon))
                {
                    continue;
                }

                addons.Add(addon);
            }

            var addonsDb = SQLDatabase.Get(addons);

            return(SQLUtil.Compare(addons, addonsDb,
                                   addon =>
            {
                var comment = StoreGetters.GetName(StoreNameType.Unit, (int)addon.Entry.GetValueOrDefault());
                if (!string.IsNullOrEmpty(addon.CommentAuras))
                {
                    comment += " - " + addon.CommentAuras;
                }
                return comment;
            }));
        }
Beispiel #2
0
        public static string CreatureTemplateAddon(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template_addon))
            {
                return(string.Empty);
            }

            var addons = new DataBag <CreatureTemplateAddon>();

            foreach (var unit in units)
            {
                Unit npc = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(npc.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                string auras        = string.Empty;
                string commentAuras = string.Empty;
                if (npc.Auras != null && npc.Auras.Count != 0)
                {
                    foreach (Aura aura in npc.Auras)
                    {
                        if (aura == null)
                        {
                            continue;
                        }

                        // usually "template auras" do not have caster
                        if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ? !aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) : !aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster))
                        {
                            continue;
                        }

                        auras        += aura.SpellId + " ";
                        commentAuras += StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", ";
                    }
                    auras        = auras.TrimEnd(' ');
                    commentAuras = commentAuras.TrimEnd(',', ' ');
                }

                CreatureTemplateAddon addon = new CreatureTemplateAddon
                {
                    Entry        = unit.Key.GetEntry(),
                    MountID      = npc.Mount.GetValueOrDefault(),
                    Bytes1       = npc.Bytes1.GetValueOrDefault(),
                    Bytes2       = npc.Bytes2.GetValueOrDefault(),
                    Auras        = auras,
                    CommentAuras = commentAuras
                };

                if (addons.ContainsKey(addon))
                {
                    continue;
                }

                addons.Add(addon);
            }

            var addonsDb = SQLDatabase.Get(addons);

            return(SQLUtil.Compare(addons, addonsDb,
                                   addon =>
            {
                string comment = StoreGetters.GetName(StoreNameType.Unit, (int)addon.Entry.GetValueOrDefault());
                if (!string.IsNullOrEmpty(addon.CommentAuras))
                {
                    comment += " - " + addon.CommentAuras;
                }
                return comment;
            }));
        }