mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
Core/Movement: Knockback improvements (#28081)
* Knockbacks with negative speeds will now be validated and processed. * Creatures that cast knockback spells on themselves will use their orientation to determine the direction of movement.
This commit is contained in:
@@ -806,23 +806,34 @@ void MotionMaster::MoveKnockbackFrom(Position const& origin, float speedXY, floa
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if (speedXY < 0.01f)
|
||||
if (std::abs(speedXY) < 0.01f /* && std::abs(speedZ) < 0.01f */)
|
||||
return;
|
||||
|
||||
Position dest = _owner->GetPosition();
|
||||
float o = dest == origin ? 0.0f : _owner->GetRelativeAngle(origin) + float(M_PI);
|
||||
if (speedXY < 0)
|
||||
{
|
||||
speedXY = -speedXY;
|
||||
o = o - float(M_PI);
|
||||
}
|
||||
|
||||
if (speedZ < 0)
|
||||
speedZ = -speedZ; // doesn't seem to be supported on official servers - packet sent for knockback with positive and negative speed has the same flags and JumpGravity
|
||||
|
||||
float moveTimeHalf = speedZ / Movement::gravity;
|
||||
float dist = 2 * moveTimeHalf * speedXY;
|
||||
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
|
||||
|
||||
// Use a mmap raycast to get a valid destination.
|
||||
_owner->MovePositionToFirstCollision(dest, dist, _owner->GetRelativeAngle(origin) + float(M_PI));
|
||||
_owner->MovePositionToFirstCollision(dest, dist, o);
|
||||
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=, effect = (spellEffectExtraData ? Optional<Movement::SpellEffectExtraData>(*spellEffectExtraData) : Optional<Movement::SpellEffectExtraData>())](Movement::MoveSplineInit& init)
|
||||
{
|
||||
init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
|
||||
init.SetParabolic(max_height, 0);
|
||||
init.SetOrientationFixed(true);
|
||||
init.SetVelocity(speedXY);
|
||||
if (speedXY >= 0.01f)
|
||||
init.SetVelocity(speedXY);
|
||||
if (effect)
|
||||
init.SetSpellEffectExtraData(*effect);
|
||||
};
|
||||
|
||||
@@ -4040,9 +4040,9 @@ void Spell::EffectKnockBack()
|
||||
return;
|
||||
|
||||
float ratio = 0.1f;
|
||||
float speedxy = float(effectInfo->MiscValue) * ratio;
|
||||
float speedz = float(damage) * ratio;
|
||||
if (speedxy < 0.01f && speedz < 0.01f)
|
||||
float speedXY = float(effectInfo->MiscValue) * ratio;
|
||||
float speedZ = float(damage) * ratio;
|
||||
if (std::abs(speedXY) < 0.01f && std::abs(speedZ) < 0.01f)
|
||||
return;
|
||||
|
||||
Position origin;
|
||||
@@ -4056,7 +4056,7 @@ void Spell::EffectKnockBack()
|
||||
else //if (effectInfo->Effect == SPELL_EFFECT_KNOCK_BACK)
|
||||
origin = m_caster->GetPosition();
|
||||
|
||||
unitTarget->KnockbackFrom(origin, speedxy, speedz);
|
||||
unitTarget->KnockbackFrom(origin, speedXY, speedZ);
|
||||
|
||||
Unit::ProcSkillsAndAuras(GetUnitCasterForEffectHandlers(), unitTarget, PROC_FLAG_NONE, { PROC_FLAG_NONE, PROC_FLAG_2_KNOCKBACK },
|
||||
PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_NONE, nullptr, nullptr, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user