Skip to content

Commit

Permalink
Implement idea from JongoFett
Browse files Browse the repository at this point in the history
Adapt for idea from JongoFett at #7 (comment)
  • Loading branch information
Viir committed Apr 21, 2020
1 parent fcda33e commit a307028
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions implement/applications/eve-online/eve-online-mining-bot/src/Bot.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{- EVE Online mining bot version 2020-04-18
{- EVE Online mining bot version 2020-04-18 - 2020-04-21 JongoFett
2020-04-21 adapted for idea from JongoFett at https://github.com/Viir/bots/issues/7#issue-602415016
The bot warps to an asteroid belt, mines there until the ore hold is full, and then docks at a station to unload the ore. It then repeats this cycle until you stop it.
It remembers the station in which it was last docked, and docks again at the same station.
Expand Down Expand Up @@ -473,7 +474,7 @@ travelToMiningSiteAndLaunchDronesAndTargetAsteroid context =
|> Maybe.withDefault
(DescribeBranch
("Choosing asteroid '" ++ (asteroidInOverview.objectName |> Maybe.withDefault "Nothing") ++ "'")
(lockTargetFromOverviewEntryAndEnsureIsInRange (min context.settings.targetingRange context.settings.miningModuleRange) asteroidInOverview)
(lockTargetFromOverviewEntryAndEnsureIsInRange context.parsedUserInterface (min context.settings.targetingRange context.settings.miningModuleRange) asteroidInOverview)
)


Expand Down Expand Up @@ -530,8 +531,8 @@ ensureOreHoldIsSelectedInInventoryWindow parsedUserInterface continueWithInvento
)


lockTargetFromOverviewEntryAndEnsureIsInRange : Int -> OverviewWindowEntry -> DecisionPathNode
lockTargetFromOverviewEntryAndEnsureIsInRange rangeInMeters overviewEntry =
lockTargetFromOverviewEntryAndEnsureIsInRange : ParsedUserInterface -> Int -> OverviewWindowEntry -> DecisionPathNode
lockTargetFromOverviewEntryAndEnsureIsInRange parsedUserInterface rangeInMeters overviewEntry =
case overviewEntry.objectDistanceInMeters of
Ok distanceInMeters ->
if distanceInMeters <= rangeInMeters then
Expand All @@ -544,22 +545,37 @@ lockTargetFromOverviewEntryAndEnsureIsInRange rangeInMeters overviewEntry =

else
DescribeBranch ("Object is not in range (" ++ (distanceInMeters |> String.fromInt) ++ " meters away). Approach.")
(EndDecisionPath
(actStartingWithRightClickOnOverviewEntry
overviewEntry
[ ( "Click menu entry 'approach'."
, lastContextMenuOrSubmenu
>> Maybe.andThen (menuEntryContainingTextIgnoringCase "approach")
>> Maybe.map (.uiNode >> clickOnUIElement MouseButtonLeft >> List.singleton)
)
]
)
(if isShipApproaching parsedUserInterface then
DescribeBranch "I see we already approach." (EndDecisionPath Wait)

else
EndDecisionPath
(actStartingWithRightClickOnOverviewEntry
overviewEntry
[ ( "Click menu entry 'approach'."
, lastContextMenuOrSubmenu
>> Maybe.andThen (menuEntryContainingTextIgnoringCase "approach")
>> Maybe.map (.uiNode >> clickOnUIElement MouseButtonLeft >> List.singleton)
)
]
)
)

Err error ->
DescribeBranch ("Failed to read the distance: " ++ error) (EndDecisionPath Wait)


isShipApproaching : ParsedUserInterface -> Bool
isShipApproaching =
.shipUI
>> maybeNothingFromCanNotSeeIt
>> Maybe.andThen (.indication >> maybeNothingFromCanNotSeeIt)
>> Maybe.andThen (.maneuverType >> maybeNothingFromCanNotSeeIt)
>> Maybe.map ((==) EveOnline.ParseUserInterface.ManeuverApproach)
-- If the ship is just floating in space, there might be no indication displayed.
>> Maybe.withDefault False


lockTargetFromOverviewEntry : OverviewWindowEntry -> DecisionPathNode
lockTargetFromOverviewEntry overviewEntry =
DescribeBranch ("Lock target from overview entry '" ++ (overviewEntry.objectName |> Maybe.withDefault "") ++ "'")
Expand Down

0 comments on commit a307028

Please sign in to comment.