mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-28 08:06:23 +00:00
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:
@@ -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) &&
|
||||
!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;
|
||||
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)
|
||||
{
|
||||
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
|
||||
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;
|
||||
}
|
||||
@@ -7968,7 +7964,6 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
}
|
||||
}
|
||||
|
||||
WorldObject* caster = nullptr;
|
||||
if (gobCaster)
|
||||
{
|
||||
if (gobCaster->GetGOInfo()->IsIgnoringLOSChecks())
|
||||
@@ -7976,15 +7971,9 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
return true;
|
||||
}
|
||||
|
||||
caster = gobCaster;
|
||||
|
||||
// If spell casted by gameobject then ignore M2 models
|
||||
losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
|
||||
}
|
||||
else
|
||||
{
|
||||
caster = m_caster;
|
||||
}
|
||||
|
||||
if (target != m_caster)
|
||||
{
|
||||
@@ -7999,7 +7988,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user