MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / IsSimplePath

Method IsSimplePath

engine/Poseidon/AI/AIUnit.cpp:1634–1676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1632 }
1633 AIUnit* leader = _subgroup->Leader();
1634 if (!leader)
1635 {
1636 Fail("No leader");
1637 return GetVehicle()->Position();
1638 }
1639 return GetFormationAbsolute(leader);
1640}
1641
1642bool AIUnit::IsSimplePath(Vector3Val from, Vector3Val pos)
1643{
1644 const float maxDist = 300;
1645 float dist2 = (from - pos).SquareSizeXZ();
1646 if (dist2 > Square(maxDist))
1647 {
1648 return false;
1649 }
1650
1651 GetVehicle()->PerformUnlock();
1652
1653 int xs = toIntFloor(from.X() * InvOperItemGrid);
1654 int zs = toIntFloor(from.Z() * InvOperItemGrid);
1655 int xe = toIntFloor(pos.X() * InvOperItemGrid);
1656 int ze = toIntFloor(pos.Z() * InvOperItemGrid);
1657
1658 int xMin = xs / OperItemRange;
1659 int zMin = zs / OperItemRange;
1660 int xMax = xe / OperItemRange;
1661 int zMax = ze / OperItemRange;
1662 if (xMax < xMin)
1663 {
1664 swap(xMax, xMin);
1665 }
1666 if (zMax < zMin)
1667 {
1668 swap(zMax, zMin);
1669 }
1670
1671 OperMap map;
1672 if ((xMax - xMin) > 50 || (zMax - zMin) > 50)
1673 {
1674 LOG_DEBUG(AI, "xMax {}, xMin {}", xMax, xMin);
1675 LOG_DEBUG(AI, "zMax {}, zMin {}", xMax, xMin);
1676 LOG_DEBUG(AI, "pos {:.2f},{:.2f},{:.2f}", pos[0], pos[1], pos[2]);
1677 LOG_DEBUG(AI, "from {:.2f},{:.2f},{:.2f}", from[0], from[1], from[2]);
1678 }
1679 map.CreateMap(GetVehicle(), xMin, zMin, xMax, zMax);

Callers 1

PositionPilotMethod · 0.45

Calls 8

swapFunction · 0.85
PerformUnlockMethod · 0.80
CreateMapMethod · 0.80
PerformLockMethod · 0.80
SquareFunction · 0.50
SquareSizeXZMethod · 0.45
XMethod · 0.45
ZMethod · 0.45

Tested by

no test coverage detected