diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 12 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSpline.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineFlag.h | 8 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.cpp | 14 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.h | 6 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInitArgs.h | 1 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MovementUtil.cpp | 4 |
9 files changed, 37 insertions, 17 deletions
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 77f383dcfd2..cc12efbd7eb 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -92,7 +92,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool IsTrigger() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) != 0; } bool IsGuard() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD) != 0; } bool CanWalk() const { return (GetCreatureTemplate()->InhabitType & INHABIT_GROUND) != 0; } - bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); } + bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); } bool CanFly() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0; } bool IsDungeonBoss() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS) != 0; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 941ad019396..aac3257e865 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13816,6 +13816,18 @@ bool Unit::IsFalling() const return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR) || movespline->isFalling(); } +bool Unit::CanSwim() const +{ + // Mirror client behavior, if this method returns false then client will not use swimming animation and for players will apply gravity as if there was no water + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CANNOT_SWIM)) + return false; + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE)) // is player + return true; + if (HasFlag(UNIT_FIELD_FLAGS_2, 0x1000000)) + return false; + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_RENAME | UNIT_FLAG_UNK_15); +} + void Unit::NearTeleportTo(Position const& pos, bool casting /*= false*/) { DisableSpline(); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 5ed2e57cc3f..32f2f1c1870 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1862,6 +1862,7 @@ class TC_GAME_API Unit : public WorldObject virtual bool CanFly() const = 0; bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } bool IsFalling() const; + virtual bool CanSwim() const; void RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker); diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 1d454f11b9c..43609f6633d 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -60,8 +60,8 @@ Location MoveSpline::ComputePosition() const c.orientation = std::atan2(hermite.y, hermite.x); } - if (splineflags.orientationInversed) - c.orientation = -c.orientation; + if (splineflags.backward) + c.orientation = c.orientation - float(M_PI); } return c; } @@ -237,7 +237,7 @@ bool MoveSplineInitArgs::_checkPathBounds() const MoveSplineInitArgs::MoveSplineInitArgs(size_t path_capacity /*= 16*/) : path_Idx_offset(0), velocity(0.f), parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f), -HasVelocity(false), TransformForTransport(true) +walk(false), HasVelocity(false), TransformForTransport(true) { path.reserve(path_capacity); } diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h index 5630349812f..bb2ea4b4ecd 100644 --- a/src/server/game/Movement/Spline/MoveSplineFlag.h +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -36,7 +36,7 @@ namespace Movement Falling = 0x00000200, // Affects elevation computation, can't be combined with Parabolic flag No_Spline = 0x00000400, Parabolic = 0x00000800, // Affects elevation computation, can't be combined with Falling flag - Walkmode = 0x00001000, + CanSwim = 0x00001000, Flying = 0x00002000, // Smooth movement(Catmullrom interpolation mode), flying animation OrientationFixed = 0x00004000, // Model orientation fixed Final_Point = 0x00008000, @@ -51,7 +51,7 @@ namespace Movement TransportExit = 0x01000000, Unknown7 = 0x02000000, Unknown8 = 0x04000000, - OrientationInversed = 0x08000000, + Backward = 0x08000000, Unknown10 = 0x10000000, Unknown11 = 0x20000000, Unknown12 = 0x40000000, @@ -110,7 +110,7 @@ namespace Movement bool falling : 1; bool no_spline : 1; bool parabolic : 1; - bool walkmode : 1; + bool canswim : 1; bool flying : 1; bool orientationFixed : 1; bool final_point : 1; @@ -125,7 +125,7 @@ namespace Movement bool transportExit : 1; bool unknown7 : 1; bool unknown8 : 1; - bool orientationInversed : 1; + bool backward : 1; bool unknown10 : 1; bool unknown11 : 1; bool unknown12 : 1; diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 5e307eea35c..f3c3e09a8e9 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -92,7 +92,12 @@ namespace Movement move_spline.onTransport = transport; uint32 moveFlags = unit->m_movementInfo.GetMovementFlags(); - moveFlags |= (MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD); + moveFlags |= MOVEMENTFLAG_SPLINE_ENABLED; + + if (!args.flags.backward) + moveFlags = moveFlags & ~(MOVEMENTFLAG_BACKWARD) | MOVEMENTFLAG_FORWARD; + else + moveFlags = moveFlags & ~(MOVEMENTFLAG_FORWARD) | MOVEMENTFLAG_BACKWARD; if (moveFlags & MOVEMENTFLAG_ROOT) moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; @@ -102,7 +107,7 @@ namespace Movement // If spline is initialized with SetWalk method it only means we need to select // walk move speed for it but not add walk flag to unit uint32 moveFlagsForSpeed = moveFlags; - if (args.flags.walkmode) + if (args.walk) moveFlagsForSpeed |= MOVEMENTFLAG_WALKING; else moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING; @@ -181,8 +186,9 @@ namespace Movement // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes args.TransformForTransport = unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID(); // mix existing state into new - args.flags.walkmode = unit->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); - args.flags.flying = unit->m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY)); + args.flags.canswim = unit->CanSwim(); + args.walk = unit->HasUnitMovementFlag(MOVEMENTFLAG_WALKING); + args.flags.flying = unit->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY); } MoveSplineInit::~MoveSplineInit() = default; diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index f726af6487f..a2ac8b0b272 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -124,7 +124,7 @@ namespace Movement void SetTransportExit(); /* Inverses unit model orientation. Disabled by default */ - void SetOrientationInversed(); + void SetBackward(); /* Fixes unit's model rotation. Disabled by default */ void SetOrientationFixed(bool enable); @@ -148,12 +148,12 @@ namespace Movement }; inline void MoveSplineInit::SetFly() { args.flags.EnableFlying(); } - inline void MoveSplineInit::SetWalk(bool enable) { args.flags.walkmode = enable; } + inline void MoveSplineInit::SetWalk(bool enable) { args.walk = enable; } inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom(); } inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; } inline void MoveSplineInit::SetFall() { args.flags.EnableFalling(); } inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; } - inline void MoveSplineInit::SetOrientationInversed() { args.flags.orientationInversed = true;} + inline void MoveSplineInit::SetBackward() { args.flags.backward = true; } inline void MoveSplineInit::SetTransportEnter() { args.flags.EnableTransportEnter(); } inline void MoveSplineInit::SetTransportExit() { args.flags.EnableTransportExit(); } inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable; } diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index d3ce9e66bc4..9ba4bc78f49 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -55,6 +55,7 @@ namespace Movement float time_perc; uint32 splineId; float initialOrientation; + bool walk; bool HasVelocity; bool TransformForTransport; diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp index 8105d886384..ca5e75701e0 100644 --- a/src/server/game/Movement/Spline/MovementUtil.cpp +++ b/src/server/game/Movement/Spline/MovementUtil.cpp @@ -153,7 +153,7 @@ namespace Movement STR(Falling ), // 0x00000200, // Not Compartible With Trajectory Movement STR(No_Spline ), // 0x00000400, STR(Trajectory ), // 0x00000800, // Not Compartible With Fall Movement - STR(Walkmode ), // 0x00001000, + STR(CanSwim ), // 0x00001000, STR(Flying ), // 0x00002000, // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation STR(Knockback ), // 0x00004000, // Model Orientation Fixed STR(Final_Point ), // 0x00008000, @@ -168,7 +168,7 @@ namespace Movement STR(Unknown6 ), // 0x01000000, STR(Unknown7 ), // 0x02000000, STR(Unknown8 ), // 0x04000000, - STR(OrientationInversed ), // 0x08000000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation + STR(Backward ), // 0x08000000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation STR(Unknown10 ), // 0x10000000, STR(Unknown11 ), // 0x20000000, STR(Unknown12 ), // 0x40000000, |
