Author Topic: [V6,ScriptSDK] Healing Trainer  (Read 4445 times)

0 Members and 1 Guest are viewing this topic.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
[V6,ScriptSDK] Healing Trainer
« on: October 03, 2015, 03:45:08 AM »
+1
Download ScriptSDK here:
http://sourceforge.net/projects/scriptsdk/files

Download Visual Studio here:
https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx

Compiling Instructions
Start a new Windows Console Application project, name it HealingTrainer
Add a reference to ScriptSDK
Copy/Paste code below into Program.cs
Right click the solution in the Solution Explorer, and click Build.
You now have an application named HealingTrainer.exe in ./bin/Debug/

Script Instructions
Simple little script here.  Start up two accounts with stealth, one of them is to be the ghost.  Make sure the character is dead before running it, but you run the script on both the person training healing as well as the ghost.  Make sure you have a container with bandages.

1.  Connect two accounts
2.  Kill one of the characters
3.  Fill container with bandages (no sub containers)
4.  Start Script on Ghost
5.  Open game client for Healer
6.  Start Script on Healer
7.  Target the container with the bandages
8.  Target your ghost
9.  Close game client
10.  Profit

Code: [Select]
using System;
using System.Diagnostics;
using System.Linq;
using ScriptSDK;
using ScriptSDK.API;
using ScriptSDK.Attributes;
using ScriptSDK.Data;
using ScriptSDK.Items;
using ScriptSDK.Mobiles;

namespace HealingTrainer
{
    class Program
    {
        private static PlayerMobile Self = PlayerMobile.GetPlayer();

        public static Item RequestTarget(uint TimeoutMS = 0)
        {
            Stealth.Client.ClientRequestObjectTarget();
            Stopwatch timer = new Stopwatch();


            timer.Start();
            while (Stealth.Client.ClientTargetResponsePresent() == false)
            {
                if (TimeoutMS != 0 && timer.ElapsedMilliseconds >= TimeoutMS)
                    return default(Item);
            }

            return new Item(new Serial(Stealth.Client.ClientTargetResponse().ID));
        }

        [STAThread]
        static void Main(string[] args)
        {

            var _targetHelper = TargetHelper.GetTarget();

            if (Self.Dead)
                GhostRoutine();
            else
            {
                Console.WriteLine("Target the container with bandages.");
                var _bandageContainer = RequestTarget();

                _bandageContainer.DoubleClick();
                
                Console.WriteLine("Target the ghost to heal");
                var _bandageTarget = RequestTarget();

                while (true)
                {
                    var _bandageList = Item.Find(typeof(Bandage), Self.Backpack.Serial.Value, false);

                    if (_bandageList.Count == 0)
                    {
                        Console.WriteLine("Backpack out of bandages.");
                        GetBandages(_bandageContainer);
                        continue;
                    }

                    var _bandages = _bandageList.First();

                    _bandages.DoubleClick();
                    _targetHelper.AutoTargetTo(_bandageTarget.Serial);
                    Stealth.Client.Wait(7000);
                }

            }

        }

        static void GetBandages(Item BandageContainer)
        {
            BandageContainer.DoubleClick();
            Stealth.Client.Wait(1000);

            var _bandageList = Item.Find(typeof(Bandage), BandageContainer.Serial.Value, false);

            if (_bandageList.Count == 0)
                Console.WriteLine("Bandage container is out of bandages");
            else
            {
                var _bandages = _bandageList.First();
                _bandages.UpdateLocalizedProperties();
                _bandages.UpdateTextProperties();
                Console.WriteLine("{0} bandages left.", _bandages.Amount);


                Console.WriteLine("Getting more bandages...");

                Stealth.Client.DragItem(_bandages.Serial.Value, 500);
                Stealth.Client.Wait(500);
                Stealth.Client.DropItem(Self.Backpack.Serial.Value, 0, 0, 0);

                Stealth.Client.Wait(1500);
            }
        }

        static void GhostRoutine()
        {
            while (true)
            {
                Stealth.Client.SetWarMode(true);
                Stealth.Client.SendTextToUO("oOoOooooo");
                Stealth.Client.Wait(5000);
            }
        }

        [QuerySearch(new ushort[] { 0xE21 })]
        public class Bandage : Item
        {
            public Bandage (Serial serial)
                : base (serial)
            {

            }
        }
    }
}

Let's talk about how it works.  The [STAThread] Main void is the entrance to the application.  We set our target helper.  Then we check if we're dead, if we are we goto a sub routine called GhostRoutine.  All that routine does is loop endlessly making sure we stay in war mode and also sending text to UO so that we stay shown.

If we're not a ghost, then we request targets for the container of bandages and the ghost to heal.  After that, there's an endless loop.  In this loop, we first search for bandages in our backpack.  If there are none, we call the GetBandages function on the container we previously targeted containing our bandages.

In the GetBandages function, we make sure our container of bandages is open and then wait full second so that we don't try and drag bandages too fast causing it to "you must wait to blah blah blah..."   Then we search the container.  If there are bandages in there, drag 500 and drop them in your backpack.  Wait another 1.5 seconds.

After GetBandages runs, we're back in the main function.   We double click our bandages and auto target to our ghost.  A 7 second wait is set, which you'll want to change tailored to your dexterity.  Maybe I should have put in an algorithm to automatically calculate the time it would take based on our dexterity, but I'm just posting this as a snippet, not really a full trainer.

Enjoy.
« Last Edit: October 21, 2015, 04:42:19 AM by unisharp »

Tags: healing trainer