Skip to content

Commit

Permalink
recheck distance for delayed spells at hit v0.5, related to #873
Browse files Browse the repository at this point in the history
  • Loading branch information
rsa committed Apr 11, 2012
1 parent 09a1b0f commit a112f03
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
50 changes: 41 additions & 9 deletions src/game/Spell.cpp
Expand Up @@ -1109,10 +1109,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
m_damage += target->damage;
}

// recheck for visibility of target
if ((m_spellInfo->speed > 0.0f ||
(m_spellInfo->EffectImplicitTargetA[0] == TARGET_CHAIN_DAMAGE && GetSpellCastTime(m_spellInfo, this) > 0)) &&
(!unit->isVisibleForOrDetect(m_caster, m_caster, false) && !m_IsTriggeredSpell))
// recheck for availability/visibility of target
if (((m_spellInfo->speed > 0.0f ||
(m_spellInfo->EffectImplicitTargetA[0] == TARGET_CHAIN_DAMAGE &&
GetSpellCastTime(m_spellInfo, this) > 0)) &&
(!unit->isVisibleForOrDetect(m_caster, m_caster, false) && !m_IsTriggeredSpell)))
{
caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
missInfo = SPELL_MISS_EVADE;
Expand Down Expand Up @@ -4071,6 +4072,7 @@ void Spell::update(uint32 difftime)
cancel();
}


switch(m_spellState)
{
case SPELL_STATE_PREPARING:
Expand Down Expand Up @@ -4108,6 +4110,35 @@ void Spell::update(uint32 difftime)
cancel();
}

// check if all targets away range
if (!m_IsTriggeredSpell && (difftime >= m_timer))
{
SpellCastResult result = CheckRange(true, m_targets.getUnitTarget());
bool checkFailed = false;
switch (result)
{
case SPELL_CAST_OK:
break;
case SPELL_FAILED_TOO_CLOSE:
case SPELL_FAILED_UNIT_NOT_INFRONT:
if (m_spellInfo->AttributesEx7 & SPELL_ATTR_EX7_HAS_CHARGE_EFFECT)
break;
checkFailed = true;
break;
case SPELL_FAILED_OUT_OF_RANGE:
default:
checkFailed = true;
break;
}

if (checkFailed)
{
SendCastResult(result);
cancel();
return;
}
}

// check if there are alive targets left
if (!IsAliveUnitPresentInTargetList())
{
Expand Down Expand Up @@ -6880,16 +6911,17 @@ SpellCastResult Spell::CanAutoCast(Unit* target)
return result; //target invalid
}

SpellCastResult Spell::CheckRange(bool strict)
SpellCastResult Spell::CheckRange(bool strict, WorldObject* checkTarget)
{
Unit *target = m_targets.getUnitTarget();
GameObject *pGoTarget = m_targets.getGOTarget();
Unit* target = (checkTarget && checkTarget->GetObjectGuid().IsUnit()) ? (Unit*)checkTarget : m_targets.getUnitTarget();
GameObject* pGoTarget = (checkTarget && checkTarget->GetObjectGuid().IsGameObject()) ? (GameObject*)checkTarget : m_targets.getGOTarget();

SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);

bool friendly = target ? target->IsFriendlyTo(m_caster) : false;
float max_range = GetSpellMaxRange(srange, friendly);
float min_range = GetSpellMinRange(srange, friendly);
float add_range = checkTarget ? 0.0f : (strict ? 1.25f : 6.25f);

// special range cases
switch(m_spellInfo->rangeIndex)
Expand All @@ -6913,7 +6945,7 @@ SpellCastResult Spell::CheckRange(bool strict)

float combat_range = m_caster->GetMeleeAttackDistance(target);

float range_mod = combat_range + (strict ? 1.25f : 6.25f);
float range_mod = combat_range + add_range;

if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range_mod, this);
Expand All @@ -6927,7 +6959,7 @@ SpellCastResult Spell::CheckRange(bool strict)
}
default:
//add radius of caster and ~5 yds "give" for non stricred (landing) check
max_range += (strict ? 1.25f : 6.25f);
max_range += add_range;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/Spell.h
Expand Up @@ -398,7 +398,7 @@ class Spell
void _handle_finish_phase();

SpellCastResult CheckItems();
SpellCastResult CheckRange(bool strict);
SpellCastResult CheckRange(bool strict, WorldObject* target = NULL);
SpellCastResult CheckPower();
SpellCastResult CheckOrTakeRunePower(bool take);
SpellCastResult CheckCasterAuras() const;
Expand Down

5 comments on commit a112f03

@Tiquihit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: Oops, my fault
Sorry

@raynar
Copy link
Member

@raynar raynar commented on a112f03 Apr 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we haven't this patch yet...Tomorrow we'll test it :D

@rsa
Copy link
Member Author

@rsa rsa commented on a112f03 Apr 12, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonsence.
all spells with trajectory has target = caster. impossible break distance in this case :)
spells with delay works fine, tested on mage fireball. if ball launched and mob run away from distance - damage appeared.

@Tiquihit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like it broken, can be the map's new system?
Works like without this patch, as before ---> http://www.youtube.com/watch?v=n8HgEjifNG8&feature=g-upl

@Tiquihit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked perfectly, a bug as big as this one that was finally fixed and must be re-fuck ... :(

Please sign in to comment.