Advertisement
sibble

Untitled

Sep 15th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading;
  6. using ScriptSDK;
  7. using ScriptSDK.API;
  8. using ScriptSDK.Attributes;
  9. using ScriptSDK.Engines;
  10. using ScriptSDK.Items;
  11. using ScriptSDK.Mobiles;
  12. using XScript.Attributes;
  13. using XScript.Enumerations;
  14. using XScript.Extensions;
  15. using XScript.Interfaces;
  16. using XScript.Items;
  17.  
  18.  
  19. namespace CorpseLooter
  20. {
  21.     class Program
  22.     {
  23.         #region Vars
  24.  
  25.         /// <summary>
  26.         /// PlayerMobile object of our player.
  27.         /// </summary>
  28.         static PlayerMobile Self = PlayerMobile.GetPlayer();
  29.  
  30.         /// <summary>
  31.         /// Bool to turn on/off loot routine.
  32.         /// </summary>
  33.         static bool Looting;
  34.  
  35.         #endregion
  36.  
  37.         #region Objects
  38.  
  39.         /// <summary>
  40.         /// Object to search for Trogs
  41.         /// </summary>
  42.         [QuerySearch(new ushort[] { 0x10B })]
  43.         public class Trog : Item
  44.         {
  45.             public Trog(Serial serial)
  46.             : base(serial)
  47.             {
  48.             }
  49.         }
  50.  
  51.         /// <summary>
  52.         /// Object to search for Liches
  53.         /// </summary>
  54.         [QuerySearch(new ushort[] { 0x18 })]
  55.         public class Liche : Item
  56.         {
  57.             public Liche(Serial serial)
  58.             : base(serial)
  59.             {
  60.             }
  61.         }
  62.  
  63.         /// <summary>
  64.         /// Container object fot loot
  65.         /// <param name="reason"/>(optional)string: reason for looting the item
  66.         /// </summary>
  67.         public class Loot : Item
  68.         {
  69.             private string _reason;
  70.             public string Reason
  71.             {
  72.                 get { return _reason; }
  73.                 set { _reason = value; }
  74.             }
  75.  
  76.             public Loot(Serial serial)
  77.                 : base(serial)
  78.             {
  79.             }
  80.  
  81.             public Loot(Serial serial, string Reason)
  82.             : base(serial)
  83.             {
  84.                 this.Reason = Reason;
  85.             }
  86.         }
  87.  
  88.         #endregion
  89.  
  90.         [STAThread]
  91.         static void Main(string[] args)
  92.         {
  93.             ConsoleMessage("starting loot routine...", ConsoleColor.DarkYellow);
  94.             Looting = true;
  95.             var _lootThread = new Thread(LootRoutine);
  96.             _lootThread.Start();
  97.  
  98.             var _backpackInventory = Item.Find(typeof(Item), Self.Backpack.Serial.Value, false);
  99.  
  100.             foreach (Item _item in _backpackInventory)
  101.             {
  102.                 Scanner.Ignore(_item);
  103.             }
  104.            
  105.             while (Stealth.Client.GetConnectedStatus())
  106.             {
  107.                 var _trogs = Item.Find(typeof(Trog), 0x0, false);
  108.                 //var _liches = Item.Find(typeof(Liche), 0x0, false).OrderBy(x => x.Distance).ToList();
  109.                 var _virtuehelper = VirtueHelper.GetVirtues();
  110.                 var _targethelper = TargetHelper.GetTarget();
  111.  
  112.                 if (_trogs.Any())
  113.                 {
  114.                     var _serial = _trogs.First().Serial;
  115.                     /*
  116.                     _virtuehelper.Use(Virtue.Honor);
  117.                     Thread.Sleep(200);
  118.                     _targethelper.TargetTo(_serial);*/
  119.  
  120.                     Self.Attack(_serial);
  121.                     Self.Movement.newMoveXY((ushort)_trogs.First().Location.X, (ushort)_trogs.First().Location.Y, false, 1, true);
  122.                 }
  123.                 /*
  124.                 if (_liches.Any())
  125.                 {
  126.                     Self.Attack(_liches.First().Serial);
  127.                 }*/
  128.  
  129.                
  130.                 #region Combat Check
  131.                 if (Self.Mana > 50)
  132.                 {
  133.                     //Self.UseSecondaryAbility();
  134.                 }
  135.                 #endregion
  136.  
  137.                 Thread.Sleep(500);
  138.             }
  139.  
  140.         }
  141.  
  142.         #region Routines
  143.  
  144.         /// <summary>
  145.         /// Routine for handling loot
  146.         /// </summary>
  147.         public static void LootRoutine()
  148.         {
  149.             while (Looting)
  150.             {
  151.                 var _corpses = Item.Find(typeof(Corpse), 0x0, false);
  152.  
  153.                 if (_corpses.Count > 0)
  154.                 {
  155.                     foreach (Corpse _corpse in _corpses)
  156.                     {
  157.                         if (_corpse.Distance < 3)
  158.                             LootCorpse(_corpse);
  159.  
  160.                         Scanner.Ignore(_corpse.Serial);
  161.  
  162.                         Thread.Sleep(500);
  163.                     }
  164.                 }
  165.                 Thread.Sleep(2000);
  166.             }
  167.         }
  168.  
  169.         #endregion
  170.  
  171.         #region Methods
  172.  
  173.         /// <summary>
  174.         /// Method for posting messages to the console
  175.         /// with a timestamp
  176.         /// </summary>
  177.         /// <param name="message">string: message to send to the console</param>
  178.         /// <param name="args">(optional)object[]: additional arguments</param>
  179.         public static void ConsoleMessage(string message, params object[] args)
  180.         {
  181.             Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("mm:ss"));
  182.             Console.WriteLine(message, args);
  183.         }
  184.  
  185.         /// <summary>
  186.         /// Method for posting messages to the console
  187.         /// with a timestamp and optional color
  188.         /// </summary>
  189.         /// <param name="message">string: message to send to the console</param>
  190.         /// <param name="color">(optional)enum ConsoleColor: the color you want the message to be</param>
  191.         /// <param name="args">(optional)object[]: additional arguments</param>
  192.         public static void ConsoleMessage(string message, ConsoleColor color = ConsoleColor.White, params object[] args)
  193.         {
  194.             Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("mm:ss"));
  195.             Console.ForegroundColor = color;
  196.             Console.WriteLine(message, args);
  197.             Console.ResetColor();
  198.         }
  199.        
  200.         /// <summary>
  201.         /// Method for looting a corpse
  202.         /// </summary>
  203.         /// <param name="Corpse">object: the corpse object</param>
  204.         public static void LootCorpse(Corpse Corpse)
  205.         {
  206.             //empty list for adding items we want to loot
  207.             List<Loot> _toLootList = new List<Loot>();
  208.  
  209.             //open the corpse and sleep for half a second
  210.             Corpse.Use();
  211.             Thread.Sleep(500);
  212.            
  213.             //start the stopwatch for searching
  214.             Stopwatch _lootingWatch = new Stopwatch();
  215.             _lootingWatch.Start();
  216.  
  217.             //searching for weapons, armor and jewery
  218.             var _weaponList = Item.Find(typeof(BaseWeapon), Corpse.Serial.Value, false);
  219.             var _armorList = Item.Find(typeof(BaseArmor), Corpse.Serial.Value, false);
  220.             var _jewelryList = Item.Find(typeof(BaseJewel), Corpse.Serial.Value, false);
  221.             //ConsoleMessage("Searching took: " + _lootingWatch.Elapsed);
  222.  
  223.             //restart the stopwatch for filtering
  224.             _lootingWatch.Restart();
  225.  
  226.             foreach (BaseWeapon _weapon in _weaponList)
  227.             {
  228.                 if (_weapon.WeaponAttributes.SplinteringWeapon >= 20)
  229.                 {
  230.                     if (_weapon.Brittle)
  231.                         _toLootList.Add(new Loot(_weapon.Serial, "Brittle splintering weapon"));
  232.                     else if (!(_weapon.Brittle))
  233.                         _toLootList.Add(new Loot(_weapon.Serial, "Clean splintering weapon"));
  234.                 }
  235.                 else if (_weapon.LootValue.Equals(LootValue.LegendaryArtifact))
  236.                     _toLootList.Add(new Loot(_weapon.Serial, "Legendary artifact weapon"));
  237.                 else if (_weapon.LootValue.Equals(LootValue.MajorArtifact))
  238.                     _toLootList.Add(new Loot(_weapon.Serial, "Major artifact weapon"));
  239.             }
  240.  
  241.             foreach (BaseArmor _armor in _armorList)
  242.             {
  243.                 if (_armor.LootValue.Equals(LootValue.LegendaryArtifact))
  244.                     _toLootList.Add(new Loot(_armor.Serial, "Legendary artifact armor"));
  245.                 else if (_armor.LootValue.Equals(LootValue.MajorArtifact))
  246.                     _toLootList.Add(new Loot(_armor.Serial, "Major artifact armor"));
  247.             }
  248.  
  249.             foreach (BaseJewel _jewel in _jewelryList)
  250.             {
  251.                 if (_jewel.LootValue.Equals(LootValue.LegendaryArtifact))
  252.                     _toLootList.Add(new Loot(_jewel.Serial, "Legendary artifact armor"));
  253.                 else if (_jewel.LootValue.Equals(LootValue.MajorArtifact))
  254.                     _toLootList.Add(new Loot(_jewel.Serial, "Major artifact armor"));
  255.             }
  256.             //ConsoleMessage("Filtering took: " + _lootingWatch.Elapsed);
  257.  
  258.  
  259.             if (_toLootList.Count() > 0)
  260.                 LootItems(_toLootList);
  261.  
  262.  
  263.         }
  264.  
  265.         /// <summary>
  266.         /// Method for looting all items in a list
  267.         /// </summary>
  268.         /// <param name="ToLootList">List<Loot>: list of items to loot</param>
  269.         public static void LootItems(List<Loot> ToLootList)
  270.         {
  271.             PlayerMobile _player = PlayerMobile.GetPlayer();
  272.  
  273.             Stealth.Client.CancelTarget();
  274.  
  275.             foreach (Loot _loot in ToLootList)
  276.             {
  277.  
  278.                 Stealth.Client.PartySay("Looting Item: " + _loot.Serial.Value + ' ' + _loot.Reason);
  279.                 ConsoleMessage("Looting Item: " + _loot.Serial.Value, ConsoleColor.Red);
  280.  
  281.                 _loot.Move(1, Self.Backpack);
  282.  
  283.                 Thread.Sleep(1500);
  284.  
  285.                 InsureItem(_loot);
  286.                
  287.                 Scanner.Ignore(_loot.Serial);
  288.             }
  289.             ToLootList.Clear();
  290.         }
  291.  
  292.         /// <summary>
  293.         /// Method for insuring a looted item
  294.         /// </summary>
  295.         /// <param name="Loot">object: representing an item</param>
  296.         public static void InsureItem(Loot Loot)
  297.         {
  298.             ConsoleMessage("Insuring Item: {0}", ConsoleColor.Red, Loot.Serial.Value.ToString());
  299.  
  300.             Stealth.Client.RequestContextMenu(Self.Serial.Value);
  301.             Stealth.Client.SetContextMenuHook(Self.Serial.Value, 9);
  302.  
  303.             Thread.Sleep(1500);
  304.  
  305.             var _helper = TargetHelper.GetTarget();
  306.            
  307.             _helper.AutoTargetTo(Loot.Serial);
  308.            
  309.             Thread.Sleep(500);
  310.  
  311.             Stealth.Client.CancelMenu();
  312.             Stealth.Client.CancelTarget();
  313.         }
  314.  
  315.         #endregion
  316.  
  317.     }
  318. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement