mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Auras: Store non-unit caster guids in auras (#27625)
This allows retrieving any caster object, not just units
This commit is contained in:
@@ -3064,14 +3064,6 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo)
|
||||
if (!createInfo.CasterGUID && !createInfo.GetSpellInfo()->IsStackableOnOneSlotWithDifferentCasters())
|
||||
createInfo.CasterGUID = createInfo.Caster->GetGUID();
|
||||
|
||||
// world gameobjects can't own auras and they send empty casterguid
|
||||
// checked on sniffs with spell 22247
|
||||
if (createInfo.CasterGUID.IsGameObject())
|
||||
{
|
||||
createInfo.Caster = nullptr;
|
||||
createInfo.CasterGUID.Clear();
|
||||
}
|
||||
|
||||
// passive and Incanter's Absorption and auras with different type can stack with themselves any number of times
|
||||
if (!createInfo.GetSpellInfo()->IsMultiSlotAura())
|
||||
{
|
||||
|
||||
@@ -249,7 +249,9 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
|
||||
// send stack amount for aura which could be stacked (never 0 - causes incorrect display) or charges
|
||||
// stack amount has priority over charges (checked on retail with spell 50262)
|
||||
auraData.Applications = aura->IsUsingStacks() ? aura->GetStackAmount() : aura->GetCharges();
|
||||
if (!(auraData.Flags & AFLAG_NOCASTER))
|
||||
if (!aura->GetCasterGUID().IsUnit())
|
||||
auraData.CastUnit = ObjectGuid::Empty; // optional data is filled in, but cast unit contains empty guid in packet
|
||||
else if (!(auraData.Flags & AFLAG_NOCASTER))
|
||||
auraData.CastUnit = aura->GetCasterGUID();
|
||||
|
||||
if (auraData.Flags & AFLAG_DURATION)
|
||||
@@ -392,14 +394,7 @@ Aura* Aura::Create(AuraCreateInfo& createInfo)
|
||||
// try to get caster of aura
|
||||
if (!createInfo.CasterGUID.IsEmpty())
|
||||
{
|
||||
// world gameobjects can't own auras and they send empty casterguid
|
||||
// checked on sniffs with spell 22247
|
||||
if (createInfo.CasterGUID.IsGameObject())
|
||||
{
|
||||
createInfo.Caster = nullptr;
|
||||
createInfo.CasterGUID.Clear();
|
||||
}
|
||||
else
|
||||
if (createInfo.CasterGUID.IsUnit())
|
||||
{
|
||||
if (createInfo._owner->GetGUID() == createInfo.CasterGUID)
|
||||
createInfo.Caster = createInfo._owner->ToUnit();
|
||||
@@ -527,6 +522,14 @@ Unit* Aura::GetCaster() const
|
||||
return ObjectAccessor::GetUnit(*GetOwner(), GetCasterGUID());
|
||||
}
|
||||
|
||||
WorldObject* Aura::GetWorldObjectCaster() const
|
||||
{
|
||||
if (GetCasterGUID().IsUnit())
|
||||
return GetCaster();
|
||||
|
||||
return ObjectAccessor::GetWorldObject(*GetOwner(), GetCasterGUID());
|
||||
}
|
||||
|
||||
AuraEffect* Aura::GetEffect(uint32 index) const
|
||||
{
|
||||
if (index >= _effects.size())
|
||||
|
||||
@@ -145,6 +145,7 @@ class TC_GAME_API Aura
|
||||
int32 GetCastItemLevel() const { return m_castItemLevel; }
|
||||
SpellCastVisual GetSpellVisual() const { return m_spellVisual; }
|
||||
Unit* GetCaster() const;
|
||||
WorldObject* GetWorldObjectCaster() const;
|
||||
WorldObject* GetOwner() const { return m_owner; }
|
||||
Unit* GetUnitOwner() const { ASSERT(GetType() == UNIT_AURA_TYPE); return m_owner->ToUnit(); }
|
||||
DynamicObject* GetDynobjOwner() const { ASSERT(GetType() == DYNOBJ_AURA_TYPE); return m_owner->ToDynObject(); }
|
||||
|
||||
Reference in New Issue
Block a user