fix(Core): creature movement bugs (#4544)

- fix UpdateEnvironmentIfNeeded was changing flying creature status all the time. closes: #4447
- fix hovering state was causing bugs at #4466
- add animation state priority: fly > hover > ground

Co-authored-by: Wotex <fm@gmail.com>
Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
Co-authored-by: Patrick Lewis <pat@lo5t.com>
This commit is contained in:
Footman
2021-02-12 13:42:41 +03:00
committed by GitHub
parent e75961756d
commit 695a7402ad
6 changed files with 61 additions and 30 deletions

View File

@@ -282,7 +282,6 @@ public:
if (!_summoned)
{
me->SetDisableGravity(true);
me->SetHover(true);
me->SetCanFly(true);
}
}
@@ -355,7 +354,6 @@ public:
if (_summoned)
{
me->SetDisableGravity(false);
me->SetHover(false);
me->SetCanFly(false);
}
}
@@ -452,8 +450,8 @@ public:
break;
case POINT_LAND_GROUND:
{
_isInAirPhase = false;
me->SetDisableGravity(false);
me->SetHover(false);
me->SetCanFly(false);
me->SetSpeed(MOVE_RUN, me->GetCreatureTemplate()->speed_run);
me->SetReactState(REACT_AGGRESSIVE);
@@ -594,6 +592,7 @@ public:
me->SetControlled(false, UNIT_STATE_ROOT);
}
_isInAirPhase = true;
_didFirstFlyPhase = true;
Talk(SAY_AIR_PHASE);
me->SetReactState(REACT_PASSIVE);
@@ -659,7 +658,7 @@ public:
me->GetMotionMaster()->MoveLand(POINT_LAND_GROUND, SindragosaLandPos, 10.0f);
break;
case EVENT_THIRD_PHASE_CHECK:
if (!me->HasByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_HOVER))
if (!_isInAirPhase)
{
Talk(SAY_PHASE_2);
events.ScheduleEvent(EVENT_ICE_TOMB, urand(7000, 10000));
@@ -697,6 +696,7 @@ public:
bool _didFirstFlyPhase;
bool _isBelow20Pct;
bool _isThirdPhase;
bool _isInAirPhase;
};
CreatureAI* GetAI(Creature* creature) const override

View File

@@ -3316,8 +3316,6 @@ public:
npc_icc_nerubar_broodkeeperAI(Creature* creature) : ScriptedAI(creature)
{
me->SetDisableGravity(true);
me->SetCanFly(true);
me->SetHover(true);
_didWebBeam = false;
me->m_SightDistance = 100.0f; // for MoveInLineOfSight distance
}
@@ -3338,16 +3336,18 @@ public:
if (!_didWebBeam && who->GetTypeId() == TYPEID_PLAYER && me->GetExactDist2d(who) < 70.0f)
{
_didWebBeam = true;
float nx = me->GetPositionX() + cos(me->GetOrientation()) * 2.0f;
float ny = me->GetPositionY() + sin(me->GetOrientation()) * 2.0f;
float nz = me->GetMap()->GetHeight(nx, ny, 50.0f);
float nx = me->GetPositionX();
float ny = me->GetPositionY();
float nz = me->GetFloorZ();
me->SetHomePosition(nx, ny, nz, me->GetOrientation());
me->CastSpell(me, SPELL_WEB_BEAM, false);
me->GetMotionMaster()->MovePoint(1, nx, ny, nz, false);
return;
}
if (me->HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY))
if (me->IsLevitating())
return;
ScriptedAI::MoveInLineOfSight(who);
}
@@ -3358,11 +3358,9 @@ public:
void JustReachedHome() override
{
if (me->IsHovering())
if (me->IsLevitating())
{
me->SetDisableGravity(false);
me->SetCanFly(false);
me->SetHover(false);
me->NearTeleportTo(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
}
@@ -3371,11 +3369,10 @@ public:
{
if (type == POINT_MOTION_TYPE && id == 1)
{
if (me->IsHovering())
if (me->IsLevitating())
{
me->SetDisableGravity(false);
me->SetCanFly(false);
me->SetHover(false);
me->SetOrientation(0.0f);
me->NearTeleportTo(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
}
@@ -3383,7 +3380,7 @@ public:
bool CanAIAttack(const Unit* /*target*/) const override
{
return !me->HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY);
return !me->IsLevitating();
}
void UpdateAI(uint32 diff) override