static bool HandleGameObjectTurnCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.ExtractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string orientation = args.NextString(); float oz = 0.0f, oy = 0.0f, ox = 0.0f; if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oz)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out oy)) { return(false); } orientation = args.NextString(); if (!orientation.IsEmpty()) { if (!float.TryParse(orientation, out ox)) { return(false); } } } } else { Player player = handler.GetPlayer(); oz = player.GetOrientation(); } Map map = obj.GetMap(); obj.Relocate(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ()); obj.SetLocalRotationAngles(oz, oy, ox); obj.SaveToDB(); // Generate a completely new spawn with new guid // client caches recently deleted objects and brings them back to life // when CreateObject block for this guid is received again // however it entirely skips parsing that block and only uses already known location obj.Delete(); obj = GameObject.CreateGameObjectFromDB(guidLow, map); if (!obj) { return(false); } handler.SendSysMessage(CypherStrings.CommandTurnobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString(), obj.GetOrientation()); return(true); }
static bool HandleGameObjectAddCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r string idStr = handler.ExtractKeyFromLink(args, "Hgameobject_entry"); if (string.IsNullOrEmpty(idStr)) { return(false); } if (!uint.TryParse(idStr, out uint objectId) || objectId == 0) { return(false); } uint spawntimeSecs = args.NextUInt32(); GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(objectId); if (objectInfo == null) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, objectId); return(false); } if (objectInfo.displayId != 0 && !CliDB.GameObjectDisplayInfoStorage.ContainsKey(objectInfo.displayId)) { // report to DB errors log as in loading case Log.outError(LogFilter.Sql, "Gameobject (Entry {0} GoType: {1}) have invalid displayId ({2}), not spawned.", objectId, objectInfo.type, objectInfo.displayId); handler.SendSysMessage(CypherStrings.GameobjectHaveInvalidData, objectId); return(false); } Player player = handler.GetPlayer(); Map map = player.GetMap(); GameObject obj = GameObject.CreateGameObject(objectInfo.entry, map, player, Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f)), 255, GameObjectState.Ready); if (!obj) { return(false); } PhasingHandler.InheritPhaseShift(obj, player); if (spawntimeSecs != 0) { obj.SetRespawnTime((int)spawntimeSecs); } // fill the gameobject data and save to the db obj.SaveToDB(map.GetId(), new List <Difficulty>() { map.GetDifficultyID() }); ulong spawnId = obj.GetSpawnId(); // this will generate a new guid if the object is in an instance obj = GameObject.CreateGameObjectFromDB(spawnId, map); if (!obj) { return(false); } // TODO: is it really necessary to add both the real and DB table guid here ? Global.ObjectMgr.AddGameObjectToGrid(spawnId, Global.ObjectMgr.GetGameObjectData(spawnId)); handler.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, spawnId, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); return(true); }
static bool HandleGameObjectMoveCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r string id = handler.ExtractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string toX = args.NextString(); string toY = args.NextString(); string toZ = args.NextString(); float x, y, z; if (string.IsNullOrEmpty(toX)) { Player player = handler.GetSession().GetPlayer(); player.GetPosition(out x, out y, out z); } else { if (!float.TryParse(toX, out x)) { return(false); } if (!float.TryParse(toY, out y)) { return(false); } if (!float.TryParse(toZ, out z)) { return(false); } if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z)) { handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, obj.GetMapId()); return(false); } } Map map = obj.GetMap(); obj.Relocate(x, y, z, obj.GetOrientation()); // update which cell has this gameobject registered for loading Global.ObjectMgr.RemoveGameObjectFromGrid(guidLow, obj.GetGameObjectData()); obj.SaveToDB(); Global.ObjectMgr.AddGameObjectToGrid(guidLow, obj.GetGameObjectData()); // Generate a completely new spawn with new guid // client caches recently deleted objects and brings them back to life // when CreateObject block for this guid is received again // however it entirely skips parsing that block and only uses already known location obj.Delete(); obj = GameObject.CreateGameObjectFromDB(guidLow, map); if (!obj) { return(false); } handler.SendSysMessage(CypherStrings.CommandMoveobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString()); return(true); }
static bool HandleGameObjectTargetCommand(StringArguments args, CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); SQLResult result; var activeEventsList = Global.GameEventMgr.GetActiveEventList(); if (!args.Empty()) { // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r string idStr = handler.ExtractKeyFromLink(args, "Hgameobject_entry"); if (string.IsNullOrEmpty(idStr)) { return(false); } if (!uint.TryParse(idStr, out uint objectId) || objectId != 0) { result = DB.World.Query("SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - '{0}', 2) + POW(position_y - '{1}', 2) + POW(position_z - '{2}', 2)) AS order_ FROM gameobject WHERE map = '{3}' AND id = '{4}' ORDER BY order_ ASC LIMIT 1", player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId); } else { result = DB.World.Query( "SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ " + "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {3} AND name LIKE CONCAT('%%', '{4}', '%%') ORDER BY order_ ASC LIMIT 1", player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId); } } else { StringBuilder eventFilter = new(); eventFilter.Append(" AND (eventEntry IS NULL "); bool initString = true; foreach (var entry in activeEventsList) { if (initString) { eventFilter.Append("OR eventEntry IN (" + entry); initString = false; } else { eventFilter.Append(',' + entry); } } if (!initString) { eventFilter.Append("))"); } else { eventFilter.Append(')'); } result = DB.World.Query("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, " + "(POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{3}' {4} ORDER BY order_ ASC LIMIT 10", handler.GetSession().GetPlayer().GetPositionX(), handler.GetSession().GetPlayer().GetPositionY(), handler.GetSession().GetPlayer().GetPositionZ(), handler.GetSession().GetPlayer().GetMapId(), eventFilter.ToString()); } if (result.IsEmpty()) { handler.SendSysMessage(CypherStrings.CommandTargetobjnotfound); return(true); } bool found = false; float x, y, z, o; ulong guidLow; uint id, phaseId, phaseGroup; ushort mapId; uint poolId; do { guidLow = result.Read <ulong>(0); id = result.Read <uint>(1); x = result.Read <float>(2); y = result.Read <float>(3); z = result.Read <float>(4); o = result.Read <float>(5); mapId = result.Read <ushort>(6); phaseId = result.Read <uint>(7); phaseGroup = result.Read <uint>(8); poolId = Global.PoolMgr.IsPartOfAPool <GameObject>(guidLow); if (poolId == 0 || Global.PoolMgr.IsSpawnedObject <GameObject>(guidLow)) { found = true; } } while (result.NextRow() && !found); if (!found) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, id); return(false); } GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(id); if (objectInfo == null) { handler.SendSysMessage(CypherStrings.GameobjectNotExist, id); return(false); } GameObject target = handler.GetObjectFromPlayerMapByDbGuid(guidLow); handler.SendSysMessage(CypherStrings.GameobjectDetail, guidLow, objectInfo.name, guidLow, id, x, y, z, mapId, o, phaseId, phaseGroup); if (target) { int curRespawnDelay = (int)(target.GetRespawnTimeEx() - GameTime.GetGameTime()); if (curRespawnDelay < 0) { curRespawnDelay = 0; } string curRespawnDelayStr = Time.secsToTimeString((uint)curRespawnDelay, true); string defRespawnDelayStr = Time.secsToTimeString(target.GetRespawnDelay(), true); handler.SendSysMessage(CypherStrings.CommandRawpawntimes, defRespawnDelayStr, curRespawnDelayStr); } return(true); }
static bool HandleModifyRepCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } Player target = handler.GetSelectedPlayerOrSelf(); if (!target) { handler.SendSysMessage(CypherStrings.PlayerNotFound); return(false); } // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } string factionTxt = handler.ExtractKeyFromLink(args, "Hfaction"); if (string.IsNullOrEmpty(factionTxt)) { return(false); } if (!uint.TryParse(factionTxt, out uint factionId)) { return(false); } string rankTxt = args.NextString(); if (factionId == 0 || !int.TryParse(rankTxt, out int amount)) { return(false); } var factionEntry = CliDB.FactionStorage.LookupByKey(factionId); if (factionEntry == null) { handler.SendSysMessage(CypherStrings.CommandFactionUnknown, factionId); return(false); } if (factionEntry.ReputationIndex < 0) { handler.SendSysMessage(CypherStrings.CommandFactionNorepError, factionEntry.Name[handler.GetSessionDbcLocale()], factionId); return(false); } // try to find rank by name if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber()) { string rankStr = rankTxt.ToLower(); int i = 0; int r = 0; for (; i != ReputationMgr.ReputationRankThresholds.Length - 1; ++i, ++r) { string rank = handler.GetCypherString(ReputationMgr.ReputationRankStrIndex[r]); if (string.IsNullOrEmpty(rank)) { continue; } if (rank.Equals(rankStr)) { break; } if (i == ReputationMgr.ReputationRankThresholds.Length - 1) { handler.SendSysMessage(CypherStrings.CommandInvalidParam, rankTxt); return(false); } amount = ReputationMgr.ReputationRankThresholds[i]; string deltaTxt = args.NextString(); if (!string.IsNullOrEmpty(deltaTxt)) { int toNextRank = 0; var nextThresholdIndex = i; ++nextThresholdIndex; if (nextThresholdIndex != ReputationMgr.ReputationRankThresholds.Length - 1) { toNextRank = nextThresholdIndex - i; } if (!int.TryParse(deltaTxt, out int delta) || delta < 0 || delta >= toNextRank) { handler.SendSysMessage(CypherStrings.CommandFactionDelta, Math.Max(0, toNextRank - 1)); return(false); } amount += delta; } } } target.GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false); target.GetReputationMgr().SendState(target.GetReputationMgr().GetState(factionEntry)); handler.SendSysMessage(CypherStrings.CommandModifyRep, factionEntry.Name[handler.GetSessionDbcLocale()], factionId, handler.GetNameLink(target), target.GetReputationMgr().GetReputation(factionEntry)); return(true); }
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); }
static bool HandleGameObjectSetStateCommand(StringArguments args, CommandHandler handler) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r string id = handler.ExtractKeyFromLink(args, "Hgameobject"); if (string.IsNullOrEmpty(id)) { return(false); } if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0) { return(false); } GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow); if (!obj) { handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow); return(false); } string type = args.NextString(); if (string.IsNullOrEmpty(type)) { return(false); } if (!int.TryParse(type, out int objectType)) { return(false); } if (objectType < 0) { if (objectType == -1) { obj.SendGameObjectDespawn(); } else if (objectType == -2) { return(false); } return(true); } string state = args.NextString(); if (string.IsNullOrEmpty(state)) { return(false); } if (!uint.TryParse(state, out uint objectState)) { return(false); } switch (objectType) { case 0: obj.SetGoState((GameObjectState)objectState); break; case 1: obj.SetGoType((GameObjectTypes)objectState); break; case 2: obj.SetGoArtKit((byte)objectState); break; case 3: obj.SetGoAnimProgress(objectState); break; case 4: obj.SendCustomAnim(objectState); break; case 5: if (objectState < 0 || objectState > (uint)GameObjectDestructibleState.Rebuilding) { return(false); } obj.SetDestructibleState((GameObjectDestructibleState)objectState); break; default: break; } handler.SendSysMessage("Set gobject type {0} state {1}", objectType, objectState); return(true); }
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); }
static bool HandleModifyRepCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } Player target = handler.GetSelectedPlayerOrSelf(); if (!target) { handler.SendSysMessage(CypherStrings.PlayerNotFound); return(false); } // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } string factionTxt = handler.ExtractKeyFromLink(args, "Hfaction"); if (string.IsNullOrEmpty(factionTxt)) { return(false); } if (!uint.TryParse(factionTxt, out uint factionId)) { return(false); } string rankTxt = args.NextString(); if (factionId == 0 || !int.TryParse(rankTxt, out int amount)) { return(false); } if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber()) { string rankStr = rankTxt.ToLower(); int r = 0; amount = -42000; for (; r < (int)ReputationRank.Max; ++r) { string rank = handler.GetCypherString(ReputationMgr.ReputationRankStrIndex[r]); if (string.IsNullOrEmpty(rank)) { continue; } if (rank.Equals(rankStr)) { string deltaTxt = args.NextString(); if (!string.IsNullOrEmpty(deltaTxt)) { if (!int.TryParse(deltaTxt, out int delta) || delta < 0 || (delta > ReputationMgr.PointsInRank[r] - 1)) { handler.SendSysMessage(CypherStrings.CommandFactionDelta, (ReputationMgr.PointsInRank[r] - 1)); return(false); } amount += delta; } break; } amount += ReputationMgr.PointsInRank[r]; } if (r >= (int)ReputationRank.Max) { handler.SendSysMessage(CypherStrings.CommandFactionInvparam, rankTxt); return(false); } } FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId); if (factionEntry == null) { handler.SendSysMessage(CypherStrings.CommandFactionUnknown, factionId); return(false); } if (factionEntry.ReputationIndex < 0) { handler.SendSysMessage(CypherStrings.CommandFactionNorepError, factionEntry.Name[handler.GetSessionDbcLocale()], factionId); return(false); } target.GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false); target.GetReputationMgr().SendState(target.GetReputationMgr().GetState(factionEntry)); handler.SendSysMessage(CypherStrings.CommandModifyRep, factionEntry.Name[handler.GetSessionDbcLocale()], factionId, handler.GetNameLink(target), target.GetReputationMgr().GetReputation(factionEntry)); return(true); }
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); }
static bool Complete(StringArguments args, CommandHandler handler) { Player player = handler.GetSelectedPlayer(); if (!player) { handler.SendSysMessage(CypherStrings.NoCharSelected); return(false); } // .quest complete #entry // number or [name] Shift-click form |color|Hquest:quest_id:quest_level:min_level:max_level:scaling_faction|h[name]|h|r string cId = handler.ExtractKeyFromLink(args, "Hquest"); if (!uint.TryParse(cId, out uint entry)) { return(false); } Quest quest = Global.ObjectMgr.GetQuestTemplate(entry); // If player doesn't have the quest if (quest == null || player.GetQuestStatus(entry) == QuestStatus.None) { handler.SendSysMessage(CypherStrings.CommandQuestNotfound, entry); return(false); } for (int i = 0; i < quest.Objectives.Count; ++i) { QuestObjective obj = quest.Objectives[i]; switch (obj.Type) { case QuestObjectiveType.Item: { uint curItemCount = player.GetItemCount((uint)obj.ObjectID, true); List <ItemPosCount> dest = new(); InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, (uint)obj.ObjectID, (uint)(obj.Amount - curItemCount)); if (msg == InventoryResult.Ok) { Item item = player.StoreNewItem(dest, (uint)obj.ObjectID, true); player.SendNewItem(item, (uint)(obj.Amount - curItemCount), true, false); } break; } case QuestObjectiveType.Monster: { CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate((uint)obj.ObjectID); if (creatureInfo != null) { for (int z = 0; z < obj.Amount; ++z) { player.KilledMonster(creatureInfo, ObjectGuid.Empty); } } break; } case QuestObjectiveType.GameObject: { for (int z = 0; z < obj.Amount; ++z) { player.KillCreditGO((uint)obj.ObjectID); } break; } case QuestObjectiveType.MinReputation: { int curRep = player.GetReputationMgr().GetReputation((uint)obj.ObjectID); if (curRep < obj.Amount) { FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(obj.ObjectID); if (factionEntry != null) { player.GetReputationMgr().SetReputation(factionEntry, obj.Amount); } } break; } case QuestObjectiveType.MaxReputation: { int curRep = player.GetReputationMgr().GetReputation((uint)obj.ObjectID); if (curRep > obj.Amount) { FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(obj.ObjectID); if (factionEntry != null) { player.GetReputationMgr().SetReputation(factionEntry, obj.Amount); } } break; } case QuestObjectiveType.Money: { player.ModifyMoney(obj.Amount); break; } } } player.CompleteQuest(entry); return(true); }