I wrote a mod that automatically sends any RC Explorer to its nearest anomaly. The underlying script uses the FindNearest function for locating an anomaly, but unfortunately this may pick an unreachable one (that would require a tunnel first). I've tried FindShortestPath as well but didn't seem to make any difference.
Is there a way to test if there is a path between the rover and the target anomaly location so that it can be filtered out if no such path exists (via the filter query function, also considering tunnels)?
My current code is as follows:
There is a similar routine for locating a Power Cable for recharing purposes, but that's usually not a problem to get to.
Is there a way to test if there is a path between the rover and the target anomaly location so that it can be filtered out if no such path exists (via the filter query function, also considering tunnels)?
My current code is as follows:
Code:
ForEach { class = "ExplorerRover", exec = function(rover)
-- Idle explorers only
if rover.command == "Idle" then
-- make sure there is plenty of battery to start with
if rover.battery_current > rover.battery_max * 0.6 then
local obj, distance = FindNearest({
class = "SubsurfaceAnomaly"
}, rover)
if obj then
AddCustomOnScreenNotification(
"AutoExploreAnomaly",
T{"RC Explorer"},
T{"Started exploring an anomaly"},
"UI/Icons/Notifications/research_2.tga",
false,
{
expiration = 15000
}
)
-- rover:Analyze(obj) doesn't work properly
rover:InteractWithObject(obj, "analyze")
end
end
end
end }
There is a similar routine for locating a Power Cable for recharing purposes, but that's usually not a problem to get to.