mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
feat(Core/LOS): restruct LOS functions and add LineOfSight check (#1459)
This commit is contained in:
committed by
Francesco Borzì
parent
6908d333db
commit
cb81f3c17a
@@ -2191,7 +2191,7 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
|
||||
if (Unit* unit = (*itr)->ToUnit())
|
||||
{
|
||||
uint32 deficit = unit->GetMaxHealth() - unit->GetHealth();
|
||||
if ((deficit > maxHPDeficit || foundItr == tempTargets.end()) && target->IsWithinDist(unit, jumpRadius) && target->IsWithinLOSInMap(unit))
|
||||
if ((deficit > maxHPDeficit || foundItr == tempTargets.end()) && target->IsWithinDist(unit, jumpRadius) && target->IsWithinLOSInMap(unit, LINEOFSIGHT_ALL_CHECKS))
|
||||
{
|
||||
foundItr = itr;
|
||||
maxHPDeficit = deficit;
|
||||
@@ -2206,10 +2206,10 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
|
||||
{
|
||||
if (foundItr == tempTargets.end())
|
||||
{
|
||||
if ((!isBouncingFar || target->IsWithinDist(*itr, jumpRadius)) && target->IsWithinLOSInMap(*itr))
|
||||
if ((!isBouncingFar || target->IsWithinDist(*itr, jumpRadius)) && target->IsWithinLOSInMap(*itr, LINEOFSIGHT_ALL_CHECKS))
|
||||
foundItr = itr;
|
||||
}
|
||||
else if (target->GetDistanceOrder(*itr, *foundItr) && target->IsWithinLOSInMap(*itr))
|
||||
else if (target->GetDistanceOrder(*itr, *foundItr) && target->IsWithinLOSInMap(*itr, LINEOFSIGHT_ALL_CHECKS))
|
||||
foundItr = itr;
|
||||
}
|
||||
}
|
||||
@@ -5518,7 +5518,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
return SPELL_FAILED_NOT_INFRONT;
|
||||
|
||||
if (m_caster->GetEntry() != WORLD_TRIGGER) // Ignore LOS for gameobjects casts (wrongly casted by a trigger)
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_spellInfo->HasAttribute(SPELL_ATTR5_SKIP_CHECKCAST_LOS_CHECK) && !m_caster->IsWithinLOSInMap(target) && !(m_spellFlags & SPELL_FLAG_REDIRECTED))
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_spellInfo->HasAttribute(SPELL_ATTR5_SKIP_CHECKCAST_LOS_CHECK) && !m_caster->IsWithinLOSInMap(target, LINEOFSIGHT_ALL_CHECKS) && !(m_spellFlags & SPELL_FLAG_REDIRECTED))
|
||||
return SPELL_FAILED_LINE_OF_SIGHT;
|
||||
}
|
||||
}
|
||||
@@ -5529,7 +5529,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
float x, y, z;
|
||||
m_targets.GetDstPos()->GetPosition(x, y, z);
|
||||
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_spellInfo->HasAttribute(SPELL_ATTR5_SKIP_CHECKCAST_LOS_CHECK) && !m_caster->IsWithinLOS(x, y, z))
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_spellInfo->HasAttribute(SPELL_ATTR5_SKIP_CHECKCAST_LOS_CHECK) && !m_caster->IsWithinLOS(x, y, z, LINEOFSIGHT_ALL_CHECKS))
|
||||
return SPELL_FAILED_LINE_OF_SIGHT;
|
||||
}
|
||||
|
||||
@@ -5708,7 +5708,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
if (!target || !pet || pet->isDead() || target->isDead())
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
if (!pet->IsWithinLOSInMap(target))
|
||||
if (!pet->IsWithinLOSInMap(target, LINEOFSIGHT_ALL_CHECKS))
|
||||
return SPELL_FAILED_LINE_OF_SIGHT;
|
||||
}
|
||||
break;
|
||||
@@ -7418,7 +7418,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
z = m_targets.GetDstPos()->GetPositionZ();
|
||||
}
|
||||
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !target->IsWithinLOS(x, y, z))
|
||||
if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !target->IsWithinLOS(x, y, z, LINEOFSIGHT_ALL_CHECKS))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -7430,7 +7430,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
{
|
||||
case SPELL_EFFECT_RESURRECT_NEW:
|
||||
// player far away, maybe his corpse near?
|
||||
if (target != m_caster && !target->IsWithinLOSInMap(m_caster))
|
||||
if (target != m_caster && !target->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS))
|
||||
{
|
||||
if (!m_targets.GetCorpseTargetGUID())
|
||||
return false;
|
||||
@@ -7442,7 +7442,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
if (target->GetGUID() != corpse->GetOwnerGUID())
|
||||
return false;
|
||||
|
||||
if (!corpse->IsWithinLOSInMap(m_caster) && !(m_spellFlags & SPELL_FLAG_REDIRECTED))
|
||||
if (!corpse->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS) && !(m_spellFlags & SPELL_FLAG_REDIRECTED))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -7450,7 +7450,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
{
|
||||
if (!m_targets.GetCorpseTargetGUID())
|
||||
{
|
||||
if (target->IsWithinLOSInMap(m_caster) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
|
||||
if (target->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -7466,7 +7466,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
if (!corpse->HasFlag(CORPSE_FIELD_FLAGS, CORPSE_FLAG_LOOTABLE))
|
||||
return false;
|
||||
|
||||
if (!corpse->IsWithinLOSInMap(m_caster))
|
||||
if (!corpse->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -7503,7 +7503,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
z = m_targets.GetDstPos()->GetPositionZ();
|
||||
}
|
||||
|
||||
if (!target->IsInMap(caster) || !target->IsWithinLOS(x, y, z))
|
||||
if (!target->IsInMap(caster) || !target->IsWithinLOS(x, y, z, LINEOFSIGHT_ALL_CHECKS))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user