Advertisement
Guest User

Untitled

a guest
Jan 14th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.20 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Threading;
  8. using MemoryRobot;
  9. using robotManager.Helpful;
  10. using robotManager.Products;
  11. using wManager;
  12. using wManager.Plugin;
  13. using wManager.Wow.Helpers;
  14. using wManager.Wow.ObjectManager;
  15.  
  16. public class Main : IPlugin
  17. {
  18.     private bool _isLaunched;
  19.  
  20.     public void Initialize()
  21.     {
  22.         _isLaunched = true;
  23.         MultiPullSettings.Load();
  24.         Logging.Write("[MultiPull] Started.");
  25.         while (_isLaunched && Products.IsStarted)
  26.         {
  27.             try
  28.             {
  29.                 Pulse();
  30.             }
  31.             catch (Exception e)
  32.             {
  33.                 Logging.WriteError("[MultiPull]: " + e);
  34.             }
  35.             Thread.Sleep(400);
  36.         }
  37.     }
  38.  
  39.     public void Dispose()
  40.     {
  41.         _isLaunched = false;
  42.         Logging.Write("[MultiPull] Stoped.");
  43.     }
  44.  
  45.     public void Settings()
  46.     {
  47.         MultiPullSettings.Load();
  48.         MultiPullSettings.CurrentSetting.ToForm();
  49.         MultiPullSettings.CurrentSetting.Save();
  50.         Logging.Write("[MultiPull] Settings saved.");
  51.     }
  52.  
  53.     public void Pulse()
  54.     {
  55.         if (_threadCount <= 1 &&
  56.             !Products.InPause &&
  57.             ObjectManager.Me.InCombat &&
  58.             Fight.InFight &&
  59.             ObjectManager.Target.IsValid &&
  60.             (ObjectManager.Target.IsTargetingMe || (ObjectManager.Pet.IsValid && ObjectManager.Target.Target == ObjectManager.Pet.Guid)) &&
  61.             ObjectManager.Me.HealthPercent >= MultiPullSettings.CurrentSetting.MinHealth &&
  62.             ObjectManager.GetNumberAttackPlayer() < MultiPullSettings.CurrentSetting.MobMax)
  63.         {
  64.             var mobs = new List<WoWUnit>();
  65.             if (MultiPullSettings.CurrentSetting.AllFactions)
  66.             {
  67.                 mobs.AddRange(ObjectManager.GetWoWUnitAttackables(MultiPullSettings.CurrentSetting.PullRange));
  68.             }
  69.             else
  70.             {
  71.                 mobs.AddRange(ObjectManager.GetWoWUnitByEntry(MultiPullSettings.CurrentSetting.MobsList));
  72.             }
  73.  
  74.             var listGuidUnitAttackPlayer = ObjectManager.GetUnitAttackPlayer().Select(m => m.Guid).ToArray();
  75.             for (int i = mobs.Count - 1; i >= 0; i--)
  76.             {
  77.                 if (!mobs[i].IsValid ||
  78.                     !mobs[i].IsAlive ||
  79.                     mobs[i].Target.IsNotZero() ||
  80.                     listGuidUnitAttackPlayer.Contains(mobs[i].Guid) ||
  81.                     mobs[i].Guid == ObjectManager.Pet.Guid ||
  82.                     MultiPullSettings.CurrentSetting.BListMobs.Contains(mobs[i].Entry) ||
  83.                     mobs[i].GetDistance > MultiPullSettings.CurrentSetting.PullRange ||
  84.                     wManagerSetting.IsBlackListedAllConditions(mobs[i]) ||
  85.                     mobs[i].Level < MultiPullSettings.CurrentSetting.MinTargetLevel ||
  86.                     mobs[i].Level > MultiPullSettings.CurrentSetting.MaxTargetLevel
  87.                     )
  88.                 {
  89.                     mobs.RemoveAt(i);
  90.                 }
  91.             }
  92.  
  93.             var unit = ObjectManager.GetNearestWoWUnit(mobs);
  94.  
  95.             if (unit.IsValid)
  96.             {
  97.                 Logging.WriteDebug(string.Format("[MultiPull] Pull {0} (distance: {1}).", unit.Name, unit.GetDistance));
  98.                 StartFight(unit.Guid);
  99.             }
  100.         }
  101.     }
  102.  
  103.     private int _threadCount = 0;
  104.     void StartFight(ulong guid)
  105.     {
  106.         Thread.Sleep(100);
  107.         var t = new Thread(StartFightNewThead) { Name = "StartFightNewThead(object guid)" };
  108.         t.Start(guid);
  109.         Thread.Sleep(1000);
  110.     }
  111.  
  112.     void StartFightNewThead(object guid)
  113.     {
  114.         _threadCount++;
  115.  
  116.         try
  117.         {
  118.             ulong m = 0;
  119.             Fight.StopFight();
  120.             lock (Fight.FightLock)
  121.             {
  122.                 Fight.StopFight();
  123.                 if (ObjectManager.Target.IsValid)
  124.                     Lua.LuaDoString("ClearTarget();");
  125.                 m = Fight.StartFight((ulong)guid, false, true);
  126.             }
  127.             if (m != 0)
  128.                 wManagerSetting.AddBlackList(m, 1000 * 50);
  129.             Thread.Sleep(700);
  130.         }
  131.         catch
  132.         {
  133.         }
  134.  
  135.         _threadCount--;
  136.     }
  137. }
  138.  
  139. public class MultiPullSettings : Settings
  140. {
  141.     public MultiPullSettings()
  142.     {
  143.         MobMax = 3;
  144.         PullRange = 35;
  145.         MinHealth = 65;
  146.         MinTargetLevel = 2;
  147.         MaxTargetLevel = 110;
  148.         AllFactions = true;
  149.         MobsList = new List<int>();
  150.         BListMobs = new List<int>();
  151.     }
  152.  
  153.     public static MultiPullSettings CurrentSetting { get; set; }
  154.  
  155.     public bool Save()
  156.     {
  157.         try
  158.         {
  159.             return Save(AdviserFilePathAndName("MultiPull", ObjectManager.Me.Name + "." + Usefuls.RealmName));
  160.         }
  161.         catch (Exception e)
  162.         {
  163.             Logging.WriteError("MultiPullSettings > Save(): " + e);
  164.             return false;
  165.         }
  166.     }
  167.  
  168.     public static bool Load()
  169.     {
  170.         try
  171.         {
  172.             if (File.Exists(AdviserFilePathAndName("MultiPull", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
  173.             {
  174.                 CurrentSetting =
  175.                     Load<MultiPullSettings>(AdviserFilePathAndName("MultiPull",
  176.                                                                  ObjectManager.Me.Name + "." + Usefuls.RealmName));
  177.                 return true;
  178.             }
  179.             CurrentSetting = new MultiPullSettings();
  180.         }
  181.         catch (Exception e)
  182.         {
  183.             Logging.WriteError("MultiPullSettings > Load(): " + e);
  184.         }
  185.         return false;
  186.     }
  187.  
  188.     [Setting]
  189.     [Category("Settings")]
  190.     [DisplayName("Max Mobs")]
  191.     [Description("Max number of mobs to fight at the same Time")]
  192.     public int MobMax { get; set; }
  193.  
  194.     [Setting]
  195.     [Category("Settings")]
  196.     [DisplayName("Range")]
  197.     [Description("Range for Pull")]
  198.     public int PullRange { get; set; }
  199.  
  200.     [Setting]
  201.     [Category("Settings")]
  202.     [DisplayName("Min health")]
  203.     [Description("Stop pulling if health smaller than %")]
  204.     public int MinHealth { get; set; }
  205.  
  206.     [Setting]
  207.     [Category("Settings")]
  208.     [DisplayName("Min target level")]
  209.     [Description("Minimum target level")]
  210.     public int MinTargetLevel { get; set; }
  211.  
  212.     [Setting]
  213.     [Category("Settings")]
  214.     [DisplayName("Max target level")]
  215.     [Description("Maximum target level")]
  216.     public int MaxTargetLevel { get; set; }
  217.  
  218.     [Setting]
  219.     [Category("Settings")]
  220.     [DisplayName("Pulls all mobs")]
  221.     [Description("Pulls all mobs type")]
  222.     public bool AllFactions { get; set; }
  223.  
  224.     [Setting]
  225.     [Category("Settings")]
  226.     [DisplayName("Mobs list")]
  227.     [Description("List of mobs at pull (to use this list don't forget to deactivate option 'Pulls all mobs') (you can found entry id of mobs in tab 'Tools' with 'Dev tools')")]
  228.     public List<int> MobsList { get; set; }
  229.  
  230.     [Setting]
  231.     [Category("Settings")]
  232.     [DisplayName("Blacklist mobs")]
  233.     [Description("List of mobs at ignore (you can found entry id of mobs in tab 'Tools' with 'Dev tools')")]
  234.     public List<int> BListMobs { get; set; }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement