Fix bot swimming behavior at the surface and in shallow waters (#908)

- Fix for Bots don't swim properly near the surface #903
- Prevents bots teleporting/warping to the surface when in (shallow) waters.
This commit is contained in:
SaW
2025-01-25 16:30:47 +01:00
committed by GitHub
parent f0d4273e4a
commit 2ebeb244ec

View File

@@ -978,11 +978,13 @@ bool MovementAction::Follow(Unit* target, float distance) { return Follow(target
void MovementAction::UpdateMovementState()
{
if (bot->Unit::IsUnderWater())
int8 botInLiquidState = bot->GetLiquidData().Status;
if (botInLiquidState == LIQUID_MAP_IN_WATER || botInLiquidState == LIQUID_MAP_UNDER_WATER)
{
bot->SetSwim(true);
}
else if (!bot->Unit::IsInWater())
else
{
bot->SetSwim(false);
}
@@ -990,18 +992,21 @@ void MovementAction::UpdateMovementState()
bool onGround = bot->GetPositionZ() <
bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f;
// Keep bot->SendMovementFlagUpdate() withing the if statements to not intefere with bot behavior on ground/(shallow) waters
if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround)
{
bot->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
bot->SendMovementFlagUpdate();
}
if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
else if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
(!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround))
{
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
bot->SendMovementFlagUpdate();
}
bot->SendMovementFlagUpdate();
// Temporary speed increase in group
// if (botAI->HasRealPlayerMaster()) {
// bot->SetSpeedRate(MOVE_RUN, 1.1f);