Core/Spells: Remove spell range increase when caster or target move backwards

(cherry picked from commit f19e1a2716)
This commit is contained in:
Shauren
2024-07-03 16:18:06 +02:00
committed by Ovahlord
parent 0617d977e9
commit 071ddfa162
3 changed files with 12 additions and 3 deletions

View File

@@ -7169,6 +7169,13 @@ SpellCastResult Spell::CheckRange(bool strict) const
return SPELL_CAST_OK;
}
bool Spell::CanIncreaseRangeByMovement(Unit const* unit)
{
// forward running only
return unit->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT | MOVEMENTFLAG_FALLING)
&& !unit->IsWalking();
}
std::pair<float, float> Spell::GetMinMaxRange(bool strict) const
{
float rangeMod = 0.0f;
@@ -7210,7 +7217,7 @@ std::pair<float, float> Spell::GetMinMaxRange(bool strict) const
}
}
if (target && unitCaster && unitCaster->isMoving() && target->isMoving() && !unitCaster->IsWalking() && !target->IsWalking() &&
if (target && unitCaster && CanIncreaseRangeByMovement(target) && CanIncreaseRangeByMovement(unitCaster) &&
((m_spellInfo->RangeEntry->Flags & SPELL_RANGE_MELEE) || target->GetTypeId() == TYPEID_PLAYER))
rangeMod += 8.0f / 3.0f;
}

View File

@@ -678,6 +678,8 @@ class TC_GAME_API Spell
bool IsWithinLOS(WorldObject const* source, Position const& target, VMAP::ModelIgnoreFlags ignoreFlags) const;
void MovePosition(Position& pos, WorldObject const* from, float dist, float angle) const;
static bool CanIncreaseRangeByMovement(Unit const* unit);
protected:
bool HasGlobalCooldown() const;
void TriggerGlobalCooldown();

View File

@@ -663,7 +663,7 @@ float SpellEffectInfo::CalcRadius(WorldObject* caster /*= nullptr*/, SpellTarget
if (caster)
{
if (Unit* casterUnit = caster->ToUnit())
if (Unit const* casterUnit = caster->ToUnit())
radius += entry->RadiusPerLevel * casterUnit->GetLevel();
radius = std::min(radius, entry->RadiusMax);
@@ -672,7 +672,7 @@ float SpellEffectInfo::CalcRadius(WorldObject* caster /*= nullptr*/, SpellTarget
modOwner->ApplySpellMod(_spellInfo, SpellModOp::Radius, radius, spell);
if (!_spellInfo->HasAttribute(SPELL_ATTR9_NO_MOVEMENT_RADIUS_BONUS))
if (Unit* casterUnit = caster->ToUnit(); casterUnit && casterUnit->isMoving() && !casterUnit->IsWalking())
if (Unit const* casterUnit = caster->ToUnit(); casterUnit && Spell::CanIncreaseRangeByMovement(casterUnit))
radius += 2.0f;
}