mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
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
This commit is contained in:
4
sql/updates/world/3.3.5/2018_10_28_00_world.sql
Normal file
4
sql/updates/world/3.3.5/2018_10_28_00_world.sql
Normal file
@@ -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;
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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_SPAWNINFO_COMPATIBILITY_MODE, thisGO->GetRespawnCompatibilityMode());
|
||||
|
||||
handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
|
||||
handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
|
||||
handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
|
||||
handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
|
||||
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user