Skip to content

Commit 22709c2

Browse files
committed
Duh, euclidean distance was already done above
1 parent cceaaa8 commit 22709c2

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

Data/Base.rte/AI/HumanBehaviors.lua

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -989,20 +989,17 @@ function HumanBehaviors.WeaponSearch(AI, Owner, Abort)
989989
end
990990

991991
if MovableMan:ValidMO(device) and pathMultipler ~= -1 then
992-
local simpleDistance = SceneMan:ShortestDistance(Owner.Pos, device.Pos, false) * pathMultipler;
993-
if simpleDistance < maxPathLength then
994-
local deviceID = device.UniqueID;
995-
SceneMan.Scene:CalculatePathAsync(
996-
function(pathRequest)
997-
local pathLength = pathRequest.PathLength * pathMultipler;
998-
if pathLength < maxPathLength then
999-
table.insert(devicesToPickUp, {deviceId = deviceID, score = score});
1000-
end
1001-
searchesRemaining = searchesRemaining - 1;
1002-
end,
1003-
Owner.Pos, device.Pos, false, Owner.DigStrength, Owner.Team
1004-
);
1005-
end
992+
local deviceID = device.UniqueID;
993+
SceneMan.Scene:CalculatePathAsync(
994+
function(pathRequest)
995+
local pathLength = pathRequest.PathLength * pathMultipler;
996+
if pathLength < maxPathLength then
997+
table.insert(devicesToPickUp, {deviceId = deviceID, score = score});
998+
end
999+
searchesRemaining = searchesRemaining - 1;
1000+
end,
1001+
Owner.Pos, device.Pos, false, Owner.DigStrength, Owner.Team
1002+
);
10061003
end
10071004
end
10081005

@@ -1107,20 +1104,17 @@ function HumanBehaviors.ToolSearch(AI, Owner, Abort)
11071104
for _, deviceEntry in pairs(devices) do
11081105
local device = deviceEntry.device;
11091106
if MovableMan:ValidMO(device) then
1110-
local simpleDistance = SceneMan:ShortestDistance(Owner.Pos, device.Pos, false);
1111-
if simpleDistance < maxPathLength then
1112-
local deviceId = device.UniqueID;
1113-
SceneMan.Scene:CalculatePathAsync(
1114-
function(pathRequest)
1115-
local pathLength = pathRequest.PathLength;
1116-
if pathRequest.Status ~= PathRequest.NoSolution and pathLength < maxPathLength then
1117-
table.insert(devicesToPickUp, {deviceId = deviceId, score = pathLength});
1118-
end
1119-
searchesRemaining = searchesRemaining - 1;
1120-
end,
1121-
Owner.Pos, device.Pos, false, Owner.DigStrength, Owner.Team
1122-
);
1123-
end
1107+
local deviceId = device.UniqueID;
1108+
SceneMan.Scene:CalculatePathAsync(
1109+
function(pathRequest)
1110+
local pathLength = pathRequest.PathLength;
1111+
if pathRequest.Status ~= PathRequest.NoSolution and pathLength < maxPathLength then
1112+
table.insert(devicesToPickUp, {deviceId = deviceId, score = pathLength});
1113+
end
1114+
searchesRemaining = searchesRemaining - 1;
1115+
end,
1116+
Owner.Pos, device.Pos, false, Owner.DigStrength, Owner.Team
1117+
);
11241118
end
11251119
end
11261120

0 commit comments

Comments
 (0)