One more update
Rev0.2a
Changed from using Drag/Drop item to MoveItem.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ScriptAPI;
using ScriptDotNet2;
/*
This script is extremely sloppy, without a plethora of sanity checks, and was written between 3:00am and 3:41am
*/
namespace oEggs
{
class Program
{
public static ushort[] SnakeTypes = new ushort[] { 52, 93, 21 };
public static List<Item> Snakes = new List<Item>();
public static List<Item> Nests = new List<Item>();
public static List<Item> Flutes = new List<Item>();
private static readonly Object locker = new Object();
#region Methods
static void ErrorExit(string ErrorText)
{
Console.WriteLine(ErrorText);
Console.Write("Press any key to suicide.");
Console.ReadKey(false);
Environment.Exit(0);
}
/// <summary>
/// Method for posting messages to the console
/// with a timestamp
/// </summary>
/// <param name="message">string: message to send to the console</param>
/// <param name="args">(optional)object[]: additional arguments</param>
public static void ConsoleMessage(string message, params object[] args)
{
Console.Write("[{0}] ", DateTime.Now.ToString("mm:ss"));
Console.WriteLine(message, args);
}
/// <summary>
/// Method for posting messages to the console
/// with a timestamp and optional color
/// </summary>
/// <param name="message">string: message to send to the console</param>
/// <param name="color">(optional)enum ConsoleColor: the color you want the message to be</param>
/// <param name="args">(optional)object[]: additional arguments</param>
public static void ConsoleMessage(string message, ConsoleColor color = ConsoleColor.White, params object[] args)
{
Console.Write("[{0}] ", DateTime.Now.ToString("mm:ss"));
Console.ForegroundColor = color;
Console.WriteLine(message, args);
Console.ResetColor();
}
#endregion
static void Main(string[] args)
{
/*while (true)
{
Item Result = Target.RequestTarget();
Console.WriteLine(Result.Type);
}*/
#region Events
//Stealth.Default.Buff_DebuffSystem += onBuff;
//Stealth.Default.UnicodeSpeech += onSpeech;
#endregion
Thread EggFinderThread = new Thread(FindEggs);
EggFinderThread.Start();
ConsoleMessage("Waiting for connection...");
while (!Profile.IsConnected) ;
ConsoleMessage("Connection detected. Welcome {0}!", Self.Name);
FindFlutes();
if (Flutes.Count < 0)
ErrorExit("Not enough snake charmer flutes. Bye.");
ConsoleMessage("Starting egg farm...");
while (Profile.IsConnected)
{
MainRoutine();
}
}
private static void MainRoutine()
{
DateTime thisTime = DateTime.Now;
Stealth.Default.ClearJournal();
#region Search
Search:
FindSnakes();
ConsoleMessage("Found {0} snakes",
ConsoleColor.DarkYellow, Snakes.Count);
if (Snakes.Count == 0)
{
Thread.Sleep(5000);
goto Search;
}
FindNests();
ConsoleMessage("Found {0} nests",
ConsoleColor.DarkYellow, Nests.Count);
if (Nests.Count == 0)
{
Thread.Sleep(5000);
goto Search;
}
FindFlutes();
ConsoleMessage("Found {0} flutes",
ConsoleColor.DarkYellow, Flutes.Count);
if (Flutes.Count < 1)
ErrorExit("Ran out of flutes.");
#endregion
Item Flute = Flutes[0];
for (int i = 0; i < Snakes.Count; i++)
{
if (i == 3)
break;
ConsoleMessage("Attempting flute process...",
ConsoleColor.DarkYellow);
Stealth.Default.CancelWaitTarget();
while (true)
{
thisTime = DateTime.Now;
Flute.Use();
if (!Stealth.Default.WaitJournalLine(thisTime, "You must wait a moment for it to recharge.", 750))
break;
ConsoleMessage("Flute waiting to recharge. Trying again in 1.5s.",
ConsoleColor.DarkRed);
Script.Wait(1500);
}
Stealth.Default.WaitTargetObject(Snakes[i].ID);
Script.Wait(1000);
Stealth.Default.WaitTargetObject(Nests[0].ID);
Script.Wait(10000);
}
}
static void FindSnakes()
{
Find.FindDistance = 10;
Snakes = Find.FindItems(52);
Snakes.AddRange(Find.FindItems(21));
Snakes.AddRange(Find.FindItems(93));
Snakes.OrderBy(x => x.Distance).ToList();
}
static void FindFlutes()
{
Flutes = Find.FindItems(0x2807, Self.Backpack.ID);
}
static void FindNests()
{
Find.FindDistance = 10;
Nests = Find.FindItems(8755);
Nests.OrderBy(n => n.Distance).ToList();
}
static void FindEggs()
{
while (true)
{
Find.FindDistance = 10;
List<Item> Eggs = Find.FindItems(16831);
if (Eggs.Count > 0)
{
for (int i = 0; i < Eggs.Count; i++)
{
while (Self.X != Eggs[i].X && Self.Y != Eggs[i].Y)
{
Script.Wait(1000);
Stealth.Default.MoveXY((ushort)Eggs[i].X, (ushort)Eggs[0].Y, false, 0, false);
if (Self.X != Eggs[i].X && Self.Y != Eggs[i].Y)
break;
}
ConsoleMessage("Trying to take egg...",
ConsoleColor.DarkYellow);
Stealth.Default.MoveItem(Eggs[i].ID, 1, Self.Backpack.ID, 0, 0, 0);
}
}
Script.Wait(10000);
}
}
}
}