ScriptUO

Scripting Resources & Utilities => Stealth Client => Stealth scripts => Topic started by: Orich on October 20, 2013, 12:16:35 AM

Title: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Orich on October 20, 2013, 12:16:35 AM

oEggs v0.0.0.0.0.1alpha
The world's only Medusa Egg Farmer (since EUO is ... < Stealth    :o)

I wrote this at 3:00am today for a friend ... She said it seemed to work well, but it's written like dogshit.  I'm releasing it because, well, dxrom just released a script and I can't let him have the limelight for more than 15 minutes.


Important things :

1.  You must have ScriptDotNet.DLL in the same directory as the .EXE

2.  If you don't want to compile it yourself follow these steps :
            STEP A:   Go to the link below "BitBucket Repository" (Orich's Scripts)
            STEP B:   Click "Source" link in the top-middle bar
            STEP C:   Navigate through the folders as follows :  oEggs -> oEggs -> bin -> Debug
            STEP D:   Download oEggs.exe (and ScriptDotNet.DLL, but you should get the latest copy from the main bitbucket repository)
            STEP E:   Run stealth, log in, use script

3.  If you experience bugs ... Not shocking, since I didn't test this (literally, I didn't test it once)   Oh and it's written horribly.. did i mention that?

4.  If you don't experience bugs ... I might be Jesus.

5.  I'm really, really tired right now.

Features

It uses flutes
Targets snake (closest one to you)
Targets nest (closest one to you)
Waits for snake to do its thing
hides you
stealths you
walks to egg
grabs egg
rinse repeat


Resources

Stealth Client Topic   Stealth SUO Topic     (http://www.scriptuo.com/index.php?topic=11628.0)Main Stealth Release Thread
Orich's ScriptsBitBucket Repository (https://bitbucket.org/Orich/orichs-scripts)Orich's Scripts Library
Bug TrackerBitBucket Issue Tracker    (https://bitbucket.org/Stealthadmin/stealth-beta-client/issues?status=new&status=open)Report Issues / Bugs Here!
Stealth HomeStealth Home (http://stealth.od.ua)Stealth Webpage & Forums (English & Russian)
Video Tutorial   oRune Tutorial Topic (http://www.scriptuo.com/index.php?topic=11675.0)Basic C# Scripting Tutorial
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: dxrom on October 20, 2013, 12:24:36 AM
ggwp :>

I'm releasing it because, well, dxrom just released a script and I can't let him have the limelight for more than 15 minutes.

(http://puu.sh/4UzwW.jpg)
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: NObama on October 20, 2013, 02:48:01 PM
Dear lord...you mean we can now script eggies?  This has been the holy grail for Abyss champs for years.  YEARS.

*sigh* I just don't have the strength to learn stealth...
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Mad Tamer on October 20, 2013, 04:02:01 PM
I am gonna try this tonight... Been wanting a script for collecting eggs for YEARS the closest I have gotten is a helper script for it. In the helper script you still had to move your self and click the holes yourself. I really hope this thing works!
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Orich on October 20, 2013, 07:04:16 PM
Dear lord...you mean we can now script eggies?  This has been the holy grail for Abyss champs for years.  YEARS.

*sigh* I just don't have the strength to learn stealth...

Just about 2.5 months ago I'd never heard of Stealth.

~2 months ago I had no experience with .NET, and had never written a single line of C# or Delphi (although, I had known Pascal when I was ~12 years old ... 20 years ago)


I'm not sure what entails "learning Stealth", but it is far less daunting than you think.

You have 3,000 posts and have done whatever it is you need to do to qualify for that Elite title.  You have two tutorials that take 90% of the mystery out of Stealth.

Pull up those bootstraps and dig in.  It isn't hard, and it pays off dividends (assuming you still care about UO)

</Motivational Speech>
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Mad Tamer on October 20, 2013, 07:17:05 PM
Hey I tried the script it works great thank you soo much I have gotten 7 eggs to drop with this! Sometimes the script itself crashes but I just click start again and it starts going again.

Just some minor problems with Range like try's using holes on other sides of walls/ really far away ect. But it did make a egg come outta a nest that was not even on my screen! Like I took 3 steps n then saw the egg.  But a button or option to research for closer holes/snakes would be nice. Or even a restart script button would work that's what I do when its trying to do something that too far away or threw a wall.

Is there any way to edit the range of the snakes distance to you and the hole distance to you? Like only use snakes n hole that are X amount of tiles away. I tried to Edit the script but I didn't understand anything soo I did nothing lol. It didn't even look like words lol!

Some great add-ons for the script would be if the char would pathfind to the dropped egg n pick it up! It seem to try picking it up you just gotta stand very close to the hole. :)

I was on an OSI shard with the most recent stealth.  Thanks again for your awesome script! I love it!
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Orich on October 21, 2013, 12:05:19 AM
Hey I tried the script it works great thank you soo much I have gotten 7 eggs to drop with this! Sometimes the script itself crashes but I just click start again and it starts going again.

Just some minor problems with Range like try's using holes on other sides of walls/ really far away ect. But it did make a egg come outta a nest that was not even on my screen! Like I took 3 steps n then saw the egg.  But a button or option to research for closer holes/snakes would be nice. Or even a restart script button would work that's what I do when its trying to do something that too far away or threw a wall.

Is there any way to edit the range of the snakes distance to you and the hole distance to you? Like only use snakes n hole that are X amount of tiles away. I tried to Edit the script but I didn't understand anything soo I did nothing lol. It didn't even look like words lol!

Some great add-ons for the script would be if the char would pathfind to the dropped egg n pick it up! It seem to try picking it up you just gotta stand very close to the hole. :)

I was on an OSI shard with the most recent stealth.  Thanks again for your awesome script! I love it!

You're welcome.

It should be walking to the eggs and looting them (in Hiding/Stealth) ... but perhaps its as broken as I anticipated.

You said you looked at the code?  Changing the FindDistance and FindVerticalDistance is extremely easy.  Do you have Visual Studio installed?

Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Mad Tamer on October 21, 2013, 12:27:54 PM
I hit Edit Script inside Stealth near the script area. What came up didn't look like words. I didn't open Eggs.exe and I don't have that program installed. Do you have a link I can click to get Visual Studio? If I install that I can look at the code n change wait times?

I also want it to click snakes closer to me rather than farther from me. Sometimes I have like 3 snakes near the hole and it clicks a snake from on the edge of my screen instead of any of the closer ones. But I still enjoy that it clicks snakes on the edge when there are no snakes closer.

I got 15 eggs with little problems last night! I keep my char Hidden and he has 120 Stealth. I would bring my char near like 2 or 3 holes and then click into my other chars and click back like 5 mins later and it has normally destroyed the holes and eggs are on the ground. So its a million times better than any other Egg Helper script I have ever used. The item Medusa drops that everyone wants is a talisman worth like 120 mill. Its got a wicked low drop rate and until now you had to farm the eggs by hand cuz no scripts would CLICK the holes for you. The eggs last a week soo its an awesome script! Thanks again man!

Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Orich on October 21, 2013, 01:50:18 PM
I hit Edit Script inside Stealth near the script area. What came up didn't look like words. I didn't open Eggs.exe and I don't have that program installed. Do you have a link I can click to get Visual Studio? If I install that I can look at the code n change wait times?

Um.  Heh.

Eggs.exe is an executable ... not an editable script.

Judging by your experience level, it looks like you'll have to wait until I fix it.  Sorry.
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Mad Tamer on October 21, 2013, 03:42:01 PM
Your super right I am a super noob when it comes to making scripts. I can edit EasyUO scripts wait times n stuff tho. Script works for me tho! I already got like 25 eggs with little effort! You would prolly need to watch it run and tweak it to make it perfect :) Soo far its done what easyuo script's have been dreaming of doing for years lol. Thanks again!
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Tidus on October 24, 2013, 08:50:20 AM
Tightening bootstraps.. now i just need to find the time.....
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: The Ghost on October 24, 2013, 03:33:51 PM
Orich ,  thx for the release.

   I did try it out for a  1hrs. and get one egg.  It does use the flute, target the hole.  It does target the far snake and hole.  so it hard to see  what happening. I'm sure I had miss a few eggs because their are off screen.    Also it doesn't pathfind to the eggs.    Sure get in interesting on how  Visual Studio work. 
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Orich on October 24, 2013, 03:42:25 PM
Orich ,  thx for the release.

   I did try it out for a  1hrs. and get one egg.  It does use the flute, target the hole.  It does target the far snake and hole.  so it hard to see  what happening. I'm sure I had miss a few eggs because their are off screen.    Also it doesn't pathfind to the eggs.    Sure get in interesting on how  Visual Studio work. 

Yeah there are a few bugs in it, I'll fix it this weekend
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Masscre on December 24, 2013, 12:23:36 PM
Since I am working on learning this Scripting Lanuage I was going to look at your script Orich but can not find it :)
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: slyone on December 27, 2013, 08:01:57 AM
Since I am working on learning this Scripting Lanuage I was going to look at your script Orich but can not find it :)

Checkout C# project from the Source tab (https://bitbucket.org/Orich/orichs-scripts/src) on the Orich's Scripts bitbucket.org page.

If you don't have Git, you can download the whole C# project on the Download tab (https://bitbucket.org/Orich/orichs-scripts/downloads).  Click the "Branches" tab on that page and select the .zip download format.
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: unisharp on May 06, 2015, 03:22:15 AM
oEggs - Revisited v0.1 Alpha

Updated and working.  Changed it around a bit, there's two parts to this:  The routine of using a flute targeting a snake and then a nest, and then a separate thread running a function that searches for eggs and picks them up.

Pretty quick and dirty I took out most of the Journal checking since we no longer need to verify whether or not a snake was successful.

Code: [Select]
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();

            lock (locker)
            {
                #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)
            {
                lock (locker)
                {
                    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;
                            }
                            Console.WriteLine("Taking the egg.");
                            Stealth.Default.DragItem(Eggs[i].ID, 1);
                            Script.Wait(1500);
                            Stealth.Default.DropHere(Self.Backpack.ID);
                        }
                    }
                }
                Script.Wait(10000);
            }
        }
    }
}

I had a hard time deciding on distance checks, because of the terrain.  The vertical changing ground tiles are a pain in the arse, you'll be 5 tiles from something but you still can't either see it or reach it.  For this reason I suggest trying out different spots if you're having difficulty.
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: unisharp on May 06, 2015, 03:32:48 AM
One more thing, for some reason when it checks for snakes it always comes up with 0 the first time.  It checks for new snakes and new nests every 5 seconds if it couldn't find any.  Just let it run, it'll find em!

I watched it successfully pick eggs up, then last night I watched it walk to an Egg and not pick it up.  More testing is needed.

EDIT: A couple other notes lol...

After searching for snakes... say it finds 20 snakes on screen.  It'll loop through the first 3 it finds and then re-search and start over.  I did it this way because if it did find 20 snakes, when it gets to say 15, the snake that it's now targeting will most likely be inaccessible (off screen.)  This way after it gets to the 3rd snake, the 1st one should be finished searching and able to search again.
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: unisharp on May 06, 2015, 04:37:02 AM
One more update
Rev0.2a

Changed from using Drag/Drop item to MoveItem.

Code: [Select]
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);
            }
        }
    }
}

Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Ultimafreak77 on May 23, 2015, 05:41:24 PM
I haven't used the stealth client before but this looks like as good a reason as any to learn.
Title: Re: [V6, C#] oEggs - Orich's Medusa Egg Farmer
Post by: Oracle on June 12, 2017, 11:57:20 PM
Has this Script been updated.  I really would like a Medusa Egg Farmer written for EasyUO.  I know that there is one written for it, as I had it at one day, but my Hard Drive crashed with all of my cool Scripts I collected on it...!


Oracle