From a7e33a6fadf8c2625ac40e41d30cffcb7bd1b7ea Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 9 Feb 2024 21:35:19 +0800 Subject: [PATCH] FIx move to --- src/strategy/actions/MovementActions.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 9437f3c1..6d0ba2dd 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -149,7 +149,13 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // if (bot->Unit::IsFalling()) { // bot->Say("I'm falling", LANG_UNIVERSAL); // } - float distance = bot->GetExactDist(x, y, z); + bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && + !bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater(); + float modifiedZ = SearchBestGroundZForPath(x, y, z, generatePath, 20.0f, normal_only); + if (modifiedZ == INVALID_HEIGHT) { + return false; + } + float distance = bot->GetExactDist(x, y, modifiedZ); if (distance > sPlayerbotAIConfig->contactDistance) { WaitForReach(distance); @@ -162,14 +168,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bot->CastStop(); botAI->InterruptSpell(); } - bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && - !bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater(); MotionMaster &mm = *bot->GetMotionMaster(); - float modifiedZ = SearchBestGroundZForPath(x, y, z, generatePath, 20.0f, normal_only); - if (modifiedZ == INVALID_HEIGHT) { - return false; - } mm.Clear(); mm.MovePoint(mapId, x, y, modifiedZ, generatePath); AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation());