Core/Creatures: correct behavior for enabling swimming for creatures on ocean floors
This commit is contained in:
@@ -2931,9 +2931,13 @@ void Creature::InitializeMovementCapabilities()
|
||||
SetDisableGravity(IsFloating());
|
||||
SetControlled(IsSessile(), UNIT_STATE_ROOT);
|
||||
|
||||
// If an amphibious creatures was swimming while engaged, disable swimming again
|
||||
if (IsAmphibious() && !_staticFlags.HasFlag(CREATURE_STATIC_FLAG_CAN_SWIM))
|
||||
RemoveUnitFlag(UNIT_FLAG_CAN_SWIM);
|
||||
if (IsSwimPrevented())
|
||||
{
|
||||
SetUnitFlag2(UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS);
|
||||
SetSwim(false);
|
||||
}
|
||||
else
|
||||
RemoveUnitFlag2(UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS);
|
||||
|
||||
UpdateMovementCapabilities();
|
||||
}
|
||||
@@ -2950,12 +2954,14 @@ void Creature::UpdateMovementCapabilities()
|
||||
if (!isInAir)
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
|
||||
|
||||
// Some Amphibious creatures toggle swimming while engaged
|
||||
if (IsAmphibious() && !HasUnitFlag(UNIT_FLAG_CANT_SWIM) && !HasUnitFlag(UNIT_FLAG_CAN_SWIM) && IsEngaged())
|
||||
if (!CanOnlySwimIfTargetSwims() || (GetVictim() && !GetVictim()->IsOnOceanFloor()))
|
||||
SetUnitFlag(UNIT_FLAG_CAN_SWIM);
|
||||
if (HasUnitFlag2(UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS))
|
||||
if (GetVictim() && GetVictim()->IsInWater() && !GetVictim()->IsOnOceanFloor())
|
||||
RemoveUnitFlag2(UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS);
|
||||
|
||||
SetSwim(IsInWater() && CanSwim());
|
||||
if (IsInWater() && CanSwim())
|
||||
SetSwim(true);
|
||||
else if (!IsInWater()) // We do not want to disable swimming again when a creature is in water - may to lead some nasty bugs
|
||||
SetSwim(false);
|
||||
}
|
||||
|
||||
CreatureMovementData const& Creature::GetMovementTemplate() const
|
||||
|
||||
@@ -154,10 +154,10 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool IsSwimDisabled() const { return _staticFlags.HasFlag(CREATURE_STATIC_FLAG_3_CANT_SWIM); }
|
||||
|
||||
// Returns true if CREATURE_STATIC_FLAG_4_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS is set which prevents 'Amphibious' creatures from swimming when engaged until the victim is no longer on the ocean floor
|
||||
bool CanOnlySwimIfTargetSwims() const { return _staticFlags.HasFlag(CREATURE_STATIC_FLAG_4_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS); }
|
||||
bool IsSwimPrevented() const { return _staticFlags.HasFlag(CREATURE_STATIC_FLAG_4_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS); }
|
||||
|
||||
bool CanSwim() const override;
|
||||
bool CanEnterWater() const override { return (CanSwim() || IsAmphibious()); }
|
||||
bool CanEnterWater() const override { return (CanSwim() || IsAmphibious()); };
|
||||
bool CanFly() const override { return (IsFlying() || HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)); }
|
||||
|
||||
MovementGeneratorType GetDefaultMovementType() const override;
|
||||
|
||||
Reference in New Issue
Block a user