Pikacuq is tweaking A-Bot :)

So this is my journey from fuzzy’s A-bot to my own P-Bot :wink: As original A-bot was not really working in general meaning, I’ve decided to rewrite almost completely all bot tasks to my like and to actually work :wink:

A lot of usefull stuff here → Fuzzy building A-Bot and → Avoiding to struggle - a guide for beginers and → Monitor overview and warpout?

I’m tweaking this bot for my personal use, but if you’ll be interested I can provide u an exe file to test on your char as well. :wink:
Message me! I’m not answering everybody in here. Thanks
(no guarantees at all)


EDIT 26.6.2018
So by this, it looks like bot is done for my usage and besides some little optimization tweaks there is nothing more to work on.

I do run current code with VNI, I had been trying Ishtar but it’s not worth and it died twice on same code on which VNI didnt → so let’s stick with VNI :wink:
Ticks are 20mill stable and no VNI has died with current bot. This may vary of course based on system and fit.

so quick summary what I’ve done

  1. takes all configurations from external file → eg. changing which anomalies/targets/tank without need of recompiling/restarting
  2. scram/disturb ewars are shot as primary targets
  3. cares about blues in anoms → ignoring those anoms, not warping there again
  4. cares about probescanner sigs → removing those which you dont want to run during warping
  5. closes windows from anoms
  6. loot officer wrecks if they are spawned (switching overview tabs, managing cargo/loot etc.)
  7. taking care about shield/armor tank automatically
  8. cycling armor reps to save cap (configurable)
  9. follows several security protocols
    a. if enemies landing on grid → warp off (drones left behind)
    b. if dread spawn → ignore site, retreat drones, move to another anomaly (optionally BM site for later usage)
    c. if shields/armor is lower then treshold → retreat to save
    d. if shields/armor is lower then critical treshold → emergency retreat (drones left behind)
    e. if droneboat (config) and drones 0 or no drone window → dock
  10. check if there are celestials to orbit (in case it warps to wrong anom)
  11. orbits around celestials if they are present
  12. move to another anomaly + ignore current if there is nothing to orbit around (defined in config)
  13. if reds on grid and no celestials to orbit, orbit around target
  14. configurable avoidance list of anoms → based on celestials/structures whatever
  15. configuration how many targets/range/how many drones to use etc.
  16. includes autopilot (toggle via config) which will just follow defined route and rest of the abot code is ignored

many thanks to @kaboonus and @Terpla for ideas and help with some parts of my code! :slight_smile:


tweaks I have in mind which can be done, but for my usage it’s not really what I will probably do

  • say in chat in which anom you are currently (mandatory in some corps)
  • drop MTU + bookmark
  • refill cargo with MTU
  • reship to salvage ship when cargo is empty on MTU
  • pilot salvage ship, loot, drop etc.
  • reship back etc.

tweaks which I will probably do just for more human-like behaviour and fun

  • some cooldown time, when it docks and will do nothing for hour or so
  • play project discovery
  • open character sheet time to time click some tabs
  • check map randomly

ADD 22.7.2018

  • cloaky campers definition (via config) → you set them light blue so they are ignored in local, but if they lands on grid with you, bot will retreatself to safe.
  • few nullexceptions fixed when something somewhere is not read properly

:sunny:

10 Likes

copy the lignes from retreatbookmark from retreat.cs to saveship.cs and change “dock” with align
later: and yes, you can put one condition: if ship is in orbit , then align
and after that call retreattask
:wink: ( you can align, retreat drones and stop afterburner in ship save .cs), on retreat task you can let : afterburner ( if is activ) and warp dock
in combat you can retreat drones, turn off afterburner and take the loot from commander

dude, I’m not asking where to do it … I’m pointing out that there is no readings which tells you if you are aligning or not eg. ShipManeuver is not containing this value.

Yes I can click thru menu, but I do like to do it nicely with given methods instead :wink:

ship maneuver status tell if you are orbiting, is enough :slight_smile:
if (ShipManeuverStatus == ShipManeuverTypeEnum.Orbit)
yield return new MenuPathTask
{
RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
Bot = Bot,
ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @“align”, ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
//ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatSafe }, new[] { @“align”, ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
};

the bot is reading :

    public enum ShipManeuverTypeEnum
    {
        None = 0,
        Stop = 9,
        Approach = 10,
        Orbit = 11,
        KeepAtRange = 12,
        Dock = 17,
        Docked = 18,
        Undock = 19,
        Warp = 30,
        Jump = 31
    }

And also you an read if is in align, if you read shipUI - by caption method

it is not enough because you cannot evaluate if align is already happening or not.
so if bot clicks on “align to” he will keep clicking on it because he does not have a clue if it is already happening.

so, my question is, if we can add align to to shipmaneuver type or how to recognize if it is aligning or not already

edit: your code above might work, you just need to add new type to parse in ParseStatic.cs, i’ll give it a try tho

so, how i told you, you can read aligning state through caption ShipUI .
but if you orbit (usual around a rock) and you comand align, the bot will read if you are still in orbit state; so he will not keep clicking align.
If you turn off afterburner before, and you give him align, in a matter of max 2 sec ( on vni) you get out from orbit state.
at least for me is like that.
Longer will take to return the drones, if you are too close and in the same spot with drones are many objects in space ( wrecks) that will take some time

				if (ShipManeuverStatus == ShipManeuverTypeEnum.Orbit)
				{
					yield return new MenuPathTask
					{
						RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
						Bot = Bot,
						ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"align", ParseStatic.MenuEntryAlignToRegexPattern } },
					};
				}

This works, I’ll look onto the caption as well, thanks

sure is works, :)) i using him ( i told you from real experience ; always, actually i struggle from +1 month with the bot, coding, recoding, etc)

well, your code was not working as you are enumerating warp, which cannot occur in align to menu, i’ve change it a bit to work in my piece, anyways thanks for hint :wink:

for me is working like a charm, he stop ab, start repairer, align and retreat drones. in 6 sec Im in warp ( if drones come fast)

				var ShipManeuverStatus = memoryMeasurement?.ShipUi?.Indication?.ManeuverType;

				if (armorHitPoitns < 1100)
				{
					yield return Bot.EnsureIsActive(armorRepairers);
				}
				if (ShipManeuverStatus == ShipManeuverTypeEnum.Orbit)
					yield return new MenuPathTask
					{
						RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
						Bot = Bot,
						ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"align", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
						//ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatSafe }, new[] { @"align", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
					};
					if (0 < droneInLocalSpaceCount)
						yield return new BotTask //return to bay drone
						{
							Effects = new[] { MotionParamExtension.KeyboardPressCombined(new[] {
									   VirtualKeyCode.SHIFT, VirtualKeyCode.VK_R
										}) }

						};

				if (5 != droneInLocalSpaceCount)
					yield return new RetreatTask { Bot = Bot, };

				if  (2 < setLocalChatWindowCandidate?.Length)
				yield return new RetreatTask { Bot = Bot,};
1 Like

If I’m not mistaken, I also mentioned the need to expand this ShipManeuverTypeEnum. Then the problem was solved as suggested by the kaboonus: by the caption.

var isAligning = memoryMeasurement?.ShipUi?.Indication?.LabelText?.Any(
		text => text?.Text?.RegexMatchSuccess("aligning", System.Text.RegularExpressions.RegexOptions.IgnoreCase) ?? false) ?? false;

if (!isAligning)
{
	yield return new MenuPathTask
	{
		RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
		Bot = Bot,
		ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"align", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
	};
}

Offtop: guys, read this thread.

1 Like

Yes , you mentioned in one post , but for personal use, i don’t “stick” nothing to align state .

My problem for now is to wait in haven anomaly to populate… you have any idea?

donne with highlight the code. Thank you

yep kaboonus, i do have very similar code as test one… but it’s very long process as it is always waits for the end. So what i’m trying to tweak, is more parallel approach eg.

click on prop, align, retreat drones, check if all stuff was done.

:wink:


another thing. I’m not sure how and when exactly, but it seems like sometimes bot after retreat is not able to continue when local is clear. He keeps clicking on infopanelwindow, hovering usually around anomalies submenu. When I physically push escape (to get rid of that menu) bot continue just fine then.
Any idea why it might happen?

hmmmmmm the normal behavior is:
check for local ( save ship and he take the standigs from parse extention)
… ( here you can insert some tasks: align, turnoff ab; call drones)
retreat task: warp - dock to home ( btw, what code you use for warping, i know you changed-him)

-so if you changed the code and you warp directly from saveship? i use that, but to another safespot and after that i call retreat.cs to dock.

if you use warp to 0 ( any method)and after that retreat near station ( warpmenu enumerated) is normal, because the menu is changed ( first is aproach and second is dock, but is an ordinaire menu). So, he try to find warpmenu.
or maybe somewhere you have a loop or condition ( IF…) because if the local become clean, normally, he must enter in anomalytask so he must try to click right on anomaly and warp at 50.
Hovering around anomalies means you:
1 he try to ignore anomaly ( but he cant so he push … save. this is a bug from anomaly, you cant avoid him ( actually yes, you can but… normally is too rare) . ALso he can try to find the one with km :slight_smile: maybe… because near you you have a blue/green and thats because maybe you are in combat mode ( so that means you have some rats and you are near stargate)

So, a good home is: far from any stargate, use a home unused by others ( because he sees them like an ocupied place)
In my opinion, because i strugled with sames troubles:
revise your code; put some conditions to enter in combat mode :

				var Anchor = memoryMeasurement?.WindowOverview?.FirstOrDefault()?.ListView?.Entry
				?.Where(entry => entry?.Name?.RegexMatchSuccessIgnoreCase("broken|pirate gate") ?? false)
				?.OrderBy(entry => entry?.DistanceMax ?? int.MaxValue)
				?.ToList();
 if ((listOverviewEntryToAttack.Count() > 0)  && (Anchor.Count > 0))
start fight

look if you can enter in skipanomaly even if you are not in anomaly ( i have condition: blue, greens, AND anchor to enter in skip anomaly ) So if Im near station, the anchor is not there :d => he enter in normal anomaly enter
Also you can change broken/pirate gate with chemical factory to avoid haven gas :wink: and take out the rats from stargates in overview.
The is another possibility for all this behavior, because he call saveship and after that retreat.cs from inside the combat file ( I think). and that means he doesn’t get out from loop. Again, rats/blues are the reason for that. And again, my anchor var could resolve your trouble, because you enter in combat file only if the anchor is present

ah, so bot thinks SAFE is occupied when there is somebody else? than it kind of make sense he is in loop. Strange, was not really expecting something like that in the code. Have to have a look.

Nope am not warping from saveship, am warping from retreat as i should.
Thing is tho, that bot waits till module stops blinking red, bot waits till drones are in bay etc. to proceed to another task… but in real life, you pres SHIFT+R, disable AB and Align in basically same time. So this is something I want to achieve, but currently without much luck, but am trying :slight_smile:

My idea is to push shortcuts for module where AB sits and for drones in one step. But I’m kind of strugling with fact, that bot keeps pushing that key more than once eg. stopping and starting AB continously. In terms of drones it does not matter, but module is a problem. Kind of can’t figure out how in C# can I run code just once properly. :slight_smile:

That anchor var is pretty clever. Would you be so kind and shared with me your combat and retreat? :wink:

my retreat is the usual one ( except off abot, to be sure, i work all on shipsave.
:slight_smile:
my combat is on development all time, is more green from too many /* */ and // :slight_smile: but i will share parts of him with explanations in Avoiding to struggle - a guide for beginers - #2 by kaboonus
Im more interested how you tweaked the warp line, from the beginning of our discussion.

you cant push all of them in same time that’s work for me Pikacuq is tweaking A-Bot :) - #11 by kaboonus but after that i put them all together … because I fly ships without drones. Also i warp from saveship to an safespot, just because some of reds just passing ( and is enough for me to be in warp before they get out from system and in the end i call retreat task

well you can push as many of buttons you want at same time, that’s not an issue.
Issue is (which am currently struggling with) that code is executing this class over and over again. What I need is to execute it only once and then continue to warpin.

I know that it is solvable with some conditions, issue is, that those conditions - like “check if drones are back” or “check if module is not active” takes quite a long time eg. I dont want to wait to my drones to proceed to another task, they can be returing whils bot is doing another tasks.

which part you are interested in? this is my work-in-progress code around aligning/warping/saving drones.
only “issue” now is that disabling propmod is in my opinion slowest part, because it is simply waiting for module to stop glowing red. Better option will be just push shortcut key, but have no yet idea how to push it just once :slight_smile:

				// step 1 align + first call of drones
				if (ShipManeuverStatus == ShipManeuverTypeEnum.Orbit)
				{
					yield return new BotTask //return to bay drone
					{
						Effects = new[] { MotionParamExtension.KeyboardPressCombined(new[] { VirtualKeyCode.VK_R }) }
					};

					yield return new MenuPathTask
					{
						RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
						Bot = Bot,
						ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"align", ParseStatic.MenuEntryAlignToRegexPattern } },
					};
				}
				// step 2 check if propmod is on and deactivate it
				yield return Bot?.DeactivateModule(setPropmod); //DEACTIVATE AF/MWD

				// step 3 recall drones if they are still in space
				if (0 < droneInLocalSpaceCount)
				{
					yield return droneGroupInLocalSpace.ClickMenuEntryByRegexPattern(Bot, @"return.*bay");
				}

				// step 4 warp to safe
				yield return new MenuPathTask
				{
					RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
					Bot = Bot,
					ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"dock", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
				};

this ones are good, but before them you can put:

if (ab.IsActive(Bot) ?? true)
{
{
yield return Bot.DeactivateModule(aboff);
//yield return Bot.EnsureIsActive(armorRepairers);
};
yield return new BotTask //return to bay drone
{
Effects = new[] { MotionParamExtension.KeyboardPressCombined(new[] {
VirtualKeyCode.SHIFT, VirtualKeyCode.VK_R
}) }

};
yield return new MenuPathTask
{
RootUIElement = memoryMeasurement?.InfoPanelCurrentSystem?.ListSurroundingsButton,
Bot = Bot,
ListMenuListPriorityEntryRegexPattern = new[] { new[] { retreatBookmark }, new[] { @"align", ParseStatic.MenuEntryWarpToAtLeafRegexPattern } },
};
}

my trick is using 2 definitions for ab :d one for interogate the modul if is active ( not with glowing because he will wait, like you said) and one for deactivate. And I come with that simply because you cant have both in same definition of ab

         var ab = Bot?.MemoryMeasurementAccu?.ShipUiModule?.Where(m => m?.IsAfterburner(Bot) ?? false).FirstOrDefault();
                var aboff = Bot?.MemoryMeasurementAccu?.ShipUiModule?.Where(m => m?.TooltipLast?.Value?.IsAfterburner ?? false);

and also i deactivated the click left from tooltip module ( so he use only f1/f2/f3). You can try to use only the tooltip module variant and you will see you cant use If is active :)) so i made 2 definitions

interesting, where you have defined m?.IsAfterburner(Bot) ? this code of yours gives me an error there