Example #1
0
        public bool Create(ulong guidlow, uint entry, uint mapid, float x, float y, float z, float ang, uint animprogress)
        {
            Relocate(x, y, z, ang);

            if (!IsPositionValid())
            {
                Log.outError(LogFilter.Transport, "Transport (GUID: {0}) not created. Suggested coordinates isn't valid (X: {1} Y: {2})",
                             guidlow, x, y);
                return(false);
            }

            _Create(ObjectGuid.Create(HighGuid.Transport, guidlow));

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

            if (goinfo == null)
            {
                Log.outError(LogFilter.Sql, "Transport not created: entry in `gameobject_template` not found, guidlow: {0} map: {1}  (X: {2} Y: {3} Z: {4}) ang: {5}", guidlow, mapid, x, y, z, ang);
                return(false);
            }

            m_goInfo          = goinfo;
            m_goTemplateAddon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            TransportTemplate tInfo = Global.TransportMgr.GetTransportTemplate(entry);

            if (tInfo == null)
            {
                Log.outError(LogFilter.Sql, "Transport {0} (name: {1}) will not be created, missing `transport_template` entry.", entry, goinfo.name);
                return(false);
            }

            _transportInfo           = tInfo;
            _nextFrame               = 0;
            _currentFrame            = tInfo.keyFrames[_nextFrame++];
            _triggeredArrivalEvent   = false;
            _triggeredDepartureEvent = false;

            GameObjectOverride goOverride = GetGameObjectOverride();

            if (goOverride != null)
            {
                SetFaction(goOverride.Faction);
                SetFlags(goOverride.Flags);
            }

            m_goValue.Transport.PathProgress = 0;
            SetObjectScale(goinfo.size);
            SetPeriod(tInfo.pathTime);
            SetEntry(goinfo.entry);
            SetDisplayId(goinfo.displayId);
            SetGoState(goinfo.MoTransport.allowstopping == 0 ? GameObjectState.Ready : GameObjectState.Active);
            SetGoType(GameObjectTypes.MapObjTransport);
            SetGoAnimProgress(animprogress);
            SetName(goinfo.name);
            SetLocalRotation(0.0f, 0.0f, 0.0f, 1.0f);
            SetParentRotation(Quaternion.Identity);

            CreateModel();
            return(true);
        }
Example #2
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);
            }

            GameObject     thisGO = null;
            GameObjectData data   = null;

            uint  entry;
            ulong spawnId = 0;

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

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

                data = Global.ObjectMgr.GetGameObjectData(spawnId);
                if (data == null)
                {
                    handler.SendSysMessage(CypherStrings.CommandObjnotfound, spawnId);
                    return(false);
                }

                entry  = data.Id;
                thisGO = handler.GetObjectFromPlayerMapByDbGuid(spawnId);
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

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

            if (gameObjectInfo == null)
            {
                handler.SendSysMessage(CypherStrings.GameobjectNotExist, entry);
                return(false);
            }

            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.SpawninfoCompatibilityMode, thisGO.GetRespawnCompatibilityMode());

                if (thisGO.GetGameObjectData() != null && thisGO.GetGameObjectData().spawnGroupData.groupId != 0)
                {
                    SpawnGroupTemplateData groupData = thisGO.ToGameObject().GetGameObjectData().spawnGroupData;
                    handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, thisGO.GetMap().IsSpawnGroupActive(groupData.groupId));
                }

                GameObjectOverride goOverride = Global.ObjectMgr.GetGameObjectOverride(spawnId);
                if (goOverride == null)
                {
                    goOverride = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);
                }
                if (goOverride != null)
                {
                    handler.SendSysMessage(CypherStrings.GoinfoAddon, goOverride.Faction, goOverride.Flags);
                }
            }

            if (data != null)
            {
                data.rotation.toEulerAnglesZYX(out float yaw, out float pitch, out float roll);
                handler.SendSysMessage(CypherStrings.SpawninfoSpawnidLocation, data.SpawnId, data.SpawnPoint.GetPositionX(), data.SpawnPoint.GetPositionY(), data.SpawnPoint.GetPositionZ());
                handler.SendSysMessage(CypherStrings.SpawninfoRotation, yaw, pitch, roll);
            }

            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);

            handler.SendSysMessage(CypherStrings.ObjectInfoAIInfo, gameObjectInfo.AIName, Global.ObjectMgr.GetScriptName(gameObjectInfo.ScriptId));
            var ai = thisGO != null?thisGO.GetAI() : null;

            if (ai != null)
            {
                handler.SendSysMessage(CypherStrings.ObjectInfoAIType, nameof(ai));
            }

            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);
        }