movement fix test

This commit is contained in:
Yunfan Li
2023-09-04 17:05:15 +08:00
parent 7e1de0b9cf
commit 80ea3426d0

View File

@@ -7,6 +7,7 @@
#include "MovementGenerator.h" #include "MovementGenerator.h"
#include "ObjectDefines.h" #include "ObjectDefines.h"
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "PathGenerator.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "SharedDefines.h" #include "SharedDefines.h"
#include "TargetedMovementGenerator.h" #include "TargetedMovementGenerator.h"
@@ -147,14 +148,15 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// if (bot->Unit::IsFalling()) { // if (bot->Unit::IsFalling()) {
// bot->Say("I'm falling", LANG_UNIVERSAL); // bot->Say("I'm falling", LANG_UNIVERSAL);
// } // }
float modified_z = z + 5.0f; float modified_z;
bot->UpdateAllowedPositionZ(x, y, modified_z); for (float delta = 2.0f; delta <= 15.0f; delta++) {
// prevent falling when bot on slope modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
if (modified_z < z - 20.0f) { PathGenerator gen(bot);
modified_z = z + 15.0f; gen.CalculatePath(x, y, modified_z);
bot->UpdateAllowedPositionZ(x, y, modified_z); if (gen.GetPathType() == PATHFIND_NORMAL) {
break;
}
} }
z = modified_z;
// z += 0.5f; // z += 0.5f;
float distance = bot->GetDistance2d(x, y); float distance = bot->GetDistance2d(x, y);
if (distance > sPlayerbotAIConfig->contactDistance) if (distance > sPlayerbotAIConfig->contactDistance)