Core/Objects: ported and implement custom visibility range functionality for creatures and gameobjects. Gameobjects will now get their visbility range read from their template data while creatures can be modified at will. The initial visbility distance changes has been parsed from MoP difficulty data by Kilyana
This commit is contained in:
1 parent
1c07e94666
commit
7543c45c7c
10 files changed
+157
-47
No files matched your search
@@ -56,6 +56,16 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max)] =
|
||||
{
|
||||
DEFAULT_VISIBILITY_DISTANCE,
|
||||
VISIBILITY_DISTANCE_TINY,
|
||||
VISIBILITY_DISTANCE_SMALL,
|
||||
VISIBILITY_DISTANCE_LARGE,
|
||||
VISIBILITY_DISTANCE_GIGANTIC,
|
||||
MAX_VISIBILITY_DISTANCE
|
||||
};
|
||||
|
||||
Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
||||
{
|
||||
m_objectTypeId = TYPEID_OBJECT;
|
||||
@@ -1253,6 +1263,15 @@ void WorldObject::SetFarVisible(bool on)
|
||||
m_isFarVisible = on;
|
||||
}
|
||||
|
||||
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
|
||||
{
|
||||
ASSERT(type < VisibilityDistanceType::Max);
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
m_visibilityDistanceOverride = VisibilityDistances[AsUnderlyingType(type)];
|
||||
}
|
||||
|
||||
void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
{
|
||||
if (IsInWorld())
|
||||
@@ -1703,7 +1722,9 @@ float WorldObject::GetGridActivationRange() const
|
||||
|
||||
float WorldObject::GetVisibilityRange() const
|
||||
{
|
||||
if (IsFarVisible() && !ToPlayer())
|
||||
if (IsVisibilityOverriden() && !ToPlayer())
|
||||
return *m_visibilityDistanceOverride;
|
||||
else if (IsFarVisible() && !ToPlayer())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else
|
||||
return GetMap()->GetVisibilityRange();
|
||||
@@ -1715,7 +1736,9 @@ float WorldObject::GetSightRange(const WorldObject* target) const
|
||||
{
|
||||
if (ToPlayer())
|
||||
{
|
||||
if (target && target->IsFarVisible() && !target->ToPlayer())
|
||||
if (target && target->IsVisibilityOverriden() && !target->ToPlayer())
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
else if (target && target->IsFarVisible() && !target->ToPlayer())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
|
||||
return DEFAULT_VISIBILITY_INSTANCE;
|
||||
|
||||
Reference in new issue
Block a user