mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/PvP: Gameobject rotation in BGs and Wintergrasp.
- Add a workaround in BattleGround correcting for bad rotations in BG scripts - Calculate rotation from rotation in Wintergrasp, this function hasn't a rotation parameter and should be added in the future. - Also removed an ugly hardcode in Battlefield::SpawnGameObject Closes #17711
This commit is contained in:
@@ -795,18 +795,21 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
|
|||||||
GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
|
GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
|
||||||
{
|
{
|
||||||
// Get map object
|
// Get map object
|
||||||
Map* map = sMapMgr->CreateBaseMap(571); // *vomits*
|
Map* map = sMapMgr->CreateBaseMap(m_MapId);
|
||||||
if (!map)
|
if (!map)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// Calculate rotation
|
||||||
|
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(o, 0.f, 0.f);
|
||||||
|
|
||||||
// Create gameobject
|
// Create gameobject
|
||||||
GameObject* go = new GameObject;
|
GameObject* go = new GameObject;
|
||||||
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, Position(x, y, z, o), G3D::Quat(), 255, GO_STATE_READY))
|
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, Position(x, y, z, o), rot, 255, GO_STATE_READY))
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Gameobject template %u could not be found in the database! Battlefield has not been created!", entry);
|
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Gameobject template %u could not be found in the database! Battlefield has not been created!", entry);
|
||||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template %u! Battlefield has not been created!", entry);
|
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template %u! Battlefield has not been created!", entry);
|
||||||
delete go;
|
delete go;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to world
|
// Add to world
|
||||||
|
|||||||
@@ -1442,12 +1442,22 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
|
|||||||
Map* map = FindBgMap();
|
Map* map = FindBgMap();
|
||||||
if (!map)
|
if (!map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
G3D::Quat rot(rotation0, rotation1, rotation2, rotation3);
|
||||||
|
// Temporally add safety check for bad spawns and send log (object rotations need to be rechecked in sniff)
|
||||||
|
if (!rotation0 && !rotation1 && !rotation2 && !rotation3)
|
||||||
|
{
|
||||||
|
TC_LOG_DEBUG("bg.battleground", "Battleground::AddObject: gameoobject [entry: %u, object type: %u] for BG (map: %u) has zeroed rotation fields, "
|
||||||
|
"orientation used temporally, but please fix the spawn", entry, type, m_MapId);
|
||||||
|
|
||||||
|
rot = G3D::Matrix3::fromEulerAnglesZYX(o, 0.f, 0.f);
|
||||||
|
}
|
||||||
|
|
||||||
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
||||||
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
||||||
// So we must create it specific for this instance
|
// So we must create it specific for this instance
|
||||||
GameObject* go = new GameObject;
|
GameObject* go = new GameObject;
|
||||||
if (!go->Create(GetBgMap()->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(),
|
if (!go->Create(GetBgMap()->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(), PHASEMASK_NORMAL, Position(x, y, z, o), rot, 255, goState))
|
||||||
PHASEMASK_NORMAL, Position(x, y, z, o), G3D::Quat(rotation0, rotation1, rotation2, rotation3), 255, goState))
|
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
|
TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
|
||||||
entry, m_MapId, m_InstanceID);
|
entry, m_MapId, m_InstanceID);
|
||||||
|
|||||||
Reference in New Issue
Block a user