AFK - Warning Script

Looking for help …

Using version 17-11-19 - stock version (modified for chat window changes)

Wanting to mine semi afk while sanderling in the background checks for conditions and plays a sound … hopefully we can work this into a working script with potential methods/functions that could be used in other scripts

Rats on Overview - done
Neutral or Hositle on Local - done
warns when ore hold is near full capacity (say 80%)
warns when fuel bay is nearly empty of heavy water (say less than 3000 units of heavy water)

Here is the script so far (Poaching from others on forum)

Made changes for chat window changing

//	This script is to warn user of particular things while gaming

using BotSharp.ToScript.Extension;
using Parse = Sanderling.Parse;
using MemoryStruct = Sanderling.Interface.MemoryStruct;

// local chat window
Sanderling.Parse.IMemoryMeasurement Measurement => Sanderling?.MemoryMeasurementParsed?.Value;
	
var chatLocal = Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase("local") ?? false);

bool hostileOrNeutralsInLocal => 1 != chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy); 

bool IsNeutralOrEnemy(IChatParticipantEntry participantEntry) =>
			!(participantEntry?.FlagIcon?.Any(flagIcon =>
			new[] { "good standing", "excellent standing", "pilot is in your (fleet|corporation|alliance)" }
			.Any(goodStandingText =>
				flagIcon?.HintText?.RegexMatchSuccessIgnoreCase(goodStandingText) ?? false)) ?? false);

//rat in overview
//Sanderling.Parse.IWindowOverview WindowOverview => Measurement?.WindowOverview?.FirstOrDefault();

Sanderling.Parse.IWindowOverview	WindowOverview	=>
	Measurement?.WindowOverview?.FirstOrDefault();

Parse.IOverviewEntry[] ListRatOverviewEntry => 
					WindowOverview?.ListView?.Entry?.
						Where(entry => (entry?.MainIconIsRed ?? false))?.
						ToArray();

while(true)
	{
	
	var chatLocal =
     		Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
     		?.FirstOrDefault(windowChat => windowChat?.Caption
     		?.RegexMatchSuccessIgnoreCase("local") ?? false);
			//added two below to check numbers and bool
			Host.Log(hostileOrNeutralsInLocal);
			Host.Log(chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy));
			//Host.Log(RatOnOverview);

	var anyRatsVisible = (ListRatOverviewEntry?.Any() ?? false);
	Host.Log(anyRatsVisible);

	 if(chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy) > 1)     
		 {
			Host.Log(hostileOrNeutralsInLocal);
			Host.Log(chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy));
			System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@"static path to soundfile.wave");
	 		simpleSound.Play();
		 }

	if (anyRatsVisible == true)
	
		{
			Host.Log(anyRatsVisible);
			System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@"static path to soundfile.wave");
	 		simpleSound.Play();
		}


	Host.Delay(4000);
		
	Sanderling.InvalidateMeasurement();
	
	}

1 Like

How would I be able to add code that would do the following …

Measures overview … everytime a red icon is measured, a variable increases by one …

I could then use that variable in if statement to sound alarm.