diff options
| author | NoName <322016+Faq@users.noreply.github.com> | 2020-03-01 21:15:54 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-22 20:50:33 +0100 |
| commit | 8ec51bf3b69b2d34607b555f2d52b09f8b73c9e3 (patch) | |
| tree | e52cdd1ee04ed883cdfb406cd5014162d3bbbf7f /src/server/game/Spells/SpellEffects.cpp | |
| parent | 8fdeaa2797c5f6c259caaf5df7f3818388c1071e (diff) | |
Core/Spell: Proper SPELL_EFFECT_PULL_TOWARDS_DEST implementation for players (#24178)
* Core/Spell: Proper SPELL_EFFECT_PULL_TOWARDS_DEST implementation for players
Closes ##23203 and also reverts 9a1282a
thnx to xvwyh
* Make it optional
(cherry picked from commit 6067a996324dc4e36a414257e6abf7f9dfdfa934)
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
| -rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a127167b186..854fd4b22d9 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -226,7 +226,7 @@ NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EF &Spell::EffectTriggerSpell, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE &Spell::EffectUnused, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER &Spell::EffectKnockBack, //144 SPELL_EFFECT_KNOCK_BACK_DEST - &Spell::EffectPullTowards, //145 SPELL_EFFECT_PULL_TOWARDS_DEST Black Hole Effect + &Spell::EffectPullTowardsDest, //145 SPELL_EFFECT_PULL_TOWARDS_DEST Black Hole Effect &Spell::EffectNULL, //146 SPELL_EFFECT_RESTORE_GARRISON_TROOP_VITALITY &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail &Spell::EffectTriggerMissileSpell, //148 SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE @@ -4002,23 +4002,37 @@ void Spell::EffectPullTowards() if (!unitTarget) return; + float speedXY = effectInfo->MiscValue / 10.0f; + float speedZ = damage / 10.0f; Position pos; - if (effectInfo->Effect == SPELL_EFFECT_PULL_TOWARDS_DEST) - { - if (m_targets.HasDst()) - pos.Relocate(*destTarget); - else - return; - } - else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_PULL_TOWARDS) + pos.Relocate(m_caster); + + unitTarget->GetMotionMaster()->MoveJump(pos, speedXY, speedZ); +} + +void Spell::EffectPullTowardsDest() +{ + if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) + return; + + if (!unitTarget) + return; + + if (!m_targets.HasDst()) { - pos.Relocate(m_caster); + TC_LOG_ERROR("spells", "Spell %u with SPELL_EFFECT_PULL_TOWARDS_DEST has no dest target", m_spellInfo->Id); + return; } - float speedXY = float(effectInfo->MiscValue) * 0.1f; - float speedZ = unitTarget->GetDistance(pos) / speedXY * 0.5f * Movement::gravity; + Position const* pos = m_targets.GetDstPos(); + // This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance + float distXY = unitTarget->GetExactDist(pos); + float distZ = pos->GetPositionZ() - unitTarget->GetPositionZ(); - unitTarget->GetMotionMaster()->MoveJump(pos, speedXY, speedZ); + float speedXY = effectInfo->MiscValue / 10.0f; + float speedZ = (2 * speedXY * speedXY * distZ + Movement::gravity * distXY * distXY) / (2 * speedXY * distXY); + + unitTarget->JumpTo(speedXY, speedZ, true, *pos); } void Spell::EffectChangeRaidMarker() |
