mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
refactor(Core): move complex functions from Object.h to Object.cpp (#9016)
Co-authored-by: QAston <qaston@gmail.com>
This commit is contained in:
@@ -291,6 +291,50 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
|
|||||||
target->GetSession()->SendPacket(&data);
|
target->GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int32 Object::GetInt32Value(uint16 index) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return m_int32Values[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] uint32 Object::GetUInt32Value(uint16 index) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return m_uint32Values[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] uint64 Object::GetUInt64Value(uint16 index) const
|
||||||
|
{
|
||||||
|
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return *((uint64*) &(m_uint32Values[index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float Object::GetFloatValue(uint16 index) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return m_floatValues[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] uint8 Object::GetByteValue(uint16 index, uint8 offset) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
ASSERT(offset < 4);
|
||||||
|
return *(((uint8*) &m_uint32Values[index]) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] uint16 Object::GetUInt16Value(uint16 index, uint8 offset) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
ASSERT(offset < 2);
|
||||||
|
return *(((uint16*) &m_uint32Values[index]) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ObjectGuid Object::GetGuidValue(uint16 index) const
|
||||||
|
{
|
||||||
|
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return *((ObjectGuid*) &(m_uint32Values[index]));
|
||||||
|
}
|
||||||
|
|
||||||
void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||||
{
|
{
|
||||||
Unit const* unit = nullptr;
|
Unit const* unit = nullptr;
|
||||||
@@ -773,6 +817,13 @@ void Object::ApplyModSignedFloatValue(uint16 index, float val, bool apply)
|
|||||||
SetFloatValue(index, cur);
|
SetFloatValue(index, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::ApplyPercentModFloatValue(uint16 index, float val, bool apply)
|
||||||
|
{
|
||||||
|
float value = GetFloatValue(index);
|
||||||
|
ApplyPercentModFloatVar(value, val, apply);
|
||||||
|
SetFloatValue(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
|
void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
|
||||||
{
|
{
|
||||||
float cur = GetFloatValue(index);
|
float cur = GetFloatValue(index);
|
||||||
@@ -814,6 +865,40 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::ToggleFlag(uint16 index, uint32 flag)
|
||||||
|
{
|
||||||
|
if (HasFlag(index, flag))
|
||||||
|
{
|
||||||
|
RemoveFlag(index, flag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFlag(index, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool Object::HasFlag(uint16 index, uint32 flag) const
|
||||||
|
{
|
||||||
|
if (index >= m_valuesCount && !PrintIndexError(index, false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (m_uint32Values[index] & flag) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::ApplyModFlag(uint16 index, uint32 flag, bool apply)
|
||||||
|
{
|
||||||
|
if (apply)
|
||||||
|
{
|
||||||
|
SetFlag(index, flag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemoveFlag(index, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
||||||
{
|
{
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||||
@@ -852,6 +937,57 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool Object::HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
ASSERT(offset < 4);
|
||||||
|
return (((uint8*) &m_uint32Values[index])[offset] & flag) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetFlag64(uint16 index, uint64 newFlag)
|
||||||
|
{
|
||||||
|
uint64 oldval = GetUInt64Value(index);
|
||||||
|
uint64 newval = oldval | newFlag;
|
||||||
|
SetUInt64Value(index, newval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::RemoveFlag64(uint16 index, uint64 oldFlag)
|
||||||
|
{
|
||||||
|
uint64 oldval = GetUInt64Value(index);
|
||||||
|
uint64 newval = oldval & ~oldFlag;
|
||||||
|
SetUInt64Value(index, newval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::ToggleFlag64(uint16 index, uint64 flag)
|
||||||
|
{
|
||||||
|
if (HasFlag64(index, flag))
|
||||||
|
{
|
||||||
|
RemoveFlag64(index, flag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFlag64(index, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool Object::HasFlag64(uint16 index, uint64 flag) const
|
||||||
|
{
|
||||||
|
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||||
|
return (GetUInt64Value(index) & flag) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::ApplyModFlag64(uint16 index, uint64 flag, bool apply)
|
||||||
|
{
|
||||||
|
if (apply)
|
||||||
|
{
|
||||||
|
SetFlag64(index, flag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemoveFlag64(index, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Object::PrintIndexError(uint32 index, bool set) const
|
bool Object::PrintIndexError(uint32 index, bool set) const
|
||||||
{
|
{
|
||||||
LOG_INFO("misc", "Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u",
|
LOG_INFO("misc", "Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u",
|
||||||
@@ -1154,6 +1290,87 @@ Position WorldObject::GetHitSpherePointFor(Position const& dest) const
|
|||||||
return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
|
return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float WorldObject::GetDistance(const WorldObject* obj) const
|
||||||
|
{
|
||||||
|
float d = GetExactDist(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||||
|
return d > 0.0f ? d : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float WorldObject::GetDistance(const Position& pos) const
|
||||||
|
{
|
||||||
|
float d = GetExactDist(&pos) - GetObjectSize();
|
||||||
|
return d > 0.0f ? d : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float WorldObject::GetDistance(float x, float y, float z) const
|
||||||
|
{
|
||||||
|
float d = GetExactDist(x, y, z) - GetObjectSize();
|
||||||
|
return d > 0.0f ? d : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float WorldObject::GetDistance2d(const WorldObject* obj) const
|
||||||
|
{
|
||||||
|
float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||||
|
return d > 0.0f ? d : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float WorldObject::GetDistance2d(float x, float y) const
|
||||||
|
{
|
||||||
|
float d = GetExactDist2d(x, y) - GetObjectSize();
|
||||||
|
return d > 0.0f ? d : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldObject::IsSelfOrInSameMap(const WorldObject* obj) const
|
||||||
|
{
|
||||||
|
if (this == obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsInMap(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldObject::IsInMap(const WorldObject* obj) const
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
return IsInWorld() && obj->IsInWorld() && (FindMap() == obj->FindMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist) const
|
||||||
|
{
|
||||||
|
return IsInDist(x, y, z, dist + GetObjectSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldObject::IsWithinDist3d(const Position* pos, float dist) const
|
||||||
|
{
|
||||||
|
return IsInDist(pos, dist + GetObjectSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool WorldObject::IsWithinDist2d(float x, float y, float dist) const
|
||||||
|
{
|
||||||
|
return IsInDist2d(x, y, dist + GetObjectSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldObject::IsWithinDist2d(const Position* pos, float dist) const
|
||||||
|
{
|
||||||
|
return IsInDist2d(pos, dist + GetObjectSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// use only if you will sure about placing both object at same map
|
||||||
|
bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius) const
|
||||||
|
{
|
||||||
|
return obj && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius) const
|
||||||
|
{
|
||||||
|
return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius);
|
||||||
|
}
|
||||||
|
|
||||||
bool WorldObject::IsWithinLOS(float ox, float oy, float oz, LineOfSightChecks checks) const
|
bool WorldObject::IsWithinLOS(float ox, float oy, float oz, LineOfSightChecks checks) const
|
||||||
{
|
{
|
||||||
if (IsInWorld())
|
if (IsInWorld())
|
||||||
@@ -1467,6 +1684,13 @@ void WorldObject::GetRandomPoint(const Position& pos, float distance, float& ran
|
|||||||
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
|
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldObject::GetRandomPoint(const Position& srcPos, float distance, Position& pos) const
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
GetRandomPoint(srcPos, distance, x, y, z);
|
||||||
|
pos.Relocate(x, y, z, GetOrientation());
|
||||||
|
}
|
||||||
|
|
||||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||||
{
|
{
|
||||||
float new_z = GetMapHeight(x, y, z);
|
float new_z = GetMapHeight(x, y, z);
|
||||||
@@ -2149,6 +2373,18 @@ void Map::SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list /*= null
|
|||||||
list->push_back(summon);
|
list->push_back(summon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, SummonPropertiesEntry const* properties)
|
||||||
|
{
|
||||||
|
if (!x && !y && !z)
|
||||||
|
{
|
||||||
|
GetClosePoint(x, y, z, GetObjectSize());
|
||||||
|
ang = GetOrientation();
|
||||||
|
}
|
||||||
|
Position pos;
|
||||||
|
pos.Relocate(x, y, z, ang);
|
||||||
|
return SummonCreature(id, pos, spwtype, despwtime, 0, properties);
|
||||||
|
}
|
||||||
|
|
||||||
GameObject* Map::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport)
|
GameObject* Map::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport)
|
||||||
{
|
{
|
||||||
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
|
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
|
||||||
@@ -2561,6 +2797,24 @@ bool WorldObject::GetClosePoint(float& x, float& y, float& z, float size, float
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldObject::GetNearPosition(Position& pos, float dist, float angle)
|
||||||
|
{
|
||||||
|
GetPosition(&pos);
|
||||||
|
MovePosition(pos, dist, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldObject::GetFirstCollisionPosition(Position& pos, float dist, float angle)
|
||||||
|
{
|
||||||
|
GetPosition(&pos);
|
||||||
|
MovePositionToFirstCollision(pos, dist, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldObject::GetRandomNearPosition(Position& pos, float radius)
|
||||||
|
{
|
||||||
|
GetPosition(&pos);
|
||||||
|
MovePosition(pos, radius * (float) rand_norm(), (float) rand_norm() * static_cast<float>(2 * M_PI));
|
||||||
|
}
|
||||||
|
|
||||||
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||||
{
|
{
|
||||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||||
@@ -2589,6 +2843,11 @@ void WorldObject::GetChargeContactPoint(const WorldObject* obj, float& x, float&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float WorldObject::GetObjectSize() const
|
||||||
|
{
|
||||||
|
return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE * GetObjectScale();
|
||||||
|
}
|
||||||
|
|
||||||
void WorldObject::MovePosition(Position& pos, float dist, float angle)
|
void WorldObject::MovePosition(Position& pos, float dist, float angle)
|
||||||
{
|
{
|
||||||
angle += m_orientation;
|
angle += m_orientation;
|
||||||
|
|||||||
@@ -116,49 +116,13 @@ public:
|
|||||||
|
|
||||||
virtual void DestroyForPlayer(Player* target, bool onDeath = false) const;
|
virtual void DestroyForPlayer(Player* target, bool onDeath = false) const;
|
||||||
|
|
||||||
[[nodiscard]] int32 GetInt32Value(uint16 index) const
|
[[nodiscard]] int32 GetInt32Value(uint16 index) const;
|
||||||
{
|
[[nodiscard]] uint32 GetUInt32Value(uint16 index) const;
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
[[nodiscard]] uint64 GetUInt64Value(uint16 index) const;
|
||||||
return m_int32Values[index];
|
[[nodiscard]] float GetFloatValue(uint16 index) const;
|
||||||
}
|
[[nodiscard]] uint8 GetByteValue(uint16 index, uint8 offset) const;
|
||||||
|
[[nodiscard]] uint16 GetUInt16Value(uint16 index, uint8 offset) const;
|
||||||
[[nodiscard]] uint32 GetUInt32Value(uint16 index) const
|
[[nodiscard]] ObjectGuid GetGuidValue(uint16 index) const;
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
return m_uint32Values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] uint64 GetUInt64Value(uint16 index) const
|
|
||||||
{
|
|
||||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
return *((uint64*) & (m_uint32Values[index]));
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] float GetFloatValue(uint16 index) const
|
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
return m_floatValues[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] uint8 GetByteValue(uint16 index, uint8 offset) const
|
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
ASSERT(offset < 4);
|
|
||||||
return *(((uint8*)&m_uint32Values[index]) + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] uint16 GetUInt16Value(uint16 index, uint8 offset) const
|
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
ASSERT(offset < 2);
|
|
||||||
return *(((uint16*)&m_uint32Values[index]) + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] ObjectGuid GetGuidValue(uint16 index) const
|
|
||||||
{
|
|
||||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
return *((ObjectGuid*)&(m_uint32Values[index]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetInt32Value(uint16 index, int32 value);
|
void SetInt32Value(uint16 index, int32 value);
|
||||||
void SetUInt32Value(uint16 index, uint32 value);
|
void SetUInt32Value(uint16 index, uint32 value);
|
||||||
@@ -180,90 +144,23 @@ public:
|
|||||||
void ApplyModUInt64Value(uint16 index, int32 val, bool apply);
|
void ApplyModUInt64Value(uint16 index, int32 val, bool apply);
|
||||||
void ApplyModPositiveFloatValue(uint16 index, float val, bool apply);
|
void ApplyModPositiveFloatValue(uint16 index, float val, bool apply);
|
||||||
void ApplyModSignedFloatValue(uint16 index, float val, bool apply);
|
void ApplyModSignedFloatValue(uint16 index, float val, bool apply);
|
||||||
|
void ApplyPercentModFloatValue(uint16 index, float val, bool apply);
|
||||||
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
|
|
||||||
{
|
|
||||||
float value = GetFloatValue(index);
|
|
||||||
ApplyPercentModFloatVar(value, val, apply);
|
|
||||||
SetFloatValue(index, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFlag(uint16 index, uint32 newFlag);
|
void SetFlag(uint16 index, uint32 newFlag);
|
||||||
void RemoveFlag(uint16 index, uint32 oldFlag);
|
void RemoveFlag(uint16 index, uint32 oldFlag);
|
||||||
|
void ToggleFlag(uint16 index, uint32 flag);
|
||||||
void ToggleFlag(uint16 index, uint32 flag)
|
[[nodiscard]] bool HasFlag(uint16 index, uint32 flag) const;
|
||||||
{
|
void ApplyModFlag(uint16 index, uint32 flag, bool apply);
|
||||||
if (HasFlag(index, flag))
|
|
||||||
RemoveFlag(index, flag);
|
|
||||||
else
|
|
||||||
SetFlag(index, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool HasFlag(uint16 index, uint32 flag) const
|
|
||||||
{
|
|
||||||
if (index >= m_valuesCount && !PrintIndexError(index, false))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (m_uint32Values[index] & flag) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
||||||
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
||||||
|
[[nodiscard]] bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const;
|
||||||
|
|
||||||
void ToggleFlag(uint16 index, uint8 offset, uint8 flag)
|
void SetFlag64(uint16 index, uint64 newFlag);
|
||||||
{
|
void RemoveFlag64(uint16 index, uint64 oldFlag);
|
||||||
if (HasByteFlag(index, offset, flag))
|
void ToggleFlag64(uint16 index, uint64 flag);
|
||||||
RemoveByteFlag(index, offset, flag);
|
[[nodiscard]] bool HasFlag64(uint16 index, uint64 flag) const;
|
||||||
else
|
void ApplyModFlag64(uint16 index, uint64 flag, bool apply);
|
||||||
SetByteFlag(index, offset, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
|
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
ASSERT(offset < 4);
|
|
||||||
return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
|
|
||||||
{
|
|
||||||
if (apply) SetFlag(index, flag);
|
|
||||||
else RemoveFlag(index, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFlag64(uint16 index, uint64 newFlag)
|
|
||||||
{
|
|
||||||
uint64 oldval = GetUInt64Value(index);
|
|
||||||
uint64 newval = oldval | newFlag;
|
|
||||||
SetUInt64Value(index, newval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveFlag64(uint16 index, uint64 oldFlag)
|
|
||||||
{
|
|
||||||
uint64 oldval = GetUInt64Value(index);
|
|
||||||
uint64 newval = oldval & ~oldFlag;
|
|
||||||
SetUInt64Value(index, newval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToggleFlag64(uint16 index, uint64 flag)
|
|
||||||
{
|
|
||||||
if (HasFlag64(index, flag))
|
|
||||||
RemoveFlag64(index, flag);
|
|
||||||
else
|
|
||||||
SetFlag64(index, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool HasFlag64(uint16 index, uint64 flag) const
|
|
||||||
{
|
|
||||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
|
||||||
return (GetUInt64Value(index) & flag) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplyModFlag64(uint16 index, uint64 flag, bool apply)
|
|
||||||
{
|
|
||||||
if (apply) SetFlag64(index, flag);
|
|
||||||
else RemoveFlag64(index, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClearUpdateMask(bool remove);
|
void ClearUpdateMask(bool remove);
|
||||||
|
|
||||||
@@ -800,45 +697,25 @@ public:
|
|||||||
void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const;
|
void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const;
|
||||||
bool GetClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = nullptr, bool force = false) const;
|
bool GetClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = nullptr, bool force = false) const;
|
||||||
void MovePosition(Position& pos, float dist, float angle);
|
void MovePosition(Position& pos, float dist, float angle);
|
||||||
void GetNearPosition(Position& pos, float dist, float angle)
|
void GetNearPosition(Position& pos, float dist, float angle);
|
||||||
{
|
|
||||||
GetPosition(&pos);
|
|
||||||
MovePosition(pos, dist, angle);
|
|
||||||
}
|
|
||||||
void MovePositionToFirstCollision(Position& pos, float dist, float angle);
|
void MovePositionToFirstCollision(Position& pos, float dist, float angle);
|
||||||
Position GetFirstCollisionPosition(float startX, float startY, float startZ, float destX, float destY);
|
Position GetFirstCollisionPosition(float startX, float startY, float startZ, float destX, float destY);
|
||||||
Position GetFirstCollisionPosition(float destX, float destY, float destZ);
|
Position GetFirstCollisionPosition(float destX, float destY, float destZ);
|
||||||
Position GetFirstCollisionPosition(float dist, float angle);
|
Position GetFirstCollisionPosition(float dist, float angle);
|
||||||
void GetFirstCollisionPosition(Position& pos, float dist, float angle)
|
void GetFirstCollisionPosition(Position& pos, float dist, float angle);
|
||||||
{
|
void GetRandomNearPosition(Position& pos, float radius);
|
||||||
GetPosition(&pos);
|
|
||||||
MovePositionToFirstCollision(pos, dist, angle);
|
|
||||||
}
|
|
||||||
void GetRandomNearPosition(Position& pos, float radius)
|
|
||||||
{
|
|
||||||
GetPosition(&pos);
|
|
||||||
MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
||||||
void GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
void GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
||||||
|
|
||||||
[[nodiscard]] float GetObjectSize() const
|
[[nodiscard]] float GetObjectSize() const;
|
||||||
{
|
|
||||||
return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE * GetObjectScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] virtual float GetCombatReach() const { return 0.0f; } // overridden (only) in Unit
|
[[nodiscard]] virtual float GetCombatReach() const { return 0.0f; } // overridden (only) in Unit
|
||||||
void UpdateGroundPositionZ(float x, float y, float& z) const;
|
void UpdateGroundPositionZ(float x, float y, float& z) const;
|
||||||
void UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ = nullptr) const;
|
void UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ = nullptr) const;
|
||||||
|
|
||||||
void GetRandomPoint(const Position& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const;
|
void GetRandomPoint(const Position& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const;
|
||||||
void GetRandomPoint(const Position& srcPos, float distance, Position& pos) const
|
void GetRandomPoint(const Position& srcPos, float distance, Position& pos) const;
|
||||||
{
|
|
||||||
float x, y, z;
|
|
||||||
GetRandomPoint(srcPos, distance, x, y, z);
|
|
||||||
pos.Relocate(x, y, z, GetOrientation());
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] uint32 GetInstanceId() const { return m_InstanceId; }
|
[[nodiscard]] uint32 GetInstanceId() const { return m_InstanceId; }
|
||||||
|
|
||||||
@@ -860,62 +737,22 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; }
|
[[nodiscard]] virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; }
|
||||||
|
|
||||||
float GetDistance(const WorldObject* obj) const
|
float GetDistance(const WorldObject* obj) const;
|
||||||
{
|
[[nodiscard]] float GetDistance(const Position& pos) const;
|
||||||
float d = GetExactDist(obj) - GetObjectSize() - obj->GetObjectSize();
|
[[nodiscard]] float GetDistance(float x, float y, float z) const;
|
||||||
return d > 0.0f ? d : 0.0f;
|
float GetDistance2d(const WorldObject* obj) const;
|
||||||
}
|
[[nodiscard]] float GetDistance2d(float x, float y) const;
|
||||||
[[nodiscard]] float GetDistance(const Position& pos) const
|
|
||||||
{
|
|
||||||
float d = GetExactDist(&pos) - GetObjectSize();
|
|
||||||
return d > 0.0f ? d : 0.0f;
|
|
||||||
}
|
|
||||||
[[nodiscard]] float GetDistance(float x, float y, float z) const
|
|
||||||
{
|
|
||||||
float d = GetExactDist(x, y, z) - GetObjectSize();
|
|
||||||
return d > 0.0f ? d : 0.0f;
|
|
||||||
}
|
|
||||||
float GetDistance2d(const WorldObject* obj) const
|
|
||||||
{
|
|
||||||
float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
|
|
||||||
return d > 0.0f ? d : 0.0f;
|
|
||||||
}
|
|
||||||
[[nodiscard]] float GetDistance2d(float x, float y) const
|
|
||||||
{
|
|
||||||
float d = GetExactDist2d(x, y) - GetObjectSize();
|
|
||||||
return d > 0.0f ? d : 0.0f;
|
|
||||||
}
|
|
||||||
float GetDistanceZ(const WorldObject* obj) const;
|
float GetDistanceZ(const WorldObject* obj) const;
|
||||||
|
|
||||||
bool IsSelfOrInSameMap(const WorldObject* obj) const
|
bool IsSelfOrInSameMap(const WorldObject* obj) const;
|
||||||
{
|
bool IsInMap(const WorldObject* obj) const;
|
||||||
if (this == obj)
|
[[nodiscard]] bool IsWithinDist3d(float x, float y, float z, float dist) const;
|
||||||
return true;
|
bool IsWithinDist3d(const Position* pos, float dist) const;
|
||||||
return IsInMap(obj);
|
[[nodiscard]] bool IsWithinDist2d(float x, float y, float dist) const;
|
||||||
}
|
bool IsWithinDist2d(const Position* pos, float dist) const;
|
||||||
bool IsInMap(const WorldObject* obj) const
|
|
||||||
{
|
|
||||||
if (obj)
|
|
||||||
return IsInWorld() && obj->IsInWorld() && (FindMap() == obj->FindMap());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
[[nodiscard]] bool IsWithinDist3d(float x, float y, float z, float dist) const
|
|
||||||
{ return IsInDist(x, y, z, dist + GetObjectSize()); }
|
|
||||||
bool IsWithinDist3d(const Position* pos, float dist) const
|
|
||||||
{ return IsInDist(pos, dist + GetObjectSize()); }
|
|
||||||
[[nodiscard]] bool IsWithinDist2d(float x, float y, float dist) const
|
|
||||||
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
|
|
||||||
bool IsWithinDist2d(const Position* pos, float dist) const
|
|
||||||
{ return IsInDist2d(pos, dist + GetObjectSize()); }
|
|
||||||
// use only if you will sure about placing both object at same map
|
// use only if you will sure about placing both object at same map
|
||||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const
|
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const;
|
||||||
{
|
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const;
|
||||||
return obj && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius);
|
|
||||||
}
|
|
||||||
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const
|
|
||||||
{
|
|
||||||
return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius);
|
|
||||||
}
|
|
||||||
[[nodiscard]] bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS) const;
|
[[nodiscard]] bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS) const;
|
||||||
bool IsWithinLOSInMap(WorldObject const* obj, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS) const;
|
bool IsWithinLOSInMap(WorldObject const* obj, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS) const;
|
||||||
[[nodiscard]] Position GetHitSpherePointFor(Position const& dest) const;
|
[[nodiscard]] Position GetHitSpherePointFor(Position const& dest) const;
|
||||||
@@ -975,17 +812,7 @@ public:
|
|||||||
[[nodiscard]] ZoneScript* GetZoneScript() const { return m_zoneScript; }
|
[[nodiscard]] ZoneScript* GetZoneScript() const { return m_zoneScript; }
|
||||||
|
|
||||||
TempSummon* SummonCreature(uint32 id, const Position& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0, SummonPropertiesEntry const* properties = nullptr) const;
|
TempSummon* SummonCreature(uint32 id, const Position& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0, SummonPropertiesEntry const* properties = nullptr) const;
|
||||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, SummonPropertiesEntry const* properties = nullptr)
|
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, SummonPropertiesEntry const* properties = nullptr);
|
||||||
{
|
|
||||||
if (!x && !y && !z)
|
|
||||||
{
|
|
||||||
GetClosePoint(x, y, z, GetObjectSize());
|
|
||||||
ang = GetOrientation();
|
|
||||||
}
|
|
||||||
Position pos;
|
|
||||||
pos.Relocate(x, y, z, ang);
|
|
||||||
return SummonCreature(id, pos, spwtype, despwtime, 0, properties);
|
|
||||||
}
|
|
||||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true);
|
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true);
|
||||||
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel = false, CreatureAI * (*GetAI)(Creature*) = nullptr);
|
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel = false, CreatureAI * (*GetAI)(Creature*) = nullptr);
|
||||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user