Hi @Viir I’m trying to adopt A-Bot, and have a problem toggling keyboard short-keys, I’m trying to stop the ship using this code but nothing happens:
MotionParamExtension.KeyboardPressCombined(new[] {
WindowsInput.Native.VirtualKeyCode.LCONTROL,
WindowsInput.Native.VirtualKeyCode.SPACE
});
Could you guide me on that?
After half a day of digging I came to conclusion the task loop you’ve coded is beyond me. As for question above - I noticed you have 2 types of “tasks” one are <IBotTask> Component
oriented others are <MotionParam> Effects
and the letter are those that can help with UI interaction. But the logic of execution flow of the public BotStepResult Step(BotStepInput input)
is blowing my mind, right now I’m trying to improve Retreat logic to make it repeat the way I do it in-game (click Citadel, Align, wait for drones, warp out) that’s what I come up so far, but thing is - it keeps clicking on citadel overview item over and over again… My changes to Retreat.cs
main method:
public IEnumerable<IBotTask> Component
{
get
{
var memoryMeasurement = Bot?.MemoryMeasurementAtTime?.Value;
if (!memoryMeasurement.ManeuverStartPossible())
yield break;
// Select citadel in overview
var citadelName = Bot?.ConfigSerialAndStruct.Value?.RetreatCitadel ?? "TEST-NAME";
var CitadelEntry = memoryMeasurement?.WindowOverview?.FirstOrDefault()?.ListView?.Entry?.Where(entry => entry?.Name == citadelName)?.First();
if (CitadelEntry != null)
{
yield return new ElementClickTask { bot = Bot, element = CitadelEntry };
}
else
{
yield break;
}
// Click Align at item UI
var alignIcon = memoryMeasurement?.WindowSelectedItemView?.FirstOrDefault()?.Sprite?.First();
if (alignIcon != null)
{
yield return new ElementClickTask { bot = Bot, element = alignIcon };
// TODO turn off AB
// wait for drones, or do urgent warp out
if (enemyOnGrid(memoryMeasurement) || dronesInSpace(memoryMeasurement) < 1)
{
// Click Dock at item UI
var dockIcon = memoryMeasurement?.WindowSelectedItemView?.FirstOrDefault()?.Sprite?.ElementAt(2);
if (dockIcon != null)
{
yield return new ElementClickTask { bot = Bot, element = dockIcon };
}
}
}
/*
var retreatBookmark = Bot?.ConfigSerialAndStruct.Value?.RetreatBookmark;
yield return new MenuPathTask
{
RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
Bot = Bot,
ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"dock", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
};
*/
}
}
and this is how I changed SaveShip.cs
main method (I’m trying to test Retreat, and want it to proceed to this step right after undocking):
public IEnumerable<IBotTask> Component
{
get
{
var memoryMeasurement = Bot?.MemoryMeasurementAtTime?.Value;
var charIsLocatedInHighsec = 500 < memoryMeasurement?.InfoPanelCurrentSystem?.SecurityLevelMilli;
var setLocalChatWindowCandidate =
memoryMeasurement?.WindowChatChannel
?.Where(window => window?.Caption?.RegexMatchSuccessIgnoreCase(@"local") ?? false)
?.ToArray();
if (1 < setLocalChatWindowCandidate?.Length)
yield return new DiagnosticTask
{
MessageText = CannotIdentifyLocalChatWindowDiagnosticText,
};
var localChatWindow = setLocalChatWindowCandidate?.FirstOrDefault();
if (null == localChatWindow)
yield return new DiagnosticTask
{
MessageText = LocalChatWindowNotFoundDiagnosticText,
};
var sessionDurationSufficient = AllowRoamSessionDurationMin <= memoryMeasurement?.SessionDurationRemaining;
// testing new retreat
var retreatTask = new RetreatTask
{
Bot = Bot,
};
yield return retreatTask;
/*
if (sessionDurationSufficient && (charIsLocatedInHighsec || ChatIsClean(localChatWindow)))
{
AllowRoam = true;
AllowAnomalyEnter = AllowAnomalyEnterSessionDurationMin <= memoryMeasurement?.SessionDurationRemaining;
yield break;
}
yield return new RetreatTask
{
Bot = Bot,
};
*/
}
}
And this is a new task I’ve to do the clicking:
public class ElementClickTask : IBotTask
{
public Bot bot;
public Interface.MemoryStruct.IUIElement element;
public IEnumerable<IBotTask> Component => null;
public IEnumerable<MotionParam> Effects
{
get
{
yield return element?.MouseMove();
yield return element?.MouseClick(MouseButtonIdEnum.Left);
}
}
}