diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-04-21 19:05:38 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-04-21 19:05:38 +0200 |
| commit | 295c8f63269d966812f37a8bd8e988a9f2dc1235 (patch) | |
| tree | bca5012bbda6309938457413292b06ee8d011a6c /src/server/game/Spells/SpellEffects.cpp | |
| parent | c8ebf077c7b934eeb33466cd11a92ba00b931a3d (diff) | |
Core/Spells: Fixed effects targeting the caster not hitting him immediately on spell launch if the spell targets a dest
* Also improve hit timing for charge spells
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
| -rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 35a4879dd5c..c50847c70e2 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -54,6 +54,7 @@ #include "Map.h" #include "MiscPackets.h" #include "MotionMaster.h" +#include "MoveSpline.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" @@ -3799,23 +3800,19 @@ void Spell::EffectCharge() // Spell is not using explicit target - no generated path if (!m_preGeneratedPath) { - //unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetCombatReach(), unitTarget->GetRelativeAngle(m_caster)); - if (G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) && m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION)) - speed = pos.GetExactDist(m_caster) / speed; - unitCaster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speed, EVENT_CHARGE, false, unitTarget, spellEffectExtraData ? &*spellEffectExtraData : nullptr); + m_preGeneratedPath = std::make_unique<PathGenerator>(unitCaster); + m_preGeneratedPath->CalculatePath(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false); } - else - { - if (G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) && m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION)) - { - G3D::Vector3 pos = m_preGeneratedPath->GetActualEndPosition(); - speed = Position(pos.x, pos.y, pos.z).GetExactDist(m_caster) / speed; - } - unitCaster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed, unitTarget, spellEffectExtraData ? &*spellEffectExtraData : nullptr); - } + if (G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) && m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION)) + speed = m_preGeneratedPath->GetPathLength() / speed; + + unitCaster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed, unitTarget, spellEffectExtraData ? &*spellEffectExtraData : nullptr); + + // abuse implementation detail of MoveCharge accepting PathGenerator argument (instantly started spline) + UpdateDelayMomentForUnitTarget(unitTarget, unitCaster->movespline->Duration()); } if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET) @@ -3851,7 +3848,18 @@ void Spell::EffectChargeDest() pos = unitCaster->GetFirstCollisionPosition(dist, angle); } - unitCaster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ); + PathGenerator path(unitCaster); + path.CalculatePath(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false); + + float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE; + + if (G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) && m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION)) + speed = path.GetPathLength() / speed; + + unitCaster->GetMotionMaster()->MoveCharge(path, speed); + + // abuse implementation detail of MoveCharge accepting PathGenerator argument (instantly started spline) + UpdateDelayMomentForDst(unitCaster->movespline->Duration()); } else if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT) { |
