More cleanup of CanSeeOrDetect
This commit is contained in:
@@ -1394,11 +1394,8 @@ bool Creature::IsInvisibleDueToDespawn() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Creature::canSeeAlways(WorldObject const* obj) const
|
bool Creature::_CanAlwaysSee(WorldObject const* obj) const
|
||||||
{
|
{
|
||||||
if (Unit::canSeeAlways(obj))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (IsAIEnabled && AI()->CanSeeAlways(obj))
|
if (IsAIEnabled && AI()->CanSeeAlways(obj))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
|||||||
uint32 guid_transport;
|
uint32 guid_transport;
|
||||||
|
|
||||||
bool IsInvisibleDueToDespawn() const;
|
bool IsInvisibleDueToDespawn() const;
|
||||||
bool canSeeAlways(WorldObject const* obj) const;
|
bool _CanAlwaysSee(WorldObject const* obj) const;
|
||||||
private:
|
private:
|
||||||
//WaypointMovementGenerator vars
|
//WaypointMovementGenerator vars
|
||||||
uint32 m_waypointID;
|
uint32 m_waypointID;
|
||||||
|
|||||||
@@ -843,9 +843,9 @@ void GameObject::SaveRespawnTime()
|
|||||||
sObjectMgr->SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime);
|
sObjectMgr->SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameObject::isAlwaysVisibleFor(WorldObject const* seer) const
|
bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
|
||||||
{
|
{
|
||||||
if (WorldObject::isAlwaysVisibleFor(seer))
|
if (WorldObject::IsAlwaysVisibleFor(seer))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IsTransport())
|
if (IsTransport())
|
||||||
|
|||||||
@@ -752,7 +752,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
|||||||
|
|
||||||
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
|
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
|
||||||
|
|
||||||
bool isAlwaysVisibleFor(WorldObject const* seer) const;
|
bool IsAlwaysVisibleFor(WorldObject const* seer) const;
|
||||||
bool IsInvisibleDueToDespawn() const;
|
bool IsInvisibleDueToDespawn() const;
|
||||||
|
|
||||||
uint8 getLevelForTarget(WorldObject const* target) const
|
uint8 getLevelForTarget(WorldObject const* target) const
|
||||||
|
|||||||
@@ -1630,19 +1630,10 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
|||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (obj->IsNeverVisible())
|
if (obj->IsNeverVisible() || _CanNeverSee(obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GetMap() != obj->GetMap())
|
if (obj->IsAlwaysVisibleFor(this) || _CanAlwaysSee(obj))
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!InSamePhase(obj))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (obj->isAlwaysVisibleFor(this))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (canSeeAlways(obj))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool corpseCheck = false;
|
bool corpseCheck = false;
|
||||||
@@ -1699,13 +1690,13 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
|||||||
if (obj->IsInvisibleDueToDespawn())
|
if (obj->IsInvisibleDueToDespawn())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!canDetect(obj, ignoreStealth))
|
if (!_CanDetect(obj, ignoreStealth))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldObject::canDetect(WorldObject const* obj, bool ignoreStealth) const
|
bool WorldObject::_CanDetect(WorldObject const* obj, bool ignoreStealth) const
|
||||||
{
|
{
|
||||||
const WorldObject* seer = this;
|
const WorldObject* seer = this;
|
||||||
|
|
||||||
@@ -1714,19 +1705,19 @@ bool WorldObject::canDetect(WorldObject const* obj, bool ignoreStealth) const
|
|||||||
if (Unit* controller = thisUnit->GetCharmerOrOwner())
|
if (Unit* controller = thisUnit->GetCharmerOrOwner())
|
||||||
seer = controller;
|
seer = controller;
|
||||||
|
|
||||||
if (obj->isAlwaysDetectableFor(seer))
|
if (obj->IsAlwaysDetectableFor(seer))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!seer->canDetectInvisibilityOf(obj))
|
if (!seer->_CanDetectInvisibilityOf(obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ignoreStealth && !seer->canDetectStealthOf(obj))
|
if (!ignoreStealth && !seer->_CanDetectStealthOf(obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldObject::canDetectInvisibilityOf(WorldObject const* obj) const
|
bool WorldObject::_CanDetectInvisibilityOf(WorldObject const* obj) const
|
||||||
{
|
{
|
||||||
uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
|
uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
|
||||||
|
|
||||||
@@ -1757,7 +1748,7 @@ bool WorldObject::canDetectInvisibilityOf(WorldObject const* obj) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldObject::canDetectStealthOf(WorldObject const* obj) const
|
bool WorldObject::_CanDetectStealthOf(WorldObject const* obj) const
|
||||||
{
|
{
|
||||||
// Combat reach is the minimal distance (both in front and behind),
|
// Combat reach is the minimal distance (both in front and behind),
|
||||||
// and it is also used in the range calculation.
|
// and it is also used in the range calculation.
|
||||||
|
|||||||
@@ -682,7 +682,6 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
|
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
|
||||||
bool IsWithinDist2d(const Position* pos, float dist) const
|
bool IsWithinDist2d(const Position* pos, float dist) const
|
||||||
{ return IsInDist2d(pos, dist + GetObjectSize()); }
|
{ return IsInDist2d(pos, dist + GetObjectSize()); }
|
||||||
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
|
||||||
// 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) const
|
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||||
{
|
{
|
||||||
@@ -730,16 +729,10 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
virtual void SaveRespawnTime() {}
|
virtual void SaveRespawnTime() {}
|
||||||
void AddObjectToRemoveList();
|
void AddObjectToRemoveList();
|
||||||
|
|
||||||
virtual bool IsNeverVisible() const { return !IsInWorld(); }
|
virtual bool IsAlwaysVisibleFor(WorldObject const* /*seer*/) const { return false; }
|
||||||
virtual bool isAlwaysVisibleFor(WorldObject const* /*seer*/) const { return false; }
|
|
||||||
virtual bool IsInvisibleDueToDespawn() const { return false; }
|
virtual bool IsInvisibleDueToDespawn() const { return false; }
|
||||||
virtual bool canSeeAlways(WorldObject const* /*obj*/) const { return false; }
|
//difference from IsAlwaysVisibleFor: 1. after distance check; 2. use owner or charmer as seer
|
||||||
bool canDetect(WorldObject const* obj, bool ignoreStealth) const;
|
virtual bool IsAlwaysDetectableFor(WorldObject const* /*seer*/) const { return false; }
|
||||||
|
|
||||||
bool canDetectInvisibilityOf(WorldObject const* obj) const;
|
|
||||||
bool canDetectStealthOf(WorldObject const* obj) const;
|
|
||||||
|
|
||||||
virtual bool isAlwaysDetectableFor(WorldObject const* /*seer*/) const { return false; }
|
|
||||||
|
|
||||||
float GetGridActivationRange() const;
|
float GetGridActivationRange() const;
|
||||||
float GetVisibilityRange() const;
|
float GetVisibilityRange() const;
|
||||||
@@ -846,6 +839,7 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
void SetLocationMapId(uint32 _mapId) { m_mapId = _mapId; }
|
void SetLocationMapId(uint32 _mapId) { m_mapId = _mapId; }
|
||||||
void SetLocationInstanceId(uint32 _instanceId) { m_InstanceId = _instanceId; }
|
void SetLocationInstanceId(uint32 _instanceId) { m_InstanceId = _instanceId; }
|
||||||
|
|
||||||
|
virtual bool IsNeverVisible() const { return !IsInWorld(); }
|
||||||
private:
|
private:
|
||||||
Map* m_currMap; //current object's Map location
|
Map* m_currMap; //current object's Map location
|
||||||
|
|
||||||
@@ -855,6 +849,14 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
|
|
||||||
uint16 m_notifyflags;
|
uint16 m_notifyflags;
|
||||||
uint16 m_executed_notifies;
|
uint16 m_executed_notifies;
|
||||||
|
|
||||||
|
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
||||||
|
|
||||||
|
bool _CanNeverSee(WorldObject const* obj) const { return GetMap() != obj->GetMap() || !InSamePhase(obj); }
|
||||||
|
virtual bool _CanAlwaysSee(WorldObject const* /*obj*/) const { return false; }
|
||||||
|
bool _CanDetect(WorldObject const* obj, bool ignoreStealth) const;
|
||||||
|
bool _CanDetectInvisibilityOf(WorldObject const* obj) const;
|
||||||
|
bool _CanDetectStealthOf(WorldObject const* obj) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Trinity
|
namespace Trinity
|
||||||
|
|||||||
@@ -21088,11 +21088,8 @@ bool Player::IsNeverVisible() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::canSeeAlways(WorldObject const* obj) const
|
bool Player::_CanAlwaysSee(WorldObject const* obj) const
|
||||||
{
|
{
|
||||||
if (Unit::canSeeAlways(obj))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Always can see self
|
// Always can see self
|
||||||
if (m_mover == obj)
|
if (m_mover == obj)
|
||||||
return true;
|
return true;
|
||||||
@@ -21104,9 +21101,9 @@ bool Player::canSeeAlways(WorldObject const* obj) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::isAlwaysDetectableFor(WorldObject const* seer) const
|
bool Player::IsAlwaysDetectableFor(WorldObject const* seer) const
|
||||||
{
|
{
|
||||||
if (Unit::isAlwaysDetectableFor(seer))
|
if (Unit::IsAlwaysDetectableFor(seer))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (const Player* seerPlayer = seer->ToPlayer())
|
if (const Player* seerPlayer = seer->ToPlayer())
|
||||||
|
|||||||
@@ -2734,9 +2734,9 @@ class Player : public Unit, public GridObject<Player>
|
|||||||
Runes *m_runes;
|
Runes *m_runes;
|
||||||
EquipmentSets m_EquipmentSets;
|
EquipmentSets m_EquipmentSets;
|
||||||
|
|
||||||
bool canSeeAlways(WorldObject const* obj) const;
|
bool _CanAlwaysSee(WorldObject const* obj) const;
|
||||||
|
|
||||||
bool isAlwaysDetectableFor(WorldObject const* seer) const;
|
bool IsAlwaysDetectableFor(WorldObject const* seer) const;
|
||||||
|
|
||||||
uint8 m_grantableLevels;
|
uint8 m_grantableLevels;
|
||||||
|
|
||||||
|
|||||||
@@ -12393,9 +12393,9 @@ int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply)
|
|||||||
return ModifyPower(power, (int32)amount - (int32)GetMaxPower(power));
|
return ModifyPower(power, (int32)amount - (int32)GetMaxPower(power));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isAlwaysVisibleFor(WorldObject const* seer) const
|
bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const
|
||||||
{
|
{
|
||||||
if (WorldObject::isAlwaysVisibleFor(seer))
|
if (WorldObject::IsAlwaysVisibleFor(seer))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Always seen by owner
|
// Always seen by owner
|
||||||
@@ -12406,9 +12406,9 @@ bool Unit::isAlwaysVisibleFor(WorldObject const* seer) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isAlwaysDetectableFor(WorldObject const* seer) const
|
bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const
|
||||||
{
|
{
|
||||||
if (WorldObject::isAlwaysDetectableFor(seer))
|
if (WorldObject::IsAlwaysDetectableFor(seer))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, seer->GetGUID()))
|
if (HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, seer->GetGUID()))
|
||||||
|
|||||||
@@ -2283,8 +2283,8 @@ class Unit : public WorldObject
|
|||||||
|
|
||||||
uint32 m_unitTypeMask;
|
uint32 m_unitTypeMask;
|
||||||
|
|
||||||
bool isAlwaysVisibleFor(WorldObject const* seer) const;
|
bool IsAlwaysVisibleFor(WorldObject const* seer) const;
|
||||||
bool isAlwaysDetectableFor(WorldObject const* seer) const;
|
bool IsAlwaysDetectableFor(WorldObject const* seer) const;
|
||||||
private:
|
private:
|
||||||
bool IsTriggeredAtSpellProcEvent(Unit* pVictim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent);
|
bool IsTriggeredAtSpellProcEvent(Unit* pVictim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent);
|
||||||
bool HandleDummyAuraProc(Unit* pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
bool HandleDummyAuraProc(Unit* pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||||
|
|||||||
Reference in New Issue
Block a user