diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2021-01-10 10:18:51 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-03-05 23:04:24 +0100 |
| commit | 6b242eee130f1ac405187a03cefaf595d857ad99 (patch) | |
| tree | 8b9db4fda2439eb8993d20492cbf331921fdefaa /src/server/game/Entities/Unit | |
| parent | 701a3927c153cd4020bc0966fb7e11c750f8d37f (diff) | |
Core/Unit: Fix movement hiccups in water (#24020)
* Core/Unit: Allow to define Units which can enter water but cannot swim
Allow to define Units which can enter water but cannot swim, i.e. crabs walking at the bottom of a sea.
* Add UNIT_FLAG_SWIMMING to creatures when entering combat
* Fix charmed creatures not entering water
* Always allow Creatures controlled by players to enter water
* Add swimming flag when possessing a unit and remove it properly at the end, even if the creature engaged combat before and after.
When adding/removing UNIT_FLAG_SWIMMING manually calling Creature::RefreshSwimmingFlag(true) might be required.
(cherry picked from commit fc1a0d936888395f114028af3337e7d674e0a43c)
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 7 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 41efb7de14a..c103c41770d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3006,7 +3006,7 @@ bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const bool Unit::isInAccessiblePlaceFor(Creature const* c) const { if (IsInWater()) - return c->CanSwim(); + return c->CanEnterWater(); else return c->CanWalk() || c->CanFly(); } @@ -11150,6 +11150,9 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au AddUnitState(UNIT_STATE_CHARMED); + if (Creature* creature = ToCreature()) + creature->RefreshSwimmingFlag(); + if ((GetTypeId() != TYPEID_PLAYER) || (charmer->GetTypeId() != TYPEID_PLAYER)) { // AI will schedule its own change if appropriate @@ -12107,7 +12110,7 @@ bool Unit::CanSwim() const return true; if (HasUnitFlag2(UnitFlags2(0x1000000))) return false; - if (IsPet() && HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT)) + if (HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT)) return true; return HasUnitFlag(UnitFlags(UNIT_FLAG_RENAME | UNIT_FLAG_CAN_SWIM)); } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 655b8f4edaf..8c579aa29b1 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1807,6 +1807,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 CanEnterWater() const = 0; virtual bool CanSwim() const; float GetHoverOffset() const |
