mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 21:56:22 +00:00
fix(Core/Spells): Far Sight auras are supposed to extend view distance and allows seeing objects from further distance (#7068)
- Closes #5793.
This commit is contained in:
@@ -1670,6 +1670,11 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
|
||||
if (thisPlayer->GetViewpoint())
|
||||
viewpoint = thisPlayer->GetViewpoint();
|
||||
|
||||
if (thisPlayer->GetFarSightDistance() && !thisPlayer->isInFront(obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Xinef: check reversely obj vs viewpoint, object could be a gameObject which overrides _IsWithinDist function to include gameobject size
|
||||
|
||||
@@ -919,7 +919,7 @@ public:
|
||||
|
||||
[[nodiscard]] float GetGridActivationRange() const;
|
||||
[[nodiscard]] float GetVisibilityRange() const;
|
||||
float GetSightRange(const WorldObject* target = nullptr) const;
|
||||
virtual float GetSightRange(const WorldObject* target = nullptr) const;
|
||||
//bool CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth = false, bool distanceCheck = false) const;
|
||||
bool CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth = false, bool distanceCheck = false, bool checkAlert = false) const;
|
||||
|
||||
|
||||
@@ -15154,3 +15154,29 @@ void Player::SetServerSideVisibilityDetect(ServerSideVisibilityType type, Accoun
|
||||
|
||||
m_serverSideVisibilityDetect.SetValue(type, sec);
|
||||
}
|
||||
|
||||
void Player::SetFarSightDistance(float radius)
|
||||
{
|
||||
_farSightDistance = radius;
|
||||
}
|
||||
|
||||
void Player::ResetFarSightDistance()
|
||||
{
|
||||
_farSightDistance.reset();
|
||||
}
|
||||
|
||||
Optional<float> Player::GetFarSightDistance() const
|
||||
{
|
||||
return _farSightDistance;
|
||||
}
|
||||
|
||||
float Player::GetSightRange(const WorldObject* target) const
|
||||
{
|
||||
float sightRange = WorldObject::GetSightRange(target);
|
||||
if (_farSightDistance)
|
||||
{
|
||||
sightRange += *_farSightDistance;
|
||||
}
|
||||
|
||||
return sightRange;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "KillRewarder.h"
|
||||
#include "MapReference.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Optional.h"
|
||||
#include "PetDefines.h"
|
||||
#include "PlayerTaxi.h"
|
||||
#include "QuestDef.h"
|
||||
@@ -2521,7 +2522,13 @@ public:
|
||||
std::string GetMapAreaAndZoneString();
|
||||
std::string GetCoordsMapAreaAndZoneString();
|
||||
|
||||
protected:
|
||||
void SetFarSightDistance(float radius);
|
||||
void ResetFarSightDistance();
|
||||
Optional<float> GetFarSightDistance() const;
|
||||
|
||||
float GetSightRange(const WorldObject* target = nullptr) const override;
|
||||
|
||||
protected:
|
||||
// Gamemaster whisper whitelist
|
||||
WhisperListContainer WhisperList;
|
||||
|
||||
@@ -2874,6 +2881,8 @@ private:
|
||||
Creature* m_CinematicObject;
|
||||
|
||||
WorldLocation _corpseLocation;
|
||||
|
||||
Optional<float> _farSightDistance = { };
|
||||
};
|
||||
|
||||
void AddItemsSetItem(Player* player, Item* item);
|
||||
|
||||
@@ -19173,8 +19173,13 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation);
|
||||
}
|
||||
else if (turn)
|
||||
{
|
||||
UpdateOrientation(orientation);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetFarSightDistance())
|
||||
UpdateObjectVisibility(false);
|
||||
}
|
||||
|
||||
return (relocated || turn);
|
||||
}
|
||||
|
||||
@@ -19687,24 +19692,31 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
|
||||
if (active->IsVehicle())
|
||||
active = player;
|
||||
|
||||
float dx = active->m_last_notify_position.GetPositionX() - active->GetPositionX();
|
||||
float dy = active->m_last_notify_position.GetPositionY() - active->GetPositionY();
|
||||
float dz = active->m_last_notify_position.GetPositionZ() - active->GetPositionZ();
|
||||
float distsq = dx * dx + dy * dy + dz * dz;
|
||||
if (!player->GetFarSightDistance())
|
||||
{
|
||||
float dx = active->m_last_notify_position.GetPositionX() - active->GetPositionX();
|
||||
float dy = active->m_last_notify_position.GetPositionY() - active->GetPositionY();
|
||||
float dz = active->m_last_notify_position.GetPositionZ() - active->GetPositionZ();
|
||||
float distsq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(active->FindMap()->GetEntry()->map_type);
|
||||
if (distsq < mindistsq)
|
||||
return;
|
||||
float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(active->FindMap()->GetEntry()->map_type);
|
||||
if (distsq < mindistsq)
|
||||
return;
|
||||
|
||||
active->m_last_notify_position.Relocate(active->GetPositionX(), active->GetPositionY(), active->GetPositionZ());
|
||||
active->m_last_notify_position.Relocate(active->GetPositionX(), active->GetPositionY(), active->GetPositionZ());
|
||||
}
|
||||
}
|
||||
|
||||
Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance
|
||||
Cell::VisitAllObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
|
||||
relocateNoLarge.SendToSelf();
|
||||
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance
|
||||
Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
|
||||
relocateLarge.SendToSelf();
|
||||
|
||||
if (!player->GetFarSightDistance())
|
||||
{
|
||||
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance
|
||||
Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
|
||||
relocateLarge.SendToSelf();
|
||||
}
|
||||
|
||||
this->AddToNotify(NOTIFY_AI_RELOCATION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user