Files
mod-playerbots/src/strategy/values/IsMovingValue.cpp
SaW 13a4dde643 Avoids the possible incorrect swimming state when bots coming ashore (#1051)
Improves the check for when in/under water, avoiding the possible incorrect swimming state when bots coming ashore (shortly swimming in air).
2025-03-03 15:10:47 +01:00

31 lines
743 B
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "IsMovingValue.h"
#include "Playerbots.h"
bool IsMovingValue::Calculate()
{
Unit* target = AI_VALUE(Unit*, qualifier);
if (!target)
return false;
return target->isMoving();
}
bool IsSwimmingValue::Calculate()
{
Unit* target = AI_VALUE(Unit*, qualifier);
if (!target)
return false;
int8 targetInLiquidState = target->GetLiquidData().Status;
return targetInLiquidState == LIQUID_MAP_UNDER_WATER || (targetInLiquidState == LIQUID_MAP_IN_WATER && target->CanSwim());
}