diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/QuaternionData.h | 1 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/Language.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 68 |
4 files changed, 38 insertions, 38 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index c81612003ea..7f4bd3e02c6 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -98,6 +98,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/QuaternionData.h b/src/server/game/Entities/GameObject/QuaternionData.h index 7b7796b2230..cf806ac6cba 100644 --- a/src/server/game/Entities/GameObject/QuaternionData.h +++ b/src/server/game/Entities/GameObject/QuaternionData.h @@ -32,6 +32,7 @@ struct TC_GAME_API QuaternionData } bool isUnit() const; + void toEulerAnglesZYX(float& Z, float& Y, float& X) const; static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X); friend bool operator==(QuaternionData const& left, QuaternionData const& right) diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index d47d6fe239e..542b1f0237f 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1154,7 +1154,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 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()); |