[Roambox] Improve Path Finding (#2324)

This commit is contained in:
Paul Coene 2022-07-30 15:52:28 -04:00 committed by GitHub
parent dd71420a0e
commit 113846c48c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1602,9 +1602,8 @@ void NPC::AI_DoMovement() {
move_delay_max
);
Log(
Logs::Detail,
Logs::NPCRoamBox, "(%s) Timer calc | random_timer [%i] roambox_move_delay [%i] move_min [%i] move_max [%i]",
LogNPCRoamBoxDetail(
"({}) Timer calc | random_timer [{}] roambox_move_delay [{}] move_min [{}] move_max [{}]",
GetCleanName(),
random_timer,
roambox_move_delay,
@ -1661,9 +1660,7 @@ void NPC::AI_DoMovement() {
}
if (zone->watermap->InLiquid(position)) {
Log(Logs::Detail,
Logs::NPCRoamBox, "%s | My destination is in water and I don't belong there!",
GetCleanName());
LogNPCRoamBoxDetail("[{}] | My destination is in water and I don't belong there!", GetCleanName());
return;
}
@ -1683,39 +1680,12 @@ void NPC::AI_DoMovement() {
}
}
PathfinderOptions opts;
opts.smooth_path = true;
opts.step_size = RuleR(Pathing, NavmeshStepSize);
opts.offset = GetZOffset();
opts.flags = PathingNotDisabled ^ PathingZoneLine;
LogNPCRoamBox("[{}] | Pathing to [{}] [{}] [{}]", GetCleanName(),
roambox_destination_x, roambox_destination_y,
roambox_destination_z);
auto partial = false;
auto stuck = false;
auto route = zone->pathing->FindPath(
glm::vec3(GetX(), GetY(), GetZ()),
glm::vec3(
roambox_destination_x,
roambox_destination_y,
roambox_destination_z
),
partial,
stuck,
opts
);
if (route.empty()) {
Log(
Logs::Detail,
Logs::NPCRoamBox, "(%s) We don't have a path route... exiting...",
GetCleanName()
);
return;
}
Log(
Logs::General,
Logs::NPCRoamBox,
"NPC (%s) distance [%.0f] X (min/max) [%.0f / %.0f] Y (min/max) [%.0f / %.0f] | Dest x/y/z [%.0f / %.0f / %.0f]",
LogNPCRoamBox(
"NPC ({}) distance [{}] X (min/max) [{} / {}] Y (min/max) [{} / {}] | Dest x/y/z [{} / {} / {}]",
GetCleanName(),
roambox_distance,
roambox_min_x,