Core/Units: consider summoned units with a creator guid also as party or raid member

the old logic was built on the false assumption that all units like totems have a ownerguid - they do not. They only have a creatorguid. Ownerguids (as the name implies) is only applied on units that the player is actively controlling. 3.3.5 has this implemented in a wrong way while 4.x does not.

*also fixed up more cherrypick mistakes while at it
This commit is contained in:
Ovahlord committed 2022-09-12 09:15:31 +02:00
1 parent 3976ae557b
commit 6a71b6d053
6 files changed
+22 -12

No files matched your search

+13 -2
View File
@@ -2340,6 +2340,19 @@ Unit* WorldObject::GetCharmerOrOwnerOrSelf() const
return const_cast<WorldObject*>(this)->ToUnit();
}
Unit* WorldObject::GetCharmerOrOwnerOrCreatorOrSelf() const
{
Unit* u = GetCharmerOrOwner();
if (!u)
u = const_cast<WorldObject*>(this)->ToUnit();
if (u)
if (Unit* creator = ObjectAccessor::GetUnit(*this, u->GetCreatorGUID()))
u = creator;
return u;
}
Player* WorldObject::GetCharmerOrOwnerPlayerOrPlayerItself() const
{
ObjectGuid guid = GetCharmerOrOwnerGUID();
@@ -3099,8 +3112,6 @@ bool WorldObject::IsValidAssistTarget(WorldObject const* target, SpellInfo const
// can't assist unattackable units
Unit const* unitTarget = target->ToUnit();
// can't assist unattackable units
if (unitTarget && unitTarget->HasUnitState(UNIT_STATE_UNATTACKABLE))
return false;
+1
View File
@@ -431,6 +431,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
Unit* GetOwner() const;
Unit* GetCharmerOrOwner() const;
Unit* GetCharmerOrOwnerOrSelf() const;
Unit* GetCharmerOrOwnerOrCreatorOrSelf() const;
Player* GetCharmerOrOwnerPlayerOrPlayerItself() const;
Player* GetAffectingPlayer() const;
+4 -4
View File
@@ -11830,8 +11830,8 @@ bool Unit::IsInPartyWith(Unit const* unit) const
if (this == unit)
return true;
Unit const* u1 = GetCharmerOrOwnerOrSelf();
Unit const* u2 = unit->GetCharmerOrOwnerOrSelf();
Unit const* u1 = GetCharmerOrOwnerOrCreatorOrSelf();
Unit const* u2 = unit->GetCharmerOrOwnerOrCreatorOrSelf();
if (u1 == u2)
return true;
@@ -11849,8 +11849,8 @@ bool Unit::IsInRaidWith(Unit const* unit) const
if (this == unit)
return true;
Unit const* u1 = GetCharmerOrOwnerOrSelf();
Unit const* u2 = unit->GetCharmerOrOwnerOrSelf();
Unit const* u1 = GetCharmerOrOwnerOrCreatorOrSelf();
Unit const* u2 = unit->GetCharmerOrOwnerOrCreatorOrSelf();
if (u1 == u2)
return true;
+1 -1
View File
@@ -2504,7 +2504,7 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* ca
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList))
units.push_back(GetUnitOwner());
// no break
[[fallthrough]];
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
{
if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner())
+2 -4
View File
@@ -2910,7 +2910,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo&
}
}
// Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add
// Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add
bool triggered = (m_triggeredByAuraSpell != nullptr);
hitInfo.DRGroup = m_spellInfo->GetDiminishingReturnsGroupForSpell(triggered);
@@ -3051,7 +3051,7 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
{
if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
{
m_caster->CastSpell(unit, i->triggeredSpell->Id, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_TARGET_CHECK));
m_caster->CastSpell(unit, i->triggeredSpell->Id, true);
TC_LOG_DEBUG("spells", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
// SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration
@@ -8026,8 +8026,6 @@ void Spell::DoEffectOnLaunchTarget(TargetInfo& targetInfo, float multiplier, uin
targetInfo.Damage += m_damage;
targetInfo.Healing += m_healing;
float critChance = m_spellValue->CriticalChance;
if (m_originalCaster)
{
+1 -1
View File
@@ -1928,7 +1928,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
SummonCreatureExtraArgs extraArgs;
extraArgs.SummonProperties = properties;
extraArgs.SummonDuration = duration;
extraArgs.Summoner = unitCaster;
extraArgs.Summoner = caster->IsUnit() ? caster->ToUnit() : nullptr;
extraArgs.SummonSpellId = m_spellInfo->Id;
extraArgs.PrivateObjectOwner = privateObjectOwner;