Skip to content

Commit f4d8105

Browse files
committed
Core/Entities: improve unit on death movement
Handle MoveFall spline manually instead on MotionMaster -> prepares and sends movespline just before Set methods -> they "detect" the fall spline and send the necessary DISABLE related packets Signal MotionMaster to not reset-initialize static idle movement with the new MOTIONMASTER_FLAG_STATIC_PREVENT_INITIALIZATION Prevent spline from generating a path, we want a straight line towards the floor
1 parent 736add6 commit f4d8105

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,13 +2006,6 @@ void Creature::setDeathState(DeathState s)
20062006
if (m_formation && m_formation->GetLeader() == this)
20072007
m_formation->FormationReset(true);
20082008

2009-
bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater();
2010-
SetHover(false, false);
2011-
SetDisableGravity(false, false);
2012-
2013-
if (needsFalling)
2014-
GetMotionMaster()->MoveFall();
2015-
20162009
Unit::setDeathState(CORPSE);
20172010
}
20182011
else if (s == JUST_RESPAWNED)

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8760,9 +8760,28 @@ void Unit::setDeathState(DeathState s)
87608760
if (!isOnVehicle)
87618761
{
87628762
if (GetMotionMaster()->StopOnDeath())
8763-
DisableSpline();
8763+
{
8764+
if (!HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED) && GetTypeId() == TYPEID_UNIT && ToCreature()->IsInAir(*this, GetFloorZ(), false) && !IsUnderWater())
8765+
{
8766+
GetMotionMaster()->AddFlag(MOTIONMASTER_FLAG_STATIC_PREVENT_INITIALIZATION);
8767+
SetFall(true);
8768+
Movement::MoveSplineInit init(this);
8769+
init.MoveTo(GetPositionX(), GetPositionY(), GetFloorZ(), false, true);
8770+
init.SetFall();
8771+
init.Launch();
8772+
}
8773+
else
8774+
{
8775+
StopMoving();
8776+
DisableSpline();
8777+
}
8778+
}
87648779
}
87658780

8781+
SetDisableGravity(false);
8782+
SetCanFly(false);
8783+
SetHover(false);
8784+
87668785
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
87678786
// do not why since in IncreaseMaxHealth currenthealth is checked
87688787
SetHealth(0);

src/server/game/Movement/MotionMaster.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ bool MotionMaster::StopOnDeath()
563563
MoveIdle();
564564
}
565565

566-
_owner->StopMoving();
567-
568566
return true;
569567
}
570568

0 commit comments

Comments
 (0)