mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: Allow implicit targeting of serverside WorldObjects (#28827)
This commit is contained in:
@@ -75,7 +75,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
|
||||
|
||||
bool IsServerSide() const { return _areaTriggerTemplate->Id.IsServerSide; }
|
||||
|
||||
bool IsNeverVisibleFor(WorldObject const* seer) const override { return WorldObject::IsNeverVisibleFor(seer) || IsServerSide(); }
|
||||
bool IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects = false) const override { return WorldObject::IsNeverVisibleFor(seer) || (IsServerSide() && !allowServersideObjects); }
|
||||
|
||||
private:
|
||||
bool Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff);
|
||||
|
||||
@@ -1791,12 +1791,12 @@ void GameObject::SaveRespawnTime(uint32 forceDelay)
|
||||
}
|
||||
}
|
||||
|
||||
bool GameObject::IsNeverVisibleFor(WorldObject const* seer) const
|
||||
bool GameObject::IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects) const
|
||||
{
|
||||
if (WorldObject::IsNeverVisibleFor(seer))
|
||||
return true;
|
||||
|
||||
if (GetGOInfo()->GetServerOnly())
|
||||
if (GetGOInfo()->GetServerOnly() && !allowServersideObjects)
|
||||
return true;
|
||||
|
||||
if (!GetDisplayId())
|
||||
|
||||
@@ -304,7 +304,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
|
||||
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
|
||||
|
||||
bool IsNeverVisibleFor(WorldObject const* seer) const override;
|
||||
bool IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects = false) const override;
|
||||
bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
|
||||
bool IsInvisibleDueToDespawn(WorldObject const* seer) const override;
|
||||
|
||||
|
||||
@@ -1479,12 +1479,12 @@ SmoothPhasing* WorldObject::GetOrCreateSmoothPhasing()
|
||||
return _smoothPhasing.get();
|
||||
}
|
||||
|
||||
bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, bool distanceCheck, bool checkAlert) const
|
||||
bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool implicitDetect, bool distanceCheck, bool checkAlert) const
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj->IsNeverVisibleFor(this) || CanNeverSee(obj))
|
||||
if (obj->IsNeverVisibleFor(this, implicitDetect) || CanNeverSee(obj))
|
||||
return false;
|
||||
|
||||
if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
|
||||
@@ -1569,7 +1569,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
if (obj->IsInvisibleDueToDespawn(this))
|
||||
return false;
|
||||
|
||||
if (!CanDetect(obj, ignoreStealth, checkAlert))
|
||||
if (!CanDetect(obj, implicitDetect, checkAlert))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1580,7 +1580,7 @@ bool WorldObject::CanNeverSee(WorldObject const* obj) const
|
||||
return GetMap() != obj->GetMap() || !InSamePhase(obj);
|
||||
}
|
||||
|
||||
bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool checkAlert) const
|
||||
bool WorldObject::CanDetect(WorldObject const* obj, bool implicitDetect, bool checkAlert) const
|
||||
{
|
||||
WorldObject const* seer = this;
|
||||
|
||||
@@ -1600,10 +1600,10 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool che
|
||||
if (obj->IsAlwaysDetectableFor(seer))
|
||||
return true;
|
||||
|
||||
if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
|
||||
if (!implicitDetect && !seer->CanDetectInvisibilityOf(obj))
|
||||
return false;
|
||||
|
||||
if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
|
||||
if (!implicitDetect && !seer->CanDetectStealthOf(obj, checkAlert))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -595,7 +595,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
float GetGridActivationRange() const;
|
||||
float GetVisibilityRange() const;
|
||||
float GetSightRange(WorldObject const* target = nullptr) const;
|
||||
bool CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth = false, bool distanceCheck = false, bool checkAlert = false) const;
|
||||
bool CanSeeOrDetect(WorldObject const* obj, bool implicitDetect = false, bool distanceCheck = false, bool checkAlert = false) const;
|
||||
|
||||
FlaggedValuesArray32<int32, uint32, StealthType, TOTAL_STEALTH_TYPES> m_stealth;
|
||||
FlaggedValuesArray32<int32, uint32, StealthType, TOTAL_STEALTH_TYPES> m_stealthDetect;
|
||||
@@ -799,7 +799,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
virtual bool CanNeverSee(WorldObject const* obj) const;
|
||||
virtual bool CanAlwaysSee([[maybe_unused]] WorldObject const* /*obj*/) const { return false; }
|
||||
virtual bool IsNeverVisibleFor([[maybe_unused]] WorldObject const* seer) const { return !IsInWorld() || IsDestroyedObject(); }
|
||||
virtual bool IsNeverVisibleFor([[maybe_unused]] WorldObject const* seer, [[maybe_unused]] bool allowServersideObjects = false) const { return !IsInWorld() || IsDestroyedObject(); }
|
||||
virtual bool IsAlwaysVisibleFor([[maybe_unused]] WorldObject const* seer) const { return false; }
|
||||
virtual bool IsInvisibleDueToDespawn([[maybe_unused]] WorldObject const* seer) const { return false; }
|
||||
//difference from IsAlwaysVisibleFor: 1. after distance check; 2. use owner or charmer as seer
|
||||
|
||||
@@ -23341,9 +23341,9 @@ bool Player::HaveAtClient(Object const* u) const
|
||||
return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end();
|
||||
}
|
||||
|
||||
bool Player::IsNeverVisibleFor(WorldObject const* seer) const
|
||||
bool Player::IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects) const
|
||||
{
|
||||
if (Unit::IsNeverVisibleFor(seer))
|
||||
if (Unit::IsNeverVisibleFor(seer, allowServersideObjects))
|
||||
return true;
|
||||
|
||||
if (GetSession()->PlayerLogout() || GetSession()->PlayerLoading())
|
||||
|
||||
@@ -2513,7 +2513,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
|
||||
bool HaveAtClient(Object const* u) const;
|
||||
|
||||
bool IsNeverVisibleFor(WorldObject const* seer) const override;
|
||||
bool IsNeverVisibleFor(WorldObject const* seer, bool allowServersideObjects = false) const override;
|
||||
|
||||
bool IsVisibleGloballyFor(Player const* player) const;
|
||||
|
||||
|
||||
@@ -2138,7 +2138,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
|
||||
if (HasAttribute(SPELL_ATTR1_EXCLUDE_CASTER) && caster == target)
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
// check visibility - ignore stealth for implicit (area) targets
|
||||
// check visibility - ignore invisibility/stealth for implicit (area) targets
|
||||
if (!HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && !caster->CanSeeOrDetect(target, implicit))
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user