Advertisement
RulerOf

Simple d3 pickit

Jun 2nd, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. using D3;
  8.  
  9. namespace PickIt
  10. {
  11.      public class Program
  12.      {
  13.           private static int _frameCount = 0;
  14.      
  15.           public static void Main(string[] args)
  16.           {
  17.                Game.Print("PickIt: Now monitoring drops");
  18.                
  19.                Game.OnTickEvent += new TickEventHandler(Game_OnTickEvent);
  20.           }
  21.                
  22.           private static void Game_OnTickEvent(EventArgs e)
  23.           {
  24.                if(++_frameCount % 20 != 0)
  25.                {
  26.                     return;
  27.                }
  28.                
  29.                PickItems();
  30.           }
  31.      
  32.           private static void PickItems()
  33.           {
  34.                List<Unit> items = GetItems();
  35.  
  36.                foreach (Unit item in items)
  37.                {
  38.                     if(GetDistance(Me.X, Me.Y, item.X, item.Y) < 5)
  39.                     {
  40.                          Game.Print("Picking: " + item.Name);
  41.                    
  42.                          Me.UsePower(SNOPowerId.Axe_Operate_Gizmo, item);          
  43.                     }
  44.                }
  45.           }
  46.          
  47.           private static List<Unit> GetItems()
  48.           {
  49.                List<Unit> items = new List<Unit>();
  50.                
  51.                foreach(Unit u in Unit.Get())
  52.                {
  53.                     if(CheckItem(u) && u.ItemContainer == Container.Unknown)
  54.                     {
  55.                          items.Add(u);
  56.                     }
  57.                }
  58.                
  59.                return items;
  60.           }
  61.          
  62.           private static bool CheckItem(Unit unit)
  63.           {
  64.                return
  65.                        unit.ActorId == SNOActorId.healthPotion_Minor
  66.                     || unit.ActorId == SNOActorId.healthPotion_Lesser
  67.                     || unit.ActorId == SNOActorId.healthPotion_Normal
  68.                     || unit.ActorId == SNOActorId.healthPotion_Greater
  69.                     || unit.ActorId == SNOActorId.healthPotion_Super
  70.                     || unit.Name.Contains("Topaz") // stones
  71.                     || unit.Name.Contains("Amethyst")
  72.                     || unit.Name.Contains("Emerald")
  73.                     || unit.Name.Contains("Ruby")
  74.                     || unit.Name.Contains("Book of") // crafting materials (add "page"?)
  75.                     || unit.Name.Contains("Page of")
  76.                     || unit.Name.Contains("Tome")
  77.                     || unit.Name.Contains("Mythic") // Health potions
  78.                     || unit.ItemQuality >= UnitItemQuality.Magic1;
  79.           }
  80.          
  81.           public static float GetDistance(float x, float y, float x2, float y2)
  82.           {
  83.                return (float)Math.Sqrt(Math.Pow(x - x2, 2) + Math.Pow(y - y2, 2));
  84.           }
  85.      }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement