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); }
/// todo get rid of this many variables passed in function. public void Start(bool isActiveAttacker = true, bool run = false, ObjectGuid playerGUID = default, Quest quest = null, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true) { // Queue respawn from the point it starts Map map = me.GetMap(); if (map != null) { CreatureData cdata = me.GetCreatureData(); if (cdata != null) { SpawnGroupTemplateData groupdata = cdata.spawnGroupData; if (groupdata != null) { if (WorldConfig.GetBoolValue(WorldCfg.RespawnDynamicEscortNpc) && groupdata.flags.HasAnyFlag(SpawnGroupFlags.EscortQuestNpc) && map.GetCreatureRespawnTime(me.GetSpawnId()) == 0) { me.SetRespawnTime(me.GetRespawnDelay()); me.SaveRespawnTime(); } } } } if (me.GetVictim()) { Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) attempts to Start while in combat"); return; } if (HasEscortState(EscortState.Escorting)) { Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) attempts to Start while already escorting"); return; } if (!_manualPath && resetWaypoints) { FillPointMovementListForCreature(); } if (_path.nodes.Empty()) { Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: {(quest != null ? quest.Id : 0)})."); return; } // set variables _activeAttacker = isActiveAttacker; _running = run; _playerGUID = playerGUID; _escortQuest = quest; _instantRespawn = instantRespawn; _returnToStart = canLoopPath; if (_returnToStart && _instantRespawn) { Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn."); } me.GetMotionMaster().MoveIdle(); me.GetMotionMaster().Clear(MovementSlot.Active); //disable npcflags me.SetNpcFlags(NPCFlags.None); me.SetNpcFlags2(NPCFlags2.None); if (me.HasUnitFlag(UnitFlags.ImmuneToNpc)) { _hasImmuneToNPCFlags = true; me.RemoveUnitFlag(UnitFlags.ImmuneToNpc); } Log.outDebug(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) started with {_path.nodes.Count} waypoints. ActiveAttacker = {_activeAttacker}, Run = {_running}, Player = {_playerGUID}"); // set initial speed me.SetWalk(!_running); _started = false; AddEscortState(EscortState.Escorting); }
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); }