mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Improve movement performance
This commit is contained in:
@@ -1290,50 +1290,49 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d
|
||||
return MoveNear(mapId, x, y, z, distance);
|
||||
}
|
||||
|
||||
float MovementAction::SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range, bool normal_only)
|
||||
float MovementAction::SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range, bool normal_only, float step)
|
||||
{
|
||||
if (!generatePath) {
|
||||
return z;
|
||||
}
|
||||
float min_length = MAX_PATH_LENGTH;
|
||||
float min_length = 100000.0f;
|
||||
float current_z = INVALID_HEIGHT;
|
||||
float modified_z;
|
||||
float delta;
|
||||
for (delta = 0.0f; delta <= range / 2; delta += 2) {
|
||||
for (delta = 0.0f; delta <= range / 2; delta += step) {
|
||||
modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
|
||||
PathGenerator gen(bot);
|
||||
gen.CalculatePath(x, y, modified_z);
|
||||
|
||||
if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
|
||||
min_length = gen.getPathLength();
|
||||
current_z = modified_z;
|
||||
// if (abs(current_z - z) < 0.1f) {
|
||||
// return current_z;
|
||||
// }
|
||||
if (abs(current_z - z) < 0.5f) {
|
||||
return current_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (delta = -1.0f; delta >= -range / 2; delta -= 2) {
|
||||
for (delta = -step; delta >= -range / 2; delta -= step) {
|
||||
modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
|
||||
PathGenerator gen(bot);
|
||||
gen.CalculatePath(x, y, modified_z);
|
||||
if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
|
||||
min_length = gen.getPathLength();
|
||||
current_z = modified_z;
|
||||
// if (abs(current_z - z) < 0.1f) {
|
||||
// return current_z;
|
||||
// }
|
||||
if (abs(current_z - z) < 0.5f) {
|
||||
return current_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (delta = range / 2 + 1.0f; delta <= range; delta += 2) {
|
||||
for (delta = range / 2 + step; delta <= range; delta += 2) {
|
||||
modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
|
||||
PathGenerator gen(bot);
|
||||
gen.CalculatePath(x, y, modified_z);
|
||||
if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
|
||||
min_length = gen.getPathLength();
|
||||
current_z = modified_z;
|
||||
// if (abs(current_z - z) < 0.1f) {
|
||||
// return current_z;
|
||||
// }
|
||||
if (abs(current_z - z) < 0.5f) {
|
||||
return current_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current_z == INVALID_HEIGHT && normal_only) {
|
||||
|
||||
@@ -41,7 +41,7 @@ class MovementAction : public Action
|
||||
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance);
|
||||
void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false);
|
||||
private:
|
||||
float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 10.0f, bool normal_only = false);
|
||||
float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 15.0f, bool normal_only = false, float step = 3.0f);
|
||||
};
|
||||
|
||||
class FleeAction : public MovementAction
|
||||
|
||||
Reference in New Issue
Block a user