Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This script mines ore from asteroids.
- // before running this script, make sure to prepare as follows:
- // +Vous devez créer au moins un dossier avec des bookmarks dedans;
- // +in the Overview create a preset which includes asteroids and rats and enter the name of that preset in the configuration section below at 'OverviewPreset'. The bot will make sure this preset is loaded when it needs to use the overview.
- // +set Overview to sort by distance with the nearest entry at the top.
- // +in the Inventory select the 'List' view.
- // +set the UI language to english.
- // +use a ship with an ore hold.
- // +put some light drones into your ships' drone bay. The bot will make use of them to attack rats when HP are too low (configurable) or it gets jammed.
- // +enable the info panel 'System info'. The bot will use the button in there to access bookmarks and asteroid belts.
- // +arrange windows to not occlude modules or info panels.
- // +in the ship UI, disable "Display Passive Modules" and disable "Display Empty Slots" and enable "Display Module Tooltips". The bot uses the module tooltips to automatically identify the properties of the modules.
- // PS. Le nom des bookmarks n'est pas important.
- // +Put the attack drones in a group.
- // +if you want to use mining drones put them also in a group.
- using BotSharp.ToScript.Extension;
- using Parse = Sanderling.Parse;
- using System.Timers;
- // begin of configuration section ->
- int SetMinerYield = 0;
- double SetMinerDuration = 0;
- // Mettre les noms des dossiers qui contien les bookmarks que vous voulez aller miner dedans. Add additional folders separated by comma.
- string[] SetMiningFolderBookmark = {""};
- // Bookmark of location where ore should be unloaded.
- string UnloadBookmark = "";
- // Name of the container to unload to as shown in inventory.
- string UnloadDestContainerName = "";
- // Bookmark of place to retreat to to prevent ship loss.
- string RetreatBookmark = UnloadBookmark;
- bool UseMiningDrones = false;
- bool UseSurveyScanView = false;
- // The name of the label that you place the attack drones
- string LabelNameAttackDrones = "";
- // The name of the label that you place the mining drones
- string LabelNameMiningDrones = null;
- // The bot loads this preset to the active tab.
- string OverviewPreset = "";
- var ActivateHardener = true;
- // bot will start fighting (and stop mining) when hitpoints are lower.
- var DefenseEnterHitpointThresholdPercent = 85;
- var DefenseExitHitpointThresholdPercent = 90;
- var EmergencyWarpOutHitpointPercent = 60;
- var FightAllRats = true; // when this is set to true, the bot will attack rats independent of shield hp.
- var RetreatOnNeutralOrHostileInLocal = false; // warp to RetreatBookmark when a neutral or hostile is visible in local.
- // <- end of configuration section
- Dictionary<string, double> asteroidUnitsPerM3 = new Dictionary<string, double>();
- System.Timers.Timer aTimer = new System.Timers.Timer(1); // Module miner 1 timer
- System.Timers.Timer bTimer = new System.Timers.Timer(1); // Module miner 2 timer
- System.Timers.Timer cTimer = new System.Timers.Timer(1); // Module miner 3 timer
- asteroidUnitsPerM3["Veldspar"] = asteroidUnitsPerM3["Concentrated Veldspar"] = asteroidUnitsPerM3["Dense Veldspar"] = 0.1;
- asteroidUnitsPerM3["Scordite"] = asteroidUnitsPerM3["Condensed Scordite"] = asteroidUnitsPerM3["Massive Scordite"] = 0.15;
- asteroidUnitsPerM3["Pyroxeres"] = asteroidUnitsPerM3["Solid Pyroxeres"] = asteroidUnitsPerM3["Viscous Pyroxeres"] = 0.3;
- Func<object> BotStopActivity = () => new object();
- Func<object> NextActivity = MainStep;
- int It => UseMiningDrones ? 1 : 0;
- ModuleMeasureAllTooltipAfterStop();
- for(;;)
- {
- MemoryUpdate();
- Host.Log(
- "ore hold fill: " + OreHoldFillPercent + "%" +
- ", mining range: " + MiningRange +
- ", mining modules (inactive): " + SetModuleMiner?.Length + "(" + SetModuleMinerInactive?.Length + ")" +
- ", shield.hp: " + ShieldHpPercent + "%" +
- ", EWO: " + EmergencyWarpOutEnabled.ToString() +
- ", JLA: " + JammedLastAge +
- ", overview.rats: " + ListRatOverviewEntry?.Length +
- ", overview.roids: " + ListAsteroidOverviewEntry?.Length +
- ", offload count: " + OffloadCount +
- ", nextAct: " + NextActivity?.Method?.Name);
- CloseModalUIElement();
- if(EmergencyWarpOutEnabled)
- if(!(Measurement?.IsDocked ?? false))
- {
- InitiateDockToOrWarpToBookmark(RetreatBookmark);
- continue;
- }
- NextActivity = NextActivity?.Invoke() as Func<object>;
- if(BotStopActivity == NextActivity)
- break;
- if(null == NextActivity)
- NextActivity = MainStep;
- Host.Delay(1111);
- }
- // seconds since ship was jammed.
- long? JammedLastAge => Jammed ? 0 : (Host.GetTimeContinuousMilli() - JammedLastTime) / 1000;
- int? ShieldHpPercent => ShipUi?.HitpointsAndEnergy?.Shield / 10;
- bool DefenseExit => (Measurement?.IsDocked ?? false) || !(0 < ListRatOverviewEntry?.Length) || (DefenseExitHitpointThresholdPercent < ShieldHpPercent && !(JammedLastAge < 40) && !(FightAllRats && 0 < ListRatOverviewEntry?.Length));
- bool DefenseEnter => !DefenseExit || !(DefenseEnterHitpointThresholdPercent < ShieldHpPercent) || JammedLastAge < 10;
- bool OreHoldFilledForOffload => 97 < OreHoldFillPercent;
- Int64? JammedLastTime = null;
- string RetreatReasonTemporary = null;
- string RetreatReasonPermanent = null;
- string RetreatReason => RetreatReasonPermanent ?? RetreatReasonTemporary;
- bool EmergencyWarpOutEnabled = false;
- int? LastCheckOreHoldFillPercent = null;
- int OffloadCount = 0;
- void DropToSpace()
- {
- EnsureWindowInventoryOpenOreHold();
- var OreHoldItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault();
- ClickMenuEntryOnMenuRoot(OreHoldItem, "Select All");
- ClickMenuEntryOnMenuRoot(OreHoldItem, "^Jettison");
- var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w => (w?.LabelText?.FirstOrDefault()?.Text?.RegexMatchSuccessIgnoreCase("Jettison") ?? false) && (w?.isModal ?? false));
- if(ConfirmWindow != null)
- Sanderling.MouseClickLeft(ConfirmWindow.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Yes") ));
- }
- Func<object> MainStep()
- {
- if(Measurement?.IsDocked ?? false)
- {
- if(ReadyForManeuver)
- InInventoryUnloadItems();
- if (EmergencyWarpOutEnabled)
- return BotStopActivity;
- Undock();
- }
- if(DestinationContainer())
- {
- if(ReadyForManeuver)
- InInventoryUnloadItems();
- if (EmergencyWarpOutEnabled)
- return BotStopActivity;
- }
- if(DefenseEnter)
- {
- Host.Log("enter defense.");
- return DefenseStep;
- }
- EnsureOverviewTypeSelectionLoaded();
- EnsureWindowInventoryOpenOreHold();
- if(ReadyForManeuver)
- {
- if(OreHoldFilledForOffload)
- {
- if(ReadyForManeuver)
- {
- DroneEnsureInBay();
- InitiateDockToOrWarpToBookmark(UnloadBookmark);
- }
- return MainStep;
- }
- if(!(0 < ListAsteroidOverviewEntry?.Length))
- {
- if(UseSurveyScanView)
- {
- if(Measurement?.WindowSurveyScanView != null)
- {
- if((0 < ListAsteroidSurveyEntry?.Length))
- {
- ModuleMeasureAllTooltip();
- return InBeltMineStepSurveyScanView;
- }
- else
- {
- if(ReadyForManeuver && !DestinationContainer())
- {
- ModuleToggle( SetModuleSurveyScanner);
- Host.Delay(7777);
- }
- if(!(0 < ListAsteroidSurveyEntry?.Length))
- {
- DroneEnsureInBay();
- InitiateWarpToRandomMiningSite();
- }
- }
- }
- }
- else
- {
- DroneEnsureInBay();
- InitiateWarpToRandomMiningSite();
- }
- }
- }
- ModuleMeasureAllTooltip();
- if(ActivateHardener)
- ActivateHardenerExecute();
- if(!UseSurveyScanView)
- return InBeltMineStep;
- else
- return InBeltMineStepSurveyScanView;
- }
- void CloseModalUIElement()
- {
- var ButtonClose =
- ModalUIElement?.ButtonText?.FirstOrDefault(button => (button?.Text).RegexMatchSuccessIgnoreCase("close|no|ok"));
- Sanderling.MouseClickLeft(ButtonClose);
- }
- void DroneEnsureInBay()
- {
- if(0 == DronesInSpaceCount)
- return;
- while(DronesInSpaceCount != 0){
- DroneReturnToBay();
- Host.Delay(4444);
- }
- }
- void DroneReturnToBay()
- {
- Host.Log("return drones to bay.");
- Sanderling.MouseClickRight(DronesInSpaceListEntry);
- Sanderling.MouseClickLeft(Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("return.*bay", RegexOptions.IgnoreCase));
- }
- Func<object> DefenseStep()
- {
- if(DefenseExit)
- {
- Host.Log("exit defense.");
- return null;
- }
- if(UseMiningDrones){
- if (!(0 < DronesInSpaceCount) || !IsDronesLaunch(LabelNameAttackDrones))
- {
- if(IsDronesLaunch(LabelNameMiningDrones)) ReturnDronesByLabelName(LabelNameMiningDrones);
- LaunchDronesByLabelName(LabelNameAttackDrones);
- }
- }
- else
- {
- if( !(0 < DronesInSpaceCount) )
- LaunchDronesByLabelName(LabelNameAttackDrones);
- }
- EnsureOverviewTypeSelectionLoaded();
- UnTarget();
- var SetRatName = ListRatOverviewEntry?.Select(entry => Regex.Split(entry?.Name ?? "", @"\s+")?.FirstOrDefault())?.Distinct()?.ToArray();
- var SetRatTarget = Measurement?.Target?.Where(target => SetRatName?.Any(ratName => target?.TextRow?.Any(row => row.RegexMatchSuccessIgnoreCase(ratName)) ?? false) ?? false);
- var RatTargetNext = SetRatTarget?.OrderBy(target => target?.DistanceMax ?? int.MaxValue)?.FirstOrDefault();
- if(null == RatTargetNext)
- {
- Host.Log("no rat targeted.");
- Sanderling.MouseClickRight(ListRatOverviewEntry?.FirstOrDefault());
- if(ListRatOverviewEntry?.FirstOrDefault(i => i?.IsSelected ?? true) != null)
- Sanderling.MouseClickLeft(MenuEntryLockTarget);
- else
- DefenseStep();
- }
- else
- {
- Host.Log("rat targeted. sending drones.");
- Sanderling.MouseClickLeft(RatTargetNext);
- Sanderling.MouseClickRight(DronesInSpaceListEntry);
- Sanderling.MouseClickLeft(Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("engage", RegexOptions.IgnoreCase));
- }
- return DefenseStep;
- }
- bool IsDronesLaunch(string LabelDrone)
- {
- Expander("Drones in Local Space");
- int? LabelDronesInLocalSpacePosition = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.FirstIndexOrNull(w => w?.Text?.RegexMatchSuccessIgnoreCase("^Drones in local Space") ?? false);
- int? LabelDronePosition = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.FirstIndexOrNull(w => w?.Text?.RegexMatchSuccessIgnoreCase("^" + LabelDrone) ?? false);
- int? LabelDronePositionLast = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.LastIndexOrNull(w => w?.Text?.RegexMatchSuccessIgnoreCase("^" + LabelDrone) ?? false);
- if(LabelDronePosition > LabelDronesInLocalSpacePosition && LabelDronePositionLast != LabelDronePosition) return true;
- else return false;
- }
- void Expander(string Label)
- {
- var Element = Measurement?.WindowDroneView?.FirstOrDefault()?.ListView?.Entry?.FirstOrDefault(w => w?.LabelText?.FirstOrDefault()?.Text?.RegexMatchSuccessIgnoreCase("^" + Label) ?? false);
- bool IsExpanded = Element?.IsExpanded ?? true;
- if(!IsExpanded) ClickMenuEntryOnMenuRoot(Element,"Expand");
- }
- void LaunchDronesByLabelName(string LabelName)
- {
- Expander("Drones in Bay");
- var Label = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.FirstOrDefault(w => w.Text.RegexMatchSuccessIgnoreCase("^" + LabelName) );
- if(ReadyForManeuver)
- ClickMenuEntryOnMenuRoot(Label, "^Launch Drones");
- }
- void ReturnDronesByLabelName(string LabelName)
- {
- Expander("Drones in Local Space");
- var Label = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.FirstOrDefault(w => w.Text.RegexMatchSuccessIgnoreCase("^" + LabelName) );
- ClickMenuEntryOnMenuRoot(Label, "^Return to Drone Bay");
- }
- void MineTarget()
- {
- Expander("Drones in Local Space");
- if(IsDronesLaunch(LabelNameMiningDrones))
- {
- var Label = Measurement?.WindowDroneView?.FirstOrDefault()?.LabelText?.FirstOrDefault(w => w.Text.RegexMatchSuccessIgnoreCase("^" + LabelNameMiningDrones) );
- ClickMenuEntryOnMenuRoot(Label, "^Mine Repeatedly");
- }
- }
- int TargetRoidCount => Sanderling?.MemoryMeasurementParsed?.Value?.Target?.Count(target => string.Join(" ", (target?.TextRow).EmptyIfNull())?.RegexMatchSuccessIgnoreCase(@"Asteroid\s*\(") ?? false) ?? 0;
- void UnTarget()
- {
- Sanderling.Parse.IShipUiTarget[] ListTarget = SetTargetAsteroid;
- var TargetOversizeRange = ListTarget?.FirstOrDefault(d => d?.DistanceMax > MiningRange);
- if(TargetOversizeRange != null)
- Host.Log("Au moin une target dépasse le mining range");
- while((TargetRoidCount > (SetModuleMiner?.Count() + It)) || (TargetOversizeRange != null))
- {
- for(int i = 0; i < ListTarget?.Count()/* && (TargetRoidCount > SetModuleMiner?.Count())*/; ++i)
- {
- if( !(ListTarget?.ElementAtOrDefault(i)?.Assigned?.Count() > 0) )
- {
- ClickMenuEntryOnMenuRoot(ListTarget?.ElementAtOrDefault(i), "Unlock Target");
- }
- if(ListTarget?.ElementAtOrDefault(i)?.DistanceMax > MiningRange)
- {
- ClickMenuEntryOnMenuRoot(ListTarget?.ElementAtOrDefault(i), "Unlock Target");
- }
- }
- }
- }
- Func<object> InBeltMineStep()
- {
- if (DefenseEnter)
- {
- Host.Log("enter defense.");
- return DefenseStep;
- }
- EnsureWindowInventoryOpenOreHold();
- EnsureOverviewTypeSelectionLoaded();
- if(OreHoldFilledForOffload)
- return null;
- var AsteroidOverviewEntry = ListAsteroidOverviewEntry?.FirstOrDefault();
- if(null == AsteroidOverviewEntry)
- {
- Host.Log("no asteroid available");
- return null;
- }
- if(UseMiningDrones){
- if(((DronesInSpaceCount == 0) || IsDronesLaunch(LabelNameAttackDrones)) && (AsteroidOverviewEntry != null))
- {
- if(IsDronesLaunch(LabelNameAttackDrones)) ReturnDronesByLabelName(LabelNameAttackDrones);
- if(DronesInSpaceCount == 0) LaunchDronesByLabelName(LabelNameMiningDrones);
- }
- }
- else
- {
- if( !(DronesInSpaceCount != 0) && (AsteroidOverviewEntry != null) )
- {
- LaunchDronesByLabelName(LabelNameAttackDrones);
- }
- }
- if(!(SetModuleMinerInactive?.Length > 0) && !(SetTargetAsteroid?.FirstOrDefault(w => !(w?.Assigned?.Count() > 0) ) != null) && !(TargetRoidCount < (SetModuleMiner?.Count() + It)))
- {
- Host.Delay(7777);
- return InBeltMineStep;
- }
- if(ReadyForManeuver)
- {
- var ListAsteroidOverviewInRangeEntry = ListAsteroidOverviewEntry?.Where(target => target?.DistanceMax <= MiningRange)?.ToArray();
- var AsteroidOverviewInRangeEntry = RandomElement(ListAsteroidOverviewInRangeEntry);
- Host.Log("Distance : " + AsteroidOverviewInRangeEntry?.DistanceMax +
- "m, Type : " + AsteroidOverviewInRangeEntry?.Type);
- Host.Log("Module de minage : " + SetModuleMiner?.Count());
- Host.Log("Nombre de taget : " + TargetRoidCount);
- if((TargetRoidCount < (SetModuleMiner?.Count() + It)) && (AsteroidOverviewInRangeEntry != null))
- {
- ClickMenuEntryOnMenuRoot(AsteroidOverviewInRangeEntry, "^lock");
- }
- var TargetOversizeRange = SetTargetAsteroid?.FirstOrDefault(d => d?.DistanceMax > MiningRange);
- if(TargetOversizeRange != null)
- Host.Log("Au moin une target dépasse le mining range");
- while((TargetRoidCount > (SetModuleMiner?.Count() + It)) || (TargetOversizeRange != null))
- {
- for(int i = 0; i < SetTargetAsteroid?.Count()/* && (TargetRoidCount > SetModuleMiner?.Count())*/; ++i)
- {
- if( !(SetTargetAsteroid?.ElementAtOrDefault(i)?.Assigned?.Count() > 0) )
- {
- ClickMenuEntryOnMenuRoot(SetTargetAsteroid?.ElementAtOrDefault(i), "Unlock Target");
- }
- if(SetTargetAsteroid?.ElementAtOrDefault(i)?.DistanceMax > MiningRange)
- {
- ClickMenuEntryOnMenuRoot(SetTargetAsteroid?.ElementAtOrDefault(i), "Unlock Target");
- }
- }
- }
- var InactiveModule = SetModuleMinerInactive?.FirstOrDefault();
- AsteroidOverviewInRangeEntry = RandomElement(ListAsteroidOverviewInRangeEntry);
- if( !(TargetRoidCount < (SetModuleMiner?.Count() + It)) && (AsteroidOverviewInRangeEntry != null) )
- {
- for(int i = 0; i < (SetModuleMiner?.Count() + It) && (SetTargetAsteroid != null); ++i)
- {
- InactiveModule = SetModuleMinerInactive?.FirstOrDefault();
- if( !(SetTargetAsteroid?.ElementAtOrDefault(i)?.Assigned?.Count() > 0) && (SetModuleMinerInactive?.Count() > 0))
- {
- Sanderling.MouseClickLeft(SetTargetAsteroid?.ElementAtOrDefault(i));
- ModuleToggle(InactiveModule);
- }
- else if( !(SetTargetAsteroid?.ElementAtOrDefault(i)?.Assigned?.Count() > 0) && !(SetModuleMinerInactive?.Count() > 0))
- {
- if(UseMiningDrones)
- {
- Sanderling.MouseClickLeft(SetTargetAsteroid?.ElementAtOrDefault(i));
- MineTarget();
- }
- }
- }
- }
- float Speed = (Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.SpeedMilli ?? 0) / 1000f;
- var ButtonSpeed0 = Measurement?.ShipUi?.ButtonSpeed0;
- if(Speed > 12 && ListAsteroidOverviewEntry?.ElementAtOrDefault(0)?.DistanceMax < MiningRange)
- Sanderling.MouseClickLeft(ButtonSpeed0);
- if(ListAsteroidOverviewEntry?.ElementAtOrDefault(0)?.DistanceMax > MiningRange)
- {
- ClickMenuEntryOnMenuRoot(ListAsteroidOverviewEntry?.ElementAtOrDefault(0), "approach");
- }
- }
- return InBeltMineStep;
- }
- void OnTimedEventA(object source, ElapsedEventArgs e)
- {
- if(SetModuleMiner?.ElementAtOrDefault(0)?.RampActive ?? false)
- ModuleToggle(SetModuleMiner?.ElementAtOrDefault(0));
- }
- void OnTimedEventB(object source, ElapsedEventArgs e)
- {
- if(SetModuleMiner?.ElementAtOrDefault(1)?.RampActive ?? false)
- ModuleToggle(SetModuleMiner?.ElementAtOrDefault(1));
- }
- void OnTimedEventC(object source, ElapsedEventArgs e)
- {
- if(SetModuleMiner?.ElementAtOrDefault(2)?.RampActive ?? false)
- ModuleToggle(SetModuleMiner?.ElementAtOrDefault(2));
- }
- void SetTimer(int interval, System.Timers.Timer timer, Action<object, ElapsedEventArgs> qwerty)
- {
- timer.Elapsed += new ElapsedEventHandler(qwerty);
- if(interval > 0)
- timer.Interval = interval;
- timer.Enabled = true;
- timer.AutoReset = false;
- }
- Func<object> InBeltMineStepSurveyScanView()
- {
- if (DefenseEnter)
- {
- Host.Log("enter defense.");
- return DefenseStep;
- }
- if(Measurement?.WindowSurveyScanView == null)
- {
- ModuleToggle( SetModuleSurveyScanner );
- return null;
- }
- /*var windowStackWithOverview = Measurement?.WindowStack?.FirstOrDefault(val => val?.Caption?.RegexMatchSuccessIgnoreCase("Overview") ?? false) ;
- var windowStackSurveyScanResultsTab = windowStackWithOverview?.Tab?.FirstOrDefault( val => val?.Label?.Text?.RegexMatchSuccessIgnoreCase("Survey Scan Results") ?? false);
- if(windowStackWithOverview?.TabSelectedWindow?.Caption != "Survey Scan Results")
- {
- Sanderling.MouseClickLeft(windowStackSurveyScanResultsTab);
- }*/
- EnsureWindowInventoryOpenOreHold();
- EnsureOverviewTypeSelectionLoaded();
- if(OreHoldFilledForOffload)
- return null;
- var AsteroidSurveyEntry = ListAsteroidSurveyEntry?.FirstOrDefault();
- if(null == AsteroidSurveyEntry)
- {
- Host.Log("no asteroid available");
- if(ReadyForManeuver && !DestinationContainer())
- {
- ModuleToggle( SetModuleSurveyScanner );
- Host.Delay(7777);
- }
- return null;
- }
- if( !(ListAsteroidSurveyEntryTargeted?.Count() != 0) )
- {
- ModuleToggle( SetModuleSurveyScanner );
- Host.Delay(7777);
- }
- if(UseMiningDrones){
- if(((DronesInSpaceCount == 0) || IsDronesLaunch(LabelNameAttackDrones)) && (AsteroidSurveyEntry != null))
- {
- if(IsDronesLaunch(LabelNameAttackDrones)) ReturnDronesByLabelName(LabelNameAttackDrones);
- if(DronesInSpaceCount == 0) LaunchDronesByLabelName(LabelNameMiningDrones);
- }
- }
- else
- {
- if( !(DronesInSpaceCount != 0) && (AsteroidSurveyEntry != null) )
- {
- LaunchDronesByLabelName(LabelNameAttackDrones);
- }
- }
- double? RampRotationMilliModule1 = SetModuleMiner?.ElementAtOrDefault(0)?.RampRotationMilli ?? 0;
- double? RampRotationMilliModule2 = SetModuleMiner?.ElementAtOrDefault(1)?.RampRotationMilli ?? 0;
- double? RampRotationMilliModule3 = SetModuleMiner?.ElementAtOrDefault(2)?.RampRotationMilli ?? 0;
- Host.Log("Ramp Rotation Module Miner 1 : " + RampRotationMilliModule1 / 10 +
- " %, Ramp Rotation Module Miner 2 : " + RampRotationMilliModule2 / 10 +
- " %, Ramp Rotation Module Miner 3 : " + RampRotationMilliModule3 / 10 + " %" );
- double? VolumeInMiner1 = ((RampRotationMilliModule1 / 1000) * SetMinerYield) ?? 0;
- double? VolumeInMiner2 = ((RampRotationMilliModule2 / 1000) * SetMinerYield) ?? 0;
- double? VolumeInMiner3 = ((RampRotationMilliModule3 / 1000) * SetMinerYield) ?? 0;
- double? VolumeOreHoldAvailable = ((int?)(OreHoldCapacityMilli?.Max - OreHoldCapacityMilli?.Used) / 1000) ?? int.MaxValue;
- Host.Log("Volume Ore Hold Available : " + VolumeOreHoldAvailable +
- " m3, Volume In Module Miner 1 : " + VolumeInMiner1 +
- " m3, Volume In Module Miner 2 : " + VolumeInMiner2 +
- " m3, Volume In Module Miner 3 : " + VolumeInMiner3 +
- " m3, Volume In Module Miner (1 + 2 + 3) : " + (VolumeInMiner1 + VolumeInMiner2 + VolumeInMiner3) + " m3" );
- if( (VolumeInMiner1 + VolumeInMiner2 + VolumeInMiner3) >= VolumeOreHoldAvailable)
- {
- foreach( var Module in SetModuleMiner?.Where(module => module?.RampActive ?? false) )
- {
- ModuleToggle(Module);
- }
- Host.Log("Astalavista baby");
- }
- if(!(SetModuleMinerInactive?.Length > 0) && !(SetTargetAsteroid?.FirstOrDefault(w => !(w?.Assigned?.Count() > 0) ) != null) && !(TargetRoidCount < (SetModuleMiner?.Count() + It)))
- {
- Host.Delay(7777);
- return InBeltMineStepSurveyScanView;
- }
- if(ReadyForManeuver)
- {
- var ListAsteroidSurveyInRangeEntry = ListAsteroidSurveyEntry?.Where(target => target?.ColumnDistanceValue()?.DistanceParseMax() <= MiningRange)?.ToArray();
- var AsteroidSurveyInRangeEntry = RandomElement(ListAsteroidSurveyInRangeEntry);
- if((TargetRoidCount < (SetModuleMiner?.Count())) && (AsteroidSurveyInRangeEntry != null) )
- {
- ClickMenuEntryOnMenuRoot(AsteroidSurveyInRangeEntry, "^lock");
- Host.Delay(1111);
- ModuleToggle( SetModuleSurveyScanner );
- Host.Delay(7777);
- }
- UnTarget();
- var ModuleMinerInactive = SetModuleMinerInactive?.FirstOrDefault();
- if( (AsteroidSurveyInRangeEntry != null) )
- {
- // ModuleToggle( SetModuleSurveyScanner );
- Sanderling.WaitForMeasurement();
- var AsteroidSurveyEntryTargeted = RandomElement(ListAsteroidSurveyEntryTargeted);
- Sanderling.MouseClickLeft(AsteroidSurveyEntryTargeted);
- Sanderling.WaitForMeasurement();
- var AsteroidSurveyEntryTargetedAndSelected = ListAsteroidSurveyEntryTargetedAndSelected?.FirstOrDefault();
- if(AsteroidSurveyEntryTargeted?.Region == AsteroidSurveyEntryTargetedAndSelected?.Region)
- {
- string OreType = AsteroidSurveyEntryTargeted?.CellValueFromColumnHeader("Ore") ?? "";
- double OreQuantity = AsteroidSurveyEntryTargeted?.CellValueFromColumnHeader("quantity")?.NumberParseDecimalMilli()/1000 ?? 0;
- double OreUnitVolume = 0;
- asteroidUnitsPerM3.TryGetValue(OreType, out OreUnitVolume);
- double rendement = SetMinerYield/SetMinerDuration;
- double interval = (( OreQuantity * OreUnitVolume ) / rendement ) * 1000;
- if( !( SetTargetAsteroid?.FirstOrDefault( target => target?.IsSelected ?? false )?.Assigned?.Count() > 0 ) )
- {
- Host.Log("Distance : " + AsteroidSurveyEntryTargeted?.ColumnDistanceValue() +
- ", Type: " + AsteroidSurveyEntryTargeted?.CellValueFromColumnHeader("Ore") +
- ", Volume per Unit : " + OreUnitVolume +
- " m3, Quantity : " + AsteroidSurveyEntryTargeted?.CellValueFromColumnHeader("Quantity") +
- " units, Interval : " + (int)(interval / 1000) + " s" +
- ", Module Miner : " + ModuleMinerInactive?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text);
- }
- if( !( SetTargetAsteroid?.FirstOrDefault( target => target?.IsSelected ?? false )?.Assigned?.Count() > 0 ) && ( SetModuleMinerInactive?.Count() > 0 ) /*&& (TargetRoidCount <= SetModuleMiner?.Count())*/ )
- {
- ModuleToggle( ModuleMinerInactive );
- if( ModuleMinerInactive?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text == "F1" )
- SetTimer( (int)interval, aTimer, OnTimedEventA );
- else if( ModuleMinerInactive?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text == "F2" )
- SetTimer( (int)interval, bTimer, OnTimedEventB );
- else if( ModuleMinerInactive?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text == "F3" )
- SetTimer( (int)interval, cTimer, OnTimedEventC );
- }
- }
- }
- float Speed = (Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.SpeedMilli ?? 0) / 1000f;
- var ButtonSpeed0 = Measurement?.ShipUi?.ButtonSpeed0;
- if(Speed > 12 && ListAsteroidSurveyEntry?.ElementAtOrDefault(0)?.ColumnDistanceValue()?.DistanceParseMax() < MiningRange)
- Sanderling.MouseClickLeft(ButtonSpeed0);
- if(ListAsteroidSurveyEntry?.ElementAtOrDefault(0)?.ColumnDistanceValue()?.DistanceParseMax() > MiningRange)
- {
- ClickMenuEntryOnMenuRoot(ListAsteroidSurveyEntry?.ElementAtOrDefault(0), "approach");
- }
- }
- // var asteroidGroupList = Measurement.WindowSurveyScanView.FirstOrDefault().ListView.Entry.Where( entry => entry?.IsGroup ?? false )?.OrderBy( entry => entry?.LabelText?.FirstOrDefault()?.Text )?.ToArray();
- // var scroolbar = Measurement.WindowSurveyScanView.FirstOrDefault().ListView.Scroll.ScrollHandleBound;
- // Sanderling.MouseClickLeft(scroolbar);
- return InBeltMineStepSurveyScanView();
- }
- Sanderling.Parse.IMemoryMeasurement Measurement => Sanderling?.MemoryMeasurementParsed?.Value;
- IWindow ModalUIElement => Measurement?.EnumerateReferencedUIElementTransitive()?.OfType<IWindow>()?.Where(window => window?.isModal ?? false)?.OrderByDescending(window => window?.InTreeIndex ?? int.MinValue)?.FirstOrDefault();
- IEnumerable<Parse.IMenu> Menu => Measurement?.Menu;
- Parse.IShipUi ShipUi => Measurement?.ShipUi;
- bool Jammed => ShipUi?.EWarElement?.Any(EwarElement => (EwarElement?.EWarType).RegexMatchSuccess("electronic")) ?? false;
- Sanderling.Interface.MemoryStruct.IMenuEntry MenuEntryLockTarget => Menu?.FirstOrDefault()?.Entry?.FirstOrDefault(entry => entry.Text.RegexMatchSuccessIgnoreCase("^lock"));
- Sanderling.Parse.IWindowOverview WindowOverview => Measurement?.WindowOverview?.FirstOrDefault();
- Sanderling.Parse.IWindowInventory WindowInventory => Measurement?.WindowInventory?.FirstOrDefault();
- Sanderling.Interface.MemoryStruct.IWindowSurveyScanView WindowSurveyScanView = Measurement?.WindowSurveyScanView?.FirstOrDefault();
- IWindowDroneView WindowDrones => Measurement?.WindowDroneView?.FirstOrDefault();
- ITreeViewEntry InventoryActiveShipOreHold => WindowInventory?.ActiveShipEntry?.TreeEntryFromCargoSpaceType(ShipCargoSpaceTypeEnum.OreHold);
- IInventoryCapacityGauge OreHoldCapacityMilli => (InventoryActiveShipOreHold?.IsSelected ?? false) ? WindowInventory?.SelectedRightInventoryCapacityMilli : null;
- int? OreHoldFillPercent => (int?)((OreHoldCapacityMilli?.Used * 100) / OreHoldCapacityMilli?.Max);
- Tab OverviewPresetTabActive => WindowOverview?.PresetTab?.OrderByDescending(tab => tab?.LabelColorOpacityMilli ?? 0)?.FirstOrDefault();
- string OverviewTypeSelectionName => WindowOverview?.Caption?.RegexMatchIfSuccess(@"\(([^\)]*)\)")?.Groups?[1]?.Value;
- Parse.IOverviewEntry[] ListRatOverviewEntry => WindowOverview?.ListView?.Entry?.Where(entry => (entry?.MainIconIsRed ?? false) && (entry?.IsAttackingMe ?? false))?.OrderBy(entry => entry?.DistanceMax ?? int.MaxValue)?.ToArray();
- Parse.IOverviewEntry[] ListAsteroidOverviewEntry => WindowOverview?.ListView?.Entry?.Where(entry => null != OreTypeFromAsteroidName(entry?.Name))?.OrderBy(entry => entry.DistanceMax ?? int.MaxValue)?.ToArray();
- DroneViewEntryGroup DronesInBayListEntry => WindowDrones?.ListView?.Entry?.OfType<DroneViewEntryGroup>()?.FirstOrDefault(Entry => null != Entry?.Caption?.Text?.RegexMatchIfSuccess(@"Drones in bay", RegexOptions.IgnoreCase));
- DroneViewEntryGroup DronesInSpaceListEntry => WindowDrones?.ListView?.Entry?.OfType<DroneViewEntryGroup>()?.FirstOrDefault(Entry => null != Entry?.Caption?.Text?.RegexMatchIfSuccess(@"Drones in Local Space", RegexOptions.IgnoreCase));
- int? DronesInSpaceCount => DronesInSpaceListEntry?.Caption?.Text?.AsDroneLabel()?.Status?.TryParseInt();
- bool ReadyForManeuverNot =>
- Measurement?.ShipUi?.Indication?.LabelText?.Any(indicationLabel =>
- (indicationLabel?.Text).RegexMatchSuccessIgnoreCase("warp|docking")) ?? false;
- bool ReadyForManeuver => !ReadyForManeuverNot && !(Measurement?.IsDocked ?? true);
- Sanderling.Parse.IShipUiTarget[] SetTargetAsteroid => Measurement?.Target?.Where(target => target?.TextRow?.Any(textRow => textRow.RegexMatchSuccessIgnoreCase("asteroid")) ?? false)?.ToArray();
- Sanderling.Interface.MemoryStruct.IListEntry WindowInventoryItem => WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault();
- Sanderling.Accumulation.IShipUiModule[] SetModuleMiner => Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Where(module => module?.TooltipLast?.Value?.IsMiner ?? false)?.ToArray();
- Sanderling.Accumulation.IShipUiModule[] SetModuleMinerInactive => SetModuleMiner?.Where(module => !(module?.RampActive ?? false))?.ToArray();
- Sanderling.Accumulation.IShipUiModule SetModuleSurveyScanner => Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.FirstOrDefault(module => module?.TooltipLast?.Value?.IsSurveyScanner ?? false);
- int? MiningRange => SetModuleMiner?.Select(module => module?.TooltipLast?.Value?.RangeOptimal ?? module?.TooltipLast?.Value?.RangeMax ?? module?.TooltipLast?.Value?.RangeWithin ?? 0)?.DefaultIfEmpty(0)?.Min();;
- Sanderling.Interface.MemoryStruct.IListEntry[] ListAsteroidSurveyEntry => Measurement.WindowSurveyScanView.FirstOrDefault().ListView.Entry.Where( entry => !(entry?.IsGroup ?? false) )?.OrderBy(entry => entry?.ColumnDistanceValue()?.DistanceParseMax() ?? int.MaxValue)?.ToArray();
- Sanderling.Interface.MemoryStruct.IListEntry[] ListAsteroidSurveyEntryTargeted => ListAsteroidSurveyEntry?.Where(sprite => sprite?.SetSprite?.FirstOrDefault()?.Name?.RegexMatchSuccessIgnoreCase("targetSprite") ?? false)?.OrderBy(entry => entry?.ColumnDistanceValue()?.DistanceParseMax() ?? int.MaxValue)?.ToArray();
- Sanderling.Interface.MemoryStruct.IListEntry[] ListAsteroidSurveyEntryTargetedAndSelected => ListAsteroidSurveyEntryTargeted?.Where(entry => entry?.IsSelected ?? false)?.OrderBy(entry => entry?.ColumnDistanceValue()?.DistanceParseMax() ?? int.MaxValue)?.ToArray();
- WindowChatChannel chatLocal =>
- Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
- ?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase("local") ?? false);
- // assuming that own character is always visible in local
- bool hostileOrNeutralsInLocal => 1 != chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy);
- // extract the ore type from the name as seen in overview. "Asteroid (Plagioclase)"
- string OreTypeFromAsteroidName(string AsteroidName) => AsteroidName.ValueFromRegexMatchGroupAtIndex(@"Asteroid \(([^\)]+)", 0);
- void ClickMenuEntryOnMenuRoot(IUIElement MenuRoot, string MenuEntryRegexPattern)
- {
- Sanderling.MouseClickRight(MenuRoot);
- var Menu = Measurement?.Menu?.FirstOrDefault();
- var MenuEntry = Menu?.EntryFirstMatchingRegexPattern(MenuEntryRegexPattern, RegexOptions.IgnoreCase);
- Sanderling.MouseClickLeft(MenuEntry);
- }
- void EnsureWindowInventoryOpen()
- {
- if (null != WindowInventory)
- return;
- Host.Log("open Inventory.");
- Sanderling.MouseClickLeft(Measurement?.Neocom?.InventoryButton);
- }
- void EnsureWindowInventoryOpenOreHold()
- {
- EnsureWindowInventoryOpen();
- if(!(InventoryActiveShipOreHold?.IsSelected ?? false))
- Sanderling.MouseClickLeft(InventoryActiveShipOreHold);
- }
- // sample label text: Intensive Reprocessing Array <color=#66FFFFFF>1,123 m</color>
- string InventoryContainerLabelRegexPatternFromContainerName(string containerName) => @"^\s*" + Regex.Escape(containerName) + @"\s*($|\<)";
- void InInventoryUnloadItems() => InInventoryUnloadItemsTo(UnloadDestContainerName);
- bool DestinationContainer()
- {
- var OreHoldItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault();
- var DestinationContainerLabelRegexPattern = InventoryContainerLabelRegexPatternFromContainerName(UnloadDestContainerName);
- var DestinationContainer = WindowInventory?.LeftTreeListEntry?.SelectMany(entry => new[] { entry }.Concat(entry.EnumerateChildNodeTransitive()))?.FirstOrDefault(entry => entry?.Text?.RegexMatchSuccessIgnoreCase(DestinationContainerLabelRegexPattern) ?? false);
- if(DestinationContainer != null)
- return true;
- else return false;
- }
- void InInventoryUnloadItemsTo(string DestinationContainerName)
- {
- Host.Log("unload items to '" + DestinationContainerName + "'.");
- EnsureWindowInventoryOpenOreHold();
- for (;;)
- {
- var oreHoldListItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.ToArray();
- var oreHoldItem = oreHoldListItem?.FirstOrDefault();
- if(null == oreHoldItem)
- break; // 0 items in OreHold
- if(1 < oreHoldListItem?.Length)
- ClickMenuEntryOnMenuRoot(oreHoldItem, @"select\s*all");
- var DestinationContainerLabelRegexPattern =
- InventoryContainerLabelRegexPatternFromContainerName(DestinationContainerName);
- var DestinationContainer =
- WindowInventory?.LeftTreeListEntry?.SelectMany(entry => new[] { entry }.Concat(entry.EnumerateChildNodeTransitive()))
- ?.FirstOrDefault(entry => entry?.Text?.RegexMatchSuccessIgnoreCase(DestinationContainerLabelRegexPattern) ?? false);
- if (null == DestinationContainer)
- Host.Log("error: Inventory entry labeled '" + DestinationContainerName + "' not found");
- Sanderling.MouseDragAndDrop(oreHoldItem, DestinationContainer);
- }
- }
- Random rand => new Random();
- int IntDefault(int? entier) => entier ?? 0;
- T RandomElement<T>(IEnumerable<T> seq)
- {
- var counted = seq?.ToArray();
- if(!(0 < counted?.Length))
- return default(T);
- return counted[rand.Next(counted.Length)];
- }
- bool InitiateWarpToRandomMiningSite()
- {
- var ListSurroundingsButton = Measurement?.InfoPanelCurrentSystem?.ListSurroundingsButton;
- Sanderling.MouseClickRight(ListSurroundingsButton);
- String MiningFolderBookmark = RandomElement(SetMiningFolderBookmark);
- var FolderMenuEntry = Measurement?.Menu?.ElementAtOrDefault(0)?.EntryFirstMatchingRegexPattern("^" + MiningFolderBookmark + "$", RegexOptions.IgnoreCase);
- Sanderling.MouseClickLeft(FolderMenuEntry);
- if(FolderMenuEntry != null)
- Host.Log("Warp to folder bookmarks : " + MiningFolderBookmark);
- var BookmarkMenuEntry = RandomElement(Measurement?.Menu?.ElementAtOrDefault(1)?.Entry);
- Sanderling.MouseClickLeft(BookmarkMenuEntry);
- if(BookmarkMenuEntry != null)
- Host.Log("Warp to bookmark : " + BookmarkMenuEntry?.Text);
- var Menu = Measurement?.Menu?.ElementAtOrDefault(2);
- var DockMenuEntry = Menu?.EntryFirstMatchingRegexPattern("dock",RegexOptions.IgnoreCase);
- var WarpMenuEntry = Menu?.EntryFirstMatchingRegexPattern(@"warp.*within\s*0",RegexOptions.IgnoreCase);
- var ApproachEntry = Menu?.EntryFirstMatchingRegexPattern(@"approach",RegexOptions.IgnoreCase);
- var MenuEntry = DockMenuEntry ?? WarpMenuEntry;
- if(null == MenuEntry)
- {
- if(null != ApproachEntry)
- {
- Host.Log("found menu entry '" + ApproachEntry.Text + "'. Assuming we are already there.");
- return false;
- }
- Host.Log("no suitable menu entry found");
- return true;
- }
- Host.Log("initiating " + MenuEntry.Text);
- Sanderling.MouseClickLeft(MenuEntry);
- return false;
- }
- bool InitiateDockToOrWarpToBookmark(string Bookmark)
- {
- var ListSurroundingsButton = Measurement?.InfoPanelCurrentSystem?.ListSurroundingsButton;
- Sanderling.MouseClickRight(ListSurroundingsButton);
- var BookmarkMenuEntry = Measurement?.Menu?.ElementAtOrDefault(0)?.EntryFirstMatchingRegexPattern("^" + Bookmark + "$", RegexOptions.IgnoreCase);
- Sanderling.MouseClickLeft(BookmarkMenuEntry);
- if(null == BookmarkMenuEntry)
- {
- Host.Log("Not found bookmark ");
- return true;
- }
- var Menu = Measurement?.Menu?.ElementAtOrDefault(1);
- var DockMenuEntry = Menu?.EntryFirstMatchingRegexPattern("dock",RegexOptions.IgnoreCase);
- var WarpMenuEntry = Menu?.EntryFirstMatchingRegexPattern(@"warp.*within\s*0",RegexOptions.IgnoreCase);
- var ApproachEntry = Menu?.EntryFirstMatchingRegexPattern(@"approach",RegexOptions.IgnoreCase);
- var MenuEntry = DockMenuEntry ?? WarpMenuEntry;
- if(null == MenuEntry)
- {
- if(null != ApproachEntry)
- {
- Host.Log("found menu entry '" + ApproachEntry.Text + "'. Assuming we are already there.");
- return false;
- }
- Host.Log("no suitable menu entry found");
- return true;
- }
- Host.Log("initiating " + MenuEntry.Text);
- Sanderling.MouseClickLeft(MenuEntry);
- return false;
- }
- void Undock()
- {
- Sanderling.MouseClickLeft(Measurement?.WindowStation?.FirstOrDefault()?.UndockButton);
- Host.Log("waiting for undocking to complete.");
- while(Measurement?.IsDocked ?? true) Host.Delay(1111);
- Host.Delay(4444);
- Sanderling.InvalidateMeasurement();
- }
- void ModuleMeasureAllTooltip()
- {
- for (;;)
- {
- var NextModule = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.FirstOrDefault(m => null == m?.TooltipLast);
- if(null == NextModule)
- break;
- Host.Log("measure module.");
- // take multiple measurements of module tooltip to reduce risk to keep bad read tooltip.
- Sanderling.MouseMove(NextModule);
- Sanderling.WaitForMeasurement();
- Sanderling.MouseMove(NextModule);
- }
- }
- void ModuleMeasureAllTooltipAfterStop()
- {
- Host.Log("measure tooltips of all modules.");
- for (int i = 0; i < Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Count(); ++i)
- {
- var NextModule = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.ElementAtOrDefault(i);
- Host.Log("measure module.");
- // take multiple measurements of module tooltip to reduce risk to keep bad read tooltip.
- Sanderling.MouseMove(NextModule);
- Sanderling.WaitForMeasurement();
- Sanderling.MouseMove(NextModule);
- }
- }
- void ActivateHardenerExecute()
- {
- var SubsetModuleHardener = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Where(module => module?.TooltipLast?.Value?.IsHardener ?? false);
- var SubsetModuleToToggle = SubsetModuleHardener?.Where(module => !(module?.RampActive ?? false));
- foreach (var Module in SubsetModuleToToggle.EmptyIfNull())
- ModuleToggle(Module);
- }
- void ModuleToggle(Sanderling.Accumulation.IShipUiModule Module)
- {
- var ToggleKey = Module?.TooltipLast?.Value?.ToggleKey;
- Host.Log("toggle module using " + (null == ToggleKey ? "mouse" : Module?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text));
- if(null == ToggleKey)
- Sanderling.MouseClickLeft(Module);
- else
- Sanderling.KeyboardPressCombined(ToggleKey);
- }
- void EnsureOverviewTypeSelectionLoaded()
- {
- if(null == OverviewPresetTabActive || null == WindowOverview || null == OverviewPreset)
- return;
- if(string.Equals(OverviewTypeSelectionName, OverviewPreset, StringComparison.OrdinalIgnoreCase))
- return;
- Host.Log("loading preset '" + OverviewPreset + "' to overview (current selection is '" + OverviewTypeSelectionName + "').");
- Sanderling.MouseClickRight(OverviewPresetTabActive);
- Sanderling.MouseClickLeft(Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("load.*preset", RegexOptions.IgnoreCase));
- var PresetMenuEntry = Menu?.ElementAtOrDefault(1)?.EntryFirstMatchingRegexPattern(@"^\s*" + Regex.Escape(OverviewPreset) + @"\s*$", RegexOptions.IgnoreCase);
- if(null == PresetMenuEntry)
- {
- Host.Log("error: menu entry '" + OverviewPreset + "' not found");
- return;
- }
- Sanderling.MouseClickLeft(PresetMenuEntry);
- }
- void MemoryUpdate()
- {
- EmergencyWarpOutUpdate();
- JammedLastTimeUpdate();
- OffloadCountUpdate();
- }
- void JammedLastTimeUpdate()
- {
- if(Jammed)
- JammedLastTime = Host.GetTimeContinuousMilli();
- }
- bool MeasurementEmergencyWarpOutEnter =>
- !(Measurement?.IsDocked ?? false) && !(EmergencyWarpOutHitpointPercent < ShieldHpPercent);
- void EmergencyWarpOutUpdate()
- {
- if (!MeasurementEmergencyWarpOutEnter)
- return;
- // measure multiple times to avoid being scared off by noise from a single measurement.
- Sanderling.InvalidateMeasurement();
- if (!MeasurementEmergencyWarpOutEnter)
- return;
- EmergencyWarpOutEnabled = true;
- }
- void RetreatUpdate()
- {
- RetreatReasonTemporary = (RetreatOnNeutralOrHostileInLocal && hostileOrNeutralsInLocal) ? "hostile or neutral in local" : null;
- if (!MeasurementEmergencyWarpOutEnter)
- return;
- // measure multiple times to avoid being scared off by noise from a single measurement.
- Sanderling.InvalidateMeasurement();
- if (!MeasurementEmergencyWarpOutEnter)
- return;
- RetreatReasonPermanent = "shield hp";
- }
- void OffloadCountUpdate()
- {
- var OreHoldFillPercentSynced = OreHoldFillPercent;
- if(!OreHoldFillPercentSynced.HasValue)
- return;
- if(0 == OreHoldFillPercentSynced && OreHoldFillPercentSynced < LastCheckOreHoldFillPercent)
- ++OffloadCount;
- LastCheckOreHoldFillPercent = OreHoldFillPercentSynced;
- }
- bool IsNeutralOrEnemy(IChatParticipantEntry participantEntry) =>
- !(participantEntry?.FlagIcon?.Any(flagIcon =>
- new[] { "good standing", "excellent standing", "Pilot is in your (fleet|corporation)", }
- .Any(goodStandingText =>
- flagIcon?.HintText?.RegexMatchSuccessIgnoreCase(goodStandingText) ?? false)) ?? false);
Advertisement
Add Comment
Please, Sign In to add comment