Skip to content

Commit 9154971

Browse files
committed
Add setting return-drones-when-no-rats-visible
+ Expand bot memory to remember last time we saw a rat. + Add setting `return-drones-when-no-rats-visible`, defaulting to 'Yes' + If `return-drones-when-no-rats-visible` is set to 'Yes' drones should not be launched if we have not seen a rat in the last ten seconds.
1 parent 8f5d68a commit 9154971

File tree

1 file changed

+75
-2
lines changed
  • implement/applications/eve-online/eve-online-mining-bot

1 file changed

+75
-2
lines changed

implement/applications/eve-online/eve-online-mining-bot/Bot.elm

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{- EVE Online mining bot version 2025-10-29
1+
{- EVE Online mining bot version 2025-11-06
22
33
This bot automates the complete mining process, including offloading the ore and traveling between the mining spot and the unloading location.
44
@@ -135,6 +135,7 @@ defaultBotSettings =
135135
, afterburnerModuleText = Nothing
136136
, afterburnerDistanceThreshold = Nothing
137137
, compressFromMiningHold = PromptParser.No
138+
, returnDronesWhenNoRatsVisible = PromptParser.Yes
138139
}
139140

140141

@@ -298,6 +299,14 @@ parseBotSettings =
298299
(\compress settings -> { settings | compressFromMiningHold = compress })
299300
}
300301
)
302+
, ( "return-drones-when-no-rats-visible"
303+
, { alternativeNames = []
304+
, description = "Return drones to bay when no rats are visible in space. The only supported values are `no` and `yes`."
305+
, valueParser =
306+
PromptParser.valueTypeYesOrNo
307+
(\returnDrones settings -> { settings | returnDronesWhenNoRatsVisible = returnDrones })
308+
}
309+
)
301310
]
302311
|> Dict.fromList
303312
)
@@ -333,6 +342,7 @@ type alias BotSettings =
333342
, afterburnerModuleText : Maybe String
334343
, afterburnerDistanceThreshold : Maybe Int
335344
, compressFromMiningHold : PromptParser.YesOrNo
345+
, returnDronesWhenNoRatsVisible : PromptParser.YesOrNo
336346
}
337347

338348

@@ -344,6 +354,7 @@ type alias BotMemory =
344354
, shipModules : ShipModulesMemory
345355
, overviewWindows : OverviewWindowsMemory
346356
, lastReadingsInSpaceDronesWindowWasVisible : List Bool
357+
, lastTimeRatVisible : Maybe Int
347358
}
348359

349360

@@ -1102,7 +1113,7 @@ travelToMiningSiteAndLaunchDronesAndTargetAsteroid selectedAsteroids context =
11021113
describeBranch ("Choosing asteroid '" ++ (asteroidInOverview.objectName |> Maybe.withDefault "Nothing") ++ "'")
11031114
(warpToOverviewEntryIfFarEnough context asteroidInOverview
11041115
|> Maybe.withDefault
1105-
(launchDrones context
1116+
(launchOrReturnDronesAccordingToSettings context
11061117
|> Maybe.withDefault
11071118
(lockTargetFromOverviewEntryAndEnsureIsInRange
11081119
context
@@ -1672,6 +1683,34 @@ dockToRandomStationOrStructure context =
16721683
context
16731684

16741685

1686+
launchOrReturnDronesAccordingToSettings : BotDecisionContext -> Maybe DecisionPathNode
1687+
launchOrReturnDronesAccordingToSettings context =
1688+
let
1689+
dronesShouldBeLaunched : Bool
1690+
dronesShouldBeLaunched =
1691+
if context.eventContext.botSettings.returnDronesWhenNoRatsVisible == PromptParser.Yes then
1692+
case context.memory.lastTimeRatVisible of
1693+
Nothing ->
1694+
False
1695+
1696+
Just lastTimeRatVisible ->
1697+
let
1698+
timeSinceLastRatVisibleInSeconds =
1699+
(context.eventContext.timeInMilliseconds // 1000)
1700+
- lastTimeRatVisible
1701+
in
1702+
timeSinceLastRatVisibleInSeconds < 10
1703+
1704+
else
1705+
True
1706+
in
1707+
if dronesShouldBeLaunched then
1708+
launchDrones context
1709+
1710+
else
1711+
returnDronesToBay context
1712+
1713+
16751714
launchDrones : BotDecisionContext -> Maybe DecisionPathNode
16761715
launchDrones context =
16771716
context.readingFromGameClient.dronesWindow
@@ -1854,6 +1893,7 @@ initBotMemory =
18541893
, shipModules = EveOnline.BotFramework.initShipModulesMemory
18551894
, overviewWindows = EveOnline.BotFramework.initOverviewWindowsMemory
18561895
, lastReadingsInSpaceDronesWindowWasVisible = []
1896+
, lastTimeRatVisible = Nothing
18571897
}
18581898

18591899

@@ -1995,6 +2035,17 @@ updateMemoryForNewReadingFromGame context botMemoryBefore =
19952035
(context.readingFromGameClient.dronesWindow /= Nothing)
19962036
:: botMemoryBefore.lastReadingsInSpaceDronesWindowWasVisible
19972037
|> List.take dockWhenDroneWindowInvisibleCount
2038+
2039+
ratsVisibleNow =
2040+
overviewShowsRat context.readingFromGameClient
2041+
2042+
lastTimeRatVisible : Maybe Int
2043+
lastTimeRatVisible =
2044+
if ratsVisibleNow then
2045+
Just (context.timeInMilliseconds // 1000)
2046+
2047+
else
2048+
botMemoryBefore.lastTimeRatVisible
19982049
in
19992050
{ lastDockedStationNameFromInfoPanel =
20002051
[ currentStationNameFromInfoPanel, botMemoryBefore.lastDockedStationNameFromInfoPanel ]
@@ -2010,6 +2061,7 @@ updateMemoryForNewReadingFromGame context botMemoryBefore =
20102061
botMemoryBefore.overviewWindows
20112062
|> EveOnline.BotFramework.integrateCurrentReadingsIntoOverviewWindowsMemory context.readingFromGameClient
20122063
, lastReadingsInSpaceDronesWindowWasVisible = lastReadingsInSpaceDronesWindowWasVisible
2064+
, lastTimeRatVisible = lastTimeRatVisible
20132065
}
20142066

20152067

@@ -2323,6 +2375,27 @@ containsSelectionIndicatorPhotonUI =
23232375
)
23242376

23252377

2378+
overviewShowsRat : ReadingFromGameClient -> Bool
2379+
overviewShowsRat readingFromGameClient =
2380+
List.any
2381+
(\overviewWindow ->
2382+
List.any iconSpriteHasColorOfRat overviewWindow.entries
2383+
)
2384+
readingFromGameClient.overviewWindows
2385+
2386+
2387+
iconSpriteHasColorOfRat : EveOnline.ParseUserInterface.OverviewWindowEntry -> Bool
2388+
iconSpriteHasColorOfRat overviewEntry =
2389+
case overviewEntry.iconSpriteColorPercent of
2390+
Nothing ->
2391+
False
2392+
2393+
Just colorPercent ->
2394+
(colorPercent.g * 3 < colorPercent.r)
2395+
&& (colorPercent.b * 3 < colorPercent.r)
2396+
&& (60 < colorPercent.r && 50 < colorPercent.a)
2397+
2398+
23262399
nothingFromIntIfGreaterThan : Int -> Int -> Maybe Int
23272400
nothingFromIntIfGreaterThan limit originalInt =
23282401
if limit < originalInt then

0 commit comments

Comments
 (0)