using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading; using ScriptSDK; using ScriptSDK.API; using ScriptSDK.Attributes; using ScriptSDK.Engines; using ScriptSDK.Items; using ScriptSDK.Mobiles; using XScript.Attributes; using XScript.Enumerations; using XScript.Extensions; using XScript.Interfaces; using XScript.Items; namespace CorpseLooter { class Program { #region Vars /// /// PlayerMobile object of our player. /// static PlayerMobile Self = PlayerMobile.GetPlayer(); /// /// Bool to turn on/off loot routine. /// static bool Looting; #endregion #region Objects /// /// Object to search for Trogs /// [QuerySearch(new ushort[] { 0x10B })] public class Trog : Item { public Trog(Serial serial) : base(serial) { } } /// /// Object to search for Liches /// [QuerySearch(new ushort[] { 0x18 })] public class Liche : Item { public Liche(Serial serial) : base(serial) { } } /// /// Container object fot loot /// (optional)string: reason for looting the item /// public class Loot : Item { private string _reason; public string Reason { get { return _reason; } set { _reason = value; } } public Loot(Serial serial) : base(serial) { } public Loot(Serial serial, string Reason) : base(serial) { this.Reason = Reason; } } #endregion [STAThread] static void Main(string[] args) { ConsoleMessage("starting loot routine...", ConsoleColor.DarkYellow); Looting = true; var _lootThread = new Thread(LootRoutine); _lootThread.Start(); var _backpackInventory = Item.Find(typeof(Item), Self.Backpack.Serial.Value, false); foreach (Item _item in _backpackInventory) { Scanner.Ignore(_item); } while (Stealth.Client.GetConnectedStatus()) { var _trogs = Item.Find(typeof(Trog), 0x0, false); //var _liches = Item.Find(typeof(Liche), 0x0, false).OrderBy(x => x.Distance).ToList(); var _virtuehelper = VirtueHelper.GetVirtues(); var _targethelper = TargetHelper.GetTarget(); if (_trogs.Any()) { var _serial = _trogs.First().Serial; /* _virtuehelper.Use(Virtue.Honor); Thread.Sleep(200); _targethelper.TargetTo(_serial);*/ Self.Attack(_serial); Self.Movement.newMoveXY((ushort)_trogs.First().Location.X, (ushort)_trogs.First().Location.Y, false, 1, true); } /* if (_liches.Any()) { Self.Attack(_liches.First().Serial); }*/ #region Combat Check if (Self.Mana > 50) { //Self.UseSecondaryAbility(); } #endregion Thread.Sleep(500); } } #region Routines /// /// Routine for handling loot /// public static void LootRoutine() { while (Looting) { var _corpses = Item.Find(typeof(Corpse), 0x0, false); if (_corpses.Count > 0) { foreach (Corpse _corpse in _corpses) { if (_corpse.Distance < 3) LootCorpse(_corpse); Scanner.Ignore(_corpse.Serial); Thread.Sleep(500); } } Thread.Sleep(2000); } } #endregion #region Methods /// /// Method for posting messages to the console /// with a timestamp /// /// string: message to send to the console /// (optional)object[]: additional arguments public static void ConsoleMessage(string message, params object[] args) { Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("mm:ss")); Console.WriteLine(message, args); } /// /// Method for posting messages to the console /// with a timestamp and optional color /// /// string: message to send to the console /// (optional)enum ConsoleColor: the color you want the message to be /// (optional)object[]: additional arguments public static void ConsoleMessage(string message, ConsoleColor color = ConsoleColor.White, params object[] args) { Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("mm:ss")); Console.ForegroundColor = color; Console.WriteLine(message, args); Console.ResetColor(); } /// /// Method for looting a corpse /// /// object: the corpse object public static void LootCorpse(Corpse Corpse) { //empty list for adding items we want to loot List _toLootList = new List(); //open the corpse and sleep for half a second Corpse.Use(); Thread.Sleep(500); //start the stopwatch for searching Stopwatch _lootingWatch = new Stopwatch(); _lootingWatch.Start(); //searching for weapons, armor and jewery var _weaponList = Item.Find(typeof(BaseWeapon), Corpse.Serial.Value, false); var _armorList = Item.Find(typeof(BaseArmor), Corpse.Serial.Value, false); var _jewelryList = Item.Find(typeof(BaseJewel), Corpse.Serial.Value, false); //ConsoleMessage("Searching took: " + _lootingWatch.Elapsed); //restart the stopwatch for filtering _lootingWatch.Restart(); foreach (BaseWeapon _weapon in _weaponList) { if (_weapon.WeaponAttributes.SplinteringWeapon >= 20) { if (_weapon.Brittle) _toLootList.Add(new Loot(_weapon.Serial, "Brittle splintering weapon")); else if (!(_weapon.Brittle)) _toLootList.Add(new Loot(_weapon.Serial, "Clean splintering weapon")); } else if (_weapon.LootValue.Equals(LootValue.LegendaryArtifact)) _toLootList.Add(new Loot(_weapon.Serial, "Legendary artifact weapon")); else if (_weapon.LootValue.Equals(LootValue.MajorArtifact)) _toLootList.Add(new Loot(_weapon.Serial, "Major artifact weapon")); } foreach (BaseArmor _armor in _armorList) { if (_armor.LootValue.Equals(LootValue.LegendaryArtifact)) _toLootList.Add(new Loot(_armor.Serial, "Legendary artifact armor")); else if (_armor.LootValue.Equals(LootValue.MajorArtifact)) _toLootList.Add(new Loot(_armor.Serial, "Major artifact armor")); } foreach (BaseJewel _jewel in _jewelryList) { if (_jewel.LootValue.Equals(LootValue.LegendaryArtifact)) _toLootList.Add(new Loot(_jewel.Serial, "Legendary artifact armor")); else if (_jewel.LootValue.Equals(LootValue.MajorArtifact)) _toLootList.Add(new Loot(_jewel.Serial, "Major artifact armor")); } //ConsoleMessage("Filtering took: " + _lootingWatch.Elapsed); if (_toLootList.Count() > 0) LootItems(_toLootList); } /// /// Method for looting all items in a list /// /// List: list of items to loot public static void LootItems(List ToLootList) { PlayerMobile _player = PlayerMobile.GetPlayer(); Stealth.Client.CancelTarget(); foreach (Loot _loot in ToLootList) { Stealth.Client.PartySay("Looting Item: " + _loot.Serial.Value + ' ' + _loot.Reason); ConsoleMessage("Looting Item: " + _loot.Serial.Value, ConsoleColor.Red); _loot.Move(1, Self.Backpack); Thread.Sleep(1500); InsureItem(_loot); Scanner.Ignore(_loot.Serial); } ToLootList.Clear(); } /// /// Method for insuring a looted item /// /// object: representing an item public static void InsureItem(Loot Loot) { ConsoleMessage("Insuring Item: {0}", ConsoleColor.Red, Loot.Serial.Value.ToString()); Stealth.Client.RequestContextMenu(Self.Serial.Value); Stealth.Client.SetContextMenuHook(Self.Serial.Value, 9); Thread.Sleep(1500); var _helper = TargetHelper.GetTarget(); _helper.AutoTargetTo(Loot.Serial); Thread.Sleep(500); Stealth.Client.CancelMenu(); Stealth.Client.CancelTarget(); } #endregion } }