예제 #1
0
        public static string GameObjectTemplateAddon(Dictionary <WowGuid, GameObject> gameobjects)
        {
            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_template_addon))
            {
                return(string.Empty);
            }

            if (gameobjects.Count == 0)
            {
                return(string.Empty);
            }

            var addons = new DataBag <GameObjectTemplateAddon>();

            foreach (var obj in gameobjects)
            {
                var goT = Storage.GameObjectTemplates.FirstOrDefault(p => p.Item1.Entry == obj.Key.GetEntry());
                if (goT == null)
                {
                    continue;
                }

                var go = obj.Value;
                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(go.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

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

                var addon = new GameObjectTemplateAddon
                {
                    Entry = obj.Key.GetEntry()
                };

                HashSet <uint> playerFactions = new HashSet <uint> {
                    1, 2, 3, 4, 5, 6, 115, 116, 1610, 1629, 2203, 2204
                };
                addon.Faction = go.Faction.GetValueOrDefault(0);
                if (playerFactions.Contains(go.Faction.GetValueOrDefault()))
                {
                    addon.Faction = 0;
                }

                addon.Flags  = go.Flags.GetValueOrDefault(GameObjectFlag.None);
                addon.Flags &= ~GameObjectFlag.Triggered;
                addon.Flags &= ~GameObjectFlag.Damaged;
                addon.Flags &= ~GameObjectFlag.Destroyed;

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

                if (addon.Flags == GameObjectFlag.None && addon.Faction == 0)
                {
                    continue;
                }

                addons.Add(addon);
            }

            var addonsDb = SQLDatabase.Get(addons);

            return(SQLUtil.Compare(addons, addonsDb, StoreNameType.GameObject));
        }
예제 #2
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            uint            entry     = 0;
            GameObjectTypes type      = 0;
            uint            displayId = 0;
            uint            lootId    = 0;

            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.extractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            if (param1.Equals("guid"))
            {
                string cValue = handler.extractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out ulong guidLow))
                {
                    return(false);
                }

                GameObjectData data = Global.ObjectMgr.GetGOData(guidLow);
                if (data == null)
                {
                    return(false);
                }
                entry = data.id;
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                return(false);
            }

            type      = gameObjectInfo.type;
            displayId = gameObjectInfo.displayId;
            string name = gameObjectInfo.name;

            lootId = gameObjectInfo.GetLootId();

            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            if (addon != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags);
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }
예제 #3
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.ExtractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            uint entry;

            if (param1.Equals("guid"))
            {
                string cValue = handler.ExtractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out ulong guidLow))
                {
                    return(false);
                }

                GameObjectData data = Global.ObjectMgr.GetGameObjectData(guidLow);
                if (data == null)
                {
                    return(false);
                }
                entry = data.Id;
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                return(false);
            }

            GameObject thisGO = null;

            if (handler.GetSession().GetPlayer())
            {
                thisGO = handler.GetSession().GetPlayer().FindNearestGameObject(entry, 30);
            }
            else if (handler.GetSelectedObject() != null && handler.GetSelectedObject().IsTypeId(TypeId.GameObject))
            {
                thisGO = handler.GetSelectedObject().ToGameObject();
            }

            GameObjectTypes type      = gameObjectInfo.type;
            uint            displayId = gameObjectInfo.displayId;
            string          name      = gameObjectInfo.name;
            uint            lootId    = gameObjectInfo.GetLootId();

            // If we have a real object, send some info about it
            if (thisGO != null)
            {
                handler.SendSysMessage(CypherStrings.SpawninfoGuidinfo, thisGO.GetGUID().ToString());
                handler.SendSysMessage(CypherStrings.SpawninfoSpawnidLocation, thisGO.GetSpawnId(), thisGO.GetPositionX(), thisGO.GetPositionY(), thisGO.GetPositionZ());
                Player player = handler.GetSession().GetPlayer();
                if (player != null)
                {
                    Position playerPos = player.GetPosition();
                    float    dist      = thisGO.GetExactDist(playerPos);
                    handler.SendSysMessage(CypherStrings.SpawninfoDistancefromplayer, dist);
                }
            }
            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            WorldObject obj = handler.GetSelectedObject();

            if (obj != null)
            {
                if (obj.IsGameObject() && obj.ToGameObject().GetGameObjectData() != null && obj.ToGameObject().GetGameObjectData().spawnGroupData.groupId != 0)
                {
                    SpawnGroupTemplateData groupData = obj.ToGameObject().GetGameObjectData().spawnGroupData;
                    handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, obj.GetMap().IsSpawnGroupActive(groupData.groupId));
                }
                if (obj.IsGameObject())
                {
                    handler.SendSysMessage(CypherStrings.SpawninfoCompatibilityMode, obj.ToGameObject().GetRespawnCompatibilityMode());
                }
            }
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            if (addon != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags);
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }