• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

akarnokd

Recruit
23 Badges
Mar 16, 2018
5
0
  • Stellaris - Path to Destruction bundle
  • Stellaris: Ancient Relics
  • Stellaris: Megacorp
  • Shadowrun: Hong Kong
  • Shadowrun: Dragonfall
  • Shadowrun Returns
  • Stellaris: Distant Stars
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Age of Wonders III
  • Stellaris: Synthetic Dawn
  • Surviving Mars
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Tyranny: Archon Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Pillars of Eternity
  • Crusader Kings II
  • Ancient Space
  • Magicka
  • Cities in Motion
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:

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.