[11105] Melee attacks distance

Inspired by patch provided by Feanordev.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Schmoozerd 2011-02-03 00:35:53 +03:00 committed by VladimirMangos
parent aa4c1be8cf
commit 8e68d1bcaf
13 changed files with 77 additions and 43 deletions

View file

@ -5711,19 +5711,33 @@ bool Spell::CanAutoCast(Unit* target)
SpellCastResult Spell::CheckRange(bool strict)
{
float range_mod;
Unit *target = m_targets.getUnitTarget();
// self cast doesn't need range checking -- also for Starshards fix
if (m_spellInfo->rangeIndex == 1)
return SPELL_CAST_OK;
// special range cases
switch(m_spellInfo->rangeIndex)
{
// self cast doesn't need range checking -- also for Starshards fix
case SPELL_RANGE_IDX_SELF_ONLY:
return SPELL_CAST_OK;
// combat range spells are treated differently
case SPELL_RANGE_IDX_COMBAT:
{
if (target)
{
if (target == m_caster)
return SPELL_CAST_OK;
if (strict) //add radius of caster
range_mod = 1.25;
else //add radius of caster and ~5 yds "give"
range_mod = 6.25;
// with additional 5 dist for non stricted case (some melee spells have delay in apply
return m_caster->CanReachWithMeleeAttack(target, strict ? 0.0f : 5.0f) ? SPELL_CAST_OK : SPELL_FAILED_OUT_OF_RANGE;
}
break; // let continue in generic way for no target
}
}
//add radius of caster and ~5 yds "give" for non stricred (landing) check
float range_mod = strict ? 1.25f : 6.25;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
Unit *target = m_targets.getUnitTarget();
bool friendly = target ? target->IsFriendlyTo(m_caster) : false;
float max_range = GetSpellMaxRange(srange, friendly) + range_mod;
float min_range = GetSpellMinRange(srange, friendly);
@ -5745,6 +5759,7 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_FAILED_UNIT_NOT_INFRONT;
}
// TODO verify that such spells really use bounding radius
if(m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0)
{
if(!m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, max_range))