fix(Core/Spells): Fixed calculating LoS checks for spells casted by g… (#12091)

fix(Core/Spells): Fixed calculating LoS checks for spells casted by gameobjects.

Fixed #12066
This commit is contained in:
UltraNix
2022-06-18 17:05:18 +02:00
committed by GitHub
parent a6b91026a7
commit d41cf026e0
+6 -17
View File
@@ -5851,31 +5851,27 @@ SpellCastResult Spell::CheckCast(bool strict)
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) && if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) &&
!m_spellInfo->HasAttribute(SPELL_ATTR5_ALWAYS_AOE_LINE_OF_SIGHT) && !(m_spellFlags & SPELL_FLAG_REDIRECTED)) !m_spellInfo->HasAttribute(SPELL_ATTR5_ALWAYS_AOE_LINE_OF_SIGHT) && !(m_spellFlags & SPELL_FLAG_REDIRECTED))
{ {
WorldObject* losCenter = nullptr; bool castedByGameobject = false;
uint32 losChecks = LINEOFSIGHT_ALL_CHECKS; uint32 losChecks = LINEOFSIGHT_ALL_CHECKS;
if (m_originalCasterGUID.IsGameObject()) if (m_originalCasterGUID.IsGameObject())
{ {
losCenter = m_caster->GetMap()->GetGameObject(m_originalCasterGUID); castedByGameobject = m_caster->GetMap()->GetGameObject(m_originalCasterGUID) != nullptr;
} }
else if (m_caster->GetEntry() == WORLD_TRIGGER) else if (m_caster->GetEntry() == WORLD_TRIGGER)
{ {
if (TempSummon* tempSummon = m_caster->ToTempSummon()) if (TempSummon* tempSummon = m_caster->ToTempSummon())
{ {
losCenter = tempSummon->GetSummonerGameObject(); castedByGameobject = tempSummon->GetSummonerGameObject() != nullptr;
} }
} }
if (losCenter) if (castedByGameobject)
{ {
// If spell casted by gameobject then ignore M2 models // If spell casted by gameobject then ignore M2 models
losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
} }
else
{
losCenter = m_caster;
}
if (!losCenter->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) if (!m_caster->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks)))
{ {
return SPELL_FAILED_LINE_OF_SIGHT; return SPELL_FAILED_LINE_OF_SIGHT;
} }
@@ -7968,7 +7964,6 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
} }
} }
WorldObject* caster = nullptr;
if (gobCaster) if (gobCaster)
{ {
if (gobCaster->GetGOInfo()->IsIgnoringLOSChecks()) if (gobCaster->GetGOInfo()->IsIgnoringLOSChecks())
@@ -7976,15 +7971,9 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
return true; return true;
} }
caster = gobCaster;
// If spell casted by gameobject then ignore M2 models // If spell casted by gameobject then ignore M2 models
losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
} }
else
{
caster = m_caster;
}
if (target != m_caster) if (target != m_caster)
{ {
@@ -7999,7 +7988,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
return false; return false;
} }
} }
else if (!target->IsWithinLOSInMap(caster, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) else if (!m_caster->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks)))
{ {
return false; return false;
} }