Core/Entities: Merge duplicate functions calculating relative positions - remove CalculatePassengerPosition/CalculatePassengerOffset from TransportBase class
This commit is contained in:
@@ -176,10 +176,7 @@ void EscortAI::UpdateAI(uint32 diff)
|
||||
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: reached end of waypoints, despawning at end ({})", me->GetGUID().ToString());
|
||||
if (_returnToStart)
|
||||
{
|
||||
Position respawnPosition;
|
||||
float orientation = 0.f;
|
||||
me->GetRespawnPosition(respawnPosition.m_positionX, respawnPosition.m_positionY, respawnPosition.m_positionZ, &orientation);
|
||||
respawnPosition.SetOrientation(orientation);
|
||||
Position respawnPosition = me->GetRespawnPosition();
|
||||
me->GetMotionMaster()->MovePoint(POINT_HOME, respawnPosition);
|
||||
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: returning to spawn location: {} ({})", respawnPosition.ToString(), me->GetGUID().ToString());
|
||||
}
|
||||
|
||||
@@ -810,11 +810,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
// Reset home position to respawn position if specified in the parameters
|
||||
if (e.action.evade.toRespawnPosition == 0)
|
||||
{
|
||||
float homeX, homeY, homeZ, homeO;
|
||||
me->GetRespawnPosition(homeX, homeY, homeZ, &homeO);
|
||||
me->SetHomePosition(homeX, homeY, homeZ, homeO);
|
||||
}
|
||||
me->SetHomePosition(me->GetRespawnPosition());
|
||||
|
||||
me->AI()->EnterEvadeMode();
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature {} EnterEvadeMode", me->GetGUID());
|
||||
@@ -1523,7 +1519,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
Position dest(e.target.x, e.target.y, e.target.z);
|
||||
if (e.action.moveToPos.transport)
|
||||
if (TransportBase* trans = me->GetDirectTransport())
|
||||
trans->CalculatePassengerPosition(dest.m_positionX, dest.m_positionY, dest.m_positionZ);
|
||||
dest = trans->GetPositionWithOffset(dest);
|
||||
|
||||
me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest, e.action.moveToPos.disablePathfinding == 0, {}, {},
|
||||
MovementWalkRunSpeedSelectionMode::Default, {}, std::move(scriptResult));
|
||||
|
||||
@@ -272,13 +272,8 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti
|
||||
transport = m_movementInfo.transport.guid.IsEmpty() ? caster->GetTransport() : nullptr;
|
||||
if (transport)
|
||||
{
|
||||
float x, y, z, o;
|
||||
pos.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerOffset(x, y, z, &o);
|
||||
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
|
||||
// This object must be added to transport before adding to map for the client to properly display it
|
||||
transport->AddPassenger(this);
|
||||
transport->AddPassenger(this, transport->GetPositionOffsetTo(pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -454,25 +454,20 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers)
|
||||
if (IsFalling())
|
||||
StopMoving();
|
||||
|
||||
float x, y, z, o;
|
||||
GetRespawnPosition(x, y, z, &o);
|
||||
Position respawnPosition = GetRespawnPosition();
|
||||
|
||||
// We were spawned on transport, calculate real position
|
||||
if (IsSpawnedOnTransport())
|
||||
{
|
||||
Position& pos = m_movementInfo.transport.pos;
|
||||
pos.m_positionX = x;
|
||||
pos.m_positionY = y;
|
||||
pos.m_positionZ = z;
|
||||
pos.SetOrientation(o);
|
||||
m_movementInfo.transport.pos = respawnPosition;
|
||||
|
||||
if (TransportBase* transport = GetDirectTransport())
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
respawnPosition = transport->GetPositionWithOffset(respawnPosition);
|
||||
}
|
||||
|
||||
UpdateAllowedPositionZ(x, y, z);
|
||||
SetHomePosition(x, y, z, o);
|
||||
GetMap()->CreatureRelocation(this, x, y, z, o);
|
||||
UpdateAllowedPositionZ(respawnPosition.GetPositionX(), respawnPosition.GetPositionY(), respawnPosition.m_positionZ);
|
||||
SetHomePosition(respawnPosition);
|
||||
GetMap()->CreatureRelocation(this, respawnPosition.GetPositionX(), respawnPosition.GetPositionY(), respawnPosition.GetPositionZ(), respawnPosition.GetOrientation());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2907,27 +2902,21 @@ void Creature::SetRespawnTime(uint32 respawn)
|
||||
m_respawnTime = respawn ? GameTime::GetGameTime() + respawn : 0;
|
||||
}
|
||||
|
||||
void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
|
||||
Position Creature::GetRespawnPosition(float* dist) const
|
||||
{
|
||||
if (m_creatureData)
|
||||
{
|
||||
if (ori)
|
||||
m_creatureData->spawnPoint.GetPosition(x, y, z, *ori);
|
||||
else
|
||||
m_creatureData->spawnPoint.GetPosition(x, y, z);
|
||||
|
||||
if (dist)
|
||||
*dist = m_creatureData->wander_distance;
|
||||
|
||||
return m_creatureData->spawnPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
Position const& homePos = GetHomePosition();
|
||||
if (ori)
|
||||
homePos.GetPosition(x, y, z, *ori);
|
||||
else
|
||||
homePos.GetPosition(x, y, z);
|
||||
if (dist)
|
||||
*dist = 0;
|
||||
|
||||
return GetHomePosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
void Update(uint32 time) override; // overwrited Unit::Update
|
||||
void Heartbeat() override;
|
||||
|
||||
void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr, float* dist = nullptr) const;
|
||||
Position GetRespawnPosition(float* dist = nullptr) const;
|
||||
bool IsSpawnedOnTransport() const { return m_creatureData && m_creatureData->mapId != GetMapId(); }
|
||||
|
||||
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio = false)
|
||||
|
||||
@@ -116,13 +116,8 @@ bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caste
|
||||
TransportBase* transport = caster->GetTransport();
|
||||
if (transport)
|
||||
{
|
||||
float x, y, z, o;
|
||||
pos.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerOffset(x, y, z, &o);
|
||||
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
|
||||
// This object must be added to transport before adding to map for the client to properly display it
|
||||
transport->AddPassenger(this);
|
||||
transport->AddPassenger(this, transport->GetPositionOffsetTo(pos));
|
||||
}
|
||||
|
||||
if (!GetMap()->AddToMap(this))
|
||||
|
||||
@@ -418,12 +418,7 @@ public:
|
||||
void UpdatePassengerPositions()
|
||||
{
|
||||
for (WorldObject* passenger : _passengers)
|
||||
{
|
||||
float x, y, z, o;
|
||||
passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o);
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
UpdatePassengerPosition(_owner.GetMap(), passenger, x, y, z, o, true);
|
||||
}
|
||||
UpdatePassengerPosition(_owner.GetMap(), passenger, _owner.GetPositionWithOffset(passenger->m_movementInfo.transport.pos), true);
|
||||
}
|
||||
|
||||
uint32 GetTransportPeriod() const
|
||||
@@ -443,7 +438,7 @@ public:
|
||||
|
||||
float GetTransportOrientation() const override { return _owner.GetOrientation(); }
|
||||
|
||||
void AddPassenger(WorldObject* passenger) override
|
||||
void AddPassenger(WorldObject* passenger, Position const& offset) override
|
||||
{
|
||||
if (!_owner.IsInWorld())
|
||||
return;
|
||||
@@ -452,6 +447,7 @@ public:
|
||||
{
|
||||
passenger->SetTransport(this);
|
||||
passenger->m_movementInfo.transport.guid = GetTransportGUID();
|
||||
passenger->m_movementInfo.transport.pos = offset;
|
||||
TC_LOG_DEBUG("entities.transport", "Object {} boarded transport {}.", passenger->GetName(), _owner.GetName());
|
||||
}
|
||||
}
|
||||
@@ -471,14 +467,14 @@ public:
|
||||
return this;
|
||||
}
|
||||
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float* o) const override
|
||||
Position GetPositionWithOffset(Position const& offset) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, o, _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), _owner.GetOrientation());
|
||||
return _owner.GetPositionWithOffset(offset);
|
||||
}
|
||||
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float* o) const override
|
||||
Position GetPositionOffsetTo(Position const& endPos) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o, _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), _owner.GetOrientation());
|
||||
return _owner.GetPositionOffsetTo(endPos);
|
||||
}
|
||||
|
||||
int32 GetMapIdForSpawning() const override
|
||||
@@ -4129,22 +4125,12 @@ void GameObject::SetPathProgressForClient(float progress)
|
||||
m_transportPathProgress = progress;
|
||||
}
|
||||
|
||||
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = nullptr*/) const
|
||||
Position GameObject::GetRespawnPosition() const
|
||||
{
|
||||
if (m_goData)
|
||||
{
|
||||
if (ori)
|
||||
m_goData->spawnPoint.GetPosition(x, y, z, *ori);
|
||||
else
|
||||
m_goData->spawnPoint.GetPosition(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ori)
|
||||
GetPosition(x, y, z, *ori);
|
||||
else
|
||||
GetPosition(x, y, z);
|
||||
}
|
||||
return m_goData->spawnPoint;
|
||||
|
||||
return GetPosition();
|
||||
}
|
||||
|
||||
TransportBase const* GameObject::ToTransportBase() const
|
||||
|
||||
@@ -397,7 +397,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
void SetFaction(uint32 faction) override { SetUpdateFieldValue(m_values.ModifyValue(&GameObject::m_gameObjectData).ModifyValue(&UF::GameObjectData::FactionTemplate), faction); }
|
||||
|
||||
GameObjectModel* m_model;
|
||||
void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr) const;
|
||||
Position GetRespawnPosition() const;
|
||||
|
||||
TransportBase* ToTransportBase() { return const_cast<TransportBase*>(const_cast<GameObject const*>(this)->ToTransportBase()); }
|
||||
TransportBase const* ToTransportBase() const;
|
||||
|
||||
@@ -1849,13 +1849,8 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
TransportBase* transport = summoner ? summoner->GetTransport() : nullptr;
|
||||
if (transport)
|
||||
{
|
||||
float x, y, z, o;
|
||||
pos.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerOffset(x, y, z, &o);
|
||||
summon->m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
|
||||
// This object must be added to transport before adding to map for the client to properly display it
|
||||
transport->AddPassenger(summon);
|
||||
transport->AddPassenger(summon, transport->GetPositionOffsetTo(pos));
|
||||
}
|
||||
|
||||
if (summoner && !(properties && properties->GetFlags().HasFlag(SummonPropertiesFlags::IgnoreSummonerPhase)))
|
||||
|
||||
@@ -33,9 +33,9 @@ bool Position::operator==(Position const& a) const
|
||||
|
||||
void Position::RelocateOffset(Position const& offset)
|
||||
{
|
||||
m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI)));
|
||||
m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation()));
|
||||
m_positionZ = GetPositionZ() + offset.GetPositionZ();
|
||||
m_positionX += offset.GetPositionX() * std::cos(GetOrientation()) - offset.GetPositionY() * std::sin(GetOrientation());
|
||||
m_positionY += offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation());
|
||||
m_positionZ += offset.GetPositionZ();
|
||||
SetOrientation(GetOrientation() + offset.GetOrientation());
|
||||
}
|
||||
|
||||
@@ -44,15 +44,18 @@ bool Position::IsPositionValid() const
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(Position const& endPos, Position& retOffset) const
|
||||
Position Position::GetPositionOffsetTo(Position const& endPos) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
float dy = endPos.GetPositionY() - GetPositionY();
|
||||
|
||||
retOffset.m_positionX = (dx + dy * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation()));
|
||||
retOffset.m_positionY = (dy - dx * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation()));
|
||||
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
|
||||
retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
|
||||
return
|
||||
{
|
||||
(dx + dy * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation())),
|
||||
(dy - dx * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation())),
|
||||
endPos.GetPositionZ() - GetPositionZ(),
|
||||
endPos.GetOrientation() - GetOrientation()
|
||||
};
|
||||
}
|
||||
|
||||
Position Position::GetPositionWithOffset(Position const& offset) const
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
float GetExactDist(Position const& pos) const { return GetExactDist(pos.m_positionX, pos.m_positionY, pos.m_positionZ); }
|
||||
float GetExactDist(Position const* pos) const { return GetExactDist(*pos); }
|
||||
|
||||
void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
|
||||
Position GetPositionOffsetTo(Position const & endPos) const;
|
||||
Position GetPositionWithOffset(Position const& offset) const;
|
||||
|
||||
float GetAbsoluteAngle(float x, float y) const
|
||||
|
||||
@@ -431,12 +431,8 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
|
||||
{
|
||||
if (Transport* transport = ObjectAccessor::GetTransport(*this, ObjectGuid::Create<HighGuid::Transport>(*position.TransportGuid)))
|
||||
{
|
||||
transport->AddPassenger(this);
|
||||
m_movementInfo.transport.pos.Relocate(position.Loc);
|
||||
float x, y, z, o;
|
||||
position.Loc.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
Relocate(x, y, z, o);
|
||||
transport->AddPassenger(this, position.Loc);
|
||||
Relocate(transport->GetPositionWithOffset(position.Loc));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18089,18 +18085,17 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
|
||||
|
||||
if (transport)
|
||||
{
|
||||
float x = fields.trans_x, y = fields.trans_y, z = fields.trans_z, o = fields.trans_o;
|
||||
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
m_movementInfo.transport.pos.Relocate(fields.trans_x, fields.trans_y, fields.trans_z, fields.trans_o);
|
||||
Position globalPosition = transport->GetPositionWithOffset(m_movementInfo.transport.pos);
|
||||
|
||||
if (!Trinity::IsValidMapCoord(x, y, z, o) ||
|
||||
if (!globalPosition.IsPositionValid() ||
|
||||
// transport size limited
|
||||
std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f ||
|
||||
std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f ||
|
||||
std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f)
|
||||
{
|
||||
TC_LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player ({}) has invalid transport coordinates (X: {} Y: {} Z: {} O: {}). Teleport to bind location.",
|
||||
guid.ToString(), x, y, z, o);
|
||||
TC_LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player ({}) has invalid transport coordinates ({}). Teleport to bind location.",
|
||||
guid.ToString(), globalPosition.ToString());
|
||||
|
||||
m_movementInfo.transport.Reset();
|
||||
|
||||
@@ -18108,10 +18103,10 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
|
||||
}
|
||||
else
|
||||
{
|
||||
Relocate(x, y, z, o);
|
||||
Relocate(globalPosition);
|
||||
mapId = transport->GetMapId();
|
||||
|
||||
transport->AddPassenger(this);
|
||||
transport->AddPassenger(this, m_movementInfo.transport.pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "Transport.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Common.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "GameEventSender.h"
|
||||
#include "GameObjectAI.h"
|
||||
@@ -28,20 +26,21 @@
|
||||
#include "PhasingHandler.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Spline.h"
|
||||
#include "Totem.h"
|
||||
#include "UpdateData.h"
|
||||
#include "Vehicle.h"
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <G3D/Vector3.h>
|
||||
#include <sstream>
|
||||
|
||||
void TransportBase::UpdatePassengerPosition(Map* map, WorldObject* passenger, float x, float y, float z, float o, bool setHomePosition)
|
||||
void TransportBase::UpdatePassengerPosition(Map* map, WorldObject* passenger, Position const& position, bool setHomePosition)
|
||||
{
|
||||
// transport teleported but passenger not yet (can happen for players)
|
||||
if (passenger->GetMap() != map)
|
||||
return;
|
||||
|
||||
float x, y, z, o;
|
||||
position.GetPosition(x, y, z, o);
|
||||
|
||||
// Do not use Unit::UpdatePosition here, we don't want to remove auras
|
||||
// as if regular movement occurred
|
||||
switch (passenger->GetTypeId())
|
||||
@@ -51,11 +50,7 @@ void TransportBase::UpdatePassengerPosition(Map* map, WorldObject* passenger, fl
|
||||
Creature* creature = passenger->ToCreature();
|
||||
map->CreatureRelocation(creature, x, y, z, o, false);
|
||||
if (setHomePosition)
|
||||
{
|
||||
creature->GetTransportHomePosition(x, y, z, o);
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
creature->SetHomePosition(x, y, z, o);
|
||||
}
|
||||
creature->SetHomePosition(GetPositionWithOffset(creature->GetTransportHomePosition()));
|
||||
break;
|
||||
}
|
||||
case TYPEID_PLAYER:
|
||||
@@ -68,7 +63,7 @@ void TransportBase::UpdatePassengerPosition(Map* map, WorldObject* passenger, fl
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
map->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
|
||||
passenger->ToGameObject()->RelocateStationaryPosition(x, y, z, o);
|
||||
passenger->ToGameObject()->RelocateStationaryPosition(position);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
map->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
|
||||
@@ -277,7 +272,7 @@ void Transport::Update(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::AddPassenger(WorldObject* passenger)
|
||||
void Transport::AddPassenger(WorldObject* passenger, Position const& offset)
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
@@ -286,6 +281,7 @@ void Transport::AddPassenger(WorldObject* passenger)
|
||||
{
|
||||
passenger->SetTransport(this);
|
||||
passenger->m_movementInfo.transport.guid = GetGUID();
|
||||
passenger->m_movementInfo.transport.pos = offset;
|
||||
TC_LOG_DEBUG("entities.transport", "Object {} boarded transport {}.", passenger->GetName(), GetName());
|
||||
|
||||
if (Player* plr = passenger->ToPlayer())
|
||||
@@ -323,16 +319,12 @@ Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData c
|
||||
|
||||
ASSERT(data);
|
||||
|
||||
float x, y, z, o;
|
||||
data->spawnPoint.GetPosition(x, y, z, o);
|
||||
|
||||
creature->SetTransport(this);
|
||||
creature->m_movementInfo.transport.guid = GetGUID();
|
||||
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
creature->m_movementInfo.transport.pos.Relocate(data->spawnPoint);
|
||||
creature->m_movementInfo.transport.seat = -1;
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
creature->Relocate(x, y, z, o);
|
||||
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
|
||||
creature->Relocate(GetPositionWithOffset(creature->m_movementInfo.transport.pos));
|
||||
creature->SetHomePosition(creature->GetPosition());
|
||||
creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);
|
||||
|
||||
/// @HACK - transport models are not added to map's dynamic LoS calculations
|
||||
@@ -372,16 +364,12 @@ GameObject* Transport::CreateGOPassenger(ObjectGuid::LowType guid, GameObjectDat
|
||||
|
||||
ASSERT(data);
|
||||
|
||||
float x, y, z, o;
|
||||
data->spawnPoint.GetPosition(x, y, z, o);
|
||||
|
||||
go->SetTransport(this);
|
||||
go->m_movementInfo.transport.guid = GetGUID();
|
||||
go->m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
go->m_movementInfo.transport.pos.Relocate(data->spawnPoint);
|
||||
go->m_movementInfo.transport.seat = -1;
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
go->Relocate(x, y, z, o);
|
||||
go->RelocateStationaryPosition(x, y, z, o);
|
||||
go->Relocate(GetPositionWithOffset(go->m_movementInfo.transport.pos));
|
||||
go->RelocateStationaryPosition(go->GetPosition());
|
||||
|
||||
if (!go->IsPositionValid())
|
||||
{
|
||||
@@ -477,11 +465,9 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
|
||||
break;
|
||||
}
|
||||
|
||||
float x, y, z, o;
|
||||
pos.GetPosition(x, y, z, o);
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
Position globalPosition = GetPositionWithOffset(pos);
|
||||
|
||||
if (!summon->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, entry, { x, y, z, o }, nullptr, vehId))
|
||||
if (!summon->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, entry, globalPosition, nullptr, vehId))
|
||||
{
|
||||
delete summon;
|
||||
return nullptr;
|
||||
@@ -499,8 +485,8 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
|
||||
summon->SetTransport(this);
|
||||
summon->m_movementInfo.transport.guid = GetGUID();
|
||||
summon->m_movementInfo.transport.pos.Relocate(pos);
|
||||
summon->Relocate(x, y, z, o);
|
||||
summon->SetHomePosition(x, y, z, o);
|
||||
summon->Relocate(globalPosition);
|
||||
summon->SetHomePosition(globalPosition);
|
||||
summon->SetTransportHomePosition(pos);
|
||||
|
||||
/// @HACK - transport models are not added to map's dynamic LoS calculations
|
||||
@@ -626,11 +612,7 @@ bool Transport::TeleportTransport(uint32 oldMapId, uint32 newMapId, float x, flo
|
||||
if (veh->GetTransport() == this)
|
||||
continue;
|
||||
|
||||
float destX, destY, destZ, destO;
|
||||
(*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
|
||||
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
|
||||
|
||||
(*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO);
|
||||
(*itr)->ToUnit()->NearTeleportTo(GetPositionWithOffset((*itr)->m_movementInfo.transport.pos));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,12 +684,7 @@ void Transport::TeleportPassengersAndHideTransport(uint32 newMapid)
|
||||
void Transport::UpdatePassengerPositions(PassengerSet const& passengers)
|
||||
{
|
||||
for (WorldObject* passenger : passengers)
|
||||
{
|
||||
float x, y, z, o;
|
||||
passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o);
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
UpdatePassengerPosition(GetMap(), passenger, x, y, z, o, true);
|
||||
}
|
||||
UpdatePassengerPosition(GetMap(), passenger, GetPositionWithOffset(passenger->m_movementInfo.transport.pos), true);
|
||||
}
|
||||
|
||||
void Transport::BuildUpdate(UpdateDataMapType& data_map)
|
||||
|
||||
@@ -43,7 +43,7 @@ class TC_GAME_API Transport final : public GameObject, public TransportBase
|
||||
|
||||
void BuildUpdate(UpdateDataMapType& data_map) override;
|
||||
|
||||
void AddPassenger(WorldObject* passenger) override;
|
||||
void AddPassenger(WorldObject* passenger, Position const& offset) override;
|
||||
Transport* RemovePassenger(WorldObject* passenger) override;
|
||||
PassengerSet const& GetPassengers() const { return _passengers; }
|
||||
|
||||
@@ -73,16 +73,10 @@ class TC_GAME_API Transport final : public GameObject, public TransportBase
|
||||
float GetTransportOrientation() const override { return GetOrientation(); }
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, o, GetPositionX(), GetPositionY(), GetPositionZ(), GetTransportOrientation());
|
||||
}
|
||||
Position GetPositionWithOffset(Position const& offset) const override { return Position::GetPositionWithOffset(offset); }
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o, GetPositionX(), GetPositionY(), GetPositionZ(), GetTransportOrientation());
|
||||
}
|
||||
Position GetPositionOffsetTo(Position const& endPos) const override { return Position::GetPositionOffsetTo(endPos); }
|
||||
|
||||
int32 GetMapIdForSpawning() const override;
|
||||
|
||||
|
||||
@@ -618,7 +618,7 @@ void Unit::UpdateSplinePosition()
|
||||
pos.SetOrientation(loc.orientation);
|
||||
|
||||
if (TransportBase* transport = GetDirectTransport())
|
||||
transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation);
|
||||
transport->GetPositionWithOffset(pos).GetPosition(loc.x, loc.y, loc.z, loc.orientation);
|
||||
else
|
||||
return;
|
||||
}
|
||||
@@ -12852,10 +12852,7 @@ void Unit::SendTeleportPacket(TeleportLocation const& teleportLocation)
|
||||
if (!transport)
|
||||
return;
|
||||
|
||||
float x, y, z, o;
|
||||
teleportLocation.Location.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
moveUpdateTeleport.Status->pos.Relocate(x, y, z, o);
|
||||
moveUpdateTeleport.Status->pos.Relocate(transport->GetPositionWithOffset(teleportLocation.Location));
|
||||
moveUpdateTeleport.Status->transport.pos.Relocate(teleportLocation.Location);
|
||||
}
|
||||
else
|
||||
@@ -13078,7 +13075,7 @@ void CharmInfo::SaveStayPosition()
|
||||
|
||||
if (_unit->movespline->onTransport)
|
||||
if (TransportBase* transport = _unit->GetDirectTransport())
|
||||
transport->CalculatePassengerPosition(stayPos.x, stayPos.y, stayPos.z);
|
||||
transport->GetPositionWithOffset({ stayPos.x, stayPos.y, stayPos.z }).GetPosition(stayPos.x, stayPos.y, stayPos.z);
|
||||
|
||||
_stayX = stayPos.x;
|
||||
_stayY = stayPos.y;
|
||||
|
||||
@@ -572,16 +572,12 @@ void Vehicle::RelocatePassengers()
|
||||
{
|
||||
ASSERT(passenger->IsInWorld());
|
||||
|
||||
float px, py, pz, po;
|
||||
passenger->m_movementInfo.transport.pos.GetPosition(px, py, pz, po);
|
||||
CalculatePassengerPosition(px, py, pz, &po);
|
||||
|
||||
seatRelocation.emplace_back(passenger, Position(px, py, pz, po));
|
||||
seatRelocation.emplace_back(passenger, _me->GetPositionWithOffset(passenger->m_movementInfo.transport.pos));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const& [passenger, position] : seatRelocation)
|
||||
UpdatePassengerPosition(_me->GetMap(), passenger, position.GetPositionX(), position.GetPositionY(), position.GetPositionZ(), position.GetOrientation(), false);
|
||||
UpdatePassengerPosition(_me->GetMap(), passenger, position, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,23 +95,13 @@ class TC_GAME_API Vehicle final : public TransportBase
|
||||
|
||||
float GetTransportOrientation() const override { return GetBase()->GetOrientation(); }
|
||||
|
||||
void AddPassenger(WorldObject* /*passenger*/) override { ABORT_MSG("Vehicle cannot directly gain passengers without auras"); }
|
||||
void AddPassenger(WorldObject* /*passenger*/, Position const& /*offset*/) override { ABORT_MSG("Vehicle cannot directly gain passengers without auras"); }
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= nullptr*/) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, o,
|
||||
GetBase()->GetPositionX(), GetBase()->GetPositionY(),
|
||||
GetBase()->GetPositionZ(), GetBase()->GetOrientation());
|
||||
}
|
||||
Position GetPositionWithOffset(Position const& offset) const override { return GetBase()->GetPositionWithOffset(offset); }
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= nullptr*/) const override
|
||||
{
|
||||
TransportBase::CalculatePassengerOffset(x, y, z, o,
|
||||
GetBase()->GetPositionX(), GetBase()->GetPositionY(),
|
||||
GetBase()->GetPositionZ(), GetBase()->GetOrientation());
|
||||
}
|
||||
Position GetPositionOffsetTo(Position const& endPos) const override { return GetBase()->GetPositionOffsetTo(endPos); }
|
||||
|
||||
int32 GetMapIdForSpawning() const override { return GetBase()->GetMapId(); }
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
#include "EnumFlag.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Optional.h"
|
||||
#include "Position.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -172,42 +175,18 @@ public:
|
||||
virtual ObjectGuid GetTransportGUID() const = 0;
|
||||
|
||||
/// This method transforms supplied transport offsets into global coordinates
|
||||
virtual void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const = 0;
|
||||
virtual Position GetPositionWithOffset(Position const& offset) const = 0;
|
||||
|
||||
/// This method transforms supplied global coordinates into local offsets
|
||||
virtual void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const = 0;
|
||||
virtual Position GetPositionOffsetTo(Position const& endPos) const = 0;
|
||||
|
||||
virtual float GetTransportOrientation() const = 0;
|
||||
|
||||
virtual void AddPassenger(WorldObject* passenger) = 0;
|
||||
virtual void AddPassenger(WorldObject* passenger, Position const& offset) = 0;
|
||||
|
||||
virtual TransportBase* RemovePassenger(WorldObject* passenger) = 0;
|
||||
|
||||
void UpdatePassengerPosition(Map* map, WorldObject* passenger, float x, float y, float z, float o, bool setHomePosition);
|
||||
|
||||
static void CalculatePassengerPosition(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
|
||||
{
|
||||
float inx = x, iny = y, inz = z;
|
||||
if (o)
|
||||
*o = Position::NormalizeOrientation(transO + *o);
|
||||
|
||||
x = transX + inx * std::cos(transO) - iny * std::sin(transO);
|
||||
y = transY + iny * std::cos(transO) + inx * std::sin(transO);
|
||||
z = transZ + inz;
|
||||
}
|
||||
|
||||
static void CalculatePassengerOffset(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
|
||||
{
|
||||
if (o)
|
||||
*o = Position::NormalizeOrientation(*o - transO);
|
||||
|
||||
z -= transZ;
|
||||
y -= transY; // y = searchedY * std::cos(o) + searchedX * std::sin(o)
|
||||
x -= transX; // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi)
|
||||
float inx = x, iny = y;
|
||||
y = (iny - inx * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
|
||||
x = (inx + iny * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
|
||||
}
|
||||
void UpdatePassengerPosition(Map* map, WorldObject* passenger, Position const& position, bool setHomePosition);
|
||||
|
||||
virtual int32 GetMapIdForSpawning() const = 0;
|
||||
};
|
||||
|
||||
@@ -670,7 +670,7 @@ GarrisonError Garrison::CheckBuildingRemoval(uint32 garrPlotInstanceId) const
|
||||
return GARRISON_SUCCESS;
|
||||
}
|
||||
|
||||
template<class T, void(T::*SecondaryRelocate)(float,float,float,float)>
|
||||
template<class T, void(T::*SecondaryRelocate)(Position const&)>
|
||||
T* BuildingSpawnHelper(GameObject* building, ObjectGuid::LowType spawnId, Map* map)
|
||||
{
|
||||
T* spawn = new T();
|
||||
@@ -680,14 +680,10 @@ T* BuildingSpawnHelper(GameObject* building, ObjectGuid::LowType spawnId, Map* m
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float x = spawn->GetPositionX();
|
||||
float y = spawn->GetPositionY();
|
||||
float z = spawn->GetPositionZ();
|
||||
float o = spawn->GetOrientation();
|
||||
TransportBase::CalculatePassengerPosition(x, y, z, &o, building->GetPositionX(), building->GetPositionY(), building->GetPositionZ(), building->GetOrientation());
|
||||
Position globalPosition = building->GetPositionWithOffset(spawn->GetPosition());
|
||||
|
||||
spawn->Relocate(x, y, z, o);
|
||||
(spawn->*SecondaryRelocate)(x, y, z, o);
|
||||
spawn->Relocate(globalPosition);
|
||||
(spawn->*SecondaryRelocate)(globalPosition);
|
||||
|
||||
if (!spawn->IsPositionValid())
|
||||
{
|
||||
|
||||
@@ -119,14 +119,13 @@ void WorldSession::HandleMoveWorldportAck()
|
||||
|
||||
if (player->m_teleport_dest.TransportGuid)
|
||||
{
|
||||
if (Transport* newTransport = newMap->GetTransport(*player->m_teleport_dest.TransportGuid))
|
||||
if (GameObject* go = newMap->GetTransport(*player->m_teleport_dest.TransportGuid))
|
||||
{
|
||||
newTransport->AddPassenger(player);
|
||||
player->m_movementInfo.transport.pos.Relocate(loc.Location);
|
||||
float x, y, z, o;
|
||||
loc.Location.GetPosition(x, y, z, o);
|
||||
newTransport->CalculatePassengerPosition(x, y, z, &o);
|
||||
player->Relocate(x, y, z, o);
|
||||
if (TransportBase* newTransport = go->ToTransportBase())
|
||||
{
|
||||
newTransport->AddPassenger(player, loc.Location);
|
||||
player->Relocate(newTransport->GetPositionWithOffset(loc.Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TransportBase* transport = player->GetTransport())
|
||||
@@ -297,14 +296,13 @@ void WorldSession::HandleMoveTeleportAck(WorldPackets::Movement::MoveTeleportAck
|
||||
|
||||
if (dest.TransportGuid)
|
||||
{
|
||||
if (Transport* transport = plMover->GetMap()->GetTransport(*dest.TransportGuid))
|
||||
if (GameObject* go = plMover->GetMap()->GetGameObject(*dest.TransportGuid))
|
||||
{
|
||||
transport->AddPassenger(plMover);
|
||||
plMover->m_movementInfo.transport.pos.Relocate(destLocation);
|
||||
float x, y, z, o;
|
||||
dest.Location.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
destLocation.Relocate(x, y, z, o);
|
||||
if (TransportBase* transport = go->ToTransportBase())
|
||||
{
|
||||
transport->AddPassenger(plMover, destLocation);
|
||||
destLocation.Relocate(transport->GetPositionWithOffset(plMover->m_movementInfo.transport.pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +395,7 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
|
||||
{
|
||||
if (GameObject* go = plrMover->GetMap()->GetGameObject(movementInfo.transport.guid))
|
||||
if (TransportBase* transport = go->ToTransportBase())
|
||||
transport->AddPassenger(plrMover);
|
||||
transport->AddPassenger(plrMover, movementInfo.transport.pos);
|
||||
}
|
||||
else if (plrMover->GetTransport()->GetTransportGUID() != movementInfo.transport.guid)
|
||||
{
|
||||
@@ -405,7 +403,7 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
|
||||
if (GameObject* go = plrMover->GetMap()->GetGameObject(movementInfo.transport.guid))
|
||||
{
|
||||
if (TransportBase* transport = go->ToTransportBase())
|
||||
transport->AddPassenger(plrMover);
|
||||
transport->AddPassenger(plrMover, movementInfo.transport.pos);
|
||||
else
|
||||
movementInfo.ResetTransport();
|
||||
}
|
||||
|
||||
@@ -1513,9 +1513,8 @@ bool Map::AreaTriggerCellRelocation(AreaTrigger* at, Cell new_cell)
|
||||
|
||||
bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
|
||||
{
|
||||
float resp_x, resp_y, resp_z, resp_o;
|
||||
c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
|
||||
Cell resp_cell(resp_x, resp_y);
|
||||
Position resp = c->GetRespawnPosition();
|
||||
Cell resp_cell(resp.GetPositionX(), resp.GetPositionY());
|
||||
|
||||
//creature will be unloaded with grid
|
||||
if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
|
||||
@@ -1531,7 +1530,7 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
|
||||
// teleport it to respawn point (like normal respawn if player see)
|
||||
if (CreatureCellRelocation(c, resp_cell))
|
||||
{
|
||||
c->Relocate(resp_x, resp_y, resp_z, resp_o);
|
||||
c->Relocate(resp);
|
||||
c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
|
||||
//CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord());
|
||||
c->UpdatePositionData();
|
||||
@@ -1544,9 +1543,8 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
|
||||
|
||||
bool Map::GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly)
|
||||
{
|
||||
float resp_x, resp_y, resp_z, resp_o;
|
||||
go->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
|
||||
Cell resp_cell(resp_x, resp_y);
|
||||
Position resp = go->GetRespawnPosition();
|
||||
Cell resp_cell(resp.GetPositionX(), resp.GetPositionY());
|
||||
|
||||
//GameObject will be unloaded with grid
|
||||
if (diffGridOnly && !go->GetCurrentCell().DiffGrid(resp_cell))
|
||||
@@ -1559,7 +1557,7 @@ bool Map::GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly)
|
||||
// teleport it to respawn point (like normal respawn if player see)
|
||||
if (GameObjectCellRelocation(go, resp_cell))
|
||||
{
|
||||
go->Relocate(resp_x, resp_y, resp_z, resp_o);
|
||||
go->Relocate(resp);
|
||||
go->UpdatePositionData();
|
||||
go->UpdateObjectVisibility(false);
|
||||
return true;
|
||||
@@ -2729,17 +2727,11 @@ void Map::AddToActive(WorldObject* obj)
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if (Creature* creature = obj->ToCreature(); !creature->IsPet() && creature->GetSpawnId())
|
||||
{
|
||||
respawnLocation.emplace();
|
||||
creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
|
||||
}
|
||||
respawnLocation = creature->GetRespawnPosition();
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
if (GameObject* gameObject = obj->ToGameObject(); gameObject->GetSpawnId())
|
||||
{
|
||||
respawnLocation.emplace();
|
||||
gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
|
||||
}
|
||||
respawnLocation = gameObject->GetRespawnPosition();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -2780,17 +2772,11 @@ void Map::RemoveFromActive(WorldObject* obj)
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if (Creature* creature = obj->ToCreature(); !creature->IsPet() && creature->GetSpawnId())
|
||||
{
|
||||
respawnLocation.emplace();
|
||||
creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
|
||||
}
|
||||
respawnLocation = creature->GetRespawnPosition();
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
if (GameObject* gameObject = obj->ToGameObject(); gameObject->GetSpawnId())
|
||||
{
|
||||
respawnLocation.emplace();
|
||||
gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
|
||||
}
|
||||
respawnLocation = gameObject->GetRespawnPosition();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -486,8 +486,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* owner, bool relaun
|
||||
{
|
||||
o -= trans->GetTransportOrientation();
|
||||
owner->SetTransportHomePosition(x, y, z, o);
|
||||
trans->CalculatePassengerPosition(x, y, z, &o);
|
||||
owner->SetHomePosition(x, y, z, o);
|
||||
owner->SetHomePosition(trans->GetPositionWithOffset(owner->GetTransportHomePosition()));
|
||||
}
|
||||
// else if (vehicle) - this should never happen, vehicle offsets are const
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Movement
|
||||
Vector3 operator()(Vector3 input) const
|
||||
{
|
||||
if (_transport)
|
||||
_transport->CalculatePassengerOffset(input.x, input.y, input.z);
|
||||
_transport->GetPositionOffsetTo({ input.x, input.y, input.z }).GetPosition(input.x, input.y, input.z);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -81,11 +81,8 @@ SpellDestination::SpellDestination(WorldObject const& wObj) : _position(wObj.Get
|
||||
void SpellDestination::Relocate(Position const& pos)
|
||||
{
|
||||
if (!_transportGUID.IsEmpty())
|
||||
{
|
||||
Position offset;
|
||||
_position.GetPositionOffsetTo(pos, offset);
|
||||
_transportOffset.RelocateOffset(offset);
|
||||
}
|
||||
_transportOffset.RelocateOffset(_position.GetPositionOffsetTo(pos));
|
||||
|
||||
_position.Relocate(pos);
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -554,16 +554,12 @@ struct battleground_strand_of_the_ancients : BattlegroundScript
|
||||
{
|
||||
if (TransportBase* transport = boat->ToTransportBase())
|
||||
{
|
||||
player->Relocate(spawnPositionOnTransport[_attackers]);
|
||||
transport->AddPassenger(player);
|
||||
player->m_movementInfo.transport.pos.Relocate(spawnPositionOnTransport[_attackers]);
|
||||
float x, y, z, o;
|
||||
spawnPositionOnTransport[_attackers].GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
player->Relocate(x, y, z, o);
|
||||
transport->AddPassenger(player, spawnPositionOnTransport[_attackers]);
|
||||
Position position = transport->GetPositionWithOffset(player->m_movementInfo.transport.pos);
|
||||
player->Relocate(position);
|
||||
|
||||
if (player->IsInWorld())
|
||||
player->NearTeleportTo({ x, y, z, o });
|
||||
player->NearTeleportTo(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,10 +632,7 @@ public:
|
||||
if (!transport || !creature)
|
||||
return;
|
||||
|
||||
float x, y, z, o;
|
||||
position.GetPosition(x, y, z, o);
|
||||
transport->CalculatePassengerPosition(x, y, z, &o);
|
||||
creature->SummonPersonalClone({ x, y, z, o }, TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
creature->SummonPersonalClone(transport->GetPositionWithOffset(position), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -567,18 +567,13 @@ struct gunship_npc_AI : public ScriptedAI
|
||||
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
|
||||
float x, y, z, o;
|
||||
Slot->TargetPosition.GetPosition(x, y, z, o);
|
||||
|
||||
me->SetTransportHomePosition(Slot->TargetPosition);
|
||||
float hx = x, hy = y, hz = z, ho = o;
|
||||
me->GetTransport()->CalculatePassengerPosition(hx, hy, hz, &ho);
|
||||
me->SetHomePosition(hx, hy, hz, ho);
|
||||
me->SetHomePosition(me->GetTransport()->GetPositionWithOffset(Slot->TargetPosition));
|
||||
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [pos = Slot->TargetPosition](Movement::MoveSplineInit& init)
|
||||
{
|
||||
init.DisableTransportPathTransformations();
|
||||
init.MoveTo(x, y, z, false);
|
||||
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false);
|
||||
};
|
||||
me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_CHARGE_PREPATH, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
|
||||
}
|
||||
@@ -1417,23 +1412,21 @@ struct npc_gunship_boarding_addAI : public gunship_npc_AI
|
||||
if (pointId == EVENT_CHARGE_PREPATH && Slot)
|
||||
{
|
||||
Position const& otherTransportPos = Instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE ? OrgrimsHammerTeleportExit : SkybreakerTeleportExit;
|
||||
float x, y, z, o;
|
||||
otherTransportPos.GetPosition(x, y, z, o);
|
||||
|
||||
TransportBase* myTransport = me->GetTransport();
|
||||
TransportBase const* myTransport = me->GetTransport();
|
||||
if (!myTransport)
|
||||
return;
|
||||
|
||||
if (Transport* destTransport = ObjectAccessor::GetTransport(*me, Instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE)))
|
||||
destTransport->CalculatePassengerPosition(x, y, z, &o);
|
||||
if (Transport const* destTransport = ObjectAccessor::GetTransport(*me, Instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE)))
|
||||
{
|
||||
Position globalPosition = destTransport->GetPositionWithOffset(otherTransportPos);
|
||||
|
||||
float angle = frand(0, float(M_PI) * 2.0f);
|
||||
x += 2.0f * std::cos(angle);
|
||||
y += 2.0f * std::sin(angle);
|
||||
float angle = frand(0, float(M_PI) * 2.0f);
|
||||
globalPosition.m_positionX += 2.0f * std::cos(angle);
|
||||
globalPosition.m_positionY += 2.0f * std::sin(angle);
|
||||
|
||||
me->SetHomePosition(x, y, z, o);
|
||||
myTransport->CalculatePassengerOffset(x, y, z, &o);
|
||||
me->SetTransportHomePosition(x, y, z, o);
|
||||
me->SetHomePosition(globalPosition);
|
||||
me->SetTransportHomePosition(myTransport->GetPositionOffsetTo(globalPosition));
|
||||
}
|
||||
|
||||
me->m_Events.AddEvent(new BattleExperienceEvent(me), me->m_Events.CalculateTime(BattleExperienceEvent::ExperiencedTimes[0]));
|
||||
DoCast(me, SPELL_BATTLE_EXPERIENCE, true);
|
||||
@@ -1974,10 +1967,7 @@ class spell_igb_teleport_to_enemy_ship : public SpellScript
|
||||
if (!dest || !target || !target->GetTransport())
|
||||
return;
|
||||
|
||||
float x, y, z, o;
|
||||
dest->GetPosition(x, y, z, o);
|
||||
target->GetTransport()->CalculatePassengerOffset(x, y, z, &o);
|
||||
target->m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
target->m_movementInfo.transport.pos.Relocate(target->GetTransport()->GetPositionOffsetTo(*dest));
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -504,9 +504,7 @@ struct boss_malygos : public BossAI
|
||||
break;
|
||||
case ACTION_HANDLE_RESPAWN:
|
||||
// Teleport to spawn position, we can't use normal relocate
|
||||
float x, y, z, o;
|
||||
me->GetRespawnPosition(x, y, z, &o);
|
||||
me->NearTeleportTo(x, y, z, o);
|
||||
me->NearTeleportTo(me->GetRespawnPosition());
|
||||
// Respawn Iris
|
||||
instance->SetData(DATA_RESPAWN_IRIS, 0);
|
||||
_despawned = false;
|
||||
|
||||
Reference in New Issue
Block a user