aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp5
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/Spell.h1
-rw-r--r--src/server/game/Spells/SpellEffects.cpp40
4 files changed, 33 insertions, 15 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 6ee765e2994..76dadac3885 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -11651,9 +11651,12 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const
return modelid;
}
-void Unit::JumpTo(float speedXY, float speedZ, bool forward)
+void Unit::JumpTo(float speedXY, float speedZ, bool forward, Optional<Position> dest)
{
float angle = forward ? 0 : float(M_PI);
+ if (dest)
+ angle += GetRelativeAngle(*dest);
+
if (GetTypeId() == TYPEID_UNIT)
GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ);
else
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 748da5146ef..05377acb549 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1188,7 +1188,7 @@ class TC_GAME_API Unit : public WorldObject
void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin);
void KnockbackFrom(Position const& origin, float speedXY, float speedZ, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr);
- void JumpTo(float speedXY, float speedZ, bool forward = true);
+ void JumpTo(float speedXY, float speedZ, bool forward = true, Optional<Position> dest = {});
void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false);
void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false);
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index ec13aaee2b4..a904844c6c9 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -325,6 +325,7 @@ class TC_GAME_API Spell
void EffectSendTaxi();
void EffectKnockBack();
void EffectPullTowards();
+ void EffectPullTowardsDest();
void EffectDispelMechanic();
void EffectResurrectPet();
void EffectDestroyAllTotems();
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()