diff options
9 files changed, 49 insertions, 36 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 623886eb78..9f0023450e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -596,7 +596,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) DisableSpline(); if (movespline->HasAnimation() && IsCreature() && IsAlive()) - SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, movespline->GetAnimationType()); + SetAnimTier(AnimTier(movespline->GetAnimationType())); } // pussywizard: update always! not every 400ms, because movement generators need the actual position @@ -15284,6 +15284,11 @@ float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spell return spellInfo->GetMinRange(!IsHostileTo(target)); } +void Unit::SetAnimTier(AnimTier animTier) +{ + SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, uint8(animTier)); +} + uint32 Unit::GetCreatureType() const { if (IsPlayer()) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 934bb1c70c..1590c2721f 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -774,6 +774,8 @@ public: inline bool IsCrowdControlled() const { return HasFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_STUNNED)); } inline bool IsImmobilizedState() const { return HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED); } + void SetAnimTier(AnimTier animTier); + /*********************************************************/ /*** UNIT TYPES, CLASSES, RACES... ***/ /*********************************************************/ diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index bf4df28aad..8e4f91c16c 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -471,7 +471,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo * * For transition movement between the ground and the air, use MoveLand or MoveTakeoff instead. */ -void MotionMaster::MovePoint(uint32 id, float x, float y, float z, ForcedMovement forcedMovement, float speed, float orientation, bool generatePath, bool forceDestination, MovementSlot slot) +void MotionMaster::MovePoint(uint32 id, float x, float y, float z, ForcedMovement forcedMovement, float speed, float orientation, bool generatePath, bool forceDestination, MovementSlot slot, std::optional<AnimTier> animTier) { if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE)) return; @@ -479,12 +479,12 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, ForcedMovemen if (_owner->IsPlayer()) { LOG_DEBUG("movement.motionmaster", "Player ({}) targeted point (Id: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z); - Mutate(new PointMovementGenerator<Player>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination), slot); + Mutate(new PointMovementGenerator<Player>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination, animTier), slot); } else { LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted point (ID: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z); - Mutate(new PointMovementGenerator<Creature>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination), slot); + Mutate(new PointMovementGenerator<Creature>(id, x, y, z, forcedMovement, speed, orientation, nullptr, generatePath, forceDestination, animTier), slot); } } @@ -556,7 +556,7 @@ void MotionMaster::MoveLand(uint32 id, Position const& pos, float speed /* = 0.0 init.SetVelocity(speed); } - init.SetAnimation(Movement::ToGround); + init.SetAnimation(AnimTier::Ground); Mutate(new EffectMovementGenerator(init, id), MOTION_SLOT_ACTIVE); } @@ -590,7 +590,7 @@ void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, float speed /* = init.SetVelocity(speed); if (!skipAnimation) - init.SetAnimation(Movement::ToFly); + init.SetAnimation(AnimTier::Hover); Mutate(new EffectMovementGenerator(init, id), MOTION_SLOT_ACTIVE); } @@ -727,12 +727,12 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id, if (_owner->IsPlayer()) { LOG_DEBUG("movement.motionmaster", "Player ({}) charge point (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z); - Mutate(new PointMovementGenerator<Player>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, targetGUID), MOTION_SLOT_CONTROLLED); + Mutate(new PointMovementGenerator<Player>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, std::nullopt, targetGUID), MOTION_SLOT_CONTROLLED); } else { LOG_DEBUG("movement.motionmaster", "Creature ({}) charge point (X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), x, y, z); - Mutate(new PointMovementGenerator<Creature>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, targetGUID), MOTION_SLOT_CONTROLLED); + Mutate(new PointMovementGenerator<Creature>(id, x, y, z, FORCED_MOVEMENT_NONE, speed, orientation, path, generatePath, generatePath, std::nullopt, targetGUID), MOTION_SLOT_CONTROLLED); } } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 637e43a91b..4ac140260f 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -95,6 +95,16 @@ enum class PathSource SMART_WAYPOINT_MGR = 1, }; +enum class AnimTier : uint8 +{ + Ground = 0, + Swim = 1, + Hover = 2, + Fly = 3, + Submerged = 4, + Max +}; + struct ChaseRange { ChaseRange(float range); @@ -225,9 +235,9 @@ public: void MoveForwards(Unit* target, float dist); void MoveConfused(); void MoveFleeing(Unit* enemy, uint32 time = 0); - void MovePoint(uint32 id, const Position& pos, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, float speed = 0.f, bool generatePath = true, bool forceDestination = true) - { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, forcedMovement, speed, pos.GetOrientation(), generatePath, forceDestination, MOTION_SLOT_ACTIVE); } - void MovePoint(uint32 id, float x, float y, float z, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, float speed = 0.f, float orientation = 0.0f, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE); + void MovePoint(uint32 id, const Position& pos, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, float speed = 0.f, bool generatePath = true, bool forceDestination = true, std::optional<AnimTier> animTier = std::nullopt) + { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, forcedMovement, speed, pos.GetOrientation(), generatePath, forceDestination, MOTION_SLOT_ACTIVE, animTier); } + void MovePoint(uint32 id, float x, float y, float z, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, float speed = 0.f, float orientation = 0.0f, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE, std::optional<AnimTier> animTier = std::nullopt); void MoveSplinePath(Movement::PointsArray* path, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE); void MovePath(uint32 path_id, ForcedMovement forcedMovement = FORCED_MOVEMENT_NONE, PathSource pathSource = PathSource::WAYPOINT_MGR); diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index 95e3c5621f..66ba79be59 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -94,6 +94,9 @@ void PointMovementGenerator<T>::DoInitialize(T* unit) init.SetFacing(i_orientation); } + if (_animTier) + init.SetAnimation(*_animTier); + init.Launch(); } @@ -152,6 +155,9 @@ bool PointMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/) else if (_forcedMovement == FORCED_MOVEMENT_RUN) init.SetWalk(false); + if (_animTier) + init.SetAnimation(*_animTier); + if (i_orientation > 0.0f) { init.SetFacing(i_orientation); diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index 6dc16eb4eb..b4b782bfd1 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -21,15 +21,16 @@ #include "Creature.h" #include "MovementGenerator.h" #include "MoveSplineInit.h" +#include <optional> template<class T> class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator<T> > { public: PointMovementGenerator(uint32 _id, float _x, float _y, float _z, ForcedMovement forcedMovement, float _speed = 0.0f, float orientation = 0.0f, const Movement::PointsArray* _path = nullptr, - bool generatePath = false, bool forceDestination = false, ObjectGuid chargeTargetGUID = ObjectGuid::Empty, bool reverseOrientation = false, ObjectGuid facingTargetGuid = ObjectGuid()) + bool generatePath = false, bool forceDestination = false, std::optional<AnimTier> animTier = std::nullopt, ObjectGuid chargeTargetGUID = ObjectGuid::Empty, bool reverseOrientation = false, ObjectGuid facingTargetGuid = ObjectGuid()) : id(_id), i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination), _reverseOrientation(reverseOrientation), - _chargeTargetGUID(chargeTargetGUID), _forcedMovement(forcedMovement), _facingTargetGuid(facingTargetGuid) + _chargeTargetGUID(chargeTargetGUID), _forcedMovement(forcedMovement), _facingTargetGuid(facingTargetGuid), _animTier(animTier) { if (_path) m_precomputedPath = *_path; @@ -60,6 +61,7 @@ private: ObjectGuid _chargeTargetGUID; ForcedMovement _forcedMovement; ObjectGuid _facingTargetGuid; + std::optional<AnimTier> _animTier; }; class AssistanceMovementGenerator : public PointMovementGenerator<Creature> diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index c113f69764..7c13fb982e 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -204,10 +204,10 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature) switch (node.move_type) { case WAYPOINT_MOVE_TYPE_LAND: - init.SetAnimation(Movement::ToGround); + init.SetAnimation(AnimTier::Ground); break; case WAYPOINT_MOVE_TYPE_TAKEOFF: - init.SetAnimation(Movement::ToFly); + init.SetAnimation(AnimTier::Hover); break; case WAYPOINT_MOVE_TYPE_RUN: init.SetWalk(false); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index 5be1ebe26b..e0761129c9 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -29,14 +29,6 @@ namespace Movement // xinef: moved declaration here so it can be accessed out of MoveSplineInit.cpp UnitMoveType SelectSpeedType(uint32 moveFlags); - enum AnimType - { - ToGround = 0, // 460 = ToGround, index of AnimationData.dbc - FlyToFly = 1, // 461 = FlyToFly? - ToFly = 2, // 458 = ToFly - FlyToGround = 3 // 463 = FlyToGround - }; - // Transforms coordinates from global to transport offsets class TransportPathTransform { @@ -89,7 +81,7 @@ namespace Movement /* Plays animation after movement done * can't be combined with parabolic movement */ - void SetAnimation(AnimType anim); + void SetAnimation(AnimTier anim); /* Adds final facing animation * sets unit's facing to specified point/angle after all path done @@ -191,7 +183,7 @@ namespace Movement args.flags.EnableParabolic(); } - inline void MoveSplineInit::SetAnimation(AnimType anim) + inline void MoveSplineInit::SetAnimation(AnimTier anim) { args.time_perc = 0.f; args.flags.EnableAnimation((uint8)anim); diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 3d77b31d5e..bdf1ba1187 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -234,6 +234,8 @@ public: me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED); me->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE); + me->SetAnimTier(AnimTier::Fly); + if (pInstance) { pInstance->SetData(DATA_ENCOUNTER_STATUS, NOT_STARTED); @@ -277,12 +279,6 @@ public: case MI_POINT_SURGE_OF_POWER_CENTER: events.RescheduleEvent(EVENT_SURGE_OF_POWER_WARNING, 0ms, 1); break; - } - } - else if (type == EFFECT_MOTION_TYPE) - { - switch (id) - { case MI_POINT_INTRO_LAND: me->SetDisableGravity(false); events.RescheduleEvent(EVENT_START_FIGHT, 0ms, 1); @@ -401,7 +397,7 @@ public: } case EVENT_INTRO_LAND: { - me->GetMotionMaster()->MoveLand(MI_POINT_INTRO_LAND, me->GetPositionX(), me->GetPositionY(), CenterPos.GetPositionZ(), 7.0f); + me->GetMotionMaster()->MovePoint(MI_POINT_INTRO_LAND, me->GetPositionX(), me->GetPositionY(), CenterPos.GetPositionZ(), FORCED_MOVEMENT_RUN, 0.f, 0.f, true, true, MOTION_SLOT_ACTIVE, AnimTier::Ground); break; } case EVENT_START_FIGHT: @@ -462,7 +458,7 @@ public: me->GetMotionMaster()->MoveIdle(); me->StopMoving(); me->SetDisableGravity(true); - me->GetMotionMaster()->MoveTakeoff(MI_POINT_VORTEX_TAKEOFF, me->GetPositionX(), me->GetPositionY(), CenterPos.GetPositionZ() + 20.0f, 7.0f); + me->GetMotionMaster()->MovePoint(MI_POINT_VORTEX_TAKEOFF, me->GetPositionX(), me->GetPositionY(), CenterPos.GetPositionZ() + 20.0f, FORCED_MOVEMENT_RUN, 0.f, 0.f, true, true, MOTION_SLOT_ACTIVE, AnimTier::Fly); events.DelayEvents(25s, 1); // don't delay berserk (group 0) } @@ -539,7 +535,7 @@ public: break; } case EVENT_VORTEX_LAND_0: - me->GetMotionMaster()->MoveLand(MI_POINT_VORTEX_LAND, CenterPos, 7.0f); + me->GetMotionMaster()->MovePoint(MI_POINT_VORTEX_LAND, CenterPos, FORCED_MOVEMENT_RUN, 0.f, true, true, AnimTier::Ground); break; case EVENT_VORTEX_LAND_1: @@ -573,7 +569,7 @@ public: me->GetMotionMaster()->MoveIdle(); me->DisableSpline(); me->SetDisableGravity(true); - me->GetMotionMaster()->MoveTakeoff(MI_POINT_CENTER_AIR_PH_2, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 32.0f, 7.0f); + me->GetMotionMaster()->MovePoint(MI_POINT_CENTER_AIR_PH_2, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 32.0f, FORCED_MOVEMENT_RUN, 0.f, 0.f, true, true, MOTION_SLOT_ACTIVE, AnimTier::Fly); events.RescheduleEvent(EVENT_START_PHASE_2_MOVE_TO_SIDE, 22s + 500ms, 1); break; } @@ -699,7 +695,7 @@ public: case EVENT_MOVE_TO_PHASE_3_POSITION: { me->SendMeleeAttackStop(me->GetVictim()); - me->GetMotionMaster()->MoveTakeoff(MI_POINT_PH_3_FIGHT_POSITION, CenterPos.GetPositionX(), CenterPos.GetPositionY(), CenterPos.GetPositionZ() - 5.0f, me->GetSpeed(MOVE_RUN)); + me->GetMotionMaster()->MovePoint(MI_POINT_PH_3_FIGHT_POSITION, CenterPos.GetPositionX(), CenterPos.GetPositionY(), CenterPos.GetPositionZ() - 5.0f, FORCED_MOVEMENT_RUN, 0.f, 0.f, true, true, MOTION_SLOT_ACTIVE, AnimTier::Fly); me->GetThreatMgr().ClearAllThreat(); // players on vehicle are unattackable -> leads to EnterEvadeMode() because target is not acceptable! |
