From afac2b174290c871d845e37f88c6f0c874d15fd6 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sun, 28 Oct 2018 11:07:56 +0200 Subject: Add rotation to .gob info (#22723) * Add rotation to .gob info - Add rotation (yaw, pitch, roll) to .gob info command - Replace LANG_SPAWNINFO_DISTANCEFROMPLAYER with LANG_SPAWNINFO_ROTATION - Fix description of .distance to describe the command arguments (the more you know..) - Fix .gob info guid targetting nearest gameobject instead of finding with given guid - Reorder the info data slightly - Print location and rotation data regardless of object found in world - Add error messages for when object is not found by guid or entry (cherry picked from commit 257ae44a20ed40469dd821845de8e27c0af838c7) --- src/server/scripts/Commands/cs_gobject.cpp | 68 ++++++++++++++---------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 91d9755e781..4a6d3a37c4b 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -608,6 +608,9 @@ public: if (!param1) return false; + GameObject* thisGO = nullptr; + GameObjectData const* data = nullptr; + ObjectGuid::LowType spawnId = 0; if (strcmp(param1, "guid") == 0) { @@ -616,10 +619,15 @@ public: if (!cValue) return false; spawnId = atoull(cValue); - GameObjectData const* data = sObjectMgr->GetGameObjectData(spawnId); + data = sObjectMgr->GetGameObjectData(spawnId); if (!data) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, spawnId); + handler->SetSentErrorMessage(true); return false; + } entry = data->id; + thisGO = handler->GetObjectFromPlayerMapByDbGuid(spawnId); } else { @@ -627,16 +635,12 @@ public: } GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); - - GameObject* thisGO = nullptr; - if (!gameObjectInfo) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, entry); + handler->SetSentErrorMessage(true); return false; - - if (*args && handler->GetSession()->GetPlayer()) - thisGO = handler->GetSession()->GetPlayer()->FindNearestGameObject(entry, 30); - else if (handler->getSelectedObject() && handler->getSelectedObject()->GetTypeId() == TYPEID_GAMEOBJECT) - thisGO = handler->getSelectedObject()->ToGameObject(); + } type = gameObjectInfo->type; displayId = gameObjectInfo->displayId; @@ -647,45 +651,35 @@ public: if (thisGO) { handler->PSendSysMessage(LANG_SPAWNINFO_GUIDINFO, thisGO->GetGUID().ToString().c_str()); - handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, std::to_string(thisGO->GetSpawnId()).c_str(), thisGO->GetPositionX(), thisGO->GetPositionY(), thisGO->GetPositionZ()); - if (Player* player = handler->GetSession()->GetPlayer()) - { - Position playerPos = player->GetPosition(); - float dist = thisGO->GetExactDist(&playerPos); - handler->PSendSysMessage(LANG_SPAWNINFO_DISTANCEFROMPLAYER, dist); - } - } - - handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); - handler->PSendSysMessage(LANG_GOINFO_TYPE, type); - handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); - handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId); + handler->PSendSysMessage(LANG_SPAWNINFO_COMPATIBILITY_MODE, thisGO->GetRespawnCompatibilityMode()); - if (thisGO) - { if (thisGO->GetGameObjectData() && thisGO->GetGameObjectData()->spawnGroupData->groupId) { SpawnGroupTemplateData const* groupData = thisGO->GetGameObjectData()->spawnGroupData; handler->PSendSysMessage(LANG_SPAWNINFO_GROUP_ID, groupData->name.c_str(), groupData->groupId, groupData->flags, thisGO->GetMap()->IsSpawnGroupActive(groupData->groupId)); } - handler->PSendSysMessage(LANG_SPAWNINFO_COMPATIBILITY_MODE, thisGO->GetRespawnCompatibilityMode()); + GameObjectOverride const* goOverride = sObjectMgr->GetGameObjectOverride(spawnId); + if (!goOverride) + goOverride = sObjectMgr->GetGameObjectTemplateAddon(entry); + if (goOverride) + handler->PSendSysMessage(LANG_GOINFO_ADDON, goOverride->Faction, goOverride->Flags); + } + + if (data) + { + float yaw, pitch, roll; + data->rotation.toEulerAnglesZYX(yaw, pitch, roll); + handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, std::to_string(data->spawnId), data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY(), data->spawnPoint.GetPositionZ()); + handler->PSendSysMessage(LANG_SPAWNINFO_ROTATION, yaw, pitch, roll); } + handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); + handler->PSendSysMessage(LANG_GOINFO_TYPE, type); + handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); + handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId); handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size); - - GameObjectOverride const* goOverride = nullptr; - if (spawnId) - if (GameObjectOverride const* ovr = sObjectMgr->GetGameObjectOverride(spawnId)) - goOverride = ovr; - - if (!goOverride) - goOverride = sObjectMgr->GetGameObjectTemplateAddon(entry); - - if (goOverride) - handler->PSendSysMessage(LANG_GOINFO_ADDON, goOverride->Faction, goOverride->Flags); - handler->PSendSysMessage(LANG_OBJECTINFO_AIINFO, gameObjectInfo->AIName.c_str(), sObjectMgr->GetScriptName(gameObjectInfo->ScriptId).c_str()); if (GameObjectAI const* ai = thisGO ? thisGO->AI() : nullptr) handler->PSendSysMessage(LANG_OBJECTINFO_AITYPE, boost::core::demangle(typeid(*ai).name()).c_str()); -- cgit v1.2.3