Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- /// <summary>
- /// PlayerMobile object of our player.
- /// </summary>
- static PlayerMobile Self = PlayerMobile.GetPlayer();
- /// <summary>
- /// Bool to turn on/off loot routine.
- /// </summary>
- static bool Looting;
- #endregion
- #region Objects
- /// <summary>
- /// Object to search for Trogs
- /// </summary>
- [QuerySearch(new ushort[] { 0x10B })]
- public class Trog : Item
- {
- public Trog(Serial serial)
- : base(serial)
- {
- }
- }
- /// <summary>
- /// Object to search for Liches
- /// </summary>
- [QuerySearch(new ushort[] { 0x18 })]
- public class Liche : Item
- {
- public Liche(Serial serial)
- : base(serial)
- {
- }
- }
- /// <summary>
- /// Container object fot loot
- /// <param name="reason"/>(optional)string: reason for looting the item
- /// </summary>
- 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
- /// <summary>
- /// Routine for handling loot
- /// </summary>
- 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
- /// <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}-{1}] ", Self.Name, 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}-{1}] ", Self.Name, DateTime.Now.ToString("mm:ss"));
- Console.ForegroundColor = color;
- Console.WriteLine(message, args);
- Console.ResetColor();
- }
- /// <summary>
- /// Method for looting a corpse
- /// </summary>
- /// <param name="Corpse">object: the corpse object</param>
- public static void LootCorpse(Corpse Corpse)
- {
- //empty list for adding items we want to loot
- List<Loot> _toLootList = new List<Loot>();
- //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);
- }
- /// <summary>
- /// Method for looting all items in a list
- /// </summary>
- /// <param name="ToLootList">List<Loot>: list of items to loot</param>
- public static void LootItems(List<Loot> 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();
- }
- /// <summary>
- /// Method for insuring a looted item
- /// </summary>
- /// <param name="Loot">object: representing an item</param>
- 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
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement