diff options
-rw-r--r-- | sql/updates/world/3.3.5/2018_10_28_00_world.sql | 4 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObjectData.h | 1 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/Language.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 68 |
5 files changed, 42 insertions, 38 deletions
diff --git a/sql/updates/world/3.3.5/2018_10_28_00_world.sql b/sql/updates/world/3.3.5/2018_10_28_00_world.sql new file mode 100644 index 00000000000..13c2f3a2e94 --- /dev/null +++ b/sql/updates/world/3.3.5/2018_10_28_00_world.sql @@ -0,0 +1,4 @@ +-- Describe distance command argument +UPDATE `command` SET `help`='Syntax: .distance [link]\r\n\r\nDisplay the distance from your character to the selected unit or given creature, player or gameobject.' WHERE `name`='distance'; +-- Repurpose existing trinity_string for rotation info string +UPDATE `trinity_string` SET `content_default`='yaw: %f pitch: %f roll: %f' WHERE `entry`=5074; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index ca2242c6aa4..188a8935d8f 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -92,6 +92,11 @@ bool QuaternionData::isUnit() const return fabs(x * x + y * y + z * z + w * w - 1.0f) < 1e-5f; } +void QuaternionData::toEulerAnglesZYX(float& Z, float& Y, float& X) const +{ + G3D::Matrix3(G3D::Quat(x, y, z, w)).toEulerAnglesZYX(Z, Y, X); +} + QuaternionData QuaternionData::fromEulerAnglesZYX(float Z, float Y, float X) { G3D::Quat quat(G3D::Matrix3::fromEulerAnglesZYX(Z, Y, X)); diff --git a/src/server/game/Entities/GameObject/GameObjectData.h b/src/server/game/Entities/GameObject/GameObjectData.h index b5b2262c410..81999bf5b88 100644 --- a/src/server/game/Entities/GameObject/GameObjectData.h +++ b/src/server/game/Entities/GameObject/GameObjectData.h @@ -603,6 +603,7 @@ struct TC_GAME_API QuaternionData QuaternionData(float X, float Y, float Z, float W) : x(X), y(Y), z(Z), w(W) { } bool isUnit() const; + void toEulerAnglesZYX(float& Z, float& Y, float& X) const; static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X); }; diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 146437829a7..a5139f48562 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1064,7 +1064,7 @@ enum TrinityStrings LANG_SPAWNINFO_COMPATIBILITY_MODE = 5071, LANG_SPAWNINFO_GUIDINFO = 5072, LANG_SPAWNINFO_SPAWNID_LOCATION = 5073, - LANG_SPAWNINFO_DISTANCEFROMPLAYER = 5074, + LANG_SPAWNINFO_ROTATION = 5074, LANG_SPAWNGROUP_BADGROUP = 5075, LANG_SPAWNGROUP_SPAWNCOUNT = 5076, LANG_LIST_RESPAWNS_RANGE = 5077, diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 3dbd19dc956..35f0f1a0ff9 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -617,6 +617,9 @@ public: if (!param1) return false; + GameObject* thisGO = nullptr; + GameObjectData const* data = nullptr; + ObjectGuid::LowType spawnId = 0; if (strcmp(param1, "guid") == 0) { @@ -625,10 +628,15 @@ public: if (!cValue) return false; spawnId = atoul(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 { @@ -636,16 +644,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; @@ -659,45 +663,35 @@ public: if (thisGO) { handler->PSendSysMessage(LANG_SPAWNINFO_GUIDINFO, thisGO->GetGUID().ToString().c_str()); - handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, thisGO->GetSpawnId(), 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, 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()); |