feat(Core/CreatureAI): improve npc position during the combat (#3369)

+ tangent equation to find correct angle and distance when moving

+ implemented proper backward

* Improved performance + random angle margin

* chore: add tollerance calculation in instance

* improved LOS checks with movements

* implemented collisions using raycast (imported by TC)

+ improved collision detection for CanReachPositionAndGetCoords

+ improved collision check

+ set correct flags for the backward movement

+ first implementation of slope angle (to improve)

Co-authored-by: Yehonal <yehonal.azeroth@gmail.com>
This commit is contained in:
Stefano Borzì
2021-01-04 20:23:08 +01:00
committed by GitHub
parent 039e143d48
commit b2761626fe
22 changed files with 1411 additions and 766 deletions

View File

@@ -85,9 +85,11 @@ public:
if (para && strcmp(para, "true") == 0)
useStraightPath = true;
bool useStraightLine = false;
if (para && strcmp(para, "line") == 0)
useStraightLine = true;
bool useRaycast = false;
if (para && (strcmp(para, "line") == 0 || strcmp(para, "ray") == 0 || strcmp(para, "raycast") == 0))
{
useRaycast = true;
}
// unit locations
float x, y, z;
@@ -96,11 +98,12 @@ public:
// path
PathGenerator path(target);
path.SetUseStraightPath(useStraightPath);
path.SetUseRaycast(useRaycast);
bool result = path.CalculatePath(x, y, z, false);
Movement::PointsArray const& pointPath = path.GetPath();
handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str());
handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : useStraightLine ? "Raycast" : "SmoothPath");
handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : useRaycast ? "Raycast" : "SmoothPath");
handler->PSendSysMessage("Result: %s - Length: " SZFMTD " - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType());
G3D::Vector3 const& start = path.GetStartPosition();