Guest User

Untitled

a guest
Jan 7th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 297.93 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7. using System.Windows.Forms;
  8.  
  9. using Buddy.Common;
  10. using Buddy.BehaviorTree;
  11. using Buddy.CommonBot;
  12. using Buddy.Swtor;
  13. using Buddy.Swtor.Objects;
  14. using Buddy.Common.Math;
  15. using Buddy.Navigation;
  16.  
  17. using Action = Buddy.BehaviorTree.Action;
  18.  
  19. /* Notes:  By JoeBrewski - Started in Sep 2012.  Recommended you REMOVE/DELETE ALL BW PLUGINS - They kill stability with the bot.
  20.  */
  21. namespace JoesCombat
  22. {
  23.     public static class MercHelpers
  24.     {
  25.         /* DRIVER VARIABLES - YOU CAN MODIFY THESE TO MODIFY BEHAVIORS WITH THE CC */
  26.         private static bool DoRandomGrind = false;                                           // ONLY RUN THIS WITH CombatBot.xml - Park character in a Mob-Rich Area first - It doesn't need any waypoints - it will find/target and kill the closest nonfriendly, and repeat.
  27.  
  28.         private static bool EnableMount = true;
  29.         private static char chMount                 = 'X';                                  // Key to use for mounting - MUST CORRESPOND TO KEY SET FOR THE QUICKBAR BUTTON IN SWTOR
  30.                                                                                             // - MUST BE UPPERCASE IF A REGULAR CHARACTER - So if 'x' (an X with no Shift) in SWTOR, here it should be 'X'.
  31.         private static int MountCheckFreq = 15;                                             // Mount Check Frequency (in Seconds)
  32.  
  33.         private static bool TagAlong                = false;                                // Tag Along in Groups (FPs, Ops, etc) - HIGHLY DEPENDENT ON MESHING FOR THE INSTANCE - IF THE INSTANCE ISN'T MESHED- IT WILL MESS EVERYTHING UP WHILE IT'S WAITING FOR A PATH GENERATION.
  34.         private static bool AllowCombat             = true;                                 // Combat - mainly for use in groups
  35.         private static bool ReportDurs              = false;                                // Report Durations in log
  36.         private static int MaxNodesBetweenFights    = 2;                                    // Max nodes to harvest between fights, IF ScanForNodes is true
  37.         private static bool ScanForLoot             = true;                                 // Set to true for Node-Scanning w/DoRandomGrind - If you're bent on levelling, set this to false - you won't hit nodes, but it will run faster.
  38.         private static bool ScanForNodes            = true;                                 // Set to true for Node-Scanning w/DoRandomGrind - If you're bent on levelling, set this to false - you won't hit nodes, but it will run faster.
  39.         private static float MaxNodeDist            = 6.0f;                                  // Max Distance Used to scan for harvestable nodes/corpses (10x multiplier in variable value vs. displayed value, so 10=100)
  40.         private static bool PullIG                  = false;                                // ONLY set this to true if you want to pull while In-Group for whatever reason
  41.         private static string MyAbilities           = "";                                   // Abilities List, Semicolon-Separated
  42.         //private static bool UseMarksSurvRot         = true;                               // Go with the (Sniper ONLY) Marksmanship 'Survival Rotation' (by Xanathos) vs. mine (mine is geared for a healer companion, his is not)
  43.         private static bool HarvestCorpses          = true;                                 // Harvest corpses if you have de skills on given corpse (i.e. strong Droid=Scav, etc)
  44.         private static bool DisplayRoughDPS         = true;
  45.         private static int RehookFreq = 60;                                                 // Re-Hook/Reload Frequency - Due to the frequent SWTOR 'Musical Chairs' with offset/addr changes - Strongly Recommend no more than 120 on this
  46.         private static bool DisableAutoRez = false;                                         // Set to true if you're running solo (CombatBot?) and don't want the bot to auto-rez
  47.         private static bool EnableMemMon = false;                                           // IF YOU ENABLE THIS WHEN YOU SHUT DOWN BUDDYWING THE .EXE __WILL__ NEED TO BE KILLED VIA TASKMANAGER - Until I figure out how to hook the Bot ShutDown event
  48.  
  49.         private static Keys CombatToggleHotKey                          = Keys.Home;                       // Combat Toggle - Mainly for Use in Ops, FPs, etc
  50.         private static Keys MovementToggleHotKey                        = Keys.Delete;                       // Movement Toggle - Mainly for Use in Ops, FPs, etc
  51.         private static Keys DRGToggle                                   = Keys.Add;                          // DoRandomGrind Toggle Key
  52.         private static Keys GroupTagAlongToggle                         = Keys.Subtract;                     // TagAlong Toggle Key
  53.         private static CombatToughness DRGMinToughness                  = CombatToughness.Standard;          // Min Combat Toughness with DoRandomGrind - if doing this above CombatToughness.Standard, park it in a spot where you KNOW there will be alot of these.
  54.  
  55.         /* END OF DRIVER VARIABLES */
  56.  
  57.         private static long RehookLastMemSize;
  58.  
  59.         private static Thread thMonMem;                                                     // if (EnableMemMon) - Thread to sit running in the background and monitor this app's memory usage and act accordingly if it goes through-the-roof.
  60.         public static DateTime DateLastPingOOC                      = DateTime.Now;
  61.         public static DateTime DateLastPingCombat                   = DateTime.Now;
  62.  
  63.         private static bool Is55H = false;
  64.  
  65.         [DllImport("user32.dll")]
  66.         private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);  // Used for mounting/keysend
  67.        
  68.         // This is sketchy at-the-moment, only good for a pure single-target fight, and won't include overkill damage
  69.         private static DateTime DPSCheckStart                       = DateTime.Now;
  70.         private static double DPSHealthStart;
  71.         private static double DPSTotalDamage                        = 0;
  72.         private static double DPSTotalFightTime                     = 0;
  73.         private static TorCharacter DPSLastTarget;
  74.         private static DateTime DPSLastCheck;
  75.         private static bool DPSWasInCombat                          = false;
  76.         //private static bool RunningCombat = false;
  77.  
  78.         private static string LastPOIName = "";
  79.         private static List<Vector3> DRGGrindPath=new List<Vector3>();
  80.         private static Vector3 DRGVendorPos;
  81.         private static string DRGVendorName = "";
  82.  
  83.         public static List<TorNpc> Attackers = new List<TorNpc>();
  84.        
  85.         //private static System.Windows.Forms.Keys TargWeakestToggleHotKey = Keys.Home;     // Obsolete
  86.         private static System.Windows.Forms.Keys ForceRestartHotKey = Keys.NumPad0;         // Obsolete w/CheckGC and (if enabled) MonMem  
  87.         private static bool KillFest = false;                                               // With DRG:  If not at least 10 lootables around, just KILL - more XP/hr.
  88.         private static Vector3 LastCombatPt;                                                // With DRG:  If we die in combat, remember where we were last fighting and try and run back
  89.         private static float PullDist= 2.0f;                                                // Char Settings - Pull Distance - .exe seems to ignore this so not of much use
  90.  
  91.         private static Buddy.CommonBot.Settings.GlobalSettings GS = new Buddy.CommonBot.Settings.GlobalSettings();
  92.  
  93.         private static int SWTORPID;                                                        // For Mounting and Spell Cancel/Stop
  94.         private static IntPtr SWTORHWnd;
  95.  
  96.         private static DateTime LastXPCheckTime = DateTime.Now;
  97.         private static ulong LastXPCheck = Me.Xp;
  98.         private static DateTime LastXPShownTime = DateTime.Now;
  99.  
  100.         private static string MountName = Buddy.Swtor.Mounts.GetFastestAvailableMount();    // For use with DoRandomGrind (since the OOC pretty much overrides any 'idle time' for normal profile operations)
  101.  
  102.         private const float MaxDist = 50;                                                   // 10x factor internally in SWTOR - For use with DoRandomGrind
  103.  
  104.         private static bool InitsComplete = false;
  105.         private static bool HasScav = false;
  106.         private static bool HasBio = false;
  107.         private static bool HasArch = false;
  108.         private static bool HasSlicing = false;                                            
  109.         private static bool IsRanged = false;                                               // Ranged or Melee Combat Spec
  110.        
  111.         private static Dictionary<ulong,DateTime> MyBlacklist = new Dictionary<ulong,DateTime>();
  112.         // Blacklist for Mob Corpse-Harvesting/Nodes
  113.  
  114.         private static bool UseAOE = true;
  115.  
  116.         private static Dictionary<string, DateTime> EquippedRelics=new Dictionary<string,DateTime>();
  117.  
  118.         private static float MeleeDist;                                                     // Melee Distance - Used mainly for LARGE MOBS - where CT.Scale < 1
  119.         private static DateTime datLLSl = DateTime.Now;                                     // Last Long Sleep - to try and help even further with GrayMagic errors
  120.         private static DateTime datLC;                                                      // Last check for harvestables
  121.         private static DateTime datLMC;                                                     // Last check for harvestables
  122.         private static DateTime datLCs;                                                     // Last cast - Used for check in ForcedCast - mainly PvP
  123.         private static DateTime datLCL;                                                     // Last Check Local (used locally in various routines)
  124.         private static DateTime datLFP;                                                     // Last Forced Pulse() - ONLY do this once every 5 seconds max
  125.         private static DateTime datLOOC;                                                    // Last OOC call - for OOC 'throttling'
  126.         private static DateTime datLCC = DateTime.Now;                                      // Last Comp Check
  127.         private static DateTime datLGC = DateTime.Now;                                      // Last GC (runs roughly once-per-minute Out-Of-Combat)
  128.         private static DateTime datLGC2 = DateTime.Now;                                     // Last GC (Purely GC.GetTotalMemory())
  129.         private static DateTime datLLS = DateTime.Now;                                      // Last Loot Scan:  To Be Used w/KillFest (only scan for loot every 2 minutes)
  130.         private static DateTime datLMPU = DateTime.Now;                                     // Last Medpack Used - 2-minute restriction
  131.         private static DateTime datLBC = DateTime.Now;                                      // Last Buff Check - Only check buffs every 20s
  132.         private static DateTime datLCCoTF = DateTime.Now;
  133.         private static DateTime CS;                                                         // Last GC
  134.         private static ulong CG;                                                            // Cur Target GUI(ID)
  135.         private static DateTime datLastHM = DateTime.Now;                                   // Last Heroic Moment:  Buggy Casting on Heroic Moment
  136.         private static bool MovementAllowed = true;
  137.         private static bool MovementAllowedOrig = true;
  138.         private static DateTime datLSC = DateTime.Now;                                      // Last Summon Companion (only try once every 5 minutes)
  139.  
  140.         private static IMovementProvider DefaultMP = Navigator.MovementProvider;
  141.         private static INavigationProvider DefaultNP = Navigator.NavigationProvider;
  142.         private static IMovementProvider CurrentMP = Navigator.MovementProvider;
  143.         private static INavigationProvider CurrentNP = Navigator.NavigationProvider;
  144.         private static NoMovement_MovementProvider NoMovementProvider = new NoMovement_MovementProvider();
  145.         private static NoMovement_NavigationProvider NoNavigationProvider = new NoMovement_NavigationProvider();
  146.         private static Buddy.CommonBot.ITargetingProvider NTP;
  147.  
  148.         public static bool Restarting = false;
  149.  
  150.         private static TorCharacter LHUnit = null;                                             // Low-Health Unit - For Healing Classes such as BG, Seer, etc
  151.         private static TorCharacter NGUnit = null;                                          // 'Needs Guarding' Unit - for Tanking
  152.         private static Dictionary<string, int> LHDebuffs = new Dictionary<string, int>();
  153.         private static TorNpc NAUnit = null;                                                // 'Needs Aggroed' NPC Unit - for Tanking
  154.         private static TorCharacter CT;                                                     // Curr Targ
  155.         private static TorPlayer CTP;                                                       // Curr Targ Player - PvP - useless
  156.         private static TorCharacter CompTarg = null;                                        // Comp Targ
  157.         private static TorCharacter LastComp = null;
  158.  
  159.         private static string MyBuffs = "";                                                 // Buffs/Affects List (String, Semicolon-Delimited)
  160.         private static string CTDebuffs = "";                                               // Cur Targ Debuffs List (String, Semicolon-Delimited)
  161.  
  162.         private static Vector3 TP;                                                          // Targ Pos
  163.         private static SkillTreeId MySpec = SpecHandler.GetSpec();                          // Current Spec
  164.         private static float HP = 0;                                                        // Health Pct
  165.         private static float EP = 0;                                                        // Energy Pct
  166.         private static float TD = 0;                                                        // Targ Dist
  167.         private static bool TC = false;                                                     // Targ Casting
  168.         private static float RS = 0;                                                        // Resource Stat
  169.         private static float THP = 0;                                                       // Targ Health Pct
  170.         public static bool IG = false;                                                      // In-Group - Important Re:  Healing and Pulls
  171.         private static float CHP = 0;                                                       // Comp Health Pct
  172.         private static CombatToughness CTT;                                                 // Cur Targ Toughness
  173.         private static int TWR30 = 0;                                                       // Target Count within 30m
  174.         private static int TWR10 = 0;                                                       // Targets within 10m
  175.         private static int TWR5 = 0;                                                        // Targets within 5m
  176.         private static float LHH = 0;                                                       // Lowest-Health Health Pct (for In-Group Healing)
  177.         private static float LHD = 0;                                                       // Lowest-Health Dist
  178.         private static Vector3 LHP;                                                         // Lowest-Health Pct
  179.  
  180.         private static TorAbility taDeployFRD=null;                                         // Field Repair Droid Deployment - Used in CheckInventory() - Issues trying to deplay and then interact with the droid ATM
  181.         private static TorAbility taSummComp = null;                                        // Summon Companion
  182.         private static TorAbility taAttack = null;                                          // Attack Ability
  183.         private static EffectResult er;                                                     // Ability Use Result (Code)
  184.  
  185.         private static Buddy.CommonBot.IBot IB;
  186.  
  187.         private static Thread thStart;
  188.         private static Thread thStop;
  189.  
  190.         public static MyQuestDef myHS_XenovirusPrime;
  191.         public static MyQuestDef myHS_DroidMalfunction;
  192.         public static PrioritySelector MyPS;
  193.         public static string MyName = "";                                                   // Issues comparing a TorChar to BuddyTor.Me, so this is used
  194.         public static string CompName = "";
  195.         public static string MyNameCompName = "";
  196.  
  197.         public static void Inits()
  198.         {
  199.             if (!InitsComplete)
  200.             {
  201.                 //CPUInfo CI=new CPUInfo();
  202.                 //int ProcessorCount = CI.PC();
  203.                 int ProcessorCount = Environment.ProcessorCount;
  204.                 Logger.Write("Reported Processor Count: " + ProcessorCount.ToString());
  205.  
  206.                 //Buddywing.MainWindow.OnClosing += OnBotShutdown;
  207.                 //Buddywing.App.Current.Exit += new System.Windows.ExitEventHandler(ShutdownHandler);
  208.                 //Buddywing.MainWindow.UnloadedEvent +=  ShutdownHandler(null, null);
  209.                 try
  210.                 {
  211.                     uint Affin = (uint)ProcessorCount;
  212.                     Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)(1 << ProcessorCount - 1);
  213.                     Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
  214.                 }
  215.                 catch { Logger.Write("Failed setting process attributes on BuddyWing."); }
  216.  
  217.                 int TorMem = 0;
  218.                 foreach (Process proc in Process.GetProcesses()) if (proc.ProcessName.Contains("swtor"))
  219.                         try
  220.                         {
  221.                             uint Affin = ProcessorCount >= 4 ?
  222.                                 (uint)((1 << (ProcessorCount - 2) | (1 << (ProcessorCount - 3)))) :
  223.                                 (uint)(1 << (ProcessorCount - 2));
  224.                             proc.PriorityClass = ProcessPriorityClass.High;
  225.                             proc.ProcessorAffinity = (IntPtr)Affin;
  226.                         }
  227.                         catch (Exception ex)
  228.                         {
  229.                             Logger.Write("Failed setting process attributes on Star Wars (Main Window).");
  230.                             Logger.Write("Error: " + ex.Message);
  231.                         }
  232.                 foreach (Process proc in Process.GetProcesses()) if (proc.ProcessName.Contains("swtor") && proc.MainWindowTitle.Contains("Star Wars"))
  233.                         if (proc.PrivateMemorySize64 > TorMem)
  234.                         {
  235.  
  236.                             SWTORPID = proc.Id;
  237.                             TorMem = (int)proc.NonpagedSystemMemorySize64;
  238.                             SWTORHWnd = proc.MainWindowHandle;
  239.                         }
  240.  
  241.                 LoadQuests();
  242.                 Logger.Write("Star Wars Process ID Detected as: " + SWTORPID.ToString());
  243.  
  244.                 Logger.Write("Checking Abilities...");
  245.  
  246.                 datLLSl = DateTime.Now;
  247.                 NTP = null;
  248.  
  249.                 foreach (Buddy.Swtor.Objects.Components.ProfessionInfo pi in BuddyTor.Me.ProfessionInfos)
  250.                 {
  251.                     Logger.Write("Abil " + pi.Name + " found");
  252.                     if (pi.Name.Contains("Bioanalysis")) HasBio = true;
  253.                     if (pi.Name.Contains("Scavenging")) HasScav = true;
  254.                     if (pi.Name.Contains("Archaeology")) HasArch = true;
  255.                     if (pi.Name.Contains("Slicing")) HasSlicing = true;
  256.                 }
  257.  
  258.                 CT = null;
  259.                 GS.PullRange = PullDist;
  260.  
  261.                 Logger.Write("Pull Range set at " + GS.PullRange.ToString());
  262.  
  263.                 Logger.Write("DoRandomGrind Key [" + DRGToggle.ToString() + "] HotKey Registered.");
  264.                 Hotkeys.RegisterHotkey("DoRandomGrind", () => { DoRandomGrind = !DoRandomGrind; Logger.Write("DoRandom Grind: " + DoRandomGrind.ToString()); OOC(); }, DRGToggle);
  265.                 Logger.Write("Combat Toggle Key [" + CombatToggleHotKey.ToString() + "] HotKey Registered.");
  266.                 Hotkeys.RegisterHotkey("Combat Toggle", () => { AllowCombat = !AllowCombat; Logger.Write("AllowCombat: " + AllowCombat.ToString()); }, CombatToggleHotKey);
  267.                 Logger.Write("Group Tag-Along Key [" + GroupTagAlongToggle.ToString() + "] HotKey Registered.");
  268.                 Hotkeys.RegisterHotkey("Tag Along Toggle", () => { TagAlong = !TagAlong; Logger.Write("Group Tag-Along: " + TagAlong.ToString()); }, GroupTagAlongToggle);
  269.                 Logger.Write("Movement Toggle Key [" + MovementToggleHotKey.ToString() + "] HotKey Registered...  You can edit the value in MercHelpers.cs if necessary (and then restart the .exe)");
  270.                 Hotkeys.RegisterHotkey("Movement Toggle", () => { MovementToggle(); }, MovementToggleHotKey);
  271.                 //Logger.Write("Target-Weakest Toggle Key [" + TargWeakestToggleHotKey.ToString() + "] HotKey Registered...  You can edit the value in MercHelpers.cs if necessary (and then restart the .exe)");
  272.                 //Hotkeys.RegisterHotkey("Targeting Toggle", () => { TargetingToggle(); }, TargWeakestToggleHotKey);
  273.                 Logger.Write("Forced Reload [" + ForceRestartHotKey.ToString() + "] HotKey Registered (to try and force Reload if hung)...");
  274.                 Hotkeys.RegisterHotkey("Rehook", () =>
  275.                 {
  276.                     try
  277.                     {
  278.                         if (BotMain.IsRunning) BotMain.CurrentBot.Stop();
  279.                         //if (BotMain.IsRunning) Buddy.CommonBot.BotMain.BotThread.Abort();
  280.                         else if (!BotMain.IsRunning) BotMain.CurrentBot.Start();
  281.                         Thread.Sleep(1000);
  282.                         //BotMain.CurrentBot.Start();
  283.                         //Buddy.CommonBot.RoutineManager.Current.Initialize();
  284.                         //Thread.Sleep(1000);
  285.                         //Buddy.Swtor.Objects.Engine.Gom GOM = new Buddy.Swtor.Objects.Engine.Gom(); // Need further testing w/this before it 'Goes into Production'
  286.                         //GOM.Client.Read();
  287.                         //Buddy.CommonBot.GameEvents.Update();
  288.                         //Thread.Sleep(2000);
  289.                         //OOC();
  290.                     }
  291.                     catch { }
  292.                     //try
  293.                     //{
  294.                     //    ObjectManager.Cache.Clear();
  295.                     //    ObjectManager.FlushOldEntries(true);
  296.                     //}
  297.                     //catch { }
  298.                     //try
  299.                     //{
  300.                     //    Buddy.Swtor.Movement.Update();
  301.                     //    DefaultNP.Clear();
  302.                     //}
  303.                     //catch { }
  304.                     //try
  305.                     //    {
  306.                     //    Buddy.CommonBot.GameEvents.Update();
  307.                     //    Buddy.CommonBot.Poi.Clear("FightAtJoes:  Cache Clear.");
  308.                     //    Thread.Sleep(3000);
  309.                     //}
  310.                     //catch { }
  311.                 }, ForceRestartHotKey);
  312.                 //Hotkeys.RegisterHotkey("Force Routine Reload", () => { DoRestart(); }, Keys.OemPipe);
  313.  
  314.                 MySpec = SpecHandler.GetSpec(Me);
  315.  
  316.                 foreach (TorAbility ta in BuddyTor.Me.KnownAbilitiesContainer)
  317.                 {
  318.                     MyAbilities += ta.Name+";";
  319.                     if (ta.Name.Contains("Incendiary Missile")) MySpec = SkillTreeId.MercenaryFirebug; // Fix the eternal Firebug mess
  320.                     if (ta.Name.Contains("Deploy Field Repair")) { taDeployFRD = ta; Logger.Write("Ability " + ta.Name + " found."); }
  321.                     if (ta.Name.Contains("Summon Companion")) { taSummComp = ta; Logger.Write("Ability " + ta.Name + " found."); }
  322.                     if (ta.Name.Contains("Attack")) { taAttack = ta; Logger.Write("Ability " + ta.Name + " found."); }
  323.                 }
  324.                 //Logger.Write("Abilities List: " + MyAbilities);
  325.                 Logger.Write("Spec Detected as: " + MySpec.ToString());
  326.  
  327.                 if (DoRandomGrind)
  328.                 {
  329.                     Logger.Write("RANDOM-GRIND IS ACTIVE.  If not intended, update the DoRandomGrind flag in MercHelpers.cs to false, and restart the .exe (as in exit and reopen).");
  330.                     Logger.Write("WITH DoRandomGrind, YOU NEED TO PARK YOUR CHARACTER IN A MOB-RICH AREA BEFORE STARTING (So it has something to find/attack).");
  331.                 }
  332.                 Logger.Write("Check Abilities: Bio " + HasBio.ToString() + " Scav " + HasScav.ToString() + " Arch " + HasArch.ToString() + " Slicing " + HasSlicing.ToString());
  333.                 Logger.Write("***IF YOU ARE RUNNING A QUESTING PROFILE AND CHANGE PLANETS/INSTANCES, OR LOG IN TO ANOTHER CHARACTER, RESTART SWTOR AND THEN RESTART THE BOT (AS IN CLOSE/RE-RUN THE APP)***");
  334.                 RehookLastMemSize = Process.GetCurrentProcess().PrivateMemorySize64;
  335.                
  336.                 CheckForGroup();
  337.  
  338.                 InitsComplete = true;
  339.                 //ForcePulse();
  340.             }
  341.         }
  342.  
  343.         private static void OnBotStart(IBot bot)
  344.         {
  345.             try {
  346.                 datLFP = DateTime.Now;
  347.                 datLGC = DateTime.Now;
  348.                 Thread.Sleep(500);
  349.             }
  350.             catch { }
  351.             InitsComplete = false;
  352.             datLLSl = DateTime.Now;
  353.             OOC();
  354.         }
  355.  
  356.         private static void OnBotStop(IBot bot)
  357.         {
  358.         }
  359.  
  360.         //public delegate BotEvent_OnBotShutdown BotEventHandler(object sender, BotEvent_OnBotShutdown e);
  361.  
  362.         private static void OnBotShutdown(IBot bot)
  363.         {
  364.         }
  365.  
  366.         // SHITLOADS of Trial-and-Error on this, it's 'Constantly Evolving' depending on updates to the .exe for the week, and SWTOR.
  367.         public static void DoRehook()
  368.         {
  369.             DateTime datRehookStart = DateTime.Now;
  370.  
  371.             try
  372.             {
  373.  
  374.                 datLGC = DateTime.Now;
  375.                 datLLSl = DateTime.Now;
  376.  
  377.                 System.GC.Collect();
  378.                 System.GC.GetTotalMemory(true);
  379.                 Buddy.CommonBot.RoutineManager.Current.Initialize();
  380.                 Thread.Sleep(3000);
  381.                 RehookLastMemSize = Process.GetCurrentProcess().PrivateMemorySize64;
  382.                 return;
  383.  
  384.                 long WS = Process.GetCurrentProcess().PrivateMemorySize64;
  385.  
  386.                 //Logger.Write("Starting GC/Rehook.  Current (Working Set) Process Memory Usage at: " + (1.0*WS/(1024^2)).ToString("0.0")+"MB" );
  387.                 Logger.Write("Starting GC/Rehook.");
  388.  
  389.                 //if (WS >= 100000000)       // If things went apeshit and monitoring memory, try and do an overhaul
  390.                 //{
  391.                 //    while (Process.GetCurrentProcess().PrivateMemorySize64 >= 100000000)
  392.                 //    {
  393.                 //        System.GC.Collect();
  394.                 //        System.GC.GetTotalMemory(true);
  395.                 //        Thread.Sleep(1000);
  396.                 //        Buddy.Swtor.Objects.Engine.Gom GOM = new Buddy.Swtor.Objects.Engine.Gom(); // Need further testing w/this before it 'Goes into Production'
  397.                 //        GOM.Client.Read();
  398.                 //        BotMain.CurrentBot.Dispose();
  399.                 //        BotMain.CurrentBot.Dispose();
  400.                 //        Thread.Sleep(1500);
  401.                 //        Buddy.Swtor.Movement.Update();
  402.                 //        DefaultNP.Clear();
  403.                 //        ObjectManager.Cache.Clear();
  404.                 //        ObjectManager.FlushOldEntries(true);
  405.                 //        Buddy.Swtor.NodeManager.Update();
  406.                 //        Buddy.CommonBot.Logic.BrainBehavior.CreateBrain();
  407.                 //        Buddy.CommonBot.RoutineManager.Current.Initialize();
  408.                 //        BotMain.CurrentBot.Stop();
  409.                 //        Thread.Sleep(5000);
  410.                 //    }
  411.                 //}
  412.                 //else
  413.                 {
  414.                     System.GC.Collect();
  415.                     System.GC.GetTotalMemory(true);
  416.                     BotMain.CurrentBot.Dispose();
  417.                     BotMain.CurrentBot.Dispose();
  418.                     //Buddy.CommonBot.Logic.BrainBehavior.CreateBrain();
  419.                     Buddy.CommonBot.Logic.BrainBehavior.CreateBrain();
  420.                     Buddy.CommonBot.RoutineManager.Current.Initialize();
  421.                     //Buddy.Swtor.Objects.Engine.Gom GOM = new Buddy.Swtor.Objects.Engine.Gom();
  422.                     //GOM.Client.Read();
  423.                     //Buddy.CommonBot.Poi.Clear("FightAtJoes:  Rehook/Reload.");
  424.                     Thread.Sleep(4500);
  425.                 }
  426.                 //Thread.Sleep(500);
  427.                 Me.Target();
  428.                 Thread.Sleep(500);
  429.                 Me.ClearTarget();
  430.                 //BuddyTor.Me.ClearTarget();
  431.                 //Buddy.CommonBot.GameEvents.Update();
  432.                 //Buddy.CommonBot.Logic.BrainBehavior.CreateBrain();
  433.                 //Buddy.CommonBot.RoutineManager.Current.Initialize();
  434.                 //Thread.Sleep(2000);
  435.                 //ForcePulse();
  436.             }
  437.             catch (Exception ex)
  438.             { //Logger.Write("Error in DoRehook: " + ex.Message);
  439.             }
  440.  
  441.             RehookLastMemSize = Process.GetCurrentProcess().PrivateMemorySize64;
  442.  
  443.             Logger.Write("Re-Hook/Reload Processed.  Total Rehook Time: " + (ReportDurs?"":DateTime.Now.Subtract(datRehookStart).TotalSeconds.ToString("0.0")));
  444.  
  445.             BotMain.CurrentBot.Pulse();
  446.  
  447.             //OOC();
  448.         }
  449.          
  450.         private static void CheckGC()
  451.         {  
  452.             Inits();
  453.             //return;
  454.  
  455.             if (DateTime.Now.Subtract(datLGC).TotalSeconds >= RehookFreq || (Process.GetCurrentProcess().PrivateMemorySize64-RehookLastMemSize>=50000000))
  456.             //if (DateTime.Now.Subtract(datLGC).TotalSeconds >= (RehookFreq + 10))
  457.                 try
  458.                 {
  459.                     DoRehook();
  460.                     //Buddy.CommonBot.GameEvents.Update();
  461.                     //OOC();
  462.                 }
  463.                 catch { Thread.Sleep(4000); }
  464.             //if (DateTime.Now.Subtract(datLGC2).TotalSeconds >= 30)
  465.             //{
  466.             //    DefaultNP.Clear();
  467.             //    //Buddy.CommonBot.Logic.BrainBehavior.CreateBrain();
  468.             //    GC.Collect();
  469.             //    GC.GetTotalMemory(true);
  470.             //    ObjectManager.Cache.Clear();
  471.             //    Thread.Sleep(1500);
  472.             //    ObjectManager.FlushOldEntries(true);
  473.             //    ObjectManager.Update();
  474.             //    datLGC2 = DateTime.Now;
  475.             //}
  476.  
  477.         }
  478.  
  479.         // Obsolete
  480.         //private static void MoveIfNec()
  481.         //{
  482.         //    MoveIfNec(2.8f);
  483.         //}
  484.  
  485.         //private static void MoveIfNec(float dist)
  486.         //{
  487.  
  488.         //    if (CT == null) return;
  489.         //    if (CTT == CombatToughness.Player) return;
  490.  
  491.         //    MoveTo(CT, dist);
  492.  
  493.         //}
  494.  
  495.         public static void WaitForCast()
  496.         {
  497.             DateTime dStart = DateTime.Now;
  498.             //Logging.Write("Waiting for Cast...");
  499.             ObjectManager.Update();
  500.             while (Me.IsCasting && DateTime.Now.Subtract(dStart).TotalSeconds < 4)
  501.             {
  502.                 Thread.Sleep(250);
  503.             }
  504.             //Logging.Write("Done with Cast...");
  505.         }
  506.  
  507.         private static void StopMoving()
  508.         {
  509.             if (!MovementAllowed) return;
  510.  
  511.             Buddy.Swtor.Movement.Stop(MovementDirection.Forward);
  512.             Thread.Sleep(50);
  513.             Buddy.CommonBot.CommonBehaviors.MoveStop();
  514.             Thread.Sleep(50);
  515.             Buddy.Swtor.Input.MoveStopAll();
  516.             Thread.Sleep(50);
  517.             Buddy.CommonBot.CommonBehaviors.MoveStop();
  518.         }
  519.  
  520.         private static void MoveTo(TorCharacter theUnit, float dist, string Cast1 ="", string Cast2="", string Cast3="", string Cast4="")
  521.         {
  522.             //if (theUnit == null)
  523.             //{
  524.             //    Logger.Write("Null MoveTo:  Aborting.");
  525.             //    return;
  526.             //}
  527.  
  528.             if (!MovementAllowed) return;
  529.  
  530.             if (theUnit == null) theUnit = CT;
  531.             if (theUnit == null || dist <= 0) return;
  532.             if (theUnit.Distance <= dist && theUnit.InLineOfSight) return;
  533.  
  534.             try
  535.             {
  536.  
  537.                 StopMoving();           // To (try and) prevent 'The Chicken Dance'
  538.                 datLCL = DateTime.Now;
  539.  
  540.                 //theUnit.Face();
  541.                 //theUnit.Face();
  542.  
  543.                 if (theUnit.Distance > dist || !theUnit.InLineOfSight)
  544.                 {
  545.                     Logger.Write("MoveTo: " + theUnit.Name + " Moving to within " + dist.ToString("0.0") + " from dist of " + theUnit.Distance.ToString("0.0") + " current LOS: " + theUnit.InLineOfSight.ToString());
  546.                     MoveResult MR = MoveResult.Moved;
  547.                     StopMoving();
  548.                     while ((MR != MoveResult.Failed && MR != MoveResult.PathGenerationFailed) && theUnit != null && DateTime.Now.Subtract(datLCL).TotalSeconds <= 15 && (theUnit.Distance > dist || !theUnit.InLineOfSight))
  549.                     {
  550.                         if (Cast1 != "") MercCast(Cast1, CT);
  551.                         if (Cast2 != "") MercCast(Cast2, CT);
  552.                         if (Cast3 != "") MercCast(Cast3, CT);
  553.                         if (Cast4 != "") MercCast(Cast4, CT);
  554.                         if (theUnit.Distance > dist || !theUnit.InLineOfSight)
  555.                         {
  556.                             MR = Buddy.Navigation.Navigator.MoveTo(theUnit.Position);
  557.                             Thread.Sleep(100);
  558.                         }
  559.                     }
  560.                     if (MR == MoveResult.Failed && MR == MoveResult.PathGenerationFailed) Logger.Write("Move Result: " + MR.ToString());
  561.                     StopMoving();
  562.                     StopMoving();
  563.                 }
  564.             }
  565.             catch { }
  566.         }
  567.  
  568.         private static bool MeOrCompInCombat()
  569.         {
  570.             try
  571.             {
  572.                 TorCharacter CompX = Comp;
  573.                 if (Me.InCombat) return true;
  574.                 if (CompX != null) if (CompX.InCombat) return true;
  575.             }
  576.             catch { }
  577.             return false;
  578.         }
  579.  
  580.         // For use mainly in groups, trying to determine if the current target's target is a player, and it IS in combat. USED EVERYWHERE IN COMBAT.
  581.         public static bool TargetInCombat()
  582.         {
  583.             try
  584.             {
  585.                 if (CT == null) { Logger.Write("TargetInCombat: Null Target."); return false; }
  586.                 if (CT.IsDead || CT.HealthPercent < .2f) { Logger.Write("TargetInCombat: Dead Target."); return false; }
  587.                 if (Me.PvpFlagged) return true;
  588.                 if (CT.Toughness == CombatToughness.Player) { CT = null; Me.ClearTarget(); Logger.Write("Player targeted outside of Heals, clearing target."); return false; }
  589.                 if (CTT == CombatToughness.Player) if (!CT.IsFriendly) return true;  // PvP - you target an enemy player, go-to-town
  590.  
  591.                 if (IG && !PullIG)
  592.                 {
  593.                     if (!CT.InCombat) { Logger.Write("In-Group and target not in combat."); return false; }    // If we're in Ops/FP/etc - DON'T ATTACK SHIT THAT HASN'T BEEN PULLED
  594.                     if (CT.IsStunned) { Me.ClearTarget(); Thread.Sleep(300); CT = null; return false; }
  595.                     if (CT.CurrentTarget == null) return false; else if (CT.CurrentTarget.Toughness != CombatToughness.Player) return false;
  596.                 }
  597.             }
  598.             catch { CT = null; Logger.Write("Error testing target."); return false; }
  599.             return true;
  600.         }
  601.  
  602.         public static void UseMedPackInInventory()
  603.         {
  604.             if (DateTime.Now.Subtract(datLMPU).TotalSeconds < 120) return;
  605.             datLMPU = DateTime.Now;  // One scan every 2 minutes
  606.             foreach (var o in Me.InventoryEquipment)
  607.             {
  608.                 if (o.Name.Contains("Medpac") && o.MinimumLevel<=Me.Level && !o.Name.Contains("Warzone"))
  609.                 { Logger.Write("Using Medpac " + o.Name + "..."); o.Use(); o.Interact(); o.Interact(); Thread.Sleep(500); return; }
  610.             }
  611.         }
  612.  
  613.         public static bool HaveBuffStacks(string strBuff, int intCount, TorCharacter theUnit=null)
  614.         {
  615.             if (theUnit == null) theUnit = Me;
  616.  
  617.             try { if (MyBuffs.Contains(strBuff)) foreach (TorEffect te in Me.Buffs) if (te.Name.Contains(strBuff)) if (te.Stacks >= intCount) return true; }
  618.             catch { }
  619.             return false;
  620.         }
  621.  
  622.         public static bool HasDebuffStacks(string strDebuff, int intCount)
  623.         {
  624.             try { if (CTDebuffs.Contains(strDebuff)) foreach (TorEffect te in CT.Debuffs) if (te.Name.Contains(strDebuff)) if (te.Stacks >= intCount) return true; }
  625.             catch { }
  626.             return false;
  627.         }
  628.  
  629.         public static bool IAmDead()
  630.         {
  631.             if (BuddyTor.Me.IsDead || BuddyTor.Me.HealthPercent < .2f)
  632.                 if (IG || DisableAutoRez)
  633.                 {
  634.                     Logger.Write("Death detected and In-Group (or DisableAutoRez set) - waiting for manual rez...");
  635.                     while (BuddyTor.Me.IsDead) Thread.Sleep(2000);
  636.                 }
  637.                 else
  638.                 {
  639.                     Logger.Write("Death detected.");
  640.                     Me.ClearTarget();
  641.                     Thread.Sleep(500);
  642.                     return true;
  643.                 }
  644.             return false;
  645.         }
  646.  
  647.         public static PrioritySelector SelfBuff(string theSpell, bool Req)
  648.         {
  649.             return new PrioritySelector(Spell.Cast(theSpell, ch=>BuddyTor.Me, ret => !BuddyTor.Me.HasBuff(theSpell) && Req));
  650.         }
  651.  
  652.         public static PrioritySelector MercenaryCombatPS()
  653.         {
  654.             return new PrioritySelector(
  655.                 new Action( ret=> {LoadVars();return RunStatus.Failure;}),
  656.                 Spell.WaitForCast(),
  657.                 new Action(ret=>{if(CT!=null){ StopMoving(); MoveTo(CT, 2.8f);} return RunStatus.Failure;}),
  658.  
  659.                 SelfBuff("Combustible Gas Cylinder", MySpec==SkillTreeId.MercenaryFirebug),
  660.                 new Action(ret=>{
  661.                     if (!CT.InCombat)
  662.                     {
  663.                         if (MercCast("Fusion Missile")) Thread.Sleep(400);
  664.                         if (MercCastOnGround("Death from Above", TD >= .6f, CT,false)) Thread.Sleep(400);
  665.                         if (MercCast("Explosive Dart")) Thread.Sleep(400);
  666.                         //if (MercCast("Concussion Missile", !CT.InCombat)) Thread.Sleep(400);
  667.                         if (MercCastOnGround("Sweeping Blasters", true, CT, false)) ;
  668.                         if (MercCast("Concussion Missile", MobsInRangeOf(CT.Position, 2.0f) >= 3)) Thread.Sleep(400);
  669.                     }
  670.                     return RunStatus.Failure;}),
  671.                     Spell.Cast("Thermal Detonator", ret=>true),
  672.                     Spell.Cast("Heatseeker Missiles", ret=>true),
  673.                     Spell.Cast("Incendiary Missile",ret=>!CTDebuffs.Contains("Burning")),
  674.                     Spell.Cast("Rapid Shots", ret=>true));
  675.         }
  676.  
  677.         public static bool MercenaryCombat()
  678.         {
  679.             datLCL = DateTime.Now;
  680.             Thread.Sleep(400); // Needs enough time to pulse for Self-Heals and Interrupts, CRUCIAL in Oricon
  681.  
  682.             WaitForCast();
  683.             LoadVars();
  684.  
  685.             if (MercBuffSelf("Combat Support Cylinder", MySpec==SkillTreeId.MercenaryBodyguard)) return true;
  686.             if (MercBuffSelf("Combustible Gas Cylinder", MySpec == SkillTreeId.MercenaryFirebug)) return true;
  687.             if (MercBuffSelf("High Velocity Gas Cylinder", MySpec == SkillTreeId.MercenaryArsenal)) return true;
  688.  
  689.             if (MercBuffSelf("Kolto Shell")) return true;
  690.             MercCast("Vent Heat", RS <= 25f);
  691.  
  692.             if (MercCast("Hunter's Boon", !MyBuffs.Contains("Hunter's Boon"))) return true;
  693.             if (HP <= 70f)
  694.             {
  695.                 Thread.Sleep(300);
  696.  
  697.                 if (MercCast("Chaff Flare", HP <= 50f)) return true;
  698.                 if (MercCast("Energy Shield", HP <= 60f)) return true;
  699.                 if (MercCastOnGround("Kolto Missile", HP < 70f, BuddyTor.Me, false)) return true;
  700.                 if (MercCast("Emergency Scan", HP <= 70f)) return true;
  701.                 if (MercCast("Rapid Scan", HP <= 70f)) return true;
  702.             }
  703.  
  704.             if (IG && MySpec == SkillTreeId.MercenaryBodyguard && IG)
  705.             {
  706.                 for (int i = 0; i < (Is55H ? 3 : 1); i++) { BGHeals(Is55H ? 85f : 70f);}
  707.                 if (Me.ResourceStat<=75f) return MercCast("Rapid Shots");
  708.             }
  709.  
  710.             MoveTo(CT, 2.8f);
  711.             StopMoving();
  712.  
  713.             if (!TargetInCombat()) return false; //else if (CT != Me.CurrentTarget) CT.Target();
  714.  
  715.             if (!CT.InCombat)
  716.             {
  717.                 if (MercCast("Fusion Missile")) Thread.Sleep(400);
  718.                 if (MercCastOnGround("Death from Above", TD >= .6f, CT)) Thread.Sleep(400);
  719.                 if (MercCast("Explosive Dart")) Thread.Sleep(400);
  720.                 //if (MercCast("Concussion Missile", !CT.InCombat)) Thread.Sleep(400);
  721.                 if (MercCastOnGround("Sweeping Blasters", true, CT)) return true;
  722.                 if (MercCast("Concussion Missile", MobsInRangeOf(CT.Position, 2.0f) >= 3)) Thread.Sleep(400);
  723.             }
  724.  
  725.             //MoveTo(CT, EliteOrGreater(CT)?1.0f:2.8f);
  726.             //if (CT.Name.Contains("Commander Zaoron")) MoveTo(CT, .50f);
  727.  
  728.             if (TC && StrongOrGreater(CT))
  729.             {
  730.                 if (MercCast("Disabling Shot")) return true;
  731.                 if (MercCast("Electro Dart")) return true;
  732.                 //if (MercCast("Neural Dart")) return true;
  733.                 if (MercCast("Electro Net")) return true;
  734.                 if (MercCast("Concussion Missile")) return true;
  735.             }
  736.  
  737.             if ((!IG && RS<=35) || (IG && RS <= 50 && MySpec == SkillTreeId.MercenaryBodyguard)) return MercCast("Rapid Shots");
  738.  
  739.             if (IG && MySpec != SkillTreeId.MercenaryBodyguard) if (BGHeals(60f)) return true;
  740.  
  741.             if (!IG && BGCheckCompHealth()) return true;
  742.  
  743.             if (MercCast("Jet Boost", TD <= .8f)) return true;
  744.             if (MercCast("Shoulder Slam", TD <= .8f)) return true;
  745.             if (MercCast("Rocket Punch", TD <= .8f)) return true;
  746.             if (MercCast("Electro Dart", TD <= .8f)) return true;
  747.  
  748.             if (IG && MySpec == SkillTreeId.MercenaryBodyguard && RS <= 70f)
  749.             {
  750.                 if (MercCast("Rapid Shots", true)) return true ;
  751.                 Thread.Sleep(300);
  752.                 return Me.InCombat;
  753.             }
  754.  
  755.             //StopMoving();
  756.             if (MercCastOnGround("Death from Above", TD >= .6f && RS >= 80f, CT)) return true;
  757.  
  758.             if (MercCast("Emergency Scan", HP < 70f)) return true;
  759.             if (MercCast("Determination", BuddyTor.Me.IsStunned)) return true;
  760.  
  761.             // I've ALWAYS had issues w/the cast on this and distance, tried to qualify the hell out of it
  762.             if (MercFaceAndCast("Flame Thrower", TD > .01f && TD <= .60f)) return true;
  763.  
  764.             if (MercCast("Heroic Moment: On the Trail", HP <= 50f)) return true;
  765.             if (MercCast("Power Surge")) return true;
  766.  
  767.             if (MercCast("Supercharged Gas", !MyBuffs.Contains("Supercharged Gas"))) return true;
  768.             if (MercCast("Thermal Sensor Override", RS <= 30f)) return true;
  769.             if (MercCast("Chaff Flare", HP <= 70f && Comp!=null)) return true;
  770.  
  771.             if (MercCast("Thermal Detonator")) return true;
  772.             if (MercCast("Heatseeker Missiles", StrongOrGreater(CT))) return true;
  773.             if (MercCast("Incendiary Missile", CT, !CTDebuffs.Contains("Burning (Tech)"))) return true;
  774.             if (MercCast("Explosive Dart", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .80f) >= 3)) return true;
  775.             if (MercCast("Unload")) return true;
  776.             if (MercCast("Rail Shot")) return true;
  777.             if (MercCast("Fusion Missile", StrongOrGreater(CT))) return true;
  778.  
  779.             if (MercCast("Power Shot", MyBuffs.Contains("Power Surge"))) return true;
  780.            
  781.  
  782.             if (MercCast("Rapid Shots", RS <= 30f)) return true;
  783.  
  784.             if (!IG || (MySpec!=SkillTreeId.MercenaryBodyguard) || (IG && RS >= 40f))
  785.             {
  786.                 if (MercCast("Concussion Missile", MobsInRangeOf(CT.Position, MeleeDist) >= 3)) return true;
  787.                 if (MercCastOnGround("Sweeping Blasters", MobsInRangeOf(CT.Position, MeleeDist) >= 3, CT)) return true;
  788.                 if (MercCast("Rapid Shots", HP < 70 && RS >= 30)) return true;
  789.  
  790.  
  791.                 if (UseAOE)
  792.                 {
  793.                     if (MercCast("Missile Blast", (TD <= .8f && !StrongOrGreater(CT)) || RS >= 50f)) return true;
  794.                     if (MercCast("Tracer Missile", StrongOrGreater(CT) && !HasDebuffStacks("Heat Signature", 4))) return true;
  795.                     if (CTT == CombatToughness.Player) MercCastOnGround("Sweeping Blasters", TD >= .1f && RS >= 35 && (TWR30 > 2 || StrongOrGreater(CT)), CT);
  796.                     if (MercCastOnGround("Sweeping Blasters", TD >= .1f && RS >= 35 && (TWR30 > 2 || StrongOrGreater(CT)), CT)) return true;
  797.                 }
  798.  
  799.                 if (MercFaceAndCast("Flame Burst", TD <= 1.0f && RS>=65f)) return true;
  800.             }
  801.  
  802.             if (MercCast("Power Shot")) return true;
  803.             if (MercCast("Rapid Shots")) return true;
  804.            
  805.             return false;
  806.  
  807.         }
  808.  
  809.         public static bool PowerTechCombat()
  810.         {
  811.             if (BuddyTor.Me.IsDead || BuddyTor.Me.HealthPercent <= .2f) return false;
  812.  
  813.             //Thread.Sleep(500);
  814.             try
  815.             {
  816.  
  817.                 //Thread.Sleep(300);
  818.  
  819.                 datLCL = DateTime.Now;
  820.                 WaitForCast();
  821.  
  822.                 LoadVars();
  823.                 if (!TargetInCombat()) return false;
  824.  
  825.                 if (CT == null || (CT != null && CT.IsFriendly)) return false;
  826.  
  827.                 //if (MercCast("Combustible Gas Cylinder", !MyBuffs.Contains("Combustible Gas Cylinder") && HP >= 95f)) return true;
  828.                 if (MercBuffSelf("Ion Gas Cylinder", MySpec==SkillTreeId.PowertechShieldTech)) return true;
  829.                 if (MercBuffSelf("High Energy Gas Cylinder", MySpec == SkillTreeId.PowertechAdvanced)) return true;
  830.                 if (MercBuffSelf("Combustible Gas Cylinder", MySpec == SkillTreeId.PowertechFirebug)) return true;
  831.  
  832.                 if (HP <= 30f) UseMedPackInInventory();
  833.  
  834.                 if (TC && StrongOrGreater(CT))
  835.                 {
  836.                     if (MercCast("Quell")) return true;
  837.                     if (MercCast("Electro Dart")) return true;
  838.                     if (MercCast("Grapple")) return true;
  839.                     if (MercCast("Rocket Punch", TD <= MeleeDist)) return true;
  840.                 }
  841.                
  842.                 if (MercCast("Kolto Shell", BuddyTor.Me, !MyBuffs.Contains("Kolto Shell") && HP <= 85f)) return true;
  843.                 if (MercCast("Kolto Overload", HP <= 70f)) return true;
  844.                 if (MercCast("Energy Shield", HP <= 60f)) return true;
  845.  
  846.                 MoveTo(CT, 2.8f);
  847.                 StopMoving();
  848.                 //if (MercCast("Oil Slick", CT, TWR10 >= 3)) return true; // Buggy spell, won't cast, and keeps trying after that till we're dead
  849.  
  850.                 if (!CT.InCombat)
  851.                 {
  852.                     if (MercCast("Explosive Dart")) Thread.Sleep(800);
  853.                     if (MercCastOnGround("Death from Above", TD >= .6f, CT)) Thread.Sleep(800);
  854.                     if (MercCast("Grapple")) Thread.Sleep(800);
  855.                 }
  856.  
  857.                 if (MercCast("Explosive Dart", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .80f) >= 3)) return true;
  858.  
  859.                 if (MercCast("Thermal Detonator", TD <= 1.0f)) return true;
  860.                 if (MercCast("Immobilize", TD <= 1.0f)) return true;
  861.                 if (MercCast("Incendiary Missile", TD <= 1.0f)) return true;
  862.                 if (MercCast("Jet Boost", TD <= .5f)) return true;
  863.                 if (MercCast("Shoulder Slam", TD <= .5f)) return true;
  864.                 if (MercCast("Rocket Punch", TD <= .5f)) return true;
  865.                 if (MercCast("Retractable Blade", TD <= .5f)) return true;
  866.                 //if (MercCast("Electro Dart", TD <= .8f)) return true;
  867.                 if (MercCast("Vent Heat", Me, RS <= 20f)) return true;
  868.  
  869.                 if (MercCast("Flame Sweep", TWR5 >= 4)) return true;
  870.  
  871.                 if (MercCastOnGround("Death from Above", TD >= .6f && (MobsInRangeOf(CT.Position, 1.0f)>=3 || StrongOrGreater(CT)) && BuddyTor.Me.ResourceStat >= 60f, CT)) return true;
  872.                 if (MercCastOnGround("Sweeping Blasters", MobsInRangeOf(CT.Position, .80f) >= 3, CT)) return true;
  873.  
  874.                 if (MercCast("Emergency Scan", HP < 70f)) return true;
  875.                 if (MercCast("Determination", BuddyTor.Me.IsStunned)) return true;
  876.  
  877.                 if (!TargetInCombat()) return true;
  878.  
  879.                 if (MercCast("Power Shot", MyBuffs.Contains("Power Surge"))) return true;
  880.                 if (MercCast("Disabling Shot", TC)) return true;
  881.                 if (MercCast("Electro Dart", TC)) return true;
  882.                 if (MercCast("Neural Dart", TC || StrongOrGreater(CT))) return true;
  883.  
  884.                 if (MercFaceAndCast("Flame Thrower", TD <= 1.0f)) return true;
  885.  
  886.                 if (MercCast("Hunter's Boon", !MyBuffs.Contains("Hunter's Boon"))) return true;
  887.                 if (MercCast("Heroic Moment: On the Trail", HP <= 50f)) return true;
  888.                 if (MercCast("Power Surge")) return true;
  889.  
  890.                 if (MercCast("Thermal Sensor Override", RS <= 30f)) return true;
  891.                 if (Comp != null) if (MercCast("Chaff Flare", HP <= 70f)) return true;
  892.                 if (MercCast("Supercharged Gas", !MyBuffs.Contains("Supercharged Gas"))) return true;
  893.  
  894.                     if (MercCast("Rapid Shots", HP < 70 && RS >= 30)) return true;
  895.  
  896.                     if (MercCast("Unload")) return true;
  897.                     if (MercCast("Rail Shot")) return true;
  898.  
  899.                     if (UseAOE)
  900.                     {
  901.                         if (MercCast("Fusion Missile", StrongOrGreater(CT))) return true;
  902.                         if (MercCast("Explosive Dart")) return true;
  903.                         if (MercCast("Missile Blast", (TD <= .8f && !StrongOrGreater(CT)) || RS >= 50f)) return true;
  904.                         if (CTT == CombatToughness.Player) MercCastOnGround("Sweeping Blasters", TD >= .1f && RS >= 35 && (TWR30 > 2 || StrongOrGreater(CT)), CT);
  905.                         if (MercCastOnGround("Sweeping Blasters", TD >= .1f && RS >= 35 && (TWR30 > 2 || StrongOrGreater(CT)), CT)) return true;
  906.                     }
  907.  
  908.                     if (MercFaceAndCast("Flame Burst", TD <= 1.0f && RS >= 65f)) return true;
  909.                 if (MercCast("Rapid Shots")) return true;
  910.             }
  911.             catch
  912.             {}
  913.             return false;
  914.         }
  915.  
  916.  
  917.         public static bool CommandoCombat()
  918.         {
  919.  
  920.             Thread.Sleep(300); // Needs enough time to pulse for Self-Heals and Interrupts, CRUCIAL in Oricon
  921.             WaitForCast();
  922.  
  923.             datLCL = DateTime.Now;
  924.  
  925.             LoadVars();
  926.  
  927.             //Thread.Sleep(100);
  928.             if (MercCast("Tenacity", BuddyTor.Me.IsStunned)) return true;
  929.  
  930.             HandleDebuffs();
  931.  
  932.             MercBuffSelf("Combat Support Cell", MySpec == SkillTreeId.CommandoCombatMedic);
  933.             MercBuffSelf("Armor Piercing Cell", MySpec == SkillTreeId.CommandoGunnery);
  934.             MercBuffSelf("Plasma Cell", MySpec == SkillTreeId.CommandoAssaultSpecialist);
  935.  
  936.             if (MercCast("Recharge Cells", RS <= 25f)) return true;
  937.             if (MercCast("Supercharge Cells", StrongOrGreater(CT) || HP<=50f || EP <=25f)) return true;
  938.  
  939.             if (HP <= 30f) UseMedPackInInventory();
  940.             if (HP <= 70f)
  941.             {
  942.                 MercBuffSelf("Trauma Probe", true);
  943.                 MercCastOnGround("Kolto Bomb", HP <= 70f, Me);
  944.                 MercCast("Reactive Shield", HP <= 50f);
  945.                 MercCast("Adrenaline Rush", Me, HP < 50f);
  946.                 MercCast("Hold the Line", Me, HP < 50f);
  947.                 MercCast("Diversion", HP < 60f);
  948.                 MercCast("Bacta Infusion", Me, HP < 70f);
  949.                 MercCast("Advanced Medical Probe", Me, HP < 70f);
  950.                 MercCast("Medical Probe", Me, HP < 60f);
  951.                 Thread.Sleep(300);
  952.                 WaitForCast();
  953.             }
  954.  
  955.             if (MySpec == SkillTreeId.CommandoCombatMedic && IG)
  956.             {
  957.                 for (int i = 0; i < 3; i++) { CMHeals(Is55H ? 85f : 75f); Thread.Sleep(100); }
  958.                 if (RS <= ((IG && Is55H) ? 95f : 50f)) return MercCast("Hammer Shot");
  959.                 //return false;
  960.             }
  961.  
  962.             if (!TargetInCombat()) return false;
  963.  
  964.             MoveTo(CT, 2.8f);
  965.             StopMoving();
  966.  
  967.             if (TC && !IG && StrongOrGreater(CT))
  968.             {
  969.                 if (MercCast("Cryo Grenade")) return true;
  970.                 if (MercCast("Disabling Shot")) return true;
  971.                 if (MercCast("Electro Net")) return true;
  972.                 if (MercCast("Tech Override")) return true;
  973.                 if (MercCast("Concussive Round", MyBuffs.Contains("Tech Override"))) return true;
  974.             }
  975.  
  976.             if (!CT.InCombat)
  977.             {
  978.                 if (MercCastOnGround("Mortar Volley", true, CT)) Thread.Sleep(500);
  979.                 if (MercCastOnGround("Hail of Bolts", true, CT)) Thread.Sleep(500);
  980.                 if (MercCast("Incendiary Round")) return true;
  981.                 if (MercCast("Sticky Grenade")) return true;
  982.             }
  983.  
  984.             //if (MercCast("Hammer Shot", CT, HP < 70f)) Thread.Sleep(1000); ;
  985.  
  986.             if (CMCheckCompHealth()) { Thread.Sleep(500); if (MercCast("Hammer Shot")) return true; }
  987.  
  988.             if (MySpec == SkillTreeId.CommandoCombatMedic) if (IG && RS <= 50f) { MercCast("Hammer Shot"); return true; }
  989.  
  990.             if (!IG || MySpec != SkillTreeId.CommandoCombatMedic || (IG && RS > 50f))
  991.             {
  992.                 if (MercCast("Concussion Charge", TD <= MeleeDist)) return true;
  993.                 if (MercCast("Blitz", TD <= MeleeDist)) return true;
  994.                 if (MercCast("Stockstrike", TD <= MeleeDist)) return true;
  995.                 if (MercFaceAndCast("Pulse Cannon", TD <= 1.0f)) return true;
  996.  
  997.                 if (MercCastOnGround("Mortar Volley", RS >= 50f && TD >= .6f && (StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .60f) >= 3), CT)) return true;
  998.                 if (MercCast("Sticky Grenade")) return true;
  999.                 if (MercCast("High Impact Bolt", StrongOrGreater(CT))) return true;
  1000.                 if (MercCast("Plasma Grenade", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .50f) >= 3)) return true;
  1001.                 if (MercCastOnGround("Hail of Bolts", BuddyTor.Me.ResourceStat > 50f && MobsInRangeOf(CT.Position, .60f) >= 3, CT, true)) return true;
  1002.  
  1003.                 if (MercCast("Incendiary Round", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .50f) >= 4)) return true;
  1004.                 if (MercCast("Explosive Round", (TD <= MeleeDist && StrongOrGreater(CT)) || (Me.Level<10 && RS>=50f))) return true;
  1005.  
  1006.                 if (MercCast("Grav Round", StrongOrGreater(CT))) return true;
  1007.                 if (MercCast("Demolition Round", StrongOrGreater(CT) && CTDebuffs.Contains("Grav"))) return true;
  1008.  
  1009.                 if (MercCast("Tech Override", StrongOrGreater(CT))) return true;
  1010.                 if (MercCast("Charged Bolts", MyBuffs.Contains("Tech Override"))) return true;
  1011.                 if (MercCast("Full Auto")) return true;
  1012.  
  1013.                 if (MercCast("Charged Bolts")) return true;
  1014.                 if (MercCast("Hammer Shot")) return true;
  1015.             }
  1016.  
  1017.             if (MercCast("Hammer Shot")) return true;
  1018.            
  1019.             return false;
  1020.  
  1021.         }
  1022.  
  1023.         public static bool SSCombat()
  1024.         {
  1025.  
  1026.             Thread.Sleep(200);
  1027.             WaitForCast();
  1028.             datLCL = DateTime.Now;
  1029.  
  1030.             LoadVars();
  1031.  
  1032.             if (CT == null) { Logger.Write("No target.  Exiting."); return false; }
  1033.             if (IG && !TargetInCombat()) return false;
  1034.  
  1035.             MercBuffSelf("Ion Cell", MySpec==SkillTreeId.VanguardShieldSpecialist);
  1036.             MercBuffSelf("Plasma Cell", MySpec==SkillTreeId.VanguardAssaultSpecialist);
  1037.  
  1038.             MoveTo(CT, 2.90f);
  1039.             StopMoving();
  1040.  
  1041.             if (!CT.InCombat) MercCast("Harpoon");
  1042.  
  1043.             if (HP <= 30f) UseMedPackInInventory();
  1044.  
  1045.             //Thread.Sleep(100);
  1046.             if (MercCast("Tenacity", BuddyTor.Me.IsStunned)) return true;
  1047.             if (MercCast("Reactive Shield", HP <= 50f)) return true;
  1048.             if (MercCast("Adrenaline Rush", HP <= 50f)) return true;
  1049.  
  1050.             if (MercCast("Recharge Cells", RS <= 6f)) return true;
  1051.             if (MercCast("Reserve Powercell", RS <= 6f)) return true;
  1052.             if (MercCast("Supercharge Cells")) return true;
  1053.  
  1054.             if (MercCast("Energy Blast", RS <= 8f)) return true;
  1055.             if (MercCast("Neural Jolt")) return true;
  1056.  
  1057.             if (!TargetInCombat()) return false;
  1058.  
  1059.             if (MercCast("Stockstrike", TD <= MeleeDist)) return true;
  1060.  
  1061.             if (MercCast("Explosive Surge", TWR5 >= 2)) return true;
  1062.  
  1063.             if (MercCastOnGround("Mortar Volley", TD >= .6f && (StrongOrGreater(CT) || TWR30 > 2), CT, true)) return true;
  1064.  
  1065.             if (MercCast("High Impact Bolt")) return true;
  1066.             if (MercFaceAndCast("Pulse Cannon", TD <= 1.0f)) return true;
  1067.             if (MercCast("Sticky Grenade")) return true;
  1068.             if (MercCast("Ion Pulse", TD <= 1.0f)) return true;
  1069.  
  1070.             if (MercCast("Battle Focus")) return true;
  1071.  
  1072.             if (MercCast("Full Auto")) return true;
  1073.  
  1074.             if (MercCast("Hammer Shot", HP < 50f && RS < 3f)) return true;
  1075.             if (MercCast("Concussive Round", HP < 50f)) { BuddyTor.Me.ClearTarget(); return true; }
  1076.  
  1077.             if (MercCast("Cryo Grenade", TC || TD <= 1.0f)) return true;
  1078.             if (MercCast("Disabling Shot", TC)) return true;
  1079.  
  1080.             if (!IG || (IG && RS > 40f))
  1081.             {
  1082.                 if (MercCast("Blitz", TD <= MeleeDist)) return true;
  1083.                 if (MercFaceAndCast("Pulse Cannon", TD <= 1.0f && RS>=50f)) return true;
  1084.                 if (MercCast("Concussion Charge", TD <= MeleeDist)) return true;
  1085.                 if (MercCast("Explosive Round", TD <= MeleeDist && !StrongOrGreater(CT))) return true;
  1086.  
  1087.                 if (MercCast("Tech Override", StrongOrGreater(CT))) return true;
  1088.                 if (MercCast("Charged Bolts", MyBuffs.Contains("Tech Override"))) return true;
  1089.                 if (MercCast("Riot Gas", StrongOrGreater(CT))) return true; // Can be a bit buggy, moved it down here to try and alleviate that
  1090.                 if (MercCast("Plasma Grenade", StrongOrGreater(CT))) return true;
  1091.                 if (MercCast("Sticky Grenade")) return true;
  1092.  
  1093.                 if (MercCastOnGround("Hail of Bolts", RS > 50f && MobsInRangeOf(CT.Position, 1.0f)>=3, CT, true)) return true;
  1094.                 if (MercCast("Hammer Shot")) return true;
  1095.             }
  1096.             if (MercCast("Hammer Shot")) return true;
  1097.             return false;
  1098.         }
  1099.  
  1100.         public static bool HandleGuardingKinetic()
  1101.         {
  1102.  
  1103.             //if (!IG) return false;
  1104.  
  1105.             CheckForGuarding();
  1106.  
  1107.             if (NAUnit != null) try
  1108.                 {
  1109.                     CT = NAUnit;
  1110.  
  1111.                     if (MercCast("Force Pull", NAUnit)) return true;
  1112.                     if (MercCast("Mind Control", NAUnit)) return true;
  1113.                     if (MercCast("Mass Mind Control", NAUnit, NAUnit.Distance <= 1.50f)) return true;
  1114.                     //if (MercCast("Guard", NGUnit)) return true;
  1115.  
  1116.                 }
  1117.                 catch { }
  1118.             return false;
  1119.         }
  1120.  
  1121.         public static bool ShadowCombat()
  1122.         {
  1123.             WaitForCast();
  1124.             datLCL = DateTime.Now;
  1125.  
  1126.             Thread.Sleep(200);
  1127.  
  1128.             LoadVars();
  1129.  
  1130.             MercBuffSelf("Combat Technique", MySpec==SkillTreeId.ShadowCombat);
  1131.             MercBuffSelf("Shadow Technique", MySpec == SkillTreeId.ShadowInfiltration);
  1132.             MercBuffSelf("Force Technique", MySpec == SkillTreeId.ShadowBalance);
  1133.  
  1134.             if (!TargetInCombat()) return false;
  1135.            
  1136.             if (!CT.InCombat && CT.HealthPercent > .2f)
  1137.             {
  1138.                 MercBuffSelf("Stealth");
  1139.                 while (CT.Distance > .15f) MoveTo(CT, .15f);
  1140.                 if (MercCast("Shadow Strike", CT.Distance <= .20f)) if (MercCast("Double Strike")) return true;
  1141.             }
  1142.  
  1143.             MercCast("Force of Will", Me.IsStunned);
  1144.             if (IG) if (HandleGuardingKinetic()) return true;
  1145.  
  1146.             if (TD > 1.5f) if (MercCast("Force Pull")) return true;
  1147.             MoveTo(CT, MeleeDist, "Force Speed");
  1148.  
  1149.             if (MercCast("Mind Snap", TC && StrongOrGreater(CT))) return true;
  1150.             if (MercCast("Mind Control", TC && StrongOrGreater(CT))) return true;
  1151.  
  1152.             if (HP <= 30) UseMedPackInInventory();
  1153.  
  1154.             if (MercCast("Kinetic Ward", HP < 80f)) return true;
  1155.             if (MercCast("Battle Readiness", HP <= 50f)) return true;
  1156.             if (MercCast("Force Potency", HP <= 50f)) return true;
  1157.             if (MercCast("Resilience", HP <= 50f)) return true;
  1158.             if (MercCast("Deflection", HP <= 50f)) return true;
  1159.            
  1160.             if (MercCast("Force Potency", HP <= 70f || (StrongOrGreater(CT) || TWR10 >= 3))) return true;
  1161.             if (MercCast("Force Breach", TD <= 1.0f && (StrongOrGreater(CT) || TWR10 >= 3))) return true;
  1162.             if (MercCastOnGround("Force in Balance",MobsInRangeOf(CT.Position,.80f)>=3,CT)) return true;
  1163.             if (MercCast("Slow Time", TWR10>=4 || StrongOrGreater(CT))) return true;
  1164.  
  1165.             if (MercCast("Force Wave", TWR10 >= 3)) return true;
  1166.             if (MercCast("Force Stun", StrongOrGreater(CT) && CTT <= CombatToughness.Boss1)) return true;
  1167.  
  1168.             if (MercCast("Sever Force", StrongOrGreater(CT))) return true;
  1169.             if (MercCast("Clairvoyant Strike", StrongOrGreater(CT))) return true;
  1170.             if (MercCast("Project", (RS > 45f && TD >= .6f) || MyBuffs.Contains("Clairvoyance"))) return true;
  1171.             if (MercCast("Telekinetic Throw", TD >= .6f && Me.ForcePercent <= 50f)) return true;
  1172.  
  1173.             if (MercCast("Tumult", TD <= MeleeDist)) return true;
  1174.             if (MercCast("Project", TD <= 1.0f && RS > 45f)) return true;
  1175.             if (MercCast("Double Strike", EP > 50f && TD <= MeleeDist)) return true;
  1176.             if (MercCast("Spinning Strike", THP <= 30f)) return true;
  1177.  
  1178.             if (MercCast("Mind Crush", StrongOrGreater(CT) && !CTDebuffs.Contains("Mind Crush") && THP >= 50)) return true;
  1179.            
  1180.             if (MercCast("Telekinetic Throw", TD <= 1.0f)) return true;
  1181.            
  1182.             if (MercCast("Force Slow", StrongOrGreater(CT))) return true;
  1183.  
  1184.             if (MercCast("Slow Time", !CTDebuffs.Contains("Slow Time (Force)"))) return true;
  1185.             if (MercCast("Force Breach", TWR10 >= 3)) return true;
  1186.             if (MercCast("Whirling Blow", TWR5 >= 3)) return true;
  1187.             if (MercCast("Project", RS > 45f)) return true;
  1188.             if (MercCast("Telekinetic Throw")) return true;            
  1189.  
  1190.             MercCast("Saber Strike");
  1191.  
  1192.             return false;
  1193.         }
  1194.  
  1195.         public static bool SageKineticCombat()
  1196.         {
  1197.             WaitForCast();
  1198.             datLCL = DateTime.Now;
  1199.  
  1200.             Thread.Sleep(200);
  1201.  
  1202.             LoadVars();
  1203.  
  1204.             if (!TargetInCombat()) return false;
  1205.  
  1206.             MercBuffSelf("Force Valor");
  1207.  
  1208.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  1209.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  1210.  
  1211.             if (CT == null) { Logger.Write("No target.  Exiting."); return false; }
  1212.  
  1213.             MoveTo(CT, 2.90f, "Force Speed");
  1214.  
  1215.             MercCast("Force of Will", Me.IsStunned);
  1216.            
  1217.             if (MercCast("Force Shield", Comp, Comp!=null && !Comp.HasBuff("Force Shield"))) return true;
  1218.             if (MercCast("Force Shield", Me, !MyBuffs.Contains("Force Shield"))) return true;
  1219.             if (MercCast("Project", RS > 45f && TD >= .6f)) return true;
  1220.  
  1221.             if (HP <= 30) UseMedPackInInventory();
  1222.  
  1223.             if (MercCast("Force Wave", TWR10 >= 2)) return true;
  1224.             //if (MercCast("Heroic Moment: Channel the Force", HP <= 40f)) return true;
  1225.  
  1226.             if (MercCast("Force Mend", Me, HP < 80f)) return true;
  1227.             if (MercCast("Benevolence", Me, HP < 80f)) return true;
  1228.             if (MercCast("Benevolence", Comp, CHP <= 70f)) return true;
  1229.  
  1230.             if (MercCast("Telekinetic Throw", TD >= .6f)) return true;
  1231.  
  1232.             if (TD > 1.5f) if (MercCast("Force Pull")) return true;
  1233.  
  1234.             if (MercCast("Mind Snap", TC)) return true;
  1235.             if (MercCast("Mind Control", TC && StrongOrGreater(CT))) return true;
  1236.  
  1237.             if (MercCast("Force Wave", TWR10 >= 3)) return true;
  1238.             if (MercCast("Force Stun", StrongOrGreater(CT) && CTT <= CombatToughness.Boss1)) return true;
  1239.  
  1240.             if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Weaken Mind", u, !u.HasDebuff("Weaken Mind (Force)"))) WaitForCast();
  1241.  
  1242.             if (MercCast("Battle Readiness", HP <= 50f)) return true;
  1243.             if (MercCast("Force Potency", HP <= 50f)) return true;
  1244.             if (MercCast("Resilience", HP <= 50f)) return true;
  1245.             if (MercCast("Deflection", HP <= 50f)) return true;
  1246.  
  1247.             if (MercCast("Force Potency", HP <= 70f || (CTT >= CombatToughness.Boss1) || (TWR10 >= 3))) return true;
  1248.  
  1249.             if (MercCast("Force Breach", (TD <= 1.0f && StrongOrGreater(CT)) || TWR10 >= 3)) return true;
  1250.             if (MercCast("Force Wave", TWR10 >= 3)) return true;
  1251.  
  1252.             if (MercCast("Tumult", TD <= MeleeDist)) return true;
  1253.             if (MercCast("Spinning Strike", THP <= 30f)) return true;
  1254.  
  1255.             if (MercCast("Mind Crush", StrongOrGreater(CT) && !CTDebuffs.Contains("Mind Crush") && THP >= 50)) return true;
  1256.  
  1257.             if (MercCast("Project", TD <= 1.0f && RS > 45f)) return true;
  1258.             if (MercCast("Telekinetic Throw", TD <= 1.0f)) return true;
  1259.  
  1260.             if (MercCast("Force Slow", StrongOrGreater(CT))) return true;
  1261.  
  1262.             if (MercCast("Slow Time", !CTDebuffs.Contains("Slow Time (Force)"))) return true;
  1263.             if (MercCast("Force Breach", TWR10 >= 3)) return true;
  1264.             if (MercCast("Whirling Blow", TWR5 >= 3)) return true;
  1265.             if (MercCast("Project", RS > 45f)) return true;
  1266.             if (MercCast("Telekinetic Throw")) return true;
  1267.  
  1268.             if (MercCast("Double Strike", RS > 65f)) return true;
  1269.  
  1270.             if (MercCast("Saber Strike"))return true;
  1271.             return false;
  1272.         }
  1273.  
  1274.         public static void InfiltrationCombat()
  1275.         {
  1276.             WaitForCast();
  1277.             datLCL = DateTime.Now;
  1278.  
  1279.             Thread.Sleep(200);
  1280.  
  1281.             LoadVars();
  1282.  
  1283.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  1284.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  1285.  
  1286.             if (CT == null) { Logger.Write("No target.  Exiting."); return; }
  1287.  
  1288.             MoveTo(CT, 2.9f);
  1289.             if (!CT.InCombat && CT.HealthPercent > .2f)
  1290.             {
  1291.                 MercCast("Stealth");
  1292.                 while (CT.Distance > .15f) MoveTo(CT, .15f);
  1293.                 if (MercCast("Shadow Strike", CT.Distance <= .20f)) if (MercCast("Double Strike")) return;
  1294.             }
  1295.  
  1296.             MercCast("Force of Will", Me.IsStunned);
  1297.             if (IG) if (HandleGuardingKinetic()) return;
  1298.  
  1299.             if (MercCast("Project", RS > 45f && TD >= .6f)) return;
  1300.             if (MercCast("Telekinetic Throw", TD >= .6f)) return;
  1301.  
  1302.             if (TD > 1.5f) if (MercCast("Force Pull")) return;
  1303.             MoveTo(CT, .490f, "Force Speed");
  1304.  
  1305.             if (MercCast("Mind Snap", TC)) return;
  1306.             if (MercCast("Mind Control", TC && StrongOrGreater(CT))) return;
  1307.  
  1308.             if (MercCast("Force Wave", TWR10 >= 3)) return;
  1309.             if (MercCast("Force Stun", StrongOrGreater(CT) && CTT <= CombatToughness.Boss1)) return;
  1310.  
  1311.             if (HP <= 30) UseMedPackInInventory();
  1312.  
  1313.             //if (MercCast("Heroic Moment: Channel the Force", HP <= 40f)) return;
  1314.  
  1315.             if (MercCast("Kinetic Ward", HP < 80f)) return;
  1316.             if (MercCast("Battle Readiness", HP <= 50f)) return;
  1317.             if (MercCast("Force Potency", HP <= 50f)) return;
  1318.             if (MercCast("Resilience", HP <= 50f)) return;
  1319.             if (MercCast("Deflection", HP <= 50f)) return;
  1320.  
  1321.             if (MercCast("Force Potency", HP <= 70f || (CTT >= CombatToughness.Boss1) || (TWR10 >= 3))) return;
  1322.  
  1323.             if (MercCast("Force Breach", (TD <= 1.0f && StrongOrGreater(CT)) || TWR10 >= 2)) return;
  1324.             if (MercCast("Force Wave", TWR10 >= 3)) return;
  1325.  
  1326.             if (MercCast("Tumult", TD <= MeleeDist)) return;
  1327.             if (MercCast("Spinning Strike", THP <= 30f)) return;
  1328.  
  1329.             if (MercCast("Mind Crush", StrongOrGreater(CT) && !CTDebuffs.Contains("Mind Crush") && THP >= 50)) return;
  1330.  
  1331.             if (MercCast("Project", TD <= 1.0f && RS > 45f)) return;
  1332.             if (MercCast("Telekinetic Throw", TD <= 1.0f)) return;
  1333.  
  1334.             if (MercCast("Force Slow", StrongOrGreater(CT))) return;
  1335.  
  1336.             if (MercCast("Slow Time", !CTDebuffs.Contains("Slow Time (Force)"))) return;
  1337.             if (MercCast("Force Breach", TWR10 >= 3)) return;
  1338.             if (MercCast("Whirling Blow", TWR10 >= 3)) return;
  1339.             if (MercCast("Project", RS > 45f)) return;
  1340.             if (MercCast("Telekinetic Throw")) return;
  1341.  
  1342.             if (MercCast("Whirling Blow", TWR5 >= 2)) return;
  1343.             if (MercCast("Double Strike", RS > 65f)) return;
  1344.  
  1345.             MercCast("Saber Strike");
  1346.  
  1347.         }
  1348.  
  1349.         public static void SniperMarksmanshipPull()
  1350.         {
  1351.             CT = Me.CurrentTarget;
  1352.             if (!TargetInCombat()) return;
  1353.  
  1354.             LoadVars();
  1355.             MoveTo(CT, 2.8f);
  1356.  
  1357.             //Me.CurrentTarget.Face();
  1358.             //Thread.Sleep(600);
  1359.             MercCast("Crouch");
  1360.             Thread.Sleep(600);
  1361.             MercCast("Ambush");
  1362.             return;
  1363.         }
  1364.  
  1365.         // Ops Medicine BLOWS, weak, WEAK, heals
  1366.         public static void MedicineCombat()
  1367.         {
  1368.             WaitForCast();
  1369.             datLCL = DateTime.Now;
  1370.  
  1371.             Thread.Sleep(300);
  1372.  
  1373.             LoadVars();
  1374.  
  1375.             MercBuffSelf("Coordination");
  1376.             if (MercCast("Escape", Me.IsStunned)) return;
  1377.  
  1378.             if (MercCast("Heroic Moment:  Advanced Recon", Me, HP <= 25)) return;
  1379.             if (MercCast("Evasion", Me, HP <= 30)) return;
  1380.             if (MercCast("Kolto Probe", Me, HP <= 70 && !MyBuffs.Contains("Kolto Probe"))) return;
  1381.             if (MercCast("Surgical Probe", HP <= 70 && MyBuffs.Contains("Tactical Advantage"))) return;
  1382.             if (MercCast("Kolto Injection", Me, HP <= 60)) return;
  1383.             if (MercCast("Kolto Infusion", Me, HP <= 70)) return;
  1384.             if (MercCast("Adrenaline Probe", EP <= 20)) return;
  1385.             if (MercCast("Stim Boost", EP <= 60 && MyBuffs.Contains("Tactical Advantage"))) return;
  1386.  
  1387.             if (IG) if (MedicineHeals(80)) return;
  1388.  
  1389.             if (!TargetInCombat()) return;
  1390.  
  1391.             MoveTo(CT, 2.80f);
  1392.             StopMoving();
  1393.  
  1394.             MercCast("Crouch", Me, !Me.IsCoverAffected);
  1395.             if (!CT.InCombat)
  1396.             {
  1397.                 Thread.Sleep(600);
  1398.                 MercCast("Snipe");
  1399.             }
  1400.  
  1401.             if (MercCast("Distraction", (IG && HP <= 50f) || (StrongOrGreater(CT) && TC))) return;
  1402.             if (MercCast("Flash Bang", TD <= MeleeDist)) return;
  1403.             if (MercCast("Carbine Burst", MyBuffs.Contains("Tactical Advantage") && StrongOrGreater(CT) && TD <= MeleeDist)) return;
  1404.  
  1405.             if (MercCast("Debilitate", StrongOrGreater(CT) && TC)) return;
  1406.             if (MercCast("Fragmentation Grenade", !IG && StrongOrGreater(CT) && TC)) return;
  1407.  
  1408.             //if (HP <= 70) MercCast("Rifle Shot");    // Force a Rifle-Shot on healing so we get at least a LITTLE DAMAGE in - may help with a Heals Catch-22
  1409.  
  1410.             if (MercCast("Eviscerate", TD <= MeleeDist)) return;
  1411.             if (MercCast("Shiv", TD <= MeleeDist)) return;
  1412.             if (MercCast("Sever Tendon", TD <= 1.0f)) return;
  1413.  
  1414.             if (MedicineCheckCompHealth()) return;
  1415.  
  1416.             if (MercCast("Rifle Shot", RS <= 30 && (StrongOrGreater(CT) || IG))) return;
  1417.  
  1418.             if (MercCast("Fragmentation Grenade", !IG)) return;
  1419.             if (MercCast("Explosive Probe")) return;
  1420.             if (MercCast("Corrosive Dart", !CTDebuffs.Contains("Poisoned (Tech)"))) return;
  1421.             if (MercCast("Flash Bang")) return;
  1422.  
  1423.             if (MercCast("Carbine Burst", TWR10 >= 3)) return;
  1424.  
  1425.             if (MercCast("Snipe")) return;
  1426.             if (MercCast("Rifle Shot")) return;
  1427.  
  1428.         }
  1429.  
  1430.         // Ops Medicine BLOWS, weak, WEAK, heals
  1431.         public static bool OperativeCombat()
  1432.         {
  1433.             datLCL = DateTime.Now;
  1434.  
  1435.             Thread.Sleep(200);
  1436.             WaitForCast();
  1437.  
  1438.             LoadVars();
  1439.  
  1440.             if (!TargetInCombat()) return false;
  1441.  
  1442.             MercBuffSelf("Coordination");
  1443.             if (MercCast("Escape", Me.IsStunned)) return true;
  1444.  
  1445.             if (Me.IsStunned) return false;
  1446.  
  1447.             if (MercCast("Heroic Moment: Advanced Recon", Me, HP <= 25f)) ;
  1448.             if (MercCast("Unity", Me, HP <= 25f)) ;
  1449.  
  1450.             if (!CT.InCombat)
  1451.             {
  1452.                 MercCast("Stealth", BuddyTor.Me);
  1453.                 Thread.Sleep(800);
  1454.                 MoveTo(CT, .20f);
  1455.                 if (!MercCast("Hidden Strike")) if (!MercCast("Backstab")) MercCast("Shiv");
  1456.             }
  1457.  
  1458.             MoveTo(CT, MySpec == SkillTreeId.OperativeMedic && IG ? 2.8f : MeleeDist, "Explosive Probe", "Fragmentation Grenade", "Rifle Shot");
  1459.  
  1460.             //if (!CT.InCombat && MySpec != SkillTreeId.OperativeMedic)
  1461.             if (MercBuffSelf("Crouch")) Thread.Sleep(800);
  1462.             if (MercBuffSelf("Shield Probe")) Thread.Sleep(800);
  1463.  
  1464.  
  1465.             if (Comp != null) try
  1466.             {
  1467.                 if (MercCast("Toxin Scan", Comp, CHP <= 70f && Comp.Debuffs.Count() >= 2)) return true;
  1468.                 if (MercCast("Kolto Infusion", Comp, CHP <= 70f && MyBuffs.Contains("Tactical Advantage"))) return true;
  1469.                 if (MercCast("Kolto Injection", Comp, CHP <= 70f)) return true;
  1470.             }
  1471.             catch { }
  1472.  
  1473.             if (MercCast("Adrenaline Probe", EP <= 20f)) ;
  1474.             if (HP < 70f)
  1475.             {
  1476.                 if (HP <= 30) UseMedPackInInventory();
  1477.                 if (MercCast("Rifle Shot")) { Thread.Sleep(900); WaitForCast(); }
  1478.                 if (MercCast("Recuperative Nanotech", Me));
  1479.                 if (MercCast("Recuperative Nanotech", Me));
  1480.                 if (MercCast("Distraction", HP<=40f));
  1481.                 if (MercCast("Toxin Scan", Me, HP <= 70f && NeedsDispell(Me))) return true;
  1482.                 if (MercCast("Stim Boost", EP <= 60f && MyBuffs.Contains("Tactical Advantage"))) ;
  1483.                 if (MercCast("Evasion", Me, HP <= 30f)) ;
  1484.                 if (MercCast("Countermeasures", Me, HP <= 50f)) return true;
  1485.                 if (MercCast("Kolto Injection", Me, HP <= 60f)) ;
  1486.                 if (MercCast("Kolto Probe", Me, HP <= 70f && !MyBuffs.Contains("Kolto Probe"))) ;
  1487.                 if (MercCast("Surgical Probe", HP <= 70f && MyBuffs.Contains("Tactical Advantage"))) ;
  1488.                 if (MercCast("Kolto Infusion", Me, HP <= 70f)) ;
  1489.             }
  1490.  
  1491.             if (MercCast("Distraction", TC && StrongOrGreater(CT))) return true;
  1492.             if (MercCast("Flash Bang", TC && StrongOrGreater(CT))) return true;
  1493.  
  1494.             //if (MercCast("Shield Probe", Me, HP <= 70f)) return true;
  1495.  
  1496.             if (TWR10 >= 3)
  1497.             {
  1498.                 if (MercCast("Explosive Probe")) return true;
  1499.                 if (MercCast("Fragmentation Grenade")) return true;
  1500.             }
  1501.  
  1502.             for (int i = 0; i < (Is55H ? 3 : 1); i++) if (IG && MySpec == SkillTreeId.OperativeMedic) MedicineHeals(MySpec == SkillTreeId.OperativeMedic ? 85 : 60);
  1503.  
  1504.             if (MercCast("Corrosive Grenade", !CTDebuffs.Contains("Poisoned (Tech)"))) return true;
  1505.             foreach (TorCharacter u in Attackers) if (MercCast("Corrosive Dart", u, !u.HasDebuff("Poisoned (Tech)"))) { Thread.Sleep(800); break; }
  1506.  
  1507.             if (MySpec == SkillTreeId.OperativeMedic && IG && RS <= 70) { MercCast("Rifle Shot"); return true; }
  1508.  
  1509.             if (MercCast("Explosive Probe")) return true;
  1510.             if (MercCast("Shiv", TD <= MeleeDist)) return true;
  1511.             if (MercCast("Backstab", TD <= MeleeDist)) return true;
  1512.             if (MercCast("Laceration", TD <= MeleeDist)) return true;
  1513.             if (MercCast("Fragmentation Grenade")) return true;
  1514.             if (MercCast("Debilitate", TD <= MeleeDist && StrongOrGreater(CT))) return true;
  1515.             if (MercFaceAndCast("Carbine Burst", TD <= 1.0f && (TWR10 >= 3 || StrongOrGreater(CT)))) return true;
  1516.             if (MercCast("Cull", TD <= 1.0f)) return true;
  1517.  
  1518.  
  1519.             if (MercCast("Sever Tendon", TD <= 1.0f && !CTDebuffs.Contains("Slowed (Tech)"))) return true;
  1520.  
  1521.             if (MercCast("Snipe")) return true;
  1522.             if (MercCast("Rifle Shot")) return true;
  1523.  
  1524.             return false;
  1525.         }
  1526.  
  1527.         public static void ConcealmentCombat()
  1528.         {
  1529.             WaitForCast();
  1530.             datLCL = DateTime.Now;
  1531.  
  1532.             Thread.Sleep(100);
  1533.  
  1534.             LoadVars();
  1535.  
  1536.             if (!TargetInCombat()) return;
  1537.  
  1538.             MercBuffSelf("Coordination");
  1539.             MoveTo(CT, 2.8f);
  1540.  
  1541.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  1542.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  1543.  
  1544.             if (CT == null) { Logger.Write("No target.  Exiting."); return; }
  1545.             if (CT == Comp) { BuddyTor.Me.ClearTarget(); return; }
  1546.  
  1547.             if (!CT.InCombat && CT.HealthPercent > .2f)
  1548.             {
  1549.                 MercCast("Stealth");
  1550.                 while (CT.Distance > .15f) MoveTo(CT, .15f);
  1551.                 MercCast("Acid Blade");
  1552.                 MercCast("Ambush", CT.Distance <= .20f);
  1553.                 MercCast("Backstab", CT.Distance <= .20f);
  1554.             }
  1555.  
  1556.             if (MercCast("Escape", Me.IsStunned)) return;
  1557.  
  1558.             MercCast("Crouch", Me, !MyBuffs.Contains("Crouch"));
  1559.  
  1560.             MoveTo(CT, MeleeDist, "Rifle Shot");
  1561.  
  1562.             if (MercCast("Acid Blade", !CTDebuffs.Contains("Acid Blade"))) return;
  1563.  
  1564.             if (MercCast("Followthrough")) return;
  1565.             if (MercCast("Takedown")) return;
  1566.             if (MercCast("Headshot")) return;
  1567.             if (MercCast("Shattershot")) return;
  1568.  
  1569.             //if (HP <= 70) MercCast("Rifle Shot");    // Force a Rifle-Shot on healing so we get at least a LITTLE DAMAGE in - may help with a Heals Catch-22
  1570.  
  1571.             if (MercCast("Shield Probe", Me, !MyBuffs.Contains("Shield Probe"))) return;
  1572.  
  1573.             if (MercCast("Heroic Moment: Advanced Recon", Me, HP <= 25)) return;
  1574.             //if (MercCast("Evasion", Me, HP <= 30)) return;
  1575.             //if (MercCast("Kolto Probe", Me, HP <= 70 && !MyBuffs.Contains("Kolto Probe"))) return;
  1576.             //if (MercCast("Surgical Probe", HP <= 70 && MyBuffs.Contains("Tactical Advantage"))) return;
  1577.  
  1578.             if (MercCast("Kolto Injection", Me, HP <= 60)) return;
  1579.             if (MercCast("Kolto Infusion", Me, HP <= 70)) return;
  1580.             if (MercCast("Adrenaline Probe", EP <= 20)) return;
  1581.             if (MercCast("Stim Boost", EP <= 60 && MyBuffs.Contains("Tactical Advantage"))) return;
  1582.  
  1583.             if (MercCast("Stim Boost", Me, RS <= 20)) return;
  1584.             if (MercCast("Fragmentation Grenade", !IG)) return;
  1585.  
  1586.             if (TD <= MeleeDist)
  1587.             {
  1588.                 if (MercCast("Orbital Strike", EliteOrGreater(CT))) return;
  1589.                 if (MercCast("Shiv")) return;
  1590.                 if (MercCast("Lacerate", MyBuffs.Contains("Tactical Advantage"))) return;
  1591.                 if (MercCast("Carbine Burst", MyBuffs.Contains("Tactical Advantage") && StrongOrGreater(CT))) return;
  1592.                 if (MercCast("Eviscerate")) return;
  1593.                 if (MercCast("Sever Tendon")) return;
  1594.             }
  1595.  
  1596.             if (MercCast("Distraction", (IG && HP <= 50) || (StrongOrGreater(CT) && TC))) return;
  1597.             if (MercCast("Flash Bang", TD <= MeleeDist)) return;
  1598.             if (MercCast("Debilitate", StrongOrGreater(CT) && TC)) return;
  1599.             if (MercCast("Fragmentation Grenade", !IG && StrongOrGreater(CT) && TC)) return;
  1600.  
  1601.             if (MercCast("Cull", MyBuffs.Contains("Tactical Advantage") && TWR10 >= 2)) return;
  1602.  
  1603.             if (MedicineCheckCompHealth()) return;
  1604.  
  1605.             if (MercCast("Rifle Shot", RS <= 30 && (StrongOrGreater(CT) || IG))) return;
  1606.  
  1607.             if (MercCast("Corrosive Grenade")) return;
  1608.             if (MercCast("Debilitate", StrongOrGreater(CT))) return;
  1609.             if (MercCast("Headshot", CT.IsStunned)) return;
  1610.             if (MercCast("Explosive Probe")) return;
  1611.             if (MercCast("Weakening Blast")) return;
  1612.             if (MercCast("Corrosive Dart", !CTDebuffs.Contains("Poisoned (Tech)"))) return;
  1613.             if (MercCast("Flash Bang")) return;
  1614.  
  1615.             if (MercCast("Carbine Burst", TWR10 >= 3)) return;
  1616.  
  1617.             if (MercCast("Snipe")) return;
  1618.             if (MercCast("Rifle Shot")) return;
  1619.  
  1620.         }
  1621.  
  1622.         public static bool ScrapperCombat()
  1623.         {
  1624.             if (Me.HealthPercent < .2f || Me.IsDead) return false;
  1625.  
  1626.             WaitForCast();
  1627.             datLCL = DateTime.Now;
  1628.  
  1629.             Thread.Sleep(200);
  1630.  
  1631.             LoadVars();
  1632.  
  1633.             if (!TargetInCombat()) return false;
  1634.            
  1635.             //if (!PvP) if(!CT.InCombat) if (TD > 1.50f) if (!Buddy.CommonBot.Blacklist.Contains(CT.Guid)) { Buddy.CommonBot.Blacklist.Add(CT.Guid,BlacklistFlags.Kill,TimeSpan.FromSeconds(120)); return; }
  1636.  
  1637.             MercBuffSelf("Lucky Shots");
  1638.             MoveTo(CT, 2.8f);
  1639.  
  1640.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  1641.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  1642.  
  1643.             if (CT == null) { Logger.Write("No target.  Exiting."); return false; }
  1644.             if (CT == Comp) { BuddyTor.Me.ClearTarget(); return false; }
  1645.  
  1646.             if (MercCast("Crouch", Me, !MyBuffs.Contains("Crouch"))) Thread.Sleep(500);
  1647.             if (TD > 3.0f || !CT.InLineOfSight) return false;
  1648.             //MoveTo(CT, MeleeDist,"Sabotage Charge", "Thermal Grenade","Flurry of Bolts");
  1649.  
  1650.             if (MercCast("Escape", Me.IsStunned)) return true;
  1651.  
  1652.             if (HP <= 30f) UseMedPackInInventory();
  1653.  
  1654.             if (MercCast("Flash Grenade", TD <= 1.0f && TC)) return true;
  1655.             if (MercCast("Dirty Kick", TD <= MeleeDist && TC)) return true;
  1656.             if (MercCast("Tranquilizer", TD <= 1.0f && TC)) return true;
  1657.             if (MercCast("Pugnacity", Me, HP <= 50f || CHP <= 50f)) return true;
  1658.  
  1659.             if (MercCast("Shield Probe", Me, HP <= 70f)) return true;
  1660.             if (MercCast("Countermeasures", Me, HP <= 60f)) return true;
  1661.             if (MercCast("Stim Boost", Me, HP <= 60f)) return true;
  1662.             if (MercCast("Adrenaline Probe", Me, EP <= 20f)) return true;
  1663.             if (MercCast("Cool Head", RS <= 30f)) return true;
  1664.             if (MercCast("Evasion", Me, EP <= 50f)) return true;
  1665.  
  1666.             if (MyBuffs.Contains("Upper Hand"))
  1667.             {
  1668.                 if (MercCast("Kolto Pack", Me, HP <= 70f)) return true;
  1669.                 if (MercCast("Kolto Pack", Comp, CHP <= 70f)) return true;
  1670.                 if (MercCast("Pugnacity", RS <= 20f)) return true;
  1671.             }
  1672.  
  1673.             if (MercCast("Kolto Infusion", Me, HP <= 70f)) return true;
  1674.             if (MercCast("Underworld Medicine", Me, HP <= 50f)) return true;
  1675.             if (MercCast("Underworld Medicine", Comp, CHP <= 50f)) return true;
  1676.  
  1677.             if (MercCastOnGround("XS Freighter Flyby", CT.Toughness >= CombatToughness.Boss1, CT)) return true;
  1678.             if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Corrosive Dart", u, !u.HasDebuff("Poisoned (Tech)"))) WaitForCast();
  1679.  
  1680.             if (MercCast("Vital Shot", !CTDebuffs.Contains("Bleeding (Tech"))) return true;
  1681.             if (MercCast("Sucker Punch", TD <= 1.0f)) return true;
  1682.             if (MercCast("Carbine Burst", TD <= 1.0f)) return true;
  1683.             if (MercCast("Tendon Blast", TD <= 1.0f)) return true;
  1684.             if (MercCast("Back Blast", CT.IsFacing && TD<=1.0f)) return true;
  1685.  
  1686.             if (MercCast("Carbine Burst", TWR10>=2)) return true;
  1687.  
  1688.             if (TD <= MeleeDist)
  1689.             {
  1690.                 if (MercCast("Blaster Whip")) return true;
  1691.                 if (MercCast("Blaster Volley")) return true;
  1692.                 if (MercCastOnGround("Flurrry of Bolts", TWR10 >= 3, CT)) return true;
  1693.                 if (MercCast("Sucker Punch")) return true;
  1694.                 if (MercCast("Dirty Kick")) return true;
  1695.                 if (MercCast("Back Blast")) return true;
  1696.             }
  1697.  
  1698.             if (MercCast("Vital Shot", StrongOrGreater(CT) && !CTDebuffs.Contains("Bleeding (Tech)"))) return true;
  1699.  
  1700.  
  1701.             if (MercCast("Thermal Grenade")) return true;
  1702.             if (MercCast("Sabotage Charge")) return true;
  1703.             if (MercCastOnGround("Flurrry of Bolts", TWR30 >= 3, CT)) return true;
  1704.             if (MercCast("Aimed Shot")) return true;
  1705.             if (MercCast("Charged Burst")) return true;
  1706.             if (MercCast("Quick Shot")) return true;
  1707.  
  1708.             if (MercCast("Flurry of Bolts")) return true;
  1709.  
  1710.             return false;
  1711.         }
  1712.  
  1713.         public static bool GunslingerCombat()
  1714.         {
  1715.             //if (Me.HealthPercent < .2f || Me.IsDead) return false;
  1716.  
  1717.             WaitForCast();
  1718.             datLCL = DateTime.Now;
  1719.  
  1720.             Thread.Sleep(200);
  1721.  
  1722.             LoadVars();
  1723.  
  1724.             if (!TargetInCombat()) return false;
  1725.  
  1726.             //if (!PvP) if(!CT.InCombat) if (TD > 1.50f) if (!Buddy.CommonBot.Blacklist.Contains(CT.Guid)) { Buddy.CommonBot.Blacklist.Add(CT.Guid,BlacklistFlags.Kill,TimeSpan.FromSeconds(120)); return; }
  1727.  
  1728.             MercBuffSelf("Lucky Shots");
  1729.  
  1730.             if (!TargetInCombat()) return false;
  1731.             MoveTo(CT, MySpec == SkillTreeId.GunslingerDirtyFighting ? MeleeDist : 2.8f);
  1732.             StopMoving();
  1733.  
  1734.             if (MercCast("Crouch", Me, !MyBuffs.Contains("Crouch"))) Thread.Sleep(800);
  1735.             if (!CT.InLineOfSight) { Movement.Move(MovementDirection.Forward, TimeSpan.FromMilliseconds(500)); MercCast("Crouch", Me, !MyBuffs.Contains("Crouch")); }
  1736.  
  1737.             //if (TD > 3.0f || !CT.InLineOfSight) return false;
  1738.             //MoveTo(CT, MeleeDist,"Sabotage Charge", "Thermal Grenade","Flurry of Bolts");
  1739.  
  1740.             if (MercCast("Escape", Me.IsStunned)) return true;
  1741.  
  1742.             if (HP <= 30f) UseMedPackInInventory();
  1743.  
  1744.             if (MercCast("Flash Grenade", StrongOrGreater(CT) && TC)) return true;
  1745.             if (MercCast("Distraction", StrongOrGreater(CT) && TC)) return true;
  1746.             if (MercCast("Leg Shot", StrongOrGreater(CT) && TC)) return true;
  1747.             if (MercCast("Dirty Kick", TD <= MeleeDist && StrongOrGreater(CT) && TC)) return true;
  1748.             if (MercCast("Tranquilizer", StrongOrGreater(CT) && TC)) return true;
  1749.  
  1750.             if (MercCast("Cool Head", Me, RS <= 30f)) return true;
  1751.             if (MercCast("Pugnacity", RS <= 20f)) return true;
  1752.             if (HP <= 70f)
  1753.             {
  1754.                 if (MercCast("Pugnacity", Me, HP <= 50f || CHP <= 50f)) return true;
  1755.                 if (MercCast("Shield Probe", Me, HP <= 70f)) return true;
  1756.                 if (MercCast("Countermeasures", Me, HP <= 60f)) return true;
  1757.                 if (MercCast("Stim Boost", Me, HP <= 60f)) return true;
  1758.                 if (MercCast("Adrenaline Probe", Me, EP <= 20f)) return true;
  1759.                 if (MercCast("Evasion", Me, EP <= 50f)) return true;
  1760.             }
  1761.  
  1762.             if (!CT.InCombat && !IG) if (MercCast("Aimed Shot")) return true;
  1763.  
  1764.             if (MercCast("Quickdraw")) return true;
  1765.             if (MercCast("Sabotage Charge")) return true;
  1766.             if (MercCast("Thermal Grenade")) return true;
  1767.             if (MercCastOnGround("XS Freighter Flyby", CT.Toughness >= CombatToughness.Boss1, CT)) return true;
  1768.             if (MercCast("Smuggler's Luck", StrongOrGreater(CT))) return true;
  1769.             if (MercCast("Charged Burst", StrongOrGreater(CT) && MyBuffs.Contains("Smuggler's Luck"))) return true;
  1770.             if (MercCastOnGround("Sweepging Gunfire", MobsInRangeOf(CT.Position, .50f) >= 3, CT)) return true;
  1771.  
  1772.             //if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Corrosive Dart", u, !u.HasDebuff("Poisoned (Tech)"))) WaitForCast();
  1773.  
  1774.             if (MercCast("Vital Shot", StrongOrGreater(CT) && !CTDebuffs.Contains("Bleeding (Tech)"))) return true;
  1775.             //if (MercCast("Flash Grenade", StrongOrGreater(CT))) return true;
  1776.  
  1777.             if (TD <= 1.0f)
  1778.             {
  1779.                 if (MercCast("Blaster Whip")) return true;
  1780.                 if (MercCast("Dirty Kick")) return true;
  1781.                 if (MercCast("Pulse Detonator", TWR10 >= 2)) return true;
  1782.                 if (MercCast("Sucker Punch", TD <= 1.0f)) return true;
  1783.                 if (MercCast("Carbine Burst", TWR10 >= 2)) return true;
  1784.                 if (MercCast("Tendon Blast", TD <= 1.0f)) return true;
  1785.                 if (MercCast("Blaster Volley")) return true;
  1786.                 if (MercCastOnGround("Sweepging Gunfire", TWR10 >= 3, CT)) return true;
  1787.                 if (MercCast("Back Blast")) return true;
  1788.             }
  1789.  
  1790.             if (MercCast("Aimed Shot")) return true;
  1791.             if (MercCast("Charged Burst")) return true;
  1792.             if (MercCast("Quick Shot")) return true;
  1793.  
  1794.             if (MercCast("Flurry of Bolts")) return true;
  1795.  
  1796.             return false;
  1797.         }
  1798.  
  1799.         public static void ScoundrelCheckCompHealth(float MinHealth)
  1800.         {
  1801.             try
  1802.             {
  1803.                 var CompX = Comp;
  1804.                 if (CompX == null) return;
  1805.  
  1806.                 if (CompX.HealthPercent <= MinHealth && !CompX.IsDead)
  1807.                 {
  1808.                     CompX.Target();
  1809.                     Thread.Sleep(350);
  1810.                     CompX.Target();
  1811.                     Thread.Sleep(350);
  1812.  
  1813.                     if (MercCast("Toxin Scan", Comp, CHP <= 70f && Comp.Debuffs.Count() >= 2)) Thread.Sleep(800);
  1814.                     if (MercCast("Triage", Comp, CHP <= 70f && Comp.Debuffs.Count() >= 2)) Thread.Sleep(800);
  1815.  
  1816.                     if (!MercCast("Kolto Pack", CompX))
  1817.                     if (!MercCast("Emergency Medpac", CompX))
  1818.                     if (!MercCast("Slow-release Medpac", CompX, !CompX.HasBuff("Slow-release Medpac")))
  1819.                     if (!MercCast("Underworld Medicine", CompX)) ;
  1820.  
  1821.                     Thread.Sleep(300);
  1822.                     WaitForCast();
  1823.                     Me.ClearTarget();
  1824.                     Thread.Sleep(150);
  1825.  
  1826.                 }
  1827.             }
  1828.             catch { }
  1829.         }
  1830.  
  1831.         public static bool SawbonesHeals(float MinHealth)
  1832.         {
  1833.             GetGroupLHUnitInfo(MinHealth);
  1834.             if (LHUnit == null) return false;
  1835.  
  1836.             while (true)
  1837.             {
  1838.                 MoveTo(LHUnit, 2.90f);
  1839.                 if (!LHUnit.InLineOfSight || LHUnit.Distance > 3.0f) break;
  1840.  
  1841.                 Thread.Sleep(250);
  1842.                 WaitForCast();
  1843.  
  1844.                 LHUnit.Target();
  1845.                 Thread.Sleep(350);
  1846.                 LHUnit.Target();
  1847.                 Thread.Sleep(350);
  1848.  
  1849.                 MercCast("Kolto Cloud", LHUnit);
  1850.                 MercCastOnGround("Kolto Cloud",true, LHUnit);
  1851.  
  1852.                 if (MercCast("Toxin Scan", Comp, CHP <= 70f && Comp.Debuffs.Count() >= 2)) Thread.Sleep(800);
  1853.  
  1854.                 MercCast("Emergency Medpac", LHUnit);
  1855.                 MercCast("Kolto Pack", LHUnit, !LHUnit.HasBuff("Kolto Pack"));
  1856.                 MercCast("Slow-release Medpac", LHUnit, !LHUnit.HasBuff("Slow-release Medpac"));
  1857.                 MercCast("Underworld Medicine", LHUnit);
  1858.                 MercCast("Diagnostic Scan", LHUnit);
  1859.  
  1860.                 Thread.Sleep(300);
  1861.                 WaitForCast();
  1862.  
  1863.                 GetGroupLHUnitInfo(MinHealth);
  1864.                 if (LHUnit == null) break;
  1865.  
  1866.             }
  1867.  
  1868.             Me.ClearTarget();
  1869.            
  1870.             var pt = GetGroupTarget();
  1871.             if (pt != null && pt.Toughness != CombatToughness.Player) pt.Target();
  1872.            
  1873.             Thread.Sleep(200);
  1874.             return false;
  1875.         }
  1876.  
  1877.         public static bool ScoundrelCombat()
  1878.         {
  1879.             Thread.Sleep(200);
  1880.             WaitForCast();
  1881.  
  1882.             datLCL = DateTime.Now;
  1883.  
  1884.             LoadVars();
  1885.  
  1886.             if (!TargetInCombat()) return false;
  1887.  
  1888.             if (!CT.InCombat)
  1889.             {
  1890.                 if (MercBuffSelf("Stealth")) Thread.Sleep(800);
  1891.                 while (CT.Distance > .20f) MoveTo(CT, .20f);
  1892.                 if (MercCast("Shoot First")) Thread.Sleep(800);
  1893.                 if (MercCast("Back Blast")) Thread.Sleep(800);
  1894.                 if (MercCast("Dirty Kick")) Thread.Sleep(800);
  1895.                 if (MercCast("Blaster Whip")) Thread.Sleep(800);
  1896.             }
  1897.  
  1898.             MoveTo(CT, IG && MySpec == SkillTreeId.ScoundrelSawbones ? 2.8f : MeleeDist, "Sabotage Charge", "Thermal Grenade", "Flurry of Bolts");
  1899.             MercBuffSelf("Crouch");
  1900.  
  1901.             if (HP <= 70f)
  1902.             {
  1903.                 if (HP < 30) UseMedPackInInventory();
  1904.  
  1905.                 if (MercCast("Flurry of Bolts")) Thread.Sleep(800);
  1906.                 if (MercBuffSelf("Slow-release Medpac")) return true;
  1907.                 if (MercBuffSelf("Kolto Pack")) return true;
  1908.                 if (MercCast("Stim Boost", Me, EP <= 20f)) return true;
  1909.                 if (MercCast("Kolto Pack", Me, HP <= 70f && MyBuffs.Contains("Upper Hand"))) return true;
  1910.                 if (MercCast("Dodge", Me, HP <= 50f)) return true;
  1911.                 if (MercCast("Surrender", Me, HP <= 50f)) return true;
  1912.                 if (MercCast("Countermeasures", Me, RS <= 60f)) return true;
  1913.                 if (MercCast("Shield Probe", Me, RS <= 70f)) return true;
  1914.                 if (MercCast("Defense Screen", Me, HP <= 70f)) return true;
  1915.                 if (MercCast("Underworld Medicine", Me, HP <= 70f)) return true;
  1916.             }
  1917.  
  1918.             ScoundrelCheckCompHealth(MySpec == SkillTreeId.ScoundrelSawbones ? 85f : 60f);
  1919.             if (IG) for (int i = 0; i < (Is55H ? 3 : 1); i++) SawbonesHeals(Is55H ? 85f : 60f);
  1920.  
  1921.             //if (!PvP) if(!CT.InCombat) if (TD > 1.50f) if (!Buddy.CommonBot.Blacklist.Contains(CT.Guid)) { Buddy.CommonBot.Blacklist.Add(CT.Guid,BlacklistFlags.Kill,TimeSpan.FromSeconds(120)); return; }
  1922.  
  1923.             MercBuffSelf("Lucky Shots");
  1924.  
  1925.             if (MercCast("Distraction", TC && StrongOrGreater(CT))) return true;
  1926.             if (MercCast("Transquilizer", TC && StrongOrGreater(CT))) return true;
  1927.             if (MercCast("Dirty Kick", TC && StrongOrGreater(CT))) return true;
  1928.             if (MercCast("Slice Droid", TC && StrongOrGreater(CT))) return true;
  1929.  
  1930.             if (MercCast("Shrap Bomb", !CTDebuffs.Contains("Bleeding"))) return true;
  1931.             if (MercCast("Thermal Grenade")) return true;
  1932.             if (MercCast("Sabotage Charge")) return true;
  1933.  
  1934.             if (MercCast("Escape", Me.IsStunned)) return true;
  1935.  
  1936.             if (TD > 3.0f || !CT.InLineOfSight) return true;
  1937.             //MoveTo(CT, MeleeDist);
  1938.  
  1939.             if (MercCast("Cool Head", Me, RS <= 20f)) return true;
  1940.             if (HP <= 30f) UseMedPackInInventory();
  1941.  
  1942.             if (MyBuffs.Contains("Upper Hand"))
  1943.             {
  1944.                 //if (MercCast("Kolto Pack", Comp, CHP <= 70f)) return true;
  1945.                 if (MercCast("Pugnacity", StrongOrGreater(CT) || HP <= 70f)) return true;
  1946.                 if (MercFaceAndCast("Blaster Volley", TD <= 1.0f && (StrongOrGreater(CT)))) return true;
  1947.                 if (MercCast("Cull")) return true;
  1948.                 if (MercCast("Carbine Burst", TD<=1.0f)) return true;
  1949.             }
  1950.  
  1951.             if (TD <= MeleeDist)
  1952.             {
  1953.                 if (MercCast("Debilitate", StrongOrGreater(CT))) return true;
  1954.                 if (MercCast("Shiv")) return true;
  1955.                 if (MercCast("Back Blast")) return true;
  1956.                 if (MercCast("Dirty Kick")) return true;
  1957.                 if (MercCast("Sever Tendon")) return true;
  1958.                 if (MercCast("Blaster Whip")) return true;
  1959.                 if (MercCast("Sucker Punch")) return true;
  1960.             }
  1961.  
  1962.             if (MercCast("Vital Shot", !CTDebuffs.Contains("Vital Shot"))) return true;
  1963.  
  1964.             if (MercCast("Flash Grenade", TWR10 >= 2 || StrongOrGreater(CT))) return true;
  1965.  
  1966.             if (MercCast("Sabotage Charge")) return true;
  1967.             if (MercCast("Charged Burst")) return true;
  1968.             if (MercCast("Thermal Grenade")) return true;
  1969.             if (MercCast("Quickdraw")) return true;
  1970.             if (MercCast("Quick Shot")) return true;
  1971.             if (MercCast("Sweeping Gunfire", MobsInRangeOf(CT.Position, MeleeDist)>=2)) return true;
  1972.             if (MercCastOnGround("XS Freighter Flyby", MobsInRangeOf(CT.Position, .80f)>=3 || StrongOrGreater(CT), CT)) return true;
  1973.  
  1974.             if (MercCast("Flurry of Bolts")) return true;
  1975.  
  1976.             return false;
  1977.         }
  1978.  
  1979.         public static bool SniperCombat()
  1980.         {
  1981.             WaitForCast();
  1982.             datLCL = DateTime.Now;
  1983.             //using (BuddyTor.Memory.AcquireFrame()) { }
  1984.  
  1985.             //StopMoving();
  1986.             Thread.Sleep(300);
  1987.  
  1988.             LoadVars();
  1989.  
  1990.             //if (!ValidTarget()) return false;
  1991.            
  1992.             MercBuffSelf("Coordination");
  1993.             //MoveTo(CT, MySpec==SkillTreeId.SniperLethality?MeleeDist:2.80f);
  1994.  
  1995.             //if (!IG) if (CTT >= CombatToughness.Boss1) MoveIfNec(9.90f); else MoveIfNec();
  1996.  
  1997.             //if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  1998.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  1999.  
  2000.             if (CT == null) { Logger.Write("No target.  Exiting."); return false; }
  2001.  
  2002.             MoveTo(CT, 2.80f);
  2003.             if (!TargetInCombat()) return false;
  2004.  
  2005.             if (MercCast("Crouch", Me, !MyBuffs.Contains("Crouch")))Thread.Sleep(1000);
  2006.             if (!CT.InCombat)
  2007.             {
  2008.                 if (MercCast("Orbital Strike", MobsInRangeOf(CT.Position, .80f)>=4)) Thread.Sleep(850);
  2009.                 if (MercCast("Ambush")) Thread.Sleep(850);
  2010.                 if (MercCast("Followthrough")) Thread.Sleep(850);
  2011.                 if (MercCast("Snipe")) Thread.Sleep(850);
  2012.                 if (MercCast("Followthrough")) Thread.Sleep(850);
  2013.                 if (MercCast("Explosive Probe")) Thread.Sleep(850);
  2014.                 if (MercCast("Fragmentation Grenade")) Thread.Sleep(850);
  2015.                 return true;
  2016.             }
  2017.  
  2018.             if (StrongOrGreater(CT) && TC)
  2019.             {
  2020.                 if (MercCast("Flash Bang")) return true;
  2021.                 if (MercCast("Debilitate")) return true;
  2022.                 if (MercCast("Distraction")) return true;
  2023.                 if (MercCast("Leg Shot")) return true;
  2024.             }
  2025.  
  2026.             if (HP <= 30f) UseMedPackInInventory();
  2027.  
  2028.             if (MercCast("Adrenaline Probe", RS <= 20)) return true;
  2029.             if (MercCast("Shatter Shot", StrongOrGreater(CT) && !CTDebuffs.Contains("Armor Reduced (Physical)"))) return true;
  2030.             if (MercCast("Diversion", HP <= 70f && StrongOrGreater(CT) && TC)) return true;
  2031.             if (MercCast("EMP Discharge", HP <= 50f)) return true;
  2032.             if (MercCast("Shield Probe", !MyBuffs.Contains("Shield Probe"))) return true;
  2033.             if (MercCast("Entrench", HP <= 70f)) return true;
  2034.             if (MercCast("Ballistic Shield", HP <= 50f)) return true;
  2035.  
  2036.             if (MercCast("Takedown")) return true;
  2037.             if (MercCast("Headshot", CT.IsStunned)) return true;
  2038.             if (MercCast("Followthrough")) return true;
  2039.             if (MercCast("Cull")) return true;
  2040.             if (MercCast("Explosive Probe")) return true;
  2041.             if (MercCast("Snapshot", MyBuffs.Contains("Snap Shot"))) return true;
  2042.  
  2043.             if (MercCastOnGround("Suppressive Fire", MobsInRangeOf(CT.Position, .5f) >= 3, CT)) return true;
  2044.  
  2045.             if (TD <= MeleeDist)
  2046.             {
  2047.                 if (MercCast("Cover Pulse")) return true;
  2048.                 if (MercCast("Flash Bang")) return true;
  2049.                 if (MercCast("Shiv")) return true;
  2050.                 if (MercCast("Eviscerate")) return true;
  2051.                 if (MercCast("Ambush")) return true;
  2052.             }
  2053.             //if (UseMarksSurvRot)
  2054.             //{
  2055.  
  2056.             //    if (MercCast("Takedown")) return true;
  2057.             //    if (MercCast("Headshot")) return true;
  2058.             //    if (MercCast("Followthrough")) return true;
  2059.  
  2060.             //    if (MercCast("Evasion", HP <= 30f)) return true;
  2061.             //    if (MercCast("Shield Probe", HP <= 75f)) return true;
  2062.             //    if (MercCast("Countermeasures", MyBuffs.Contains("Shield Probe"))) return true;
  2063.             //    if (MercCast("Cover Pulse", TD <= MeleeDist)) return true;
  2064.             //    if (MercCast("Target Acquired", StrongOrGreater(CT) && THP >= 50f)) return true;
  2065.             //    if (MercCast("Laze Target", StrongOrGreater(CT) && THP >= 50f)) return true;
  2066.             //    if (MercCast("Adrenaline Probe", RS <= 50f)) return true;
  2067.             //    if (MercCast("Sniper Volley", HP <= 50f || RS <= 40f)) return true;
  2068.  
  2069.             //    if (MercCastOnGround("Orbital Strike", CTT >= CombatToughness.Boss1 && THP >= 30f, CT)) return true;
  2070.             //    if (MercCast("Fragmentation Grenade", TWR30 >= 3)) return true;
  2071.  
  2072.             //    if (MercCast("Distraction", TC && StrongOrGreater(CT))) return true;
  2073.             //    if (MercCast("Flash Bang", TWR5 >= 2)) return true;
  2074.             //    if (MercCast("Debilitate", TC)) return true;
  2075.  
  2076.             //    if (MercCast("Shiv", TD <= MeleeDist)) return true;
  2077.             //    if (MercCast("Eviscerate", TD <= MeleeDist)) return true;
  2078.  
  2079.             //    if (MercCast("Snipe", MyBuffs.Contains("Snap Shot"))) return true;
  2080.             //    if (MercCast("Shatter Shot", !CTDebuffs.Contains("Armor Reduced (Physical)") && StrongOrGreater(CT))) return true;
  2081.             //    if (MercCast("Takedown")) return true;
  2082.             //    if (MercCast("Ambush", MyBuffs.Contains("Reactive Shot"))) return true;
  2083.             //    if (MercCast("Followthrough")) return true;
  2084.             //    if (MercCast("Series of Shots")) return true;
  2085.             //    if (MercCast("Ambush", MyBuffs.Contains("Followthrough"))) return true;
  2086.             //    if (MercCast("Snipe", MyBuffs.Contains("Followthrough"))) return true;
  2087.             //    if (MercCast("Snipe", MyBuffs.Contains("Laze Target"))) return true;
  2088.             //    if (MercCast("Headshot")) return true;
  2089.             //    if (MercCast("Explosive Probe", StrongOrGreater(CT))) return true;
  2090.             //    if (MercCast("Corrosive Dart", !CTDebuffs.Contains("Poisoned (Tech)") && StrongOrGreater(CT))) return true;
  2091.             //    if (MercCast("Ambush")) return true;
  2092.             //    if (MercCast("Snipe")) return true;
  2093.  
  2094.             //    if (MercCast("Rifle Shot")) return true;
  2095.             //}
  2096.             //else
  2097.             //{
  2098.  
  2099.                 if (MercCastOnGround("Orbital Strike", !CT.CombatMoving && EliteOrGreater(CT), CT)) return true;
  2100.  
  2101.                 if (MercCast("Interrogation Probe", StrongOrGreater(CT) && !CTDebuffs.Contains("Interrogation Probe"))) return true;
  2102.                 if (MercCast("Sniper Volley", StrongOrGreater(CT))) return true;
  2103.                 if (MercCast("Series of Shots", StrongOrGreater(CT))) return true;
  2104.                 if (MercCast("Weakening Blast", StrongOrGreater(CT))) return true;
  2105.                 if (MercCast("Plasma Probe", MobsInRangeOf(CT.Position, .50f) >= 2)) return true;
  2106.                 if (MercCast("Corrosive Grenade", MobsInRangeOf(CT.Position, .50f) >= 2) && !CTDebuffs.Contains("Poison")) return true;
  2107.  
  2108.                 if (MercCast("Ambush", StrongOrGreater(CT))) return true;
  2109.                
  2110.                 if (MercCast("Fragmentation Grenade")) return true;
  2111.                 if (MercCast("Explosive Probe")) return true;
  2112.                 if (MercCastOnGround("Suppressive Fire", MobsInRangeOf(CT.Position, .50f) >= 3, CT)) return true;
  2113.                 if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Corrosive Dart", u, !u.HasDebuff("Poisoned (Tech)"))) WaitForCast();
  2114.                 //if (MercCast("Corrosive Dart", !CTDebuffs.Contains("Poisoned (Tech)"))) return true;
  2115.  
  2116.                 if (MercCast("Sniper Volley", HP <= 50 || RS <= 20 || StrongOrGreater(CT))) return true;
  2117.  
  2118.                 if (MercCast("Laze Target", StrongOrGreater(CT) && THP >= 50f)) return true;
  2119.                 if (MercCast("Target Acquired", StrongOrGreater(CT) && THP >= 50f)) return true;
  2120.                 if (MercCast("Debilitate", StrongOrGreater(CT))) return true;
  2121.                 if (MercCast("Leg Shot", StrongOrGreater(CT))) return true;
  2122.  
  2123.                 if (MercCast("Snipe", StrongOrGreater(CT))) return true;
  2124.  
  2125.                 if (MercCast("Snipe", CTDebuffs.Contains("Laze Target"))) return true;
  2126.                 if (MercCast("Series of Shots")) return true;
  2127.  
  2128.                 if (MercCast("Ambush")) return true;
  2129.                 if (MercCast("Snipe")) return true;
  2130.  
  2131.                 if (MercCast("Rifle Shot")) return true;
  2132.  
  2133.             //}
  2134.             ////Logger.Write(RS.ToString("0.0") + " Forced Cast:  Rifle Shot");
  2135.             ////Buddy.CommonBot.AbilityManager.Cast("Rifle Shot", CT);
  2136.             return false;
  2137.         }
  2138.  
  2139.         public static bool MarauderAnnihilationCombat()
  2140.         {
  2141.  
  2142.             //WaitForCast();
  2143.             datLCL = DateTime.Now;
  2144.  
  2145.             Thread.Sleep(100);
  2146.             LoadVars();
  2147.  
  2148.             if (!TargetInCombat()) return false;
  2149.  
  2150.             if (MercCast("Juyo Form", !MyBuffs.Contains("Juyo Form"))) return true;
  2151.             if (MercCast("Unnatural Might", Me, !MyBuffs.Contains("Unnatural Might"))) return true;
  2152.  
  2153.             MoveTo(CT, (float)(.490/Math.Min(1,CT.Scale)), "Force Charge", "Deadly Throw", "Dual Saber Throw", "Force Scream");
  2154.  
  2155.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2156.  
  2157.             //Thread.Sleep(100);
  2158.             if (MercCast("Unleash", BuddyTor.Me.IsStunned)) return true;
  2159.             if (MercCast("Disruption", TC)) return true;
  2160.  
  2161.             if (MercCast("Saber Ward", Me, HP <= 50f)) return true;
  2162.             if (MercCast("Undying Rage", Me, HP <= 20f)) return true;
  2163.             if (MercCast("Berserk", Me, MyBuffs.Contains("Fury") && HP <= 70)) return true;
  2164.  
  2165.             if (MercCast("Pommel Strike", CT.IsStunned)) return true;
  2166.  
  2167.             if (MercCast("Rupture")) return true;
  2168.             if (MercCast("Deadly Saber")) return true;
  2169.  
  2170.             if (HP <= 30f) UseMedPackInInventory();
  2171.  
  2172.             if (MercCast("Annihilate")) return true;
  2173.             if (MercCast("Ravage")) return true;
  2174.             if (MercCast("Retaliation")) return true;
  2175.             if (MercCast("Force Scream")) return true;
  2176.             if (MercCast("Vicious Slash")) return true;
  2177.             if (MercCast("Smash", TWR5 >= 2)) return true;
  2178.             if (MercCast("Intimidating Roar", TWR5 >= 4)) return true;
  2179.  
  2180.             if (HP <= 80f)
  2181.             {
  2182.                 if (MercCast("Frenzy", Me, !MyBuffs.Contains("Fury"))) return true;
  2183.                 if (MercCast("Cloak of Pain", Me)) return true;
  2184.                 if (MercCast("Obfuscate")) return true;
  2185.                 if (MercCast("Intimidating Roar")) return true;
  2186.                 if (MercCast("Deadly Throw")) return true;
  2187.                 if (MercCast("Force Choke", HP >= 40f)) return true;
  2188.             }
  2189.  
  2190.             if (MercCast("Bloodthirst", Me)) return true;
  2191.             if (MercCast("Smash", TWR5 >= 2)) return true;
  2192.             if (MercCast("Force Scream")) return true;
  2193.             if (MercCast("Annihilate")) return true;
  2194.             if (MercCast("Sweeping Slash", TWR10 >= 4)) return true;
  2195.             if (MercCast("Battering Assault")) return true;
  2196.  
  2197.             if (MercCast("Vicious Throw", THP <= 30f)) return true;
  2198.  
  2199.             if (MercCast("Assault")) return true;
  2200.  
  2201.             return false;
  2202.         }
  2203.  
  2204.         // For Hybrid Trees - Covers It ALL
  2205.  
  2206.         public static bool MarauderCombat()
  2207.         {
  2208.  
  2209.             WaitForCast();
  2210.             datLCL = DateTime.Now;
  2211.  
  2212.             //Thread.Sleep(450);
  2213.             LoadVars();
  2214.  
  2215.             MoveTo(CT, MeleeDist);
  2216.             StopMoving();
  2217.  
  2218.             if (!TargetInCombat()) return false;
  2219.  
  2220.             if (MercBuffSelf("Ataru Form", MySpec==SkillTreeId.MarauderCarnage)) return true;
  2221.             if (MercBuffSelf("Juyo Form", MySpec == SkillTreeId.MarauderAnnihilation)) return true;
  2222.             if (MercBuffSelf("Shii-Cho Form", MySpec == SkillTreeId.MarauderRage)) return true;
  2223.  
  2224.             if (MercCast("Unnatural Might", Me, !MyBuffs.Contains("Unnatural Might"))) return true;
  2225.  
  2226.             //MoveTo(CT, 2.8f);
  2227.  
  2228.             if (MercCast("Predation", TD >= 1.5f)) return true;
  2229.             if (MercCast("Force Charge", TD >= 1.0f && TD <= 3.0f)) return true;
  2230.             if (MercCast("Deadly Throw", TD>=1.0f && TD<=3.0f)) return true;
  2231.  
  2232.             //Thread.Sleep(100);
  2233.             if (MercCast("Unleash", BuddyTor.Me.IsStunned)) return true;
  2234.            
  2235.             if (MercCast("Disruption", TC && StrongOrGreater(CT))) return true;
  2236.             if (MercCast("Intimidating Roar", TC && StrongOrGreater(CT))) return true;
  2237.             if (MercCast("Dual Saber Throw", TC && StrongOrGreater(CT))) return true; // Force Choke WILL NOT WORK on all Elites (See Oricon)
  2238.             if (MercCast("Force Choke", TC && StrongOrGreater(CT))) return true;
  2239.  
  2240.             ///HandleDebuffs();
  2241.  
  2242.             if (HP <= 30f) UseMedPackInInventory();
  2243.  
  2244.             if (MercCast("Frenzy", Me, HP <= 50f)) return true;
  2245.             if (MercCast("Saber Ward", Me, HP <= 50f)) return true;
  2246.             if (MercCast("Undying Rage", Me, HP <= 20f)) return true;
  2247.             if (MercCast("Berserk", Me, HP <= 70)) return true;
  2248.             //if (MercCast("Unity", Me, HP <= 40f)) return true;
  2249.  
  2250.             if (MercCast("Pommel Strike", CT.IsStunned)) return true;
  2251.  
  2252.             if (MercCast("Rupture")) return true;
  2253.             if (MercCast("Deadly Saber")) return true;
  2254.             //if (MercCast("Berserk")) return true;
  2255.  
  2256.             if (HP <= 30f) UseMedPackInInventory();
  2257.  
  2258.             if (MercCast("Vicious Throw", THP <= 30f)) return true;
  2259.  
  2260.             if (MercCast("Smash", TWR5 >= 2 || StrongOrGreater(CT))) return true;
  2261.  
  2262.             if (MercCast("Force Scream")) return true;
  2263.             if (MercCast("Annihilate")) return true;
  2264.             if (MercCast("Obliterate")) return true;
  2265.             if (MercCast("Force Crush")) return true;
  2266.             if (MercCast("Ravage")) return true;
  2267.             if (MercCast("Gore")) return true;
  2268.             if (MercCast("Vicious Slash")) return true;
  2269.             if (MercCast("Battering Assault")) return true;
  2270.  
  2271.             if (MercCast("Force Scream")) return true;
  2272.             if (MercCast("Retaliation")) return true;
  2273.             if (MercCast("Vicious Slash")) return true;
  2274.             if (MercCast("Battering Assault")) return true;
  2275.             if (MercCast("Intimidating Roar", TWR5 >= 4)) return true;
  2276.             if (MercCast("Sweeping Slash", TWR5 >= 3)) return true;
  2277.  
  2278.             if (MercCast("Frenzy", Me, HP<=80f && !MyBuffs.Contains("Fury"))) return true;
  2279.             if (MercCast("Cloak of Pain", Me, HP <= 80f)) return true;
  2280.             if (MercCast("Obfuscate", HP <= 80f)) return true;
  2281.             if (MercCast("Intimidating Roar", HP <= 80f)) return true;
  2282.             if (MercCast("Deadly Throw", HP <= 80f)) return true;
  2283.  
  2284.             if (MercCast("Bloodthirst", Me)) return true;
  2285.             if (MercCast("Force Scream")) return true;
  2286.             if (MercCast("Massacre")) return true;
  2287.  
  2288.             if (MercCast("Assault")) return true;
  2289.  
  2290.             Buddy.CommonBot.AbilityManager.Cast("Assault", CT);
  2291.  
  2292.             return false;
  2293.         }
  2294.  
  2295.         public static void MarauderRageCombat()
  2296.         {
  2297.  
  2298.             WaitForCast();
  2299.             datLCL = DateTime.Now;
  2300.  
  2301.             Thread.Sleep(100);
  2302.             LoadVars();
  2303.  
  2304.             if (MercCast("Shii-Cho Form", !MyBuffs.Contains("Shii-Cho Form"))) return;
  2305.             if (MercCast("Unnatural Might", !MyBuffs.Contains("Unnatural Might"))) return;
  2306.  
  2307.             if (MercCast("Unleash", BuddyTor.Me.IsStunned)) return;
  2308.  
  2309.             if (MercCast("Saber Ward", HP <= 50f)) return;
  2310.             if (MercCast("Undying Rage", HP <= 20f)) return;
  2311.             if (MercCast("Berserk", Me, MyBuffs.Contains("Fury") && HP <= 70)) return;
  2312.  
  2313.             if (MercCast("Predation", Me)) return;
  2314.             if (MercCast("Bloodthirst", Me, HP > 70)) return;
  2315.  
  2316.             if (MercCast("Cloak of Pain", Me)) return;
  2317.             if (MercCast("Obfuscate")) return;
  2318.  
  2319.             if (!TargetInCombat()) return;
  2320.  
  2321.             if (TD >= MeleeDist && TD <= 3.0f) if (MercCast("Force Charge")) return;
  2322.  
  2323.             MoveTo(CT, MeleeDist, "Force Charge");
  2324.             StopMoving();
  2325.             //if (!IG) MoveIfNec(.49f);
  2326.  
  2327.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2328.  
  2329.             //Thread.Sleep(100);
  2330.             if (MercCast("Disruption", TC)) return;
  2331.  
  2332.             ///HandleDebuffs();
  2333.  
  2334.             if (MercCast("Smash", MyBuffs.Contains("Dominate") || HaveBuffStacks("Shockwave", 4))) return;
  2335.             if (MercCast("Frenzy", Me, !MyBuffs.Contains("Fury") && StrongOrGreater(CT))) return;
  2336.             if (MercCast("Force Crush", StrongOrGreater(CT))) return;
  2337.             if (MercCast("Rupture")) return;
  2338.             if (MercCast("Intimidating Roar", TWR10 >= 2)) return;
  2339.  
  2340.             if (MercCast("Force Choke")) return;
  2341.             if (MercCast("Obliterate")) return;
  2342.             if (MercCast("Vicious Throw", THP <= 30f)) return;
  2343.             if (MercCast("Pommel Strike", CT.IsStunned)) return;
  2344.  
  2345.             if (MercCast("Battering Assault")) return;
  2346.  
  2347.             //if (MercCast("Annihilate")) return;
  2348.             if (MercCast("Force Scream")) return;
  2349.  
  2350.             if (MercCast("Deadly Throw")) return;
  2351.  
  2352.             if (MercCast("Deadly Saber")) return;
  2353.             if (MercCast("Predation", MyBuffs.Contains("Fury") && HP < 50) && !MyBuffs.Contains("Predation")) return;
  2354.             if (MercCast("Bloodthirst", MyBuffs.Contains("Fury") && HP > 50) && !MyBuffs.Contains("Bloodthirst")) return;
  2355.  
  2356.             if (MercCast("Retaliation")) return;
  2357.             if (MercCast("Ravage")) return;
  2358.  
  2359.             if (MercCast("Deadly Throw")) return;
  2360.  
  2361.             if (MercCast("Bloodthirst")) return;
  2362.  
  2363.             if (MercCast("Vicious Slash")) return;
  2364.             if (MercCast("Assault")) return;
  2365.  
  2366.         }
  2367.  
  2368.         public static bool SageCombat()
  2369.         {
  2370.  
  2371.             Thread.Sleep(200);
  2372.             WaitForCast();
  2373.             datLCL = DateTime.Now;
  2374.  
  2375.             LoadVars();
  2376.  
  2377.             if (MercCast("Noble Sacrifice", Me, HP >= 30f && (Me.ForcePercent<= 25f || Me.Force<=Me.ForceMax*.30f))) return true;
  2378.             if (HP <= 50f && EP >= 10f) MercCastOnGround("Salvation", true, Me);
  2379.  
  2380.             // Redundant, most of the time it won't proc like it should
  2381.             if (MercCast("Noble Sacrifice", HP >= 30f && (Me.ForcePercent <= 50f || Me.Force <= Me.ForceMax * .50f))) return true;
  2382.             if (MercCast("Noble Sacrifice", HP >= 30f && (Me.ForcePercent <= 50f || Me.Force <= Me.ForceMax * .50f))) return true;
  2383.             if (MercCast("Noble Sacrifice", HP >= 30f && (Me.ForcePercent <= 50f || Me.Force <= Me.ForceMax * .50f))) return true;
  2384.  
  2385.             if (CT !=null && TC && StrongOrGreater(CT))
  2386.             {
  2387.                 if (MercCast("Force Stun", TC)) return true;
  2388.                 if (MercCast("Mind Snap", TC)) return true;
  2389.                 if (MercCast("Mental Alacrity")) return true;
  2390.             }
  2391.  
  2392.             if (HP <= 30f) UseMedPackInInventory();
  2393.             if (HP <= 70f)
  2394.             {
  2395.                 Thread.Sleep(300);
  2396.                 if (MercCast("Cloud Mind", HP <= 70f)) return true;
  2397.                 if (MercCast("Restoration", NeedsDispell(Me))) return true;
  2398.                 if (MercCast("Force Mend", HP <= 70f)) return true;
  2399.                 if (MercCastOnGround("Salvation", HP <= 50f && !MyBuffs.Contains("Salvation"), Me)) return true;
  2400.                 if (MercCast("Rejuvenate", HP <= 70f && !MyBuffs.Contains("Rejuvenate"))) return true;
  2401.                 if (MercCast("Mental Alacrity", HP <= 50f)) return true;
  2402.                 if (MercCast("Benevolence", HP <= 50f)) return true;
  2403.                 return true;
  2404.             }
  2405.  
  2406.             if (IG && MySpec == SkillTreeId.SageSeer)
  2407.             {
  2408.                 for (int i = 0; i < (Is55H ? 3 : 1); i++) SeerHeals(Is55H?85f:75f);
  2409.                 MercCast("Telekinetic Throw", Me.ForcePercent <= 30f);
  2410.                 MercCast("Forcequake", Me.ForcePercent <= 30f);
  2411.             }
  2412.             else if (SeerHeals(60f)) return true;
  2413.             if (!IG && SeerCheckCompHealth()) return true;
  2414.  
  2415.             MoveTo(CT, 2.8f, "Force Speed");
  2416.             if (!TargetInCombat()) return false;
  2417.  
  2418.             if (MySpec == SkillTreeId.SageSeer) foreach (TorCharacter u in Attackers) if (MercCast("Weaken Mind", u, !u.HasDebuff("Weaken Mind (Force)"))) { Thread.Sleep(800); break; }
  2419.             if (MercCast("Force Valor", !MyBuffs.Contains("Force Valor"))) return true;
  2420.  
  2421.             StopMoving();
  2422.             //if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2423.  
  2424.             if (MercCast("Force of Will", Me.IsStunned)) return true;
  2425.             if (MercCast("Force Potency", HP <= 50f)) return true;
  2426.             if (MercCast("Mind Crush", StrongOrGreater(CT))) return true;
  2427.  
  2428.             if (MercBuffSelf("Force Armor")) return true;
  2429.  
  2430.             try { var CompX = Comp; if (MercCast("Force Armor", CompX, CompX != null && !CompX.HasBuff("Force Armor"))) return true; }
  2431.             catch { }
  2432.  
  2433.             if (MercCastOnGround("Forcequake", (!IG && MobsInRangeOf(CT.Position, .80f) >= 3) || (IG && MobsInRangeOf(CT.Position, .80f) >= 6), CT)) return true;
  2434.  
  2435.             if (MercCast("Telekinetic Throw", MyBuffs.Contains("Psychic Projection"))) return true;
  2436.             if (MercCast("Telekinetic Wave", MyBuffs.Contains("Tidal Force") || (!IG && !CT.InCombat && !Me.InCombat) || MyBuffs.Contains("Mental Alacrity") )) return true;
  2437.             if (MercCastOnGround("Force in Balance", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .80f) >= 2, CT)) return true;
  2438.             if (MercCast("Project")) return true;
  2439.             if (MercCastOnGround("Forcequake", MyAbilities.Contains("Tidal Force") && MobsInRangeOf(CT.Position, .80f) >= 4, CT)) return true;
  2440.             if (MercCast("Disturbance", MyAbilities.Contains("Tidal Force") || !CT.InCombat || MyBuffs.Contains("Presence of Mind"))) return true;
  2441.  
  2442.             if (!CT.InCombat)
  2443.             {
  2444.                 if (MercCast("Mind Crush")) Thread.Sleep(500);
  2445.                 if (MercCast("Disturbance")) Thread.Sleep(500);
  2446.             }
  2447.             if (MercFaceAndCast("Force Wave", StrongOrGreater(CT) && TD <= MeleeDist)) return true;
  2448.  
  2449.             //if (MercCast("Deliverance", BuddyTor.Me, HP <= 70f)) return true;
  2450.             if (TD <= MeleeDist)
  2451.             {
  2452.                 if (MercCast("Force Wave", TD <= MeleeDist)) return true;
  2453.                 if (MercCast("Tumult")) return true;
  2454.             }
  2455.  
  2456.             //if (MercCast("Heroic Moment: Channel the Force", Me.HealthPercent <= 30f)) return true;
  2457.  
  2458.             if (MercCast("Force Potency", Me.ForcePercent <= 50f || StrongOrGreater(CT))) return true;
  2459.             if (MercCastOnGround("Force in Balance", MobsInRangeOf(CT.Position, .80f) >= 2, CT)) return true;
  2460.             if (MercCastOnGround("Forcequake", (!IG && MobsInRangeOf(CT.Position, .80f) >= 3) || (IG && MobsInRangeOf(CT.Position, .80f) >= 6), CT)) return true;
  2461.  
  2462.             //if (MercCast("Turbulence", CTDebuffs.Contains("Weaken Mind"))) return true;
  2463.  
  2464.             if (!IG || Me.ForcePercent > 30f)
  2465.             {
  2466.  
  2467.                 if (MercCast("Weaken Mind", !CTDebuffs.Contains("Weaken Mind (Force)"))) return true;
  2468.                 //if (MercCast("Force Stun", StrongOrGreater(CT))) return true;
  2469.                 if (MercCast("Force Slow", StrongOrGreater(CT) && !CTDebuffs.Contains("Slowed (Force)"))) return true;
  2470.  
  2471.                 if (MercCast("Telekinetic Throw")) return true;
  2472.                 if (MercCast("Disturbance")) return true;
  2473.                 if (MercCastOnGround("Forcequake", MobsInRangeOf(CT.Position, .80f) >= 3, CT)) return true;
  2474.             }
  2475.  
  2476.             if (MercCast("Double Strike")) return true;
  2477.             if (MercCast("Saber Strike")) return true;
  2478.  
  2479.             return false;
  2480.         }
  2481.  
  2482.         public static void MadnessCombat()
  2483.         {
  2484.  
  2485.             WaitForCast();
  2486.             datLCL = DateTime.Now;
  2487.  
  2488.             Thread.Sleep(200);
  2489.             LoadVars();
  2490.             if (!TargetInCombat()) return;
  2491.  
  2492.             if (MercCast("Mark of Power", !MyBuffs.Contains("Mark of Power"))) return;
  2493.             if (!IG) MoveTo(CT, 2.8f, "Force Speed");
  2494.             //if (!IG) MoveIfNec(.49f);
  2495.  
  2496.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2497.  
  2498.             if (MercCast("Unbreakable Will", Me.IsStunned)) return;
  2499.  
  2500.             if (MercCastOnGround("Death Field", HP <= 50 || StrongOrGreater(CT), CT)) return;
  2501.  
  2502.             if (MercCast("Affliction", !CTDebuffs.Contains("Affliction (Force)"))) return;
  2503.             if (MercCast("Creeping Terror")) return;
  2504.  
  2505.             if (MercCast("Static Barrier", Me, !MyBuffs.Contains("Static Barrier"))) return;
  2506.             if (MercCast("Unnatural Preservation", Me, HP <= 70f)) return;
  2507.             if (MercCast("Dark Heal", Me, HP <= 70f)) return;
  2508.             if (MercCast("Dark Infusion", Me, HP <= 70f)) return;
  2509.             if (MercCast("Cloud Mind", Me, CTT != CombatToughness.Player && HP <= 70f)) return;
  2510.  
  2511.             if (CorruptionCheckCompHealth()) return;
  2512.  
  2513.             if (MercCast("Recklessness", Me.ForcePercent <= 50f)) return;
  2514.             //if (MercCast("Heroic Moment:  Channel the Force", Me.ForcePercent <= 30f)) return;
  2515.  
  2516.             if (MercCast("Crushing Darkness", StrongOrGreater(CT) && !CTDebuffs.Contains("Crushing Darkness (Force)"))) return;
  2517.  
  2518.             if (MercCast("Consumption", HP > 50 && Me.ForcePercent <= 20)) return;
  2519.             //if (SeerHeals(75f)) return;
  2520.  
  2521.             if (TD <= MeleeDist)
  2522.             {
  2523.                 if (MercCast("Overload", TD <= MeleeDist)) return;
  2524.                 if (MercCast("Tumult")) return;
  2525.                 //if (MercCast("Double Strike")) return;
  2526.             }
  2527.  
  2528.             if (!IG || Me.ForcePercent > 30f)
  2529.             {
  2530.  
  2531.                 if (MercCast("Electrocute", (TC || TD <= .5f) && StrongOrGreater(CT))) return;
  2532.  
  2533.                 if (MercCast("Jolt", TC && StrongOrGreater(CT))) return;
  2534.                 if (MercCast("Shock", TC && StrongOrGreater(CT))) return;
  2535.  
  2536.                 if (MercCastOnGround("Death Field", StrongOrGreater(CT) || TWR30 >= 3, CT)) return;
  2537.  
  2538.                 if (MercCast("Force Slow", StrongOrGreater(CT) && !CTDebuffs.Contains("Slow (Force)"))) return;
  2539.  
  2540.                 if (MercCastOnGround("Force Storm", TWR30 >= 3, CT)) return;
  2541.                 if (MercCast("Force Lightning")) return;
  2542.  
  2543.             }
  2544.  
  2545.             if (MercCast("Saber Strike")) return;
  2546.  
  2547.         }
  2548.  
  2549.         public static bool SorcererCombat()
  2550.         {
  2551.  
  2552.             Thread.Sleep(200);
  2553.             WaitForCast();
  2554.             datLCL = DateTime.Now;
  2555.  
  2556.             LoadVars();
  2557.  
  2558.             if (MercCast("Unbreakable Will", Me.IsStunned)) return true;
  2559.             if (MercCast("Consumption", Me, HP > 30 && (Me.ForcePercent <= 25f || Me.Force<Me.ForceMax*.50f))) return true;
  2560.             if (MercBuffSelf("Mark of Power")) return true;
  2561.             if (MercCast("Static Barrier", Me, !MyBuffs.Contains("Static Barrier"))) ;// return true;
  2562.  
  2563.             if (MercCast("Force Barrier", Me, HP<=25f)) ;// return true;
  2564.  
  2565.             if (HP <= 70f) {
  2566.                 if (HP <= 30f) UseMedPackInInventory();
  2567.                 if (MercCast("Cloud Mind", HP <= 60f)) return true;
  2568.                 MercCast("Purge", Me, NeedsDispell(Me));
  2569.                 MercCast("Unnatural Preservation", BuddyTor.Me, HP <= 70f);
  2570.                 MercCast("Dark Heal", Me, HP <= 70f);
  2571.                 //if (MercCast("Dark Infusion", BuddyTor.Me, HP <= 70f)) return true;
  2572.             }
  2573.  
  2574.             if (IG && MySpec == SkillTreeId.SorcererCorruption && IG)
  2575.             {
  2576.                 for (int i = 0; i < (Is55H?3:1); i++) { CorruptionHeals(Is55H ? 85f : 75f); }
  2577.                 if (EP <= 90f && Is55H) return MercCast("Force Lightning");
  2578.             }
  2579.             if (IG && MySpec != SkillTreeId.SorcererCorruption && CorruptionHeals(65f)) return true;
  2580.  
  2581.             if (CorruptionCheckCompHealth()) return true;
  2582.  
  2583.             if (!TargetInCombat()) return false;
  2584.             MoveTo(CT, 2.90f, "Force Speed");
  2585.             StopMoving();
  2586.  
  2587.             if (MercCast("Electrocute", TC && StrongOrGreater(CT))) return true;
  2588.             if (MercCast("Jolt", TC && StrongOrGreater(CT))) return true;
  2589.             if (MercCast("Overload", TC && StrongOrGreater(CT) && TD <= 1.0f)) return true;
  2590.             if (MercCast("Creeping Terror", TC && StrongOrGreater(CT))) return true;
  2591.             if (MercCastOnGround("Force Storm", MobsInRangeOf(CT.Position, .80f) >= 5, CT)) return true;
  2592.  
  2593.             if (MercCast("Recklessness", Me, EP <= 20f || EliteOrGreater(CT))) ;// return true;
  2594.             if (MercCast("Polarity Shift", Me, EP <= 20f || EliteOrGreater(CT))) ;// return true;
  2595.  
  2596.             if (MercCastOnGround("Death Field", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .80f) >= 3, CT)) return true;
  2597.  
  2598.             if (MercCast("Crushing Darkness", StrongOrGreater(CT) && !CTDebuffs.Contains("Crushing Darkness")
  2599.                 && (!MyAbilities.Contains("Wrath") || MyBuffs.Contains("Polarity Shift") || MyBuffs.Contains("Wrath")))) return true;
  2600.             if (MercCast("Lightning Strike", MyBuffs.Contains("Wrath"))) return true;
  2601.  
  2602.             if (MercCast("Chain Lightning", StrongOrGreater(CT) && MyBuffs.Contains("Lightning Storm"))) return true;
  2603.             if (MercCast("Force Lightning", StrongOrGreater(CT) && MyBuffs.Contains("Lightning Barrage"))) return true;
  2604.             if (MercCast("Thundering Blast", StrongOrGreater(CT) && CTDebuffs.Contains("Affliction"))) return true;
  2605.             if (MercCast("Chain Lightning", MyBuffs.Contains("Polarity Shift") || MobsInRangeOf(CT.Position, .80f) >= 4)) return true;
  2606.            
  2607.             if (MercCast("Creeping Terror", StrongOrGreater(CT))) return true;
  2608.             if (MercCast("Shock")) return true;
  2609.  
  2610.             if (MercCast("Force Lightning", EP <= 30f)) return true;
  2611.  
  2612.             if (TD <= MeleeDist)
  2613.             {
  2614.                 if (MercCast("Overload", TD <= MeleeDist)) return true;
  2615.                 if (MercCast("Tumult")) return true;
  2616.             }
  2617.  
  2618.             if (MercCastOnGround("Force Storm", MobsInRangeOf(CT.Position, .80f) >= (IG ? 5 : 2), CT)) return true;
  2619.  
  2620.             if (MercCast("Affliction", !CTDebuffs.Contains("Affliction (Force)"))) return true;
  2621.  
  2622.             if (MercCast("Force Slow", StrongOrGreater(CT) && !CTDebuffs.Contains("Slow (Force)"))) return true;
  2623.             if (MercCast("Force Lightning", MySpec==SkillTreeId.SorcererCorruption || (MyAbilities.Contains("Wrath") && !MyBuffs.Contains("Wrath")))) return true;
  2624.             if (MercCast("Lightning Strike", MyAbilities.Contains("Forked Lightning") || MyAbilities.Contains("Lightning Storm"))) return true;
  2625.             if (MercCast("Crushing Darkness", StrongOrGreater(CT) && !CTDebuffs.Contains("Crushing Darkness (Force)"))) return true;
  2626.  
  2627.             if (MercCast("Force Lightning")) return true;
  2628.  
  2629.             if (!IG || (IG && EP >= 50f)) foreach (TorCharacter u in Attackers) if (MercCast("Affliction", u, !u.HasDebuff("Affliction (Force)"))) break; ;
  2630.  
  2631.             if (MercCast("Saber Strike")) return true;
  2632.             return false;
  2633.         }
  2634.  
  2635.         public static bool CorruptionCombat()
  2636.         {
  2637.             try
  2638.             {
  2639.                 WaitForCast();
  2640.                 datLCL = DateTime.Now;
  2641.  
  2642.                 Thread.Sleep(200);
  2643.                 LoadVars();
  2644.  
  2645.                 if (MercCast("Mark of Power", Me, !MyBuffs.Contains("Mark of Power"))) return true;
  2646.  
  2647.                 if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2648.  
  2649.                 if (MercCast("Unbreakable Will", Me.IsStunned)) return true;
  2650.  
  2651.                 if (MercCast("Static Barrier", Me, !MyBuffs.Contains("Static Barrier"))) return true;
  2652.  
  2653.                 if (MercCast("Force Barrier", Me, HP <= 30f)) return true;
  2654.                 if (MercCast("Resurgence", Me, !MyBuffs.Contains("Resurgence") && HP <= 70f)) return true;
  2655.                 if (MercCast("Unnatural Preservation", Me, HP <= 70f)) return true;
  2656.                 if (MercCastOnGround("Revivification", HP <= 70f, Me)) return true;
  2657.                 if (MercCast("Dark Heal", Me, HP <= 70f)) return true;
  2658.                 if (MercCast("Dark Infusion", Me, HP <= 70f)) return true;
  2659.                 if (MercCast("Purge", Me, Me.Debuffs.Count() >= 3)) return true;
  2660.  
  2661.                 if (!IG) if (CorruptionCheckCompHealth()) return true;
  2662.                 if (IG && MySpec==SkillTreeId.SorcererCorruption) if (CorruptionHeals(85f)) return true;
  2663.  
  2664.                 if (!TargetInCombat()) return false;
  2665.  
  2666.                 MoveTo(CT, 2.8f); ;
  2667.  
  2668.                 if (MercCast("Electrocute", TC && StrongOrGreater(CT))) return true;
  2669.                 if (MercCast("Jolt", TC && StrongOrGreater(CT))) return true;
  2670.                 if (MercCast("Shock", TC && StrongOrGreater(CT))) return true;
  2671.  
  2672.                 if (MercCast("Consumption", HP > 50 && Me.ForcePercent <= 20)) return true;
  2673.  
  2674.                 if (MercFaceAndCast("Overload", TD <= MeleeDist)) return true;
  2675.                 if (MercCast("Tumult", TD <= MeleeDist)) return true;
  2676.  
  2677.                 if (!IG || MySpec!=SkillTreeId.SorcererCorruption || Me.ForcePercent > 30f)
  2678.                 {
  2679.  
  2680.                     if (MercCast("Cloud Mind", CTT != CombatToughness.Player && HP <= 70f)) return true;
  2681.                     if (MercCast("Recklessness", Me, !IG && StrongOrGreater(CT))) return true;
  2682.  
  2683.                     if (MercCastOnGround("Death Field", MobsInRangeOf(CT.Position, .8f) >= 4, CT)) return true;
  2684.                     if (MercCastOnGround("Force Storm", MobsInRangeOf(CT.Position, .80f) >= 4, CT)) return true;
  2685.                     if (MercCast("Chain Lightning", MobsInRangeOf(CT.Position, .8f) >= 4)) return true;
  2686.  
  2687.                     if (MercCast("Recklessness", Me.ForcePercent <= 50f)) return true;
  2688.                     //if (MercCast("Heroic Moment: Channel the Force", Me.ForcePercent <= 30f)) return true;
  2689.  
  2690.                     if (MercCast("Creeping Terror", StrongOrGreater(CT) && !CTDebuffs.Contains("Creeping Terror"))) return true;
  2691.                     if (MercCast("Shock")) return true;
  2692.  
  2693.                     if (MercCast("Lightning Strike", MyBuffs.Contains("Wrath"))) return true;
  2694.                     if (MercCast("Force Lightning")) return true;
  2695.  
  2696.                     if (MercCast("Crushing Darkness", StrongOrGreater(CT) && !CTDebuffs.Contains("Crushing Darkness (Force)"))) return true;
  2697.                     if (MercCast("Affliction", !CTDebuffs.Contains("Affliction"))) return true;
  2698.                     if (MercCast("Force Slow", StrongOrGreater(CT) && !CTDebuffs.Contains("Slow (Force)"))) return true;
  2699.                 }
  2700.  
  2701.                 //if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Affliction", u, !u.HasDebuff("Affliction (Force)"))) Thread.Sleep(400);
  2702.  
  2703.                 if (MercCast("Thrash", TD <= MeleeDist)) return true;
  2704.                 if (MercCast("Saber Strike", TD <= MeleeDist)) return true;
  2705.                 if (MercCast("Lightning Strike")) return true;
  2706.                 //Buddy.CommonBot.AbilityManager.Cast("Force Lightning", CT);   // Forced Cast - CanCast gets just a little flaky
  2707.             }
  2708.             catch { }
  2709.             return false;
  2710.         }
  2711.  
  2712.         public static void CorruptionCombatPvP()
  2713.         { // Tried and tried on this - BW seems just about uselesss with it due to all of the bugs and hangs.....  With PVP.
  2714.                 try
  2715.                 {
  2716.                     Thread.Sleep(300);
  2717.  
  2718.                     IG = true;
  2719.  
  2720.                     if (Me.IsDead || Me.HealthPercent < .2f) return;
  2721.  
  2722.                     WaitForCast();
  2723.                     datLCL = DateTime.Now;
  2724.  
  2725.                     CT = Me.CurrentTarget;
  2726.                     if (CT == null) return;
  2727.                     TD = CT.Distance;
  2728.                     if (TD >= 3.0f) return;
  2729.                     HP = Me.HealthPercent;
  2730.                     RS = Me.ResourceStat;
  2731.  
  2732.                     MyBuffs = "";
  2733.                     foreach (TorEffect te in Me.Buffs) MyBuffs += te.Name + ";";
  2734.                     CTDebuffs = "";
  2735.                     if (CT != null) foreach (TorEffect te in CT.Debuffs) CTDebuffs += te.Name + ";";
  2736.  
  2737.                     MySpec = SkillTreeId.SorcererCorruption;
  2738.  
  2739.                     if (TD <= MeleeDist)
  2740.                     {
  2741.                         if (MercCast("Overload", TD <= MeleeDist)) return;
  2742.                         if (MercCast("Tumult")) return;
  2743.                         if (MercCast("Electrocute")) return;
  2744.                     }
  2745.  
  2746.                     if (MercCast("Mark of Power", !MyBuffs.Contains("Mark of Power"))) return;
  2747.                     if (!IG) MoveTo(CT, 2.8f, "Force Speed");
  2748.  
  2749.                     if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  2750.                     if (MercCast("Static Barrier", Me, !MyBuffs.Contains("Static Barrier"))) return;
  2751.  
  2752.                     if (MercCast("Unbreakable Will", Me.IsStunned)) return;
  2753.  
  2754.                     if (MercCast("Unnatural Preservation", Me, HP <= 70f)) return;
  2755.                     if (MercCast("Resurgence", Me, MyBuffs.Contains("Resurgence") && HP <= 70f)) return;
  2756.                     if (MercCast("Dark Infusion", Me, HP <= 70f)) return;
  2757.                     if (MercCast("Dark Heal", Me, HP <= 70f)) return;
  2758.  
  2759.                     if (CorruptionHeals(80f)) return;
  2760.  
  2761.                     if (MercCast("Recklessness", Me, !IG && StrongOrGreater(CT))) return;
  2762.  
  2763.                     if (MercCast("Recklessness", Me.ForcePercent <= 50f)) return;
  2764.                     //if (MercCast("Heroic Moment: Channel the Force", Me.ForcePercent <= 30f)) return;
  2765.  
  2766.                     if (MercCast("Consumption", HP > 50 && Me.ForcePercent <= 20)) return;
  2767.  
  2768.                     if (TD <= MeleeDist)
  2769.                     {
  2770.                         if (MercCast("Overload", TD <= MeleeDist)) return;
  2771.                         if (MercCast("Tumult")) return;
  2772.                     }
  2773.  
  2774.                     if (!IG || Me.ForcePercent > 30f)
  2775.                     {
  2776.  
  2777.                         if (MercCast("Electrocute", (TC || TD <= .5f) && StrongOrGreater(CT))) return;
  2778.                         if (MercCast("Jolt", TC && StrongOrGreater(CT))) return;
  2779.  
  2780.                         if (MercCast("Affliction", !CTDebuffs.Contains("Affliction"))) return;
  2781.                         if (MercCast("Shock")) return;
  2782.  
  2783.                         if (MercCast("Force Slow", StrongOrGreater(CT) && !CTDebuffs.Contains("Slow (Force)"))) return;
  2784.                     }
  2785.                     if (MercCast("Force Lightning")) return;
  2786.  
  2787.                     if (MercCast("Thrash", TD <= MeleeDist)) return;
  2788.                     if (MercCast("Saber Strike", TD <= MeleeDist)) return;
  2789.                 }
  2790.                 catch { }
  2791.                 if (DateTime.Now.Subtract(datLCs).TotalSeconds >= 4) MercForcedCast("Lightning Strike", CT);
  2792.         }
  2793.  
  2794.         public static bool WatchmanCombatPvP()
  2795.         {
  2796.             try
  2797.             {
  2798.                 CheckGC();
  2799.                 Thread.Sleep(150);
  2800.                 if (IAmDead()) { BuddyTor.Me.ClearTarget(); return false; }
  2801.  
  2802.                 var x = BuddyTor.Me.CurrentTarget;
  2803.                 if (x == null) return false;
  2804.                 //x = (TorCharacter)x;
  2805.                 //WaitForCast();
  2806.  
  2807.                 if (MercCastX("Force Leap", x)) return true;
  2808.                 if (MercCastX("Crippling Throw", x)) return true;
  2809.  
  2810.                 while (x.Distance >= MeleeDist || !x.InLineOfSight) {
  2811.                     if (IAmDead()) return false;
  2812.                     Buddy.Swtor.Input.MoveTo(BuddyTor.Me.CurrentTarget.Position);
  2813.                     Thread.Sleep(150);
  2814.                     MercCastX("Force Leap", x);
  2815.                     MercCastX("Crippling Throw", x);
  2816.                 }
  2817.                 //Buddy.Navigation.Navigator.MoveTo(x.Position);
  2818.                 x.Face();
  2819.                 CT = x;
  2820.                 double HPx = Me.HealthPercent;
  2821.                
  2822.                 MercBuffSelf("Juyo Form");
  2823.  
  2824.                 if (MercCastX("Resolute", Me, Me.IsStunned)) return true;
  2825.  
  2826.                 if (MercCastX("Guarded by the Force", Me, HPx <= 20f)) return true;
  2827.                 if (MercCastX("Saber Ward", Me, HPx <= 50f)) return true;
  2828.                 if (MercCastX("Zen", BuddyTor.Me, HPx <= 80f)) return true;
  2829.                 if (MercCastX("Inspiration", Me, HPx <= 70f)) return true;
  2830.                 if (MercCastX("Rebuke", Me, HPx <= 70f)) return true;
  2831.  
  2832.                 if (MercCastX("Zen", BuddyTor.Me)) return true;
  2833.                 if (MercCastX("Transcendence", BuddyTor.Me)) return true;
  2834.                 if (MercCastX("Cauterize", x)) return true;
  2835.                 if (MercCastX("Overload Saber", x)) return true;
  2836.                 if (MercCastX("Force Kick", x)) return true;
  2837.                 if (MercCastX("Zealous Strike", x)) return true;
  2838.                 if (MercCastX("Force Stasis", x)) return true;
  2839.                 if (MercCastX("Blade Storm", x)) return true;
  2840.                 if (MercCastX("Pacify", x)) return true;
  2841.                 if (MercCastX("Cyclone Slash", x)) return true;
  2842.                 if (MercCastX("Slash", x)) return true;
  2843.                 if (MercCastX("Riposte", x)) return true;
  2844.                 if (MercCastX("Strike", x)) return true;
  2845.  
  2846.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Force Leap", x)) { Buddy.CommonBot.AbilityManager.Cast("Force Leap", x); Thread.Sleep(700); return true; }
  2847.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Cauterize", x)) { Buddy.CommonBot.AbilityManager.Cast("Cauterize", x); Thread.Sleep(700); return true; }
  2848.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Force Kick", x)) { Buddy.CommonBot.AbilityManager.Cast("Force Kick", x); Thread.Sleep(700); return true; }
  2849.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Zealous Strike", x)) { Buddy.CommonBot.AbilityManager.Cast("Zealous Strike", x); Thread.Sleep(700); return true; }
  2850.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Riposte", x)) { Buddy.CommonBot.AbilityManager.Cast("Riposte", x); Thread.Sleep(700); return true; }
  2851.                 //if (Buddy.CommonBot.AbilityManager.CanCast("Strike", x)) { Buddy.CommonBot.AbilityManager.Cast("Strike", x); Thread.Sleep(700); return true; }
  2852.             }
  2853.             catch { }
  2854.             return false;
  2855.         }
  2856.  
  2857.         public static bool BGCombatPvP()
  2858.         {
  2859.             try
  2860.             {
  2861.                 CheckGC();
  2862.                 Thread.Sleep(150);
  2863.                 if (IAmDead()) { BuddyTor.Me.ClearTarget(); return false; }
  2864.  
  2865.                 var x = BuddyTor.Me.CurrentTarget;
  2866.  
  2867.                 BGHeals(70f);
  2868.  
  2869.                 if (x == null) return false;
  2870.                 CT = x;
  2871.                 TD = x.Distance;
  2872.                 RS = Me.ResourceStat;
  2873.  
  2874.                 while (x.Distance >= 2.8f || !x.InLineOfSight)
  2875.                 {
  2876.                     if (IAmDead()) return false;
  2877.                     Buddy.Swtor.Input.MoveTo(BuddyTor.Me.CurrentTarget.Position);
  2878.                     Thread.Sleep(150);
  2879.                 }
  2880.  
  2881.                 x.Face();
  2882.                 CT = x;
  2883.                 float HP = BuddyTor.Me.HealthPercent;
  2884.                 double HPx = Me.HealthPercent;
  2885.  
  2886.                 if (MercCastX("Determination", BuddyTor.Me.IsStunned)) return true;
  2887.  
  2888.                 if (MercCastX("Kolto Shell", BuddyTor.Me, !Me.HasBuff("Kolto Shell") && HP <= 85f)) return true;
  2889.                 if (MercCastOnGround("Kolto Missile", HP < 60f, Me)) return true;
  2890.                 if (MercCastX("Emergency Scan", Me, HP <= 70)) return true;
  2891.                 if (MercCastX("Rapid Scan", Me, HP <= 70)) return true;
  2892.                 if (MercCastX("Kolto Overload", Me, HP <= 70f)) return true;
  2893.                 if (MercCastX("Energy Shield", Me, HP <= 60f)) return true;
  2894.  
  2895.                 if (MercCastX("Jet Boost", TD <= .8f)) return true;
  2896.                 if (MercCastX("Shoulder Slam", TD <= .8f)) return true;
  2897.                 if (MercCastX("Rocket Punch", TD <= .8f)) return true;
  2898.                 if (MercCastX("Elactro Dart", TD <= .8f)) return true;
  2899.                 if (MercCastX("Vent Heat", RS <= 20)) return true;
  2900.  
  2901.                 if (MercCastOnGround("Death from Above", TD >= .6f && BuddyTor.Me.ResourceStat >= 80f, CT)) return true;
  2902.  
  2903.                 if (MercCastX("Emergency Scan", HP < 70f)) return true;
  2904.  
  2905.                 if (!TargetInCombat()) return true;
  2906.  
  2907.                 if (MercCastX("Power Shot", Me.HasBuff("Power Surge"))) return true;
  2908.                 if (MercCastX("Disabling Shot", TC)) return true;
  2909.                 if (MercCastX("Electro Dart", TC)) return true;
  2910.                 if (MercCastX("Neural Dart", TC || StrongOrGreater(CT))) return true;
  2911.  
  2912.                 if (MercFaceAndCast("Flame Thrower", TD <= 1.0f)) return true;
  2913.  
  2914.                 if (MercCastX("Hunter's Boon", !Me.HasBuff("Hunter's Boon"))) return true;
  2915.                 if (MercCastX("Heroic Moment: On the Trail", HP <= 50f)) return true;
  2916.                 if (MercCastX("Power Surge", true)) return true;
  2917.  
  2918.                 if (MercCastX("Thermal Sensor Override", RS <= 30f)) return true;
  2919.                 if (Comp != null) if (MercCastX("Chaff Flare", HP <= 70f)) return true;
  2920.                 if (MercCastX("Supercharged Gas", Me.HasBuff("Supercharged Gas"))) return true;
  2921.  
  2922.                 if (!IG || (IG && RS >= 40f))
  2923.                 {
  2924.                     if (MercCastX("Explosive Dart", StrongOrGreater(CT) || MobsInRangeOf(CT.Position, .80f) >= 3)) return true;
  2925.                     if (MercCastOnGround("Sweeping Blasters", TWR10 >= 5, CT)) return true;
  2926.                     if (MercCastX("Rapid Shots", HP < 70 && RS >= 30)) return true;
  2927.  
  2928.                     if (MercCastX("Unload", true)) return true;
  2929.                     if (MercCastX("Rail Shot", true)) return true;
  2930.  
  2931.                     if (UseAOE)
  2932.                     {
  2933.                         if (MercCastX("Fusion Missile", StrongOrGreater(CT))) return true;
  2934.                         if (MercCastX("Explosive Dart", true)) return true;
  2935.                         if (MercCastX("Missile Blast", (TD <= .8f && !StrongOrGreater(CT)) || RS >= 50f)) return true;
  2936.                         if (CTT == CombatToughness.Player) MercCastOnGround("Sweeping Blasters", TD >= .1f && RS >= 35, CT);
  2937.                     }
  2938.  
  2939.                     if (MercFaceAndCast("Flame Burst", TD <= 1.0f && RS >= 65f)) return true;
  2940.                 }
  2941.                 if (MercCastX("Rapid Shots", true)) return true;
  2942.             }
  2943.             catch { }
  2944.             return false;
  2945.         }
  2946.  
  2947.         public static bool SageCombatPvP()
  2948.         {
  2949.             try
  2950.             {
  2951.                 CheckGC();
  2952.                 Thread.Sleep(150);
  2953.                 if (IAmDead()) { BuddyTor.Me.ClearTarget(); return false; }
  2954.                 GetEffects();
  2955.  
  2956.                 var x = BuddyTor.Me.CurrentTarget;
  2957.  
  2958.                 //SeerHeals(70f);
  2959.  
  2960.                 if (x == null) return false;
  2961.                 CT = x;
  2962.                 TD = x.Distance;
  2963.                 RS = Me.ResourceStat;
  2964.                 TC = x.IsCasting;
  2965.  
  2966.                 while (x.Distance >= 2.8f || !x.InLineOfSight)
  2967.                 {
  2968.                     if (IAmDead()) return false;
  2969.                     Buddy.Swtor.Input.MoveTo(BuddyTor.Me.CurrentTarget.Position);
  2970.                     Thread.Sleep(150);
  2971.                 }
  2972.  
  2973.                 x.Face();
  2974.                 CT = x;
  2975.                 float HP = BuddyTor.Me.HealthPercent;
  2976.                 double HPx = Me.HealthPercent;
  2977.  
  2978.                 if (MercCastX("Force of Will", Me.IsStunned)) return true;
  2979.                 if (MercCastX("Force Potency", HP <= 50f)) return true;
  2980.                 if (HP <= 30f) UseMedPackInInventory();
  2981.  
  2982.                 HandleDebuffs();
  2983.  
  2984.                     if (MercCastX("Force Stun", TC)) return true;
  2985.                     if (MercCastX("Mind Snap", TC)) return true;
  2986.                     if (MercCastX("Mental Alacrity", RS<=30f)) return true;
  2987.  
  2988.                 if (MercBuffSelf("Force Armor")) return true;
  2989.  
  2990.                 if (HP <= 70f)
  2991.                 {
  2992.  
  2993.                     if (MercCastX("Restoration", NeedsDispell(Me))
  2994.                         || MercCastOnGround("Salvation", HP <= 50f && !MyBuffs.Contains("Salvation"), Me)
  2995.                         || MercCastX("Cloud Mind", HP <= 70f)
  2996.                         || MercCastX("Force Mend", HP <= 70f)
  2997.                         || MercCastX("Rejuvenate", HP <= 70f && !MyBuffs.Contains("Rejuvenate"))
  2998.                         || MercCastX("Mental Alacrity", HP <= 50f)
  2999.                         || MercCastX("Benevolence", HP <= 50f)) { Thread.Sleep(600); MercCast("Project"); return true; }
  3000.                 }
  3001.  
  3002.                 //if (IG && MySpec == SkillTreeId.SageSeer) { if (SeerHeals(85f)) return true; } else if (SeerHeals(70f)) return true;
  3003.                 //if (!IG && SeerCheckCompHealth()) return true;
  3004.  
  3005.                 if (MercCastX("Telekinetic Throw", MyBuffs.Contains("Psychic Projection"))) return true;
  3006.                 if (MercCastX("Telekinetic Wave", MyBuffs.Contains("Tidal Force"))) return true;
  3007.                 if (MercCastOnGround("Force in Balance", MobsInRangeOf(CT.Position, .80f) >= 2, CT)) return true;
  3008.                 if (MercCastX("Project",true)) return true;
  3009.                 if (MercCastOnGround("Forcequake", MyAbilities.Contains("Tidal Force") && MobsInRangeOf(CT.Position, .80f) >= 4, CT)) return true;
  3010.                 if (MercCastX("Disturbance", MyAbilities.Contains("Tidal Force") || !CT.InCombat || MyBuffs.Contains("Presence of Mind"))) return true;
  3011.  
  3012.                 if (!CT.InCombat)
  3013.                 {
  3014.                     //if (MercCast("Mind Crush")) Thread.Sleep(500);
  3015.                     if (MercCast("Disturbance")) Thread.Sleep(500);
  3016.                 }
  3017.                 if (MercFaceAndCast("Force Wave", TD <= MeleeDist)) return true;
  3018.  
  3019.                 //if (MercCast("Deliverance", BuddyTor.Me, HP <= 70f)) return true;
  3020.                 if (TD <= MeleeDist)
  3021.                 {
  3022.                     if (MercCastX("Force Wave", TD <= MeleeDist)) return true;
  3023.                     if (MercCastX("Tumult",true)) return true;
  3024.                 }
  3025.  
  3026.                 //if (MercCast("Heroic Moment: Channel the Force", Me.HealthPercent <= 30f)) return true;
  3027.  
  3028.                 if (MercCastX("Force Potency", Me.ForcePercent <= 50f || StrongOrGreater(CT))) return true;
  3029.                 if (MercCastOnGround("Force in Balance", MobsInRangeOf(CT.Position, .80f) >= 2, CT)) return true;
  3030.                 if (MercCastOnGround("Forcequake", (!IG && MobsInRangeOf(CT.Position, .80f) >= 3) || (IG && MobsInRangeOf(CT.Position, .80f) >= 6), CT)) return true;
  3031.  
  3032.                 //if (MercCast("Turbulence", CTDebuffs.Contains("Weaken Mind"))) return true;
  3033.  
  3034.                 if (MercCastX("Noble Sacrifice", HP >= 50 && RS <= Me.ForceMax * .2f)) return true;
  3035.                 if (MercCastX("Mind Crush", StrongOrGreater(CT))) return true;
  3036.  
  3037.                 if (!IG || Me.ForcePercent > 30f)
  3038.                 {
  3039.  
  3040.                     if (MercCastX("Weaken Mind", !CTDebuffs.Contains("Weaken Mind (Force)"))) return true;
  3041.                     //if (MercCast("Force Stun", StrongOrGreater(CT))) return true;
  3042.                     if (MercCastX("Force Slow", !CTDebuffs.Contains("Slowed (Force)"))) return true;
  3043.  
  3044.                     if (MercCastX("Telekinetic Throw",true)) return true;
  3045.                     if (MercCastX("Disturbance",true)) return true;
  3046.                     if (MercCastOnGround("Forcequake", MobsInRangeOf(CT.Position, .80f) >= 3, CT)) return true;
  3047.                 }
  3048.  
  3049.                 //if (!IG) foreach (TorCharacter u in Attackers) if (MercCast("Weaken Mind", u, !u.HasDebuff("Weaken Mind (Force)"))) WaitForCast();
  3050.                 if (MercCastX("Double Strike",true)) return true;
  3051.                 if (MercCastX("Saber Strike", true)) return true;
  3052.  
  3053.             }
  3054.             catch { }
  3055.             return false;
  3056.         }
  3057.  
  3058.         public static bool WatchmanCombat()
  3059.         {  
  3060.             WaitForCast();
  3061.             datLCL = DateTime.Now;
  3062.  
  3063.             Thread.Sleep(100);
  3064.             LoadVars();
  3065.  
  3066.             if (!TargetInCombat())
  3067.             {
  3068.                 Logger.Write("Target not in combat, exiting.");
  3069.                 return false;
  3070.             }
  3071.  
  3072.             if (MercCast("Crippling Throw", TD >= 1.0f && TD <= 3.0f)) return true;
  3073.             if (MercCast("Dual Saber Throw", TD >= 1.0f && TD <= 3.0f)) return true;
  3074.             MoveTo(CT, .490f, "Force Leap", "Transcendence");
  3075.  
  3076.             if (MercCast("Resolute", Me, Me.IsStunned)) return true;
  3077.  
  3078.             if (HP <= 30f) UseMedPackInInventory();
  3079.            
  3080.             MercBuffSelf("Juyo Form");
  3081.  
  3082.             if (MercCast("Pacify", TC && StrongOrGreater(CT))) return true;
  3083.             if (MercCast("Force Kick", TC && StrongOrGreater(CT))) return true;
  3084.             if (MercCast("Force Stasis", TC && StrongOrGreater(CT))) return true;
  3085.  
  3086.             if (MercCast("Guarded by the Force", HP <= 20f)) return true;
  3087.             if (MercCast("Saber Ward", HP <= 50f)) return true;
  3088.             if (MercCast("Inspiration", HP <= 70f)) return true;
  3089.             if (MercCast("Rebuke", HP <= 70f)) return true;
  3090.  
  3091.             if (MercCast("Zen", BuddyTor.Me)) return true;
  3092.             if (MercCast("Transcendence", BuddyTor.Me)) return true;
  3093.  
  3094.             if (MercCast("Overload Saber")) return true;
  3095.  
  3096.             if (MercCast("Dispatch", THP <= 30f)) return true;
  3097.             if (MercCast("Master Strike", StrongOrGreater(CT) && THP >= 30f)) return true;
  3098.             if (MercCast("Blade Storm", TWR10 >= 2 || StrongOrGreater(CT))) return true;
  3099.             if (MercCast("Riposte")) return true;
  3100.             if (MercCast("Merciless Slash", StrongOrGreater(CT) && THP >= 30f)) return true;
  3101.             if (MercCast("Slash")) return true;
  3102.             if (MercCast("Zealous Strike")) return true;
  3103.  
  3104.             if (MercCast("Cauterize")) return true;
  3105.  
  3106.             if (MercCast("Force Sweep", TWR5 >= 2)) return true;
  3107.             if (MercCast("Cyclone Slash", TWR5 >= 2)) return true;
  3108.  
  3109.  
  3110.  
  3111.             if (MercCast("Crippling Throw", StrongOrGreater(CT) && HP <= 80f)) return true;
  3112.             if (MercCast("Leg Slash", StrongOrGreater(CT) && HP <= 80f)) return true;
  3113.  
  3114.             if (MercCast("Rebuke")) return true;
  3115.             if (MercCast("Strike")) return true;
  3116.  
  3117.             return false;
  3118.         }
  3119.  
  3120.         public static bool GuardianCombat()
  3121.         {
  3122.             Thread.Sleep(300);
  3123.             while (Me.IsCasting) Thread.Sleep(300);
  3124.             ////Thread.Sleep(200);
  3125.             ////WaitForCast();
  3126.  
  3127.             datLCL = DateTime.Now;
  3128.  
  3129.             LoadVars();
  3130.  
  3131.             if (MercBuffSelf("Soresu Form")) return true;
  3132.             if (MercBuffSelf("Force Might")) return true;
  3133.  
  3134.             if (!TargetInCombat()) return false;
  3135.  
  3136.             //if (MercCast("Force Leap", TD >= 1.0f && TD <= 3.0f)) return true;
  3137.             //if (MercCast("Crippling Throw", TD >= 1.0f && TD <= 3.0f)) return true;
  3138.             //if (MercCast("Taunt", TD >= 1.0f && TD <= 3.0f)) return true;
  3139.  
  3140.             MoveTo(CT, .490f,"Force Leap", "Crippling Throw", "Taunt");
  3141.  
  3142.             if (MercCast("Pacify", TC && StrongOrGreater(CT))) return true;
  3143.             if (MercCast("Force Kick", TC && StrongOrGreater(CT))) return true;
  3144.             if (MercCast("Force Stasis", TC && StrongOrGreater(CT))) return true;
  3145.  
  3146.             if (MercCast("Resolute", Me, Me.IsStunned)) return true;
  3147.  
  3148.             if (HP < 70f)
  3149.             {
  3150.                 if (HP <= 30f) UseMedPackInInventory();
  3151.  
  3152.                 if (MercCast("Warding Call", HP <= 50f)) return true;
  3153.                 if (MercCast("Enure", HP <= 60f)) return true;
  3154.                 if (MercCast("Guarded by the Force", HP <= 20f)) return true;
  3155.                 if (MercCast("Saber Ward", HP <= 50f)) return true;
  3156.                 if (MercCast("Inspiration", HP <= 70f)) return true;
  3157.                 if (MercCast("Rebuke", HP <= 70f)) return true;
  3158.                 if (MercCast("Combat Focus", Me, HP <= 70f)) return true;
  3159.             }
  3160.  
  3161.             if (MercCast("Zen", Me)) return true;
  3162.             if (MercCast("Transcendence", Me)) return true;
  3163.  
  3164.             if (MercCast("Crippling Throw", StrongOrGreater(CT) && HP <= 80f)) return true;
  3165.             if (MercCast("Leg Slash", StrongOrGreater(CT) && HP <= 80f)) return true;
  3166.  
  3167.             if (MercCast("Dispatch", THP <= 30f)) return true;
  3168.             if (MercCast("Blade Storm", TWR10 >= 2 || StrongOrGreater(CT))) return true;
  3169.  
  3170.             if (MercCast("Riposte")) return true;
  3171.             if (MercCast("Overload Saber")) return true;
  3172.             if (MercCast("Sundering Strike")) return true;
  3173.             if (MercCast("Merciless Slash", StrongOrGreater(CT) && THP >= 30f)) return true;
  3174.             if (MercCast("Master Strike", StrongOrGreater(CT) && THP >= 30f)) return true;
  3175.             if (MercCast("Challenging Call", IG)) return true;
  3176.  
  3177.             if (MercCast("Force Sweep", TWR5 >= 2)) return true;
  3178.             if (MercCast("Cauterize")) return true;
  3179.             if (MercCast("Zealous Strike")) return true;
  3180.  
  3181.             if (MercCast("Riposte")) return true;
  3182.             if (MercCast("Rebuke")) return true;
  3183.  
  3184.             if (MercCast("Slash")) return true;
  3185.             if (MercCast("Strike")) return true;
  3186.  
  3187.             return false;
  3188.         }
  3189.  
  3190.         public static bool FocusCombat()
  3191.         {
  3192.  
  3193.             WaitForCast();
  3194.             datLCL = DateTime.Now;
  3195.  
  3196.             Thread.Sleep(100);
  3197.             LoadVars();
  3198.             if (Attackers == null || Attackers.Count() == 0) return false;
  3199.  
  3200.             if (MercCast("Shii-Cho Form", !MyBuffs.Contains("Shii-Cho Form"))) return true;
  3201.             if (MercCast("Force Might", !MyBuffs.Contains("Force Might"))) return true;
  3202.  
  3203.             if (!TargetInCombat()) return false;
  3204.  
  3205.             if (MercCast("Crippling Throw", TD >= 1.0f && TD <= 3.0f)) return true;
  3206.             if (MercCast("Zealous Leap", Me, TD <= 1.0f)) return true;
  3207.             if (MercCast("Transcendence", Me, TD >= 1.0f)) return true;
  3208.             if (MercCast("Zealous Leap", TD <= 1.0f)) return true;
  3209.  
  3210.             MoveTo(CT, .490f, "Force Leap");
  3211.  
  3212.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  3213.  
  3214.             if (MercCast("Resolute", Me, Me.IsStunned)) return true;
  3215.  
  3216.  
  3217.             if (HP <= 30) UseMedPackInInventory();
  3218.             if (MercCast("Guarded by the Force", Me, HP <= 20f)) return true;
  3219.             if (MercCast("Zen", Me, HP <= 70f)) return true;
  3220.             if (MercCast("Saber Ward", Me, HP <= 50)) return true;
  3221.             if (MercCast("Rebuke", HP <= 70)) return true;
  3222.  
  3223.             if (MercCast("Dispatch", THP <= 30f)) return true;
  3224.  
  3225.             if (MercCast("Awe", TC && StrongOrGreater(CT))) return true;
  3226.             if (MercCast("Force Kick", TC && StrongOrGreater(CT))) return true;
  3227.             if (MercCast("Force Stasis", TC && StrongOrGreater(CT))) return true;
  3228.  
  3229.             if (MercCast("Overload Saber", Me)) return true;
  3230.             if (MercCast("Blade Storm", TWR10 >= 2 || StrongOrGreater(CT))) return true;
  3231.             if (MercCast("Cyclone Slash", TWR5 >= 2)) return true;
  3232.             if (MercCast("Force Sweep", TWR5 >= 2)) return true;
  3233.             if (MercCast("Cauterize")) return true;
  3234.             if (MercCast("Zealous Strike")) return true;
  3235.             if (MercCast("Merciless Slash")) return true;
  3236.             if (MercCast("Master Strike")) return true;
  3237.  
  3238.             if (MercCast("Dispatch")) return true;
  3239.  
  3240.             if (MercCast("Crippling Throw", StrongOrGreater(CT))) return true;
  3241.             if (MercCast("Leg Slash", StrongOrGreater(CT))) return true;
  3242.             if (MercCast("Pacify", StrongOrElite(CT))) return true;
  3243.             if (MercCast("Riposte")) return true;
  3244.  
  3245.             if (MercCastOnGround("Force Sweep", TWR5 >= 3 || StrongOrGreater(CT), CT)) return true;
  3246.  
  3247.             if (MercCast("Master Strike")) return true;
  3248.             if (MercCast("Force Leap")) return true;
  3249.  
  3250.             if (MercCast("Slash")) return true;
  3251.             if (MercCast("Strike")) return true;
  3252.  
  3253.             return false;
  3254.         }
  3255.  
  3256.         public static bool SentinelCombat()
  3257.         {
  3258.  
  3259.             WaitForCast();
  3260.             datLCL = DateTime.Now;
  3261.  
  3262.             Thread.Sleep(150);
  3263.             LoadVars();
  3264.             if (Attackers == null || Attackers.Count() == 0) return false;
  3265.  
  3266.             if (MercBuffSelf("Shii-Cho Form",MySpec==SkillTreeId.SentinelFocus)) return true;
  3267.             if (MercBuffSelf("Ataru Form", MySpec == SkillTreeId.SentinelCombat)) return true;
  3268.             if (MercBuffSelf("Juyo Form", MySpec == SkillTreeId.SentinelWatchman)) return true;
  3269.  
  3270.             if (MercCast("Force Might", !MyBuffs.Contains("Force Might"))) return true;
  3271.  
  3272.             if (!TargetInCombat()) return false;
  3273.  
  3274.             if (MercCast("Crippling Throw", TD >= 1.0f && TD <= 3.0f)) return true;
  3275.             if (MercCast("Zealous Leap", Me, TD <= 1.0f)) return true;
  3276.             if (MercCast("Transcendence", Me, TD >= 1.0f)) return true;
  3277.             if (MercCast("Zealous Leap", TD <= 1.0f)) return true;
  3278.  
  3279.             MoveTo(CT, MeleeDist, "Force Leap");
  3280.  
  3281.             if (TC && StrongOrGreater(CT))
  3282.             {
  3283.                 if (MercCast("Force Kick")) return true;
  3284.                 if (MercCast("Force Stasis")) return true;
  3285.                 if (MercCast("Awe")) return true;
  3286.             }
  3287.  
  3288.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  3289.  
  3290.             if (MercCast("Resolute", Me, Me.IsStunned)) return true;
  3291.  
  3292.             if (HP <= 30) UseMedPackInInventory();
  3293.  
  3294.             if (MercCast("Overload Saber")) return true;
  3295.             if (MercCast("Cauterize")) return true;
  3296.  
  3297.             if (MercCast("Dispatch", THP <= 30f)) return true;
  3298.  
  3299.             if (MercCast("Zen", Me, HP <= 70f)) return true;
  3300.             if (MercCast("Rebuke", HP <= 70)) return true;
  3301.             if (MercCast("Guarded by the Force", Me, HP <= 20f)) return true;
  3302.             if (MercCast("Saber Ward", Me, HP <= 50)) return true;
  3303.  
  3304.             if (MercCast("Dispatch", THP <= 30f)) return true;
  3305.  
  3306.             if (MercCast("Blade Storm", TWR10 >= 2 || StrongOrGreater(CT))) return true;
  3307.             if (MercCast("Cyclone Slash", TWR5 >= 2)) return true;
  3308.             if (MercCast("Master Strike")) return true;
  3309.             if (MercCast("Force Sweep", TWR5 >= 2)) return true;
  3310.             if (MercCast("Cauterize")) return true;
  3311.             if (MercCast("Zealous Strike")) return true;
  3312.             if (MercCast("Merciless Slash")) return true;
  3313.             if (MercCast("Zealous Leap")) return true;
  3314.             if (MercCast("Force Exhaustion")) return true;
  3315.  
  3316.             if (MercCast("Dispatch")) return true;
  3317.  
  3318.             if (MercCast("Crippling Throw", StrongOrGreater(CT))) return true;
  3319.             if (MercCast("Leg Slash", StrongOrGreater(CT))) return true;
  3320.             if (MercCast("Pacify", StrongOrElite(CT))) return true;
  3321.             if (MercCast("Riposte")) return true;
  3322.  
  3323.             if (MercCastOnGround("Force Sweep", TWR5 >= 3 || StrongOrGreater(CT), CT)) return true;
  3324.  
  3325.             if (MercCast("Master Strike")) return true;
  3326.             if (MercCast("Force Leap")) return true;
  3327.  
  3328.             if (MercCast("Slash")) return true;
  3329.             if (MercCast("Strike")) return true;
  3330.  
  3331.             return false;
  3332.         }
  3333.  
  3334.         public static bool AssassinCombat()
  3335.         {
  3336.  
  3337.             //WaitForCast();
  3338.             datLCL = DateTime.Now;
  3339.  
  3340.             //Thread.Sleep(100);
  3341.             LoadVars();
  3342.  
  3343.             MercBuffSelf("Mark of Power");
  3344.             MercBuffSelf("Dark Charge");
  3345.  
  3346.             if (!TargetInCombat()) return false;
  3347.  
  3348.             if (!CT.InCombat && CT.HealthPercent > .2f)
  3349.             {
  3350.                 MercBuffSelf("Stealth");
  3351.                 Thread.Sleep(400);
  3352.                 while (CT.Distance > .15f) MoveTo(CT, .15f);
  3353.                 if (!MercCast("Maul", CT.Distance <= .20f)) if (!MercCast("Thrash")) MercCast("Shock");
  3354.                 return true;
  3355.             }
  3356.  
  3357.             if (MercCast("Unbreakable Will", Me.IsStunned)) return true;
  3358.  
  3359.             if (HP <= 30f) UseMedPackInInventory();
  3360.  
  3361.             if (MercCast("Electrocute", TC && StrongOrGreater(CT))) return true;
  3362.             if (MercCast("Shock", TC && StrongOrGreater(CT))) return true;
  3363.             if (MercCast("Jolt", TC && StrongOrGreater(CT))) return true;
  3364.  
  3365.             MercCast("Force Speed", TD >= 1.5f);
  3366.  
  3367.             MoveTo(CT, MeleeDist);
  3368.  
  3369.             if (MercCast("Overcharge Saber", HP <= 70f)) return true;
  3370.             if (MercCast("Force Shroud", HP <= 40f)) return true;
  3371.             if (MercCast("Deflection", HP <= 50f)) return true;
  3372.  
  3373.             if (MercCast("Dark Ward")) return true;
  3374.             if (MercCast("Wither", TWR10 >= 2)) return true;
  3375.             //if (MercCast("Dark Charge")) return true;
  3376.             if (MercCast("Discharge", MyBuffs.Contains("Dark Charge"))) return true;
  3377.             if (MercCast("Force Lightning", MyBuffs.Contains("Harnessed Darkness"))) return true;
  3378.             if (MercCast("Assassinate", THP <= 30f)) return true;
  3379.  
  3380.             if (MercCast("Lacerate", TWR10 >= 3)) return true;
  3381.             if (MercCast("Maul")) return true;
  3382.  
  3383.             if (MercCast("Shock")) return true;
  3384.             if (MercCast("Force Lightning")) return true;
  3385.  
  3386.             if (StrongOrGreater(CT))
  3387.             {
  3388.                 if (MercCast("Recklessness")) return true;
  3389.                 if (MercCast("Electrocute")) return true;
  3390.                 if (MercCast("Force Slow")) return true;
  3391.             }
  3392.  
  3393.             //if (!IG) MoveIfNec(.49f);
  3394.  
  3395.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  3396.             if (MercFaceAndCast("Overload", TD <= MeleeDist)) return true;
  3397.             if (MercCast("Thrash")) return true;
  3398.             if (MercCast("Saber Strike")) return true;
  3399.  
  3400.             return false;
  3401.         }
  3402.  
  3403.         public static void DefenseCombat()
  3404.         {
  3405.  
  3406.             WaitForCast();
  3407.             datLCL = DateTime.Now;
  3408.  
  3409.             Thread.Sleep(200);
  3410.             LoadVars();
  3411.  
  3412.             if (!TargetInCombat()) return;
  3413.  
  3414.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  3415.  
  3416.             if (!IG) StopMoving();
  3417.  
  3418.             MoveTo(CT, MeleeDist, "Force Leap");
  3419.  
  3420.             if (MercCast("Resolute", Me.IsStunned)) return;
  3421.  
  3422.             if (!MyBuffs.Contains("Soresu Form")) if (AbilityManager.CanCast("Soresu Form", Me)) if (MercCast("Soresu Form", Me)) return;
  3423.             if (!MyBuffs.Contains("Shii-Cho Form")) if (!AbilityManager.CanCast("Soresu Form", Me)) if (MercCast("Shii-Cho Form", Me)) return;
  3424.  
  3425.             if (MercCast("Hilt Strike", CT.IsStunned && RS >= 3)) return;
  3426.             if (MercCast("Pommel Strike", CT.IsStunned)) return;
  3427.  
  3428.             if (MercCast("Dispatch", HP <= 20 && RS >= 3)) return;
  3429.             if (MercCast("Hilt Strike", TC && HP <= 30f && MyBuffs.Contains("Saber Ward"))) return;
  3430.             if (MercBuffSelf("Endure", HP <= 30)) return;
  3431.  
  3432.             if (MercBuffSelf("Saber Ward", HP <= 50)) return;
  3433.             if (MercCast("Awe", TWR5 >= 3 && HP <= 60)) return;
  3434.             if (MercCast("Force Stasis", TC && HP <= 60f && MyBuffs.Contains("Saber Ward"))) return;
  3435.             if (MercBuffSelf("Warding Call", HP <= 60)) return;
  3436.  
  3437.             if (MercCast("Sundering Strike")) return;
  3438.             if (MercCast("Master Strike")) return;
  3439.             if (MercCast("Freezing Force", !CTDebuffs.Contains("Slowed (Force)") && (TWR5 >= 2 || StrongOrGreater(CT)))) return;
  3440.             if (MercCast("Blade Storm")) return;
  3441.  
  3442.             if (MercCast("Force Sweep", TWR5 >= 2 && RS >= 3)) return;
  3443.             if (MercCast("Guardian Slash", RS >= 4 && TWR10 >= 3)) return;
  3444.             if (MercCast("Cyclone Slash", TWR5 >= 4)) return;
  3445.             if (MercCast("Force Push", TWR10 >= 3)) return;
  3446.  
  3447.             if (MercCast("Saber Throw", TD >= MeleeDist)) return;
  3448.             if (MercCast("Combat Focus", RS <= 6)) return;
  3449.  
  3450.             if (MercCast("Force Kick", TC)) return;
  3451.  
  3452.             if (MercCast("Opportune Strike", CTT != CombatToughness.Player)) return;
  3453.  
  3454.  
  3455.             if (MercCast("Slash", RS >= 6)) return;
  3456.             if (MercCast("Strike")) return;
  3457.  
  3458.         }
  3459.  
  3460.         public static void CheckForGuarding()
  3461.         {
  3462.             NGUnit = null;
  3463.             NAUnit = null;
  3464.  
  3465.             foreach (TorNpc tn in Helpers.Targets.OrderBy(t => t.Distance).Where(t=> t!=null && !t.IsDeleted && !t.IsDead && t.CurrentTarget != Me))
  3466.                 try
  3467.                 {
  3468.                     bool Att = false;
  3469.                     if (tn != null) if (!tn.IsDeleted) if (tn.InCombat)
  3470.                             {
  3471.                                 Att = (tn.CurrentTarget.Toughness == CombatToughness.Player);
  3472.                                 if (!Att) if (Comp != null) if (tn.CurrentTarget == Comp) Att = true;
  3473.                                 if (Att)
  3474.                                 {
  3475.                                     TorCharacter pt = tn.CurrentTarget;
  3476.                                     if (pt.HealthPercent < 80) { NGUnit = pt; NAUnit = tn; break; }
  3477.                                 }
  3478.                             }
  3479.                 }
  3480.                 catch { }
  3481.         }
  3482.  
  3483.         public static bool HandleGuardingJugg()
  3484.         {
  3485.            
  3486.             //if (!IG) return false;
  3487.  
  3488.             if(IG) CheckForGuarding();
  3489.  
  3490.             if (NAUnit != null) try
  3491.                 {
  3492.                     CT = NAUnit;
  3493.  
  3494.                     if (MercCast("Taunt", NAUnit)) return true;
  3495.                     if (MercCast("Intercede", NGUnit)) return true;
  3496.                     if (MercCast("Saber Throw", NAUnit)) return true;
  3497.                     //if (MercCast("Guard", NGUnit)) return true;
  3498.  
  3499.                 }
  3500.                 catch { }
  3501.             return false;
  3502.         }
  3503.  
  3504.  
  3505.         public static bool JuggernautCombat()
  3506.         {
  3507.             //Thread.Sleep(200);
  3508.  
  3509.             //WaitForCast();
  3510.             datLCL = DateTime.Now;
  3511.  
  3512.             LoadVars();
  3513.  
  3514.             //if (CT == null && Me.CurrentTarget != null ) CT = Me.CurrentTarget;
  3515.             if (!TargetInCombat()) return false;
  3516.  
  3517.             if (HP<=30f) UseMedPackInInventory();
  3518.  
  3519.             if (MySpec == SkillTreeId.JuggernautImmortal) if (MercBuffSelf("Soresu Form")) return true;
  3520.             if (MySpec == SkillTreeId.JuggernautVengeance) if (MercBuffSelf("Shien Form")) return true;
  3521.             if (MySpec == SkillTreeId.JuggernautRage) if (MercBuffSelf("Shii-Cho Form")) return true;
  3522.  
  3523.             if (MercBuffSelf("Unnatural Might")) return true;
  3524.  
  3525.             if (MercCast("Force Charge", CT, TD >= 1.0f && TD <= 3.0f)) return true;
  3526.             if (MercCast("Saber Throw", CT, TD >= 1.0f && TD <= 3.0f)) return true;
  3527.             if (MercCast("Force Scream", CT, TD <= 1.0f)) return true;
  3528.             if (MercCast("Taunt", CT, (TD >= 1.2f && TD <= 3.0f) || StrongOrGreater(CT))) return true;
  3529.             //if (!IG) MoveTo(CT, .490f, "Force Charge");
  3530.             MoveTo(CT, MeleeDist, "Force Charge");
  3531.  
  3532.             // ALOT of these are bugged in SWTOR for Elites in Oricon - annoying as all hell
  3533.             if (TC && StrongOrGreater(CT)) {
  3534.                 if (MercCast("Disruption")) return true;
  3535.                 if (MercCast("Backhand")) return true;
  3536.                 if (MercCast("Force Push")) return true;
  3537.                 if (MercCast("Force Charge")) return true;
  3538.                 if (MercCast("Savage Kick")) return true;
  3539.                 if (MercCast("Taunt")) return true;
  3540.                 if (MercCast("Force Choke")) return true;
  3541.             }
  3542.             //StopMoving();
  3543.  
  3544.             if (MercCast("Unleash", CT, BuddyTor.Me.IsStunned)) return true;
  3545.  
  3546.             if (MercCast("Smash", CT, TWR5 >= 2 || (StrongOrGreater(CT) && TD <= MeleeDist))) return true;
  3547.  
  3548.             if (MercCast("Heroic Moment: Call on the Force", BuddyTor.Me, DateTime.Now.Subtract(datLCCoTF).TotalSeconds >= 900 && HP <= 50f)) { datLCCoTF = DateTime.Now; return true; }
  3549.  
  3550.             if (HP <= 30f) UseMedPackInInventory();
  3551.  
  3552.             if (HP <= 70f)
  3553.             {
  3554.                 if (MercCast("Endure Pain", HP <= 40f)) return true;
  3555.                 if (MercCast("Invincible", HP <= 50f)) return true;
  3556.                 if (MercCast("Saber Ward", HP <= 60f)) return true;
  3557.                 if (MercCast("Enraged Defense", HP <= 70f)) return true;
  3558.                 if (MercCast("Saber Reflect", HP <= 70f)) return true;
  3559.                 if (MercCast("Heroic Moment: Call on the Force", BuddyTor.Me, DateTime.Now.Subtract(datLCCoTF).TotalSeconds >= 900 && HP <= 50f)) { datLCCoTF = DateTime.Now; return true; }
  3560.             }
  3561.  
  3562.             if (MercCast("Sundering Assault", CT)) return true;
  3563.             if (MercCast("Deadly Throw", StrongOrGreater(CT))) return true;
  3564.             if (MercCast("Force Scream", CT)) return true;
  3565.             if (MercCast("Backhand")) return true;
  3566.             if (MercCast("Retaliation", CT)) return true;
  3567.             if (MercCast("Crushing Blow", CT, CTDebuffs.Contains("Armor Reduced") && (TWR5 >= 2 || StrongOrGreater(CT)))) return true;
  3568.             if (MercCast("Impale")) return true;
  3569.             if (MercCast("Shatter", StrongOrGreater(CT))) return true;
  3570.  
  3571.             //if (MercCast("Force Push", (TWR10 >= 3))) return true;
  3572.  
  3573.             if (IG && MySpec==SkillTreeId.JuggernautImmortal)
  3574.             {
  3575.                 //if (MercCast("Guard", Comp, CHP <= 50)) return true;
  3576.                 HandleGuardingJugg();
  3577.             }
  3578.  
  3579.             if (MercCast("Obliterate", StrongOrGreater(CT))) return true;
  3580.             if (MercCast("Ravage")) return true;
  3581.             if (MercCast("Force Crush", StrongOrGreater(CT))) return true;
  3582.  
  3583.             if (MercCast("Enrage", CT)) return true;
  3584.             if (MercCast("Sweeping Slash", (TWR5 >= 3))) return true;
  3585.  
  3586.             if (MercCast("Vicious Throw", THP <= 30f)) return true;
  3587.             if (MercCast("Pommel Strike", CT.IsStunned)) return true;
  3588.             if (MercCast("Force Choke", THP <= 30f)) return true;
  3589.  
  3590.             if (MercCast("Intimidating Roar")) return true;
  3591.  
  3592.             if (MercCast("Threatening Scream", (TWR10 >= 3 || StrongOrGreater(CT)))) return true;
  3593.  
  3594.             if (MercCast("Vicious Slash")) return true;
  3595.             if (MercCast("Sweeping Slash",TWR5>=3)) return true;
  3596.             if (MercCast("Chilling Scream", !CTDebuffs.Contains("Slow (Force)") && (HP <= 50 || TWR10 >= 2))) return true;
  3597.             if (MercCast("Assault")) return true;
  3598.  
  3599.             return false;
  3600.         }
  3601.  
  3602.         public static void VengeanceCombat()
  3603.         {
  3604.             Thread.Sleep(200);
  3605.  
  3606.             WaitForCast();
  3607.             datLCL = DateTime.Now;
  3608.  
  3609.             LoadVars();
  3610.  
  3611.             if (CT == null && Me.CurrentTarget != null) CT = Me.CurrentTarget;
  3612.  
  3613.             if (MercCast("Shien Form", !MyBuffs.Contains("Shien Form"))) return;
  3614.             //if (MercCast("Shi-Cho Form", !MyBuffs.Contains("Shii-Cho Form"))) return;
  3615.             if (MercCast("Unnatural Might", !MyBuffs.Contains("Unnatural Might"))) return;
  3616.  
  3617.             if (MercCast("Saber Throw", TD >= 1.1f && TD <= 3.0f)) return;
  3618.             if (MercCast("Force Charge", TD >= 1.0f && TD <= 3.0f)) return;
  3619.             if (MercCast("Force Scream", TD <= 1.0f)) return;
  3620.             if (MercCast("Taunt", (TD >= 1.2f && TD <= 3.0f) || StrongOrGreater(CT))) return;
  3621.             //if (!IG) MoveTo(CT, .490f, "Force Charge");
  3622.             MoveTo(CT, .490f, "Force Charge");
  3623.  
  3624.             if (!IG && BuddyTor.Me.IsMoving) StopMoving();
  3625.  
  3626.             if (MercCast("Unleash", Me, BuddyTor.Me.IsStunned)) return;
  3627.  
  3628.             if (MercCast("Disruption", TC)) return;
  3629.  
  3630.             if (MercCast("Smash", (TWR5 >= 2 || (StrongOrGreater(CT)) && TD <= MeleeDist))) return;
  3631.  
  3632.             if (MercCast("Enraged Defense", Me, HP <= 80f)) return;
  3633.             if (MercCast("Saber Reflect", BuddyTor.Me, HP <= 70f)) return;
  3634.             if (MercCast("Heroic Moment: Call on the Force", BuddyTor.Me, DateTime.Now.Subtract(datLCCoTF).TotalSeconds >= 900 && HP <= 50f)) { datLCCoTF = DateTime.Now; return; }
  3635.             if (MercCast("Saber Ward", BuddyTor.Me, HP <= 60f)) return;
  3636.             if (MercCast("Invincible", BuddyTor.Me, HP <= 50f)) return;
  3637.             if (MercCast("Endure Pain", BuddyTor.Me, HP <= 40f)) return;
  3638.             if (HP <= 60f) UseMedPackInInventory();
  3639.  
  3640.             //if (MercCast("Force Push", (TWR10 >= 3))) return;
  3641.  
  3642.             //if (MercCast("Guard", Comp, CHP <= 50)) return;
  3643.             HandleGuardingJugg();
  3644.  
  3645.             if (MercCast("Impale")) return;
  3646.             if (MercCast("Savage Kick")) return;
  3647.             if (MercCast("Sundering Assault")) return;
  3648.             if (MercCast("Retaliation")) return;
  3649.             if (MercCast("Ravage")) return;
  3650.  
  3651.             if (MercCast("Enrage", Me)) return;
  3652.             if (MercCast("Crushing Blow")) return;
  3653.             if (MercCast("Backhand")) return;
  3654.             if (MercCast("Sweeping Slash", (TWR5 >= 3))) return;
  3655.  
  3656.             if (MercCast("Vicious Throw", THP <= 30f)) return;
  3657.             if (MercCast("Pommel Strike", CT.IsStunned)) return;
  3658.             if (MercCast("Force Choke", THP <= 30f)) return;
  3659.  
  3660.             if (MercCast("Deadly Throw")) return;
  3661.             if (MercCast("Intimidating Roar")) return;
  3662.  
  3663.             if (MercCast("Chilling Scream", !CTDebuffs.Contains("Slow (Force)") && (HP <= 50 || TWR10 >= 2))) return;
  3664.             if (MercCast("Threatening Scream", (TWR10 >= 3))) return;
  3665.  
  3666.             if (MercCast("Vicious Slash")) return;
  3667.             if (MercCast("Assault")) return;
  3668.  
  3669.         }
  3670.  
  3671.         // Credit to ChinaJade and WingIt for this routine
  3672.         public static void MovementToggle()
  3673.         {
  3674.             MovementAllowedOrig = !MovementAllowedOrig;
  3675.             Logger.Write("Movement Toggled " + (MovementAllowedOrig ? "ON" : "OFF"));
  3676.             MovementToggle(MovementAllowedOrig);
  3677.         }
  3678.  
  3679.         public static void MovementToggle(bool MoveOn)
  3680.         {
  3681.            
  3682.             if (!MoveOn)
  3683.             {
  3684.                 Buddy.Navigation.Navigator.NavigationProvider = NoNavigationProvider;
  3685.                 Buddy.Navigation.Navigator.MovementProvider = NoMovementProvider;
  3686.             }
  3687.             else
  3688.             {
  3689.                 Buddy.Navigation.Navigator.NavigationProvider = DefaultNP;
  3690.                 Buddy.Navigation.Navigator.MovementProvider = DefaultMP;
  3691.             }
  3692.  
  3693.         }
  3694.  
  3695.         //private static System.EventHandler ShutdownHandler(object obj, System.Windows.ExitEventArgs args)
  3696.         ////private static System.EventHandler ShutdownHandler()
  3697.         //{
  3698.         //    if (thMonMem != null && thMonMem.IsAlive)
  3699.         //    {
  3700.         //        thMonMem.Abort();
  3701.         //        Thread.Sleep(2000);
  3702.         //        thMonMem = null;
  3703.         //        Thread.Sleep(2000);
  3704.         //    }
  3705.         //    return null;
  3706.         //}
  3707.  
  3708.         private static bool HandleDebuffs()
  3709.         {
  3710.             return HandleDebuffs(Me);
  3711.         }
  3712.  
  3713.         private static bool HandleDebuffs(TorCharacter unit)
  3714.         {
  3715.             try
  3716.             {
  3717.  
  3718.                 if (unit == null) return false;
  3719.  
  3720.                 foreach (TorEffect te in unit.Debuffs)
  3721.                 {
  3722.                     string spellCure = "";
  3723.                     if (MySpec == SkillTreeId.MercenaryBodyguard) spellCure = "Cure";
  3724.                     else if (MySpec == SkillTreeId.CommandoCombatMedic) spellCure = "Field Aid";
  3725.                     else if (MySpec == SkillTreeId.SageSeer) spellCure = "Restoration";
  3726.                     else if (MySpec == SkillTreeId.SorcererCorruption) spellCure = "Purge";
  3727.                     else { return false; }
  3728.  
  3729.                     if (te.Name.Contains("Burning")) if (MercCast(spellCure, unit)) return true;
  3730.                     //if (te.Name.Contains("Armor")) if (MercCast(spellCure, unit)) return true;  // Can't be dispelled
  3731.                     if (te.Name.Contains("Slowed")) if (MercCast(spellCure, unit)) return true;
  3732.                     if (te.Name.Contains("Shocked")) if (MercCast(spellCure, unit)) return true;
  3733.                     if (te.Name.Contains("Poisoned")) if (MercCast(spellCure, unit)) return true;
  3734.                     if (te.Name.Contains("Crippling")) if (MercCast(spellCure, unit)) return true;
  3735.                     if (te.Name.Contains("Crush")) if (MercCast(spellCure, unit)) return true;
  3736.                     if (te.Name.Contains("Infected")) if (MercCast(spellCure, unit)) return true;
  3737.                     if (te.Name.Contains("Bleeding")) if (MercCast(spellCure, unit)) return true;
  3738.                     if (te.Name.Contains("Grav")) if (MercCast(spellCure, unit)) return true;
  3739.                     if (te.Name.Contains("Hallucinat")) if (MercCast(spellCure, unit)) return true;
  3740.                 }
  3741.             }
  3742.             catch { }
  3743.             return false;
  3744.         }
  3745.  
  3746.         public static bool MercBuffSelf(string theSpell, bool req=true)
  3747.         {
  3748.             if (theSpell == "") return false;
  3749.             if (Me.HasBuff(theSpell)) return false;
  3750.             return MercCast(theSpell, BuddyTor.Me, req);
  3751.         }
  3752.  
  3753.         //public static bool MercCastOnGround(string theSpell, bool requirements, TorCharacter unit)
  3754.         //{
  3755.         //    if (unit == null) return false;
  3756.         //    if (theSpell == "") return false;
  3757.         //    return MercCastOnGround(theSpell, requirements, unit, false);
  3758.         //}
  3759.  
  3760.         public static bool MercCastOnGround(string theSpell, bool requirements, TorCharacter unit, bool OnlyInCombat=false)
  3761.         {
  3762.             if (unit == null) unit=CT;
  3763.             if (theSpell == "") return false;
  3764.             if (unit.IsDead) return false;
  3765.  
  3766.             try
  3767.             {
  3768.                 if (requirements) if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, unit))
  3769.                     {
  3770.                         datLCs = DateTime.Now;
  3771.  
  3772.                         Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " THP: " + CT.HealthPercent.ToString("00.00") + " Casting " + theSpell);
  3773.                         AbilityManager.Cast(theSpell, unit.Position);
  3774.                         Thread.Sleep(500);
  3775.                         if (OnlyInCombat)
  3776.                         {
  3777.                             while (Me.InCombat && Me.IsCasting) Thread.Sleep(500);
  3778.                             return true;
  3779.                         }
  3780.                         WaitForCast();
  3781.                         BuddyTor.Me.ClearTarget();
  3782.                         return true;
  3783.                     }
  3784.             }
  3785.             catch { }
  3786.             return false;
  3787.         }
  3788.  
  3789.         // Used in 'Directional Casting' such as Pulse Cannon - WE HAVE TO BE FACING THE TARGET FIRST - otherwise - useless
  3790.         public static bool MercFaceAndCast(string theSpell, bool req)
  3791.         {
  3792.             if (CT == null) return false;
  3793.             if (theSpell == "") return false;
  3794.  
  3795.             if (req)
  3796.             {
  3797.                 CT.Face();          // Bug w/Face() - do it twice to be safe
  3798.                 CT.Face();
  3799.                 Thread.Sleep(300);
  3800.  
  3801.                 if (MercCast(theSpell, TD <= 1.0f)) return true;
  3802.             }
  3803.             return false;
  3804.         }
  3805.  
  3806.         public static bool MercCast(string theSpell)
  3807.         {
  3808.             return MercCast(theSpell, CT, true);
  3809.         }
  3810.  
  3811.         public static bool MercCast(string theSpell, bool req = true)
  3812.         {
  3813.             return MercCast(theSpell, CT, req);
  3814.         }
  3815.  
  3816.         public static bool MercCastX(string theSpell, bool req = true)
  3817.         {
  3818.             return MercCastX(theSpell, CT, req);
  3819.         }
  3820.  
  3821.         public static bool MercCastX(string theSpell, TorCharacter theChar = null, bool req = true)
  3822.         {
  3823.             try
  3824.             {
  3825.  
  3826.                 if (theChar == null) return false;
  3827.  
  3828.                 if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, theChar) && CT != BuddyTor.Me)
  3829.                 {
  3830.                     Buddy.CommonBot.AbilityManager.Cast(theSpell, theChar);
  3831.                     Logger.Write("PvP Cast " + theSpell);
  3832.                     WaitForCast();
  3833.                     return true;
  3834.                 }
  3835.                 if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, Me))
  3836.                 {
  3837.                     Buddy.CommonBot.AbilityManager.Cast(theSpell, Me);
  3838.                     Logger.Write("PvP Cast " + theSpell);
  3839.                     WaitForCast();
  3840.                     return true;
  3841.                 }
  3842.             }
  3843.             catch { }
  3844.             return false;
  3845.         }
  3846.  
  3847.         public static bool MercCast(string theSpell, TorCharacter theChar=null, bool req = true)
  3848.         {
  3849.             try
  3850.             {
  3851.                 ObjectManager.Update();
  3852.  
  3853.                 if (!req) return false;
  3854.                 if (theChar == null) theChar=CT;
  3855.                 if (theChar == null) return false;
  3856.                 if (theSpell == "") return false;
  3857.                 if (theChar.IsDead) return false;
  3858.                 //if (theChar.Toughness==CombatToughness.Player) theChar=(TorCharacter)theChar;
  3859.                 //if (BuddyTor.Me.PvpFlagged)
  3860.                 //    if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, BuddyTor.Me.CurrentTarget) && CT!=BuddyTor.Me)
  3861.                 //    {
  3862.                 //        datLCs = DateTime.Now;
  3863.                 //        Buddy.CommonBot.AbilityManager.Cast(theSpell, BuddyTor.Me.CurrentTarget);
  3864.                 //        Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " THP: " + CT.HealthPercent.ToString("00.00") + " CT Scale: " + theChar.Scale.ToString("00.00") + " Casting " + theSpell //+ " on " + Me.CurrentTarget.Name
  3865.                 //            );
  3866.                 //        Thread.Sleep(1100);
  3867.                 //        WaitForCast();
  3868.                 //        BuddyTor.Me.ClearTarget();
  3869.                 //        //if (Me.CurrentTarget.Name == Me.Name) BuddyTor.Me.ClearTarget();
  3870.                 //        return true;
  3871.                 //    }
  3872.                 int SleepAfterCast = 300;
  3873.                 if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, theChar))
  3874.                 {
  3875.                     datLCs = DateTime.Now;
  3876.                     Buddy.CommonBot.AbilityManager.Cast(theSpell, theChar);
  3877.                     //Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " MyFac: " + Me.cbtFaction.ToString() +" AC: " + (Attackers==null?0:Attackers.Count()).ToString() + " TFac: " + CT.cbtFaction.ToString() +
  3878.                     //Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " HostileFriendly: " + CT.IsHostile.ToString() + " " + CT.IsFriendly.ToString() + " " + CT.IsNeutral.ToString() + " AC: " + (Attackers==null?0:Attackers.Count()).ToString() +
  3879.                     Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " AC: " + (Attackers==null?0:Attackers.Count()).ToString() +
  3880.                         " CTScale: " + CT.Scale.ToString("0.0") +
  3881.                         " THP: " + CT.HealthPercent.ToString("00.00") + " Comp: " + (Comp != null ? Comp.Name : "NONE").ToString() +
  3882.                         " CHP: " + CHP.ToString("000.0") + " Casting " + theSpell //+ " on " + theChar.Name
  3883.                         );
  3884.                     Thread.Sleep(SleepAfterCast);
  3885.                     WaitForCast();
  3886.                     //if (theChar.Name==Me.Name) BuddyTor.Me.ClearTarget();
  3887.                     return true;
  3888.                 }
  3889.                 //if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, BuddyTor.Me.CurrentTarget))
  3890.                 //{
  3891.                 //    datLCs = DateTime.Now;
  3892.                 //    Buddy.CommonBot.AbilityManager.Cast(theSpell, BuddyTor.Me.CurrentTarget);
  3893.                 //    Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " AC: " + (Attackers == null ? 0 : Attackers.Count()).ToString() + " CTScale: " + CT.Scale.ToString("0.0") +
  3894.                 //        " THP: " + CT.HealthPercent.ToString("00.00") + " Comp: " + (Comp != null ? Comp.Name : "NONE").ToString() +
  3895.                 //        " CHP: " + CHP.ToString("000.0") + " Casting " + theSpell //+ " on " + theChar.Name
  3896.                 //        );
  3897.                 //    Thread.Sleep(SleepAfterCast);
  3898.                 //    WaitForCast();
  3899.                 //    //if (theChar.Name==Me.Name) BuddyTor.Me.ClearTarget();
  3900.                 //    return true;
  3901.                 //}
  3902.                 //if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, null))
  3903.                 //{
  3904.                 //    datLCs = DateTime.Now;
  3905.                 //    Buddy.CommonBot.AbilityManager.Cast(theSpell, null);
  3906.                 //    Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " AC: " + (Attackers == null ? 0 : Attackers.Count()).ToString() + " CTScale: " + CT.Scale.ToString("0.0") +
  3907.                 //        " THP: " + CT.HealthPercent.ToString("00.00") + " Comp: " + (Comp != null ? Comp.Name : "NONE").ToString() +
  3908.                 //        " CHP: " + CHP.ToString("000.0") + " Casting " + theSpell //+ " on " + theChar.Name
  3909.                 //        );
  3910.                 //    Thread.Sleep(SleepAfterCast);
  3911.                 //    WaitForCast();
  3912.                 //    //if (theChar.Name==Me.Name) BuddyTor.Me.ClearTarget();
  3913.                 //    return true;
  3914.                 //}
  3915.                 if (Buddy.CommonBot.AbilityManager.CanCast(theSpell, BuddyTor.Me))
  3916.                 {
  3917.                     datLCs = DateTime.Now;
  3918.                     Buddy.CommonBot.AbilityManager.Cast(theSpell, BuddyTor.Me);
  3919.                     Logger.Write("HP: " + HP.ToString("000.0") + " RS: " + RS.ToString("000.0") + " AC: " + (Attackers == null ? 0 : Attackers.Count()).ToString() + " CTScale: " + CT.Scale.ToString("0.0") +
  3920.                         " THP: " + CT.HealthPercent.ToString("00.00") + " Comp: " + (Comp != null ? Comp.Name : "NONE").ToString() +
  3921.                         " CHP: " + CHP.ToString("000.0") + " Casting " + theSpell //+ " on " + theChar.Name
  3922.                         );
  3923.                     Thread.Sleep(SleepAfterCast);
  3924.                     WaitForCast();
  3925.                     //if (theChar.Name==Me.Name) BuddyTor.Me.ClearTarget();
  3926.                     return true;
  3927.                 }
  3928.             }
  3929.             catch { }
  3930.             return false;
  3931.         }
  3932.  
  3933.         public static void MercForcedCast(string theSpell, TorCharacter theUnit)
  3934.         {
  3935.             try
  3936.             {
  3937.                 if (theSpell == "") return;
  3938.                 datLCs = DateTime.Now;
  3939.                 Buddy.CommonBot.AbilityManager.Cast(theSpell, theUnit);
  3940.                 WaitForCast();
  3941.             }
  3942.             catch { }
  3943.         }
  3944.  
  3945.         static bool HaveTarget()
  3946.         {
  3947.             if (CT != null) if (!CT.IsFriendly && !CT.IsDead) return true;
  3948.             return false;
  3949.         }
  3950.  
  3951.         static void CheckForGroup()
  3952.         {
  3953.                 IG = (!PullIG && BuddyTor.Me.GroupId != 0);
  3954.         }
  3955.  
  3956.         public static void GetEffects()
  3957.         {
  3958.             MyBuffs = "";  // Me.HasBuff(X) will ignore element 0 - buggy, so created this
  3959.             try {foreach (TorEffect te in BuddyTor.Me.Buffs) MyBuffs += te.Name + ";";} catch { }
  3960.             CTDebuffs = "";
  3961.             try {if (CT != null) foreach (TorEffect te in CT.Debuffs) CTDebuffs += te.Name + ";";} catch { }
  3962.         }
  3963.  
  3964.         public static int MobsInRangeOf(Buddy.Common.Math.Vector3 Loc, float Range)
  3965.         {
  3966.             int MC = 0;
  3967.             try
  3968.             {  
  3969.                 foreach (TorNpc t in Attackers.Where(t => t!=null && !t.IsDeleted && !t.IsDead))
  3970.                 if ( !(t.Toughness==CombatToughness.Player || t.Toughness==CombatToughness.Companion) && t.HealthPercent>=.2f
  3971.                     && !t.IsFriendly && Buddy.Common.Math.Vector3.Distance(Loc, t.Position)<=Range) MC+=1;
  3972.             }
  3973.             catch { }
  3974.             return MC;
  3975.         }
  3976.  
  3977.         public static TorPlayer Me { get { return (TorPlayer)BuddyTor.Me; } }
  3978.  
  3979.         public static void UseQuestItem(string theItem, TorCharacter theUnit=null, float WithinRange=1.5f, int SleepAfterUse=5000)
  3980.         {
  3981.             //foreach (var o in BuddyTor.Me.InventoryEquipment)
  3982.             foreach (var o in BuddyTor.Me.InventoryQuest)
  3983.             {
  3984.                 if (o.Name.Contains(theItem) && o.MinimumLevel <= Me.Level)
  3985.                 {
  3986.                     Logger.Write("Using Quest Item " + o.Name + "...");
  3987.                     if (theUnit != null)
  3988.                     {
  3989.                         MoveTo(theUnit, WithinRange);
  3990.                         Thread.Sleep(500);
  3991.                     }
  3992.                     o.Use();
  3993.                     o.Interact();
  3994.                     o.Interact();
  3995.                     Thread.Sleep(1000);
  3996.                     WaitForCast();
  3997.                     if (SleepAfterUse != 0)
  3998.                     {
  3999.                         Thread.Sleep(SleepAfterUse);
  4000.                         Logger.Write("Sleeping after Item-Use for " + SleepAfterUse.ToString() + "...");
  4001.                     }
  4002.                     return;
  4003.                 }
  4004.             }
  4005.         }
  4006.  
  4007.         public static void AdjCTIfNull()
  4008.         {
  4009.             if (CT != null && (CT.Name == MyName || CT.Name == CompName))
  4010.             {
  4011.                 CT = null;
  4012.                 BuddyTor.Me.ClearTarget();
  4013.             }
  4014.  
  4015.             if (CT != null) return;
  4016.  
  4017.             TorCharacter CTx = BuddyTor.Me.CurrentTarget;
  4018.             string CTName = "NONE";
  4019.            
  4020.             if (CTx!=null) CTName = CTx.Name;
  4021.  
  4022.             if (!IG && CT == null && CTName!=MyName && CTName!=CompName) CT = CTx;
  4023.         }
  4024.  
  4025.         public static void CheckCombatQuestItemUsage()
  4026.         {
  4027.             var CTx = Me.CurrentTarget;
  4028.             if (Buddy.CommonBot.ConditionParser.HasQuest(0xE0006744EE8D74C2) && !Buddy.CommonBot.ConditionParser.IsStepComplete(0xE0006744EE8D74C2, 2))
  4029.                 if (CTx != null && CTx.Name.Contains("Savant") && CTx.HealthPercent<=30f) UseQuestItem("Savant Subjugation Device", CTx, 20f, 15000);
  4030.             if (Buddy.CommonBot.ConditionParser.HasQuest(0xE0003BF69E6650DB) && !Buddy.CommonBot.ConditionParser.IsStepComplete(0xE0003BF69E6650DB, 2))
  4031.                 if (CTx != null && CTx.Name.Contains("Unstable Defense Droid")) UseQuestItem("Veek's Modified Ion Gun", CTx, 1.0f, 15000);
  4032.         }
  4033.  
  4034.         // If I have myself or my own companion targeted, clear the target - name used due to possibility of a non-pointer/handle-match
  4035.         public static void ClearTargetIfNec()
  4036.         {
  4037.             try
  4038.             {
  4039.                 if (Me.CurrentTarget != null && (Me.CurrentTarget.Name == MyName || Me.CurrentTarget.Name == CompName)) BuddyTor.Me.ClearTarget();
  4040.             }
  4041.             catch { }
  4042.         }
  4043.  
  4044.         public static void LoadVars()
  4045.         {
  4046.  
  4047.             CheckGC();
  4048.  
  4049.             DateTime LVStart = DateTime.Now;
  4050.  
  4051.             if (Me.InCombat) CheckCombatQuestItemUsage();
  4052.  
  4053.             try
  4054.             {
  4055.                 ObjectManager.FlushOldEntries();
  4056.                 ObjectManager.Update();
  4057.  
  4058.                 GetEffects();
  4059.                 CompName = "NONE";
  4060.                 MyName = "NONE";
  4061.  
  4062.                 ClearTargetIfNec();
  4063.  
  4064.                 CheckForGroup();
  4065.                 GetAttackers();
  4066.  
  4067.                 CompTarg = null;
  4068.  
  4069.                 PullIG = false;                                 // They wanna pull shit, they can do it MANUALLY
  4070.  
  4071.                 TD = 100;
  4072.                 RS = 50;
  4073.                 TC = false;
  4074.                 LHH = 0;
  4075.                 CTT = CombatToughness.None;
  4076.                 LHD = 100;
  4077.                 THP = 0;
  4078.                 TC = false;
  4079.                 THP = 100;
  4080.  
  4081.                 if (Me.CurrentTarget!=null && Me.CurrentTarget.Name==MyName) BuddyTor.Me.ClearTarget();
  4082.                
  4083.                 RS = BuddyTor.Me.ResourceStat;
  4084.                 HP = BuddyTor.Me.HealthPercent;
  4085.                 EP = BuddyTor.Me.EnergyPercent;
  4086.  
  4087.                 if (!IG)
  4088.                 {
  4089.                     LHDebuffs.Clear();
  4090.                     string strLHDebuffs = "";
  4091.                     foreach (var db in Me.Debuffs) try
  4092.                         {
  4093.                             { LHDebuffs.Add(db.Name, db.Stacks); strLHDebuffs += db.Name + ":" + db.Stacks.ToString() + ";"; }
  4094.                         }
  4095.                         catch { }
  4096.                 }
  4097.  
  4098.                 if (Me.Class == CharacterClass.BountyHunter || Me.Class == CharacterClass.Trooper)
  4099.                 {
  4100.                     RS = Math.Min((float)Me.ResourceStat, (float)Me.EnergyPercent);
  4101.                     RS = Math.Min(RS, (float)Me.Energy);
  4102.                 }
  4103.  
  4104.                 if (MyName == "") MyName = BuddyTor.Me.Name;
  4105.  
  4106.                 if (BuddyTor.Me.InCombat && HP >= 10f) LastCombatPt = Me.Position;
  4107.  
  4108.                 //using (BuddyTor.Memory.AcquireFrame()) ...
  4109.  
  4110.                 CTP = null;
  4111.  
  4112.                 if (!IG && CT != null && (CT.IsDead || CT.HealthPercent < .2f) && CT == DPSLastTarget)
  4113.                 {
  4114.                     DPSTotalDamage += DPSHealthStart;
  4115.                     DPSTotalFightTime += DateTime.Now.Subtract(DPSCheckStart).TotalSeconds;
  4116.                     Logger.Write("Rough Average Single-Target DPS: " + (DPSTotalDamage / DPSTotalFightTime).ToString("0.0"));
  4117.                 }
  4118.                 if (!IG && CT != null && CT != DPSLastTarget && BuddyTor.Me.InCombat)
  4119.                 {
  4120.                     DPSLastTarget = CT;
  4121.                     DPSCheckStart = DateTime.Now;
  4122.                     DPSHealthStart = CT.Health;
  4123.                 }
  4124.  
  4125.                 CT = null;
  4126.  
  4127.                 try
  4128.                 {
  4129.                     if (!IG && Attackers != null) if (Attackers.Count() > 0) foreach (TorNpc d in Attackers) if (!d.IsDead && d.HealthPercent > .1f) { CT = d; break; }
  4130.                     if (Me.CurrentTarget != null && Me.CurrentTarget.Toughness == CombatToughness.Player && !Me.PvpFlagged) { CT = null; Me.ClearTarget(); }
  4131.                 }
  4132.                 catch { }
  4133.  
  4134.                 TorCharacter GT = null;
  4135.                 if (IG)
  4136.                 {
  4137.                     GT = GetGroupTarget();
  4138.                     if (GT != null)
  4139.                     {
  4140.                         if (GT!=null) CT = (TorCharacter)GT;
  4141.                         GT.Target();
  4142.                         if (IG && CT!=null && !CT.IsDeleted && CT.Toughness != CombatToughness.Player && CT.IsHostile) Is55H = (CT.Level >= 55);
  4143.                     }
  4144.                 }
  4145.  
  4146.                 //if (IG) CT = Me.CurrentTarget;
  4147.  
  4148.                 if (!IG && CHP <= 70f && Attackers != null && Attackers.Count() > 0) foreach (TorCharacter att in Attackers) if (att.CurrentTarget.Name == CompName) { CT = att; break; }
  4149.  
  4150.                 //if (!IG && CT != null && !(CT.IsNeutral || CT.IsFriendly || CT.IsHostile))
  4151.                 //{
  4152.                 //    Logger.Write("Vendor/'Friendly' targeted, blacklisting.");
  4153.                 //    if (!Buddy.CommonBot.Blacklist.Contains(CT.Guid)) Buddy.CommonBot.Blacklist.Add(CT, BlacklistFlags.Kill, TimeSpan.FromSeconds(300));
  4154.                 //    if (!MyBlacklist.ContainsKey(CT.Guid)) MyBlacklist.Add(CT.Guid, DateTime.Now);
  4155.                 //    CT = null;
  4156.                 //    Me.ClearTarget();
  4157.                 //}
  4158.                 if (!IG && CT == null && LastComp != null && LastComp.CurrentTarget != null && LastComp.CurrentTarget.Name!=MyName && LastComp.CurrentTarget.Name!=CompName) {CT = LastComp.CurrentTarget; CT.Target();}
  4159.  
  4160.                 if (CT != null) if (CT.Guid != CG)
  4161.                     {
  4162.                         Logger.Write("Initiating Combat with " + CT.Name + " InGroup: " + IG.ToString() + " My Spec: " + MySpec.ToString());
  4163.                         Me.ClearTarget();
  4164.                         CT.Target();
  4165.                         CG = CT.Guid;
  4166.                         CS = DateTime.Now;
  4167.                     }
  4168.  
  4169.  
  4170.                 if (CT != null)
  4171.                     try
  4172.                     {
  4173.                         CTT = CombatToughness.None;
  4174.  
  4175.                         MeleeDist = .50f;
  4176.                         if (CT.Scale == .80f || CT.Scale == 1.3f) MeleeDist = 1.0f;
  4177.                         CTT = CT.Toughness;
  4178.                         TD = BuddyTor.Me.Position.Distance(CT.Position);
  4179.                         TC = CT.IsCasting;
  4180.                         THP = CT.HealthPercent;
  4181.                     }
  4182.                     catch { }
  4183.  
  4184.                 CompTarg = null;
  4185.                 CHP = 100;
  4186.  
  4187.                 if (!IG)
  4188.                 {
  4189.                     var CompX = Comp;
  4190.                     if (CompX != null && !CompX.IsDead && CompX.CurrentTarget != null)
  4191.                     {
  4192.                         var CTx = CompX.CurrentTarget;
  4193.                         if (!CTx.IsFriendly && CTx != CompX && CTx != Me && CTx.Name != MyName) CompTarg = CompX.CurrentTarget;
  4194.                     }
  4195.                 }
  4196.  
  4197.                 TWR30 = 0;
  4198.                 TWR10 = 0;
  4199.                 TWR5 = 0;
  4200.             }
  4201.  
  4202.             catch { }
  4203.              
  4204.             if (Attackers != null)
  4205.                 try
  4206.                 {
  4207.                     TWR30 = Attackers.Where(o => o.Distance <= 3.0f).Count();
  4208.                     TWR10 = Attackers.Where(o => o.Distance <= 1.50f).Count();
  4209.                     TWR5 = Attackers.Where(o => o.Distance <= MeleeDist).Count();
  4210.                 }
  4211.                 catch { }
  4212.             if (ReportDurs) Logger.Write("LoadVar Dur: " + DateTime.Now.Subtract(LVStart).TotalMilliseconds.ToString("0ms"));
  4213.         }
  4214.  
  4215.         public static TorCharacter Comp
  4216.         {  
  4217.             get
  4218.             {
  4219.                 float HealthTest = 0;
  4220.                 float DistTest = 0;
  4221.  
  4222.                 if (IG || BuddyTor.Me.IsMounted || BuddyTor.Me.PvpFlagged) return null;
  4223.  
  4224.                 bool bErr = false;
  4225.                 if (LastComp!=null) try
  4226.                 {
  4227.                     HealthTest = ((TorNpc)LastComp).HealthPercent;
  4228.                     DistTest = LastComp.Distance;
  4229.                 }
  4230.                 catch { bErr = true; }
  4231.  
  4232.                 // If it's been 10 or more seconds since we acquired the 'last reused the comp handle' then force a requery to get the most recent comp, otherwise if no error on Health/Distance, return the last comp queried
  4233.                 if (DateTime.Now.Subtract(datLCC).TotalSeconds < 10 && !bErr && LastComp != null) { CHP = HealthTest; CompName = LastComp.Name; return (TorCharacter)LastComp; }
  4234.  
  4235.                 DateTime CompCheckBeg = DateTime.Now;
  4236.  
  4237.                 TorCharacter LastCompX=null;
  4238.                 foreach (TorNpc mob in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance))
  4239.                 try
  4240.                 {
  4241.                     if (mob != null && !mob.IsDeleted && mob.Toughness==CombatToughness.Companion && mob.Distance<=5.0f) //if (!mob.IsDeleted)
  4242.                     {
  4243.                         CHP = mob.HealthPercent;
  4244.                         datLCC = DateTime.Now;
  4245.                         LastComp = mob;
  4246.                         LastCompX=mob;
  4247.                         break;
  4248.                     }
  4249.                 }
  4250.                 catch {}
  4251.                
  4252.                 if (LastCompX != null)
  4253.                 {
  4254.                     try
  4255.                     {
  4256.                         //LastComp = (TorCharacter)LastCompX;
  4257.                         CompName = LastComp.Name;
  4258.                         //CHP = LastComp.HealthPercent;
  4259.                     }
  4260.                     catch { LastComp = null; CompName = "NONE"; CHP = 100; }
  4261.                 }
  4262.  
  4263.                 if (ReportDurs) Logger.Write("Companion Check Dur: " + DateTime.Now.Subtract(CompCheckBeg).TotalMilliseconds.ToString("0ms"));
  4264.  
  4265.                 return (TorCharacter)LastComp;
  4266.             }
  4267.         }
  4268.  
  4269.         public static bool IsBG { get { return BuddyTor.Me.AdvancedClass == Buddy.Swtor.AdvancedClass.Mercenary; } }
  4270.         public static bool IsCM { get { return BuddyTor.Me.AdvancedClass == Buddy.Swtor.AdvancedClass.Commando; } }
  4271.         public static bool IsSage { get { return BuddyTor.Me.AdvancedClass == Buddy.Swtor.AdvancedClass.Sage; } }
  4272.  
  4273.         //public static void CheckForHeals(float minH)
  4274.         //{
  4275.         //    try
  4276.         //    {
  4277.  
  4278.         //        LHUnit = null;
  4279.         //        LHUnit = UnitLowOnHealth(minH);
  4280.         //        LHH = 100f;
  4281.         //        LHD = 100f;
  4282.  
  4283.         //        if (LHUnit != null)
  4284.         //        {
  4285.         //            LHH = LHUnit.HealthPercent;
  4286.         //            LHD = LHUnit.Distance;
  4287.         //            LHP = LHUnit.Position;
  4288.         //        }
  4289.         //    }
  4290.         //    catch { }
  4291.         //}
  4292.  
  4293.         // Get the 'Group Target'
  4294.         // Verify that the player's target IS NOT a player.
  4295.         // Trying to query objects objects of NPC/Player type, by using type, doesn't work at the moment, so you get Players with an NPC query, and vice versa.
  4296.         // To Sum it All Up:  Listen to the song, 'Hot Dog', by Limp Bizkit.
  4297.  
  4298.         public static TorCharacter GetGroupTarget()
  4299.         {
  4300.                 foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().OrderBy(o => o.Distance).Where(o => o!=null && !o.IsDeleted && o.Toughness==CombatToughness.Player && o.Name!=MyName))
  4301.                     try
  4302.                     {
  4303.                         if (unit.Distance <= 4.5f && unit.Toughness==CombatToughness.Player)
  4304.                         {
  4305.                             var t=unit.CurrentTarget;
  4306.                             if (t != null && !t.IsFriendly && t.Toughness!=CombatToughness.Player && unit.InCombat && !unit.IsStunned)
  4307.                                     {
  4308.                                         Logger.Write("Group Target Determined: " + t.Name);
  4309.                                         return (TorCharacter)t;
  4310.                                     }
  4311.                         }
  4312.                     }
  4313.                     catch { }
  4314.                 foreach (TorCharacter o in ObjectManager.GetObjects<TorCharacter>().OrderBy(o => o.Distance)
  4315.                   .Where(o => o != null && !o.IsDeleted && o.Toughness != CombatToughness.Player && o.Name != MyName && o.InCombat && o.CurrentTarget != null &&
  4316.                    o.CurrentTarget.Name == MyName)) return (TorCharacter)o;
  4317.              return null;
  4318.         }
  4319.  
  4320.         public static bool CheckPlayerBuffs(string Buff)
  4321.         {
  4322.             if (BuddyTor.Me.IsMounted) return false;
  4323.             if (DateTime.Now.Subtract(datLBC).TotalSeconds < 20) return false;
  4324.             try
  4325.             {
  4326.                 foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().OrderBy(t => t.HealthPercent).Where(t=>t!=Me))
  4327.                     if (unit.Distance <= 2.8f && unit.IsFriendly && unit.InLineOfSight && !unit.HasBuff(Buff))
  4328.                     { datLBC = DateTime.Now; MercCast(Buff, unit); Thread.Sleep(500); BuddyTor.Me.ClearTarget(); return true; }
  4329.             }
  4330.             catch {
  4331.                 return false;
  4332.             }
  4333.             return false;
  4334.         }
  4335.  
  4336.         public static void GetGroupLHUnitInfo(float minH)
  4337.         {
  4338.             LHUnit = null;
  4339.             LHH = 100f;
  4340.             LHD = 100f;
  4341.             for (int inti = 0; inti < 3; inti++)
  4342.             {
  4343.                 try
  4344.                 {
  4345.                     //foreach (TorCharacter unit in ObjectManager.GetObjects<TorCharacter>().OrderBy(t => t.HealthPercent))
  4346.                     foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().OrderBy(o=>o.HealthPercent))//.Where(o=>o.Distance<=3.00f))
  4347.                         if (unit!=null && !unit.IsDeleted && !unit.IsHostile && unit.Toughness==CombatToughness.Player && unit.Distance <= 3.0f
  4348.                             && (float)unit.HealthPercent < minH )
  4349.                         {
  4350.                             TorCharacter unitX = (TorCharacter)unit;
  4351.                             float uhp = (float)unitX.HealthPercent;
  4352.                             //Logger.Write("Unit: " + unit.Name + " HP: " + uhp.ToString());
  4353.                             if (uhp < .2f)
  4354.                             {
  4355.                                 if (MySpec == SkillTreeId.SorcererCorruption) MercForcedCast("Reanimation", unitX);
  4356.                                 else if (MySpec == SkillTreeId.OperativeMedic) MercForcedCast("Resuscitation Probe", unitX);
  4357.                                 else if (MySpec == SkillTreeId.MercenaryBodyguard) MercForcedCast("Onboard AED", unitX);
  4358.                                 else if (MySpec == SkillTreeId.SageSeer) MercForcedCast("Revival", unitX);
  4359.                                 else if (MySpec == SkillTreeId.CommandoCombatMedic) MercForcedCast("Emergency Medical Probe", unitX);
  4360.                                 WaitForCast();
  4361.                             } else                           //else
  4362.                             if (uhp <= minH)
  4363.                             {
  4364.                                 LHUnit = unitX;
  4365.                                 LHH = LHUnit.HealthPercent;
  4366.                                 LHD = LHUnit.Distance;
  4367.                                 LHP = LHUnit.Position;
  4368.                                 LHDebuffs.Clear();
  4369.                                 string strLHDebuffs="";
  4370.                                 foreach (var db in LHUnit.Debuffs) try
  4371.                                     {
  4372.                                         try { LHDebuffs.Add(db.Name, db.Stacks); strLHDebuffs += db.Name + ":" + db.Stacks.ToString() + ";"; }
  4373.                                         catch { }
  4374.                                     }
  4375.                                     catch { }
  4376.                                 //Logger.Write("LH Debuffs: " + strLHDebuffs);
  4377.                                 return ;
  4378.                             }
  4379.                         }
  4380.                 }
  4381.                 catch {}
  4382.                 Thread.Sleep(50);
  4383.             }
  4384.         }
  4385.  
  4386.         public static bool MercMoveAndStop(TorCharacter tc, float rng)
  4387.         {
  4388.             CommonBehaviors.MoveAndStop(ret => tc.Position, rng, true, "Target Position");
  4389.             return false;
  4390.  
  4391.         }
  4392.  
  4393.         public static bool BGCheckCompHealth()
  4394.         {
  4395.             try
  4396.             {  
  4397.                 TorCharacter CompX = Comp;
  4398.                 if (CompX == null) return false;
  4399.                 TorCharacter PT = Me.CurrentTarget;
  4400.  
  4401.                 if (CHP < 1f)
  4402.                 {
  4403.                     if (MercCast("Onboard AED", (TorPlayer)CompX)) return true;
  4404.                 }
  4405.                 else if (CHP <= 90f)
  4406.                 {
  4407.                     CompX.Target();
  4408.                     Thread.Sleep(300);
  4409.                     WaitForCast();
  4410.                     if (CompX.Distance > 2.8f) { MoveTo(CompX, 2.8f); Thread.Sleep(300); }
  4411.                     else
  4412.                     {
  4413.                         MercCastOnGround("Kolto Missile", true, CompX);
  4414.                         MercCast("Emergency Scan", CompX);
  4415.                         MercCast("Kolto Shell", CompX,!CompX.HasBuff("Kolto Shell"));
  4416.                         MercCast("Kolto Shield", CompX,!CompX.HasBuff("Kolto Shield"));
  4417.                         MercCast("Healing Scan", CompX);
  4418.                         MercCast("Rapid Scan", CompX);
  4419.                         if (MyBuffs.Contains("Combat Support Cylinder")) MercCast("Rapid Shots", CompX);
  4420.                     }
  4421.                     WaitForCast();
  4422.                     PT.Target();
  4423.                     Thread.Sleep(300);
  4424.                 }
  4425.             }
  4426.             catch { Logger.Write("Error in CheckCompHealth()"); }
  4427.  
  4428.             return false;
  4429.         }
  4430.  
  4431.         public static bool CMCheckCompHealth()
  4432.         {
  4433.             try
  4434.             {
  4435.  
  4436.                 if (Comp == null) return false;
  4437.                 var CompX = (TorCharacter)Comp;
  4438.                 HandleDebuffs(CompX);
  4439.  
  4440.                 if (CHP <= 85f)
  4441.                 {
  4442.                     WaitForCast();
  4443.                     var PT=Me.CurrentTarget;
  4444.                     CompX.Target();
  4445.                     Thread.Sleep(250);
  4446.                     if (Comp.Distance > 2.8f) { MoveTo(Comp, 2.8f); Thread.Sleep(300); }
  4447.                     if (CHP < 1f)
  4448.                     {
  4449.                         if (MercCast("Onboard AED", CompX)) return true;
  4450.                     }
  4451.                     else
  4452.                     {
  4453.  
  4454.                         if (MercCastOnGround("Kolto Bomb", true, CompX)) Thread.Sleep(600);
  4455.  
  4456.                         if (
  4457.                             MercCast("Trauma Probe", CompX, !CompX.HasBuff("Trauma Probe")) ||
  4458.                             MercCast("Advanced Medical Probe", CompX) ||
  4459.                             MercCast("Bacta Infusion", CompX) ||
  4460.                             MercCast("Medical Probe", CompX) ||
  4461.                             (MyBuffs.Contains("Combat Support Cell") && MercCast("Hammer Shot", CompX)))
  4462.                         {
  4463.                             Thread.Sleep(250);
  4464.                             if (PT == null || PT.Toughness == CombatToughness.Companion)
  4465.                                 Me.ClearTarget();
  4466.                             else
  4467.                                 PT.Target();
  4468.                             return true;
  4469.                         }
  4470.                     }
  4471.                 }
  4472.             }
  4473.             catch { Logger.Write("Error in CheckCompHealth()"); }
  4474.  
  4475.             return false;
  4476.         }
  4477.  
  4478.         public static bool MedicineCheckCompHealth()
  4479.         {
  4480.             try
  4481.             {
  4482.  
  4483.                 if (Comp == null) return false;
  4484.  
  4485.                 if (CHP <= 50)
  4486.                 {
  4487.                     WaitForCast();
  4488.                     if (Comp.Distance > 2.8f) { MoveTo(Comp, 2.8f); Thread.Sleep(300); }
  4489.                     if (CHP < 1f)
  4490.                     {
  4491.                         //if (MercCast("Onboard AED", Comp)) return true;
  4492.                     }
  4493.                     else
  4494.                     {
  4495.                         if (MercCast("Surgical Probe", Comp, MyBuffs.Contains("Tactical Advantage"))) return true;
  4496.                         if (MercCast("Kolto Infusion", Comp, MyBuffs.Contains("Tactical Advantage"))) return true;
  4497.                         if (MercCast("Kolto Probe", Comp, HP <= 70 && !Comp.HasBuff("Kolto Probe"))) return true;
  4498.                         if (MercCast("Kolto Injection", Comp)) return true;
  4499.                     }
  4500.                 }
  4501.             }
  4502.             catch { Logger.Write("Error in CheckCompHealth()"); }
  4503.  
  4504.             return false;
  4505.         }
  4506.  
  4507.         public static bool SeerCheckCompHealth()
  4508.         {
  4509.             try
  4510.             {
  4511.  
  4512.                 if (Comp == null) return false;
  4513.                 var CompX = (TorCharacter)Comp;
  4514.  
  4515.                 if (!CompX.HasBuff("Force Armor")) if (MercCast("Force Armor", CompX)) return true;
  4516.  
  4517.                 if (CHP <= 50)
  4518.                 {
  4519.                     WaitForCast();
  4520.                     if (Comp.Distance > 2.8f) { MoveTo(Comp, 2.8f); Thread.Sleep(300); }
  4521.                     if (CHP < 1f || Comp.IsDead)
  4522.                     {
  4523.                         if (MercCast("Onboard AED", Comp)) return true;
  4524.                     }
  4525.                     else
  4526.                     {
  4527.                         var pt = Me.CurrentTarget;
  4528.                         CompX.Target();
  4529.                         Thread.Sleep(500);
  4530.                         if (
  4531.                             MercCast("Force Armor", CompX, !CompX.HasBuff("Force Armor")) ||
  4532.                             MercCast("Healing Trance", CompX, true) ||
  4533.                             MercCast("Rejuvenate", CompX, !CompX.HasBuff("Rejuvenate")) ||
  4534.                             MercCastOnGround("Salvation", !CompX.HasBuff("Salvation"), CompX) ||
  4535.                             MercCast("Benevolence", CompX) ||
  4536.                             MercCast("Deliverance", CompX) ||
  4537.                             MercCast("Rescue", CompX, CHP <= 20)
  4538.                             ) { if (pt != null && pt != CompX)pt.Target(); else Me.ClearTarget(); return true; }
  4539.  
  4540.                     }
  4541.                 }
  4542.             }
  4543.             catch { Logger.Write("Error in CheckCompHealth()"); }
  4544.  
  4545.             return false;
  4546.         }
  4547.  
  4548.         public static bool CorruptionCheckCompHealth()
  4549.         {
  4550.             try
  4551.             {
  4552.                 if (Comp == null) return false;
  4553.  
  4554.                 var CompX = (TorCharacter)Comp;
  4555.                 if (!CompX.HasBuff("Static Barrier") && !Comp.HasDebuff("Deionized")) if (MercCast("Static Barrier", CompX)) return true;
  4556.  
  4557.                 if (CHP <= 75f)
  4558.                 {
  4559.                     WaitForCast();
  4560.                     MoveTo(CompX, 2.8f);
  4561.                     if (CHP < .2f)
  4562.                     {
  4563.                         if (MercCast("Reanimation", CompX)) return true;
  4564.                     }
  4565.                     else
  4566.                     {
  4567.                         var pt = Me.CurrentTarget;
  4568.                         CompX.Target();
  4569.                         Thread.Sleep(200);
  4570.                         //bool HealedComp = false;
  4571.                         //if (CompX.Debuffs.Count() >= 2) if (MercCast("Purge")) HealedComp=true;
  4572.                         //else if (MercCast("Rejuvenate", CompX, !CompX.HasBuff("Rejuvenate"))) HealedComp = true;
  4573.                         //else if (MercCastOnGround("Revivification", !CompX.HasBuff("Revivification"), CompX)) HealedComp = true;
  4574.                         //else if (MercCast("Resurgence", CompX)) HealedComp = true;
  4575.                         //else if (MercCast("Dark Heal", CompX)) HealedComp = true;
  4576.                         //else if (MercCast("Dark Infusion", CompX)) HealedComp = true;
  4577.                         //else if (MercCast("Innervate", CompX, !CompX.HasBuff("Innervate"))) HealedComp = true;
  4578.                         //else if (MercCast("Rescue", CompX, CHP <= 20)) HealedComp = true;
  4579.  
  4580.                         bool HealedComp = false;
  4581.                         if (CompX.Debuffs.Count() >= 2) {if (MercCast("Purge")) HealedComp=true;};
  4582.                         if (!HealedComp) if (
  4583.                             MercCast("Rejuvenate", CompX, !CompX.HasBuff("Rejuvenate")) ||
  4584.                             MercCastOnGround("Revivification", !CompX.HasBuff("Revivification"), CompX)||
  4585.                             MercCast("Resurgence", CompX) ||
  4586.                             MercCast("Dark Heal", CompX) ||
  4587.                             MercCast("Dark Infusion", CompX) ||
  4588.                             MercCast("Innervate", CompX, !CompX.HasBuff("Innervate"))||
  4589.                             MercCast("Rescue", CompX, CHP <= 20)) HealedComp = true;
  4590.  
  4591.                         if (pt == null || pt == CompX) Me.ClearTarget(); else pt.Target();
  4592.                         Thread.Sleep(200);
  4593.                         if (HealedComp) return true;
  4594.                     }
  4595.                 }
  4596.             }
  4597.             catch (Exception ex) { Logger.Write("Error in CorruptionCheckCompHealth: " + ex.Message); }
  4598.  
  4599.             return false;
  4600.         }
  4601.  
  4602.         public static void TagAlongWithGroup()
  4603.         {
  4604.             if (BuddyTor.Me.PvpFlagged) return;
  4605.  
  4606.             foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().OrderBy(t => t.Distance).Reverse())
  4607.                 if (unit!=null && !unit.IsDeleted) try
  4608.                 {
  4609.                     MoveTo(unit, 2.0f);
  4610.                     break;
  4611.                 }
  4612.                 catch { }
  4613.            
  4614.         }
  4615.  
  4616.         public static bool UnitHasBuff(TorCharacter theUnit, string theBuff)
  4617.         {
  4618.             foreach (var buf in theUnit.Buffs) try
  4619.                 {
  4620.                     if (buf != null && !buf.IsDeleted && buf.Name.Contains(theBuff)) return true;
  4621.                 }
  4622.                 catch { }
  4623.             return false;
  4624.         }
  4625.  
  4626.  
  4627.         // All Redundant code here is due to timing issues, where the game would bug on the healtargeting, or the bot might miss the 'window'
  4628.         // The redundancy mainly added for 55HMs.  Apparently the healtargeting bug has been around in SWTOR (game, not bot, bug) and BIG SURPRISE - they haven't fixed it yet.
  4629.         // Namely, where you target someone in range for a Cure, heal, etc, and it casts the spell on YOU instead.  Good times.  Happens mainly with Emergency Scan from what I've seen.
  4630.  
  4631.         public static bool BGHeals(float minH, bool UntilFullyHealed=true)
  4632.         {
  4633.             try
  4634.             {
  4635.                 GetGroupLHUnitInfo(minH);
  4636.                 if (LHUnit == null) return false;
  4637.  
  4638.                 while (true)
  4639.                 {
  4640.                     Thread.Sleep(150);
  4641.                     WaitForCast();
  4642.  
  4643.                     if (!LHUnit.InLineOfSight || LHUnit.Distance > 3.0f) MoveTo(LHUnit, 2.5f);
  4644.                     if (!LHUnit.InLineOfSight || LHUnit.Distance > 3.0f) break;
  4645.  
  4646.                     //Me.ClearTarget();
  4647.                     //Thread.Sleep(100);
  4648.  
  4649.                     // Heal-Targeting in SWTOR is buggy as all fuck, specially for Mercs
  4650.                    
  4651.                     LHUnit.Target(); Thread.Sleep(350);
  4652.                     LHUnit.Target(); Thread.Sleep(350);
  4653.  
  4654.                     if (MercCastOnGround("Kolto Missile", true, LHUnit)) Thread.Sleep(800);
  4655.                     if (MercCast("Kolto Shell", LHUnit, !LHUnit.HasBuff("Kolto Shell"))) Thread.Sleep(800);
  4656.                     if (MercCast("Cure", LHUnit, NeedsDispell(LHUnit))) Thread.Sleep(800);
  4657.  
  4658.                     if (!MercCast("Emergency Scan", (TorCharacter)LHUnit, Me.CurrentTarget == LHUnit))
  4659.                     if (!MercCast("Rapid Scan", LHUnit, MyBuffs.Contains("Critical Efficiency") || LHUnit.HealthPercent<=65f))
  4660.                     if (!MercCast("Healing Scan", LHUnit, true))
  4661.                     if (!MercCast("Supercharged Gas", Me, HaveBuffStacks("Supercharge", 30)))
  4662.                     if (!MercCast("Vent Heat")) ;
  4663.  
  4664.                     Thread.Sleep(250);
  4665.                     WaitForCast();
  4666.  
  4667.                     if (MercCast("Rapid Shots", LHUnit, true)) Thread.Sleep(800);
  4668.  
  4669.                     GetGroupLHUnitInfo(minH);
  4670.                     if (LHUnit == null) break;
  4671.  
  4672.                 }
  4673.  
  4674.                 var pt = GetGroupTarget();
  4675.                 Me.ClearTarget();
  4676.                 if (pt != null && pt.Toughness!=CombatToughness.Player) pt.Target();
  4677.                
  4678.                 return false;
  4679.             }
  4680.             catch { }
  4681.             return false;
  4682.         }
  4683.  
  4684.         public static bool CMHeals(Single minH)
  4685.         {
  4686.  
  4687.             GetGroupLHUnitInfo(minH);
  4688.             if (LHUnit == null) return false;
  4689.  
  4690.             TorCharacter pt;
  4691.             while (true)
  4692.             {
  4693.                 Thread.Sleep(200);
  4694.                 WaitForCast();
  4695.  
  4696.                 MoveTo(LHUnit, 2.5f);
  4697.                 if (!LHUnit.InLineOfSight || LHUnit.Distance > 2.90f) break;
  4698.  
  4699.                 LHUnit.Target();
  4700.                 Thread.Sleep(350);
  4701.                 LHUnit.Target();
  4702.                 Thread.Sleep(350);
  4703.  
  4704.                 if (MercCastOnGround("Kolto Bomb", true, LHUnit)) Thread.Sleep(800);
  4705.                 if (MercCast("Trauma Probe", LHUnit, LHUnit.InCombat && !LHUnit.HasBuff("Trauma Probe"))) Thread.Sleep(800);
  4706.                 if (MercCast("Field Aid", LHUnit, NeedsDispell(LHUnit))) Thread.Sleep(800);
  4707.  
  4708.                 if(!MercCast("Medical Probe", LHUnit, MyBuffs.Contains("Field Triage") || MyBuffs.Contains("Tech Override") || LHUnit.HealthPercent<=70f))
  4709.                 if(!MercCast("Bacta Infusion", LHUnit, LHH <= 70f))
  4710.                 if(!MercCast("Advanced Medical Probe", LHUnit, true))
  4711.                 if(!MercCastOnGround("Kolto Bomb", true, LHUnit))
  4712.                 if (!MercCast("Hammer Shot", LHUnit)) ;
  4713.  
  4714.                 Thread.Sleep(200);
  4715.                 WaitForCast();
  4716.                 if (MyBuffs.Contains("Combat Support Cell")) if (MercCast("Hammer Shot", LHUnit)) Thread.Sleep(800);
  4717.  
  4718.                 GetGroupLHUnitInfo(minH);
  4719.                 if (LHUnit == null) break;
  4720.             }
  4721.  
  4722.             Me.ClearTarget();
  4723.             pt = GetGroupTarget();
  4724.             if (pt != null && pt.Toughness != CombatToughness.Player) pt.Target();
  4725.  
  4726.             Thread.Sleep(200);
  4727.             return false;
  4728.         }
  4729.  
  4730.         public static bool NeedsDispell(TorCharacter theUnit)
  4731.         {
  4732.  
  4733.             bool DoPurge = false;
  4734.             DoPurge=LHDebuffs.Count()>=2 || LHDebuffs.Where(t=>t.Value>=3).Count()>=3;
  4735.             //try
  4736.             //{ if (!DoPurge) DoPurge = theUnit.Debuffs.Where(db => db != null && !db.IsDeleted && db.Name.Contains("Targeted Laser")).Count() > 0; }
  4737.             //catch { }
  4738.  
  4739.             //if (!DoPurge) try
  4740.             //{
  4741.             //    int dbC = theUnit.Debuffs.Where(db => db != null && !db.IsDeleted).Count();
  4742.             //    int dbStack2 = theUnit.Debuffs.Where(db => db != null && !db.IsDeleted && db.Stacks >= 2).Count();
  4743.             //    if (dbStack2 >= 1 || dbC >= 4) DoPurge = true;
  4744.             //}
  4745.             //catch { }
  4746.  
  4747.             //if (!DoPurge)
  4748.             //    foreach (TorEffect deb in theUnit.Debuffs)
  4749.             //        try { if (deb != null && !deb.IsDeleted && deb.Stacks >= 3) { DoPurge = true; break; } }
  4750.             //        catch { }
  4751.             return DoPurge;
  4752.         }
  4753.  
  4754.         public static bool SeerHeals(float minH)
  4755.         {
  4756.             GetGroupLHUnitInfo(minH);
  4757.             if (LHUnit == null) return false;
  4758.             if (LHUnit.HealthPercent>minH) return false;
  4759.  
  4760.             var pt = Me.CurrentTarget;
  4761.             while (true)
  4762.             {
  4763.                 WaitForCast();
  4764.                 MoveTo(LHUnit, 2.5f);
  4765.  
  4766.                 if (!LHUnit.InLineOfSight || LHUnit.Distance > 2.90f) break;
  4767.  
  4768.                 LHUnit.Target();
  4769.                 Thread.Sleep(350);
  4770.                 LHUnit.Target();
  4771.                 Thread.Sleep(350);
  4772.  
  4773.                 if (MercCast("Force Armor", LHUnit, LHH <= minH && !LHUnit.HasBuff("Force Armor")))Thread.Sleep(900);
  4774.                 if(NeedsDispell(LHUnit)) if (MercCast("Restoration", LHUnit)) Thread.Sleep(900);
  4775.                 if(MercCast("Deliverance", LHUnit, MyBuffs.Contains("Resplendence"))) Thread.Sleep(900);
  4776.  
  4777.                 //if(!MercCast("Rescue", LHUnit, LHH <= 20f))
  4778.                 if(!MercCast("Healing Trance",LHUnit, true))
  4779.                 if(!MercCast("Rejuvenate", LHUnit, !LHUnit.HasBuff("Rejuvenate")))
  4780.                 if(!MercCastOnGround("Salvation", true, LHUnit))
  4781.                 if(!MercCast("Benevolence", LHUnit, true))
  4782.                 if(!MercCast("Deliverance", LHUnit, true)) ;
  4783.                 if(!MercCast("Noble Sacrifice", HP >= 30f && (Me.ForcePercent <= 50f || Me.Force <= Me.ForceMax * .50f)));
  4784.  
  4785.                 Thread.Sleep(250);
  4786.                 WaitForCast();
  4787.  
  4788.                 if (MercCast("Deliverance", LHUnit, MyBuffs.Contains("Resplendence"))) Thread.Sleep(900);
  4789.  
  4790.                 GetGroupLHUnitInfo(minH);
  4791.                 if (LHUnit == null) break;
  4792.                 if (LHUnit.HealthPercent > minH) break;
  4793.             }
  4794.  
  4795.             Me.ClearTarget();
  4796.             pt = GetGroupTarget();
  4797.             if (pt != null && pt.Toughness != CombatToughness.Player) pt.Target();
  4798.             Thread.Sleep(200);
  4799.             return false;
  4800.  
  4801.         }
  4802.  
  4803.         // MAJOR Heal-Targeting bugs in SWTOR - You ARE gonna hit alot of heals that go to YOU instead of the target in here - game bug, not a bot bug
  4804.  
  4805.         //public static bool ShieldTank(string theSpell)
  4806.         //{
  4807.         //    foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().OrderBy(o=>o.HealthPercent))//.Where(o=>o.Distance<=3.00f))
  4808.         //        if (unit!=null && !unit.IsDeleted && !unit.IsHostile && unit.Toughness==CombatToughness.Player && unit!=Me && unit.Distance <= 3.0f
  4809.         //          && unit.AdvancedClass==AdvancedClass. )
  4810.  
  4811.         //}
  4812.  
  4813.         public static bool CorruptionHeals(float minH)
  4814.         {
  4815.  
  4816.             var pt = Me.CurrentTarget;
  4817.             while (true)
  4818.             {
  4819.  
  4820.                 GetGroupLHUnitInfo(minH);
  4821.                 if (LHUnit == null) return false;
  4822.  
  4823.                 WaitForCast();
  4824.  
  4825.                 if (LHUnit.InLineOfSight) MoveTo((TorCharacter)LHUnit, 2.5f);
  4826.                 if (!LHUnit.InLineOfSight || LHUnit.Distance>3.0f) return false;
  4827.  
  4828.                 LHUnit.Target();
  4829.                 Thread.Sleep(350);
  4830.                 LHUnit.Target();
  4831.                 Thread.Sleep(350);
  4832.  
  4833.                 if (MercCast("Static Barrier", LHUnit, !LHUnit.HasBuff("Static Barrier"))) Thread.Sleep(900);
  4834.                 if (NeedsDispell(LHUnit)) if (MercCast("Purge", LHUnit)) Thread.Sleep(800);
  4835.                 if (MercCastOnGround("Revivification", MyBuffs.Contains("Force Surge"), LHUnit)) Thread.Sleep(900);
  4836.  
  4837.                 if (!MercCast("Rescue", LHUnit, LHH <= 20))
  4838.                 if (!MercCast("Innervate", LHUnit, true))
  4839.                 if (!MercCast("Resurgence", LHUnit, !LHUnit.HasBuff("Resurgence")))
  4840.                 if (!MercCast("Dark Heal", LHUnit, true))
  4841.                 if (!MercCast("Dark Infusion", LHUnit, LHH <= 70f))
  4842.                 if (!MercCastOnGround("Revivification", true, LHUnit))
  4843.                 if (!MercCast("Consumption", Me.HealthPercent>=30f));
  4844.                 //if (MercCast("", LHUnit, LHH <= minH && !LHUnit.HasBuff("Healing Trance"))) return true;
  4845.  
  4846.                 if (MercCastOnGround("Revivification", MyBuffs.Contains("Force Surge"), LHUnit)) Thread.Sleep(900);
  4847.  
  4848.                 Thread.Sleep(250);
  4849.                 WaitForCast();
  4850.             }
  4851.  
  4852.             pt = GetGroupTarget();
  4853.             Me.ClearTarget();
  4854.             if (pt != null && pt.Toughness != CombatToughness.Player) pt.Target();
  4855.  
  4856.             Thread.Sleep(200);
  4857.             return false;
  4858.         }
  4859.  
  4860.         public static bool MedicineHeals(float minH)
  4861.         {
  4862.             if (Me.ResourceStat < 16.0f && !Me.HasBuff("Tactical Advantage")) return false;
  4863.  
  4864.             GetGroupLHUnitInfo(minH);
  4865.             if (LHUnit == null) return false ;
  4866.             if (LHUnit.HealthPercent > minH) return false;
  4867.  
  4868.             var pt = Me.CurrentTarget;
  4869.            
  4870.             while (true)
  4871.             {
  4872.                 Thread.Sleep(250);
  4873.                 WaitForCast();
  4874.  
  4875.                 MoveTo(LHUnit, 2.5f);
  4876.                 if (!LHUnit.InLineOfSight || LHUnit.Distance > 3.0f) break;
  4877.  
  4878.                 LHUnit.Target(); Thread.Sleep(350);
  4879.                 LHUnit.Target(); Thread.Sleep(350);
  4880.  
  4881.                 if (MercCast("Recuperative Nanotech", LHUnit))Thread.Sleep(900);
  4882.  
  4883.                 if (MercCast("Toxin Scan", LHUnit, NeedsDispell(LHUnit)));
  4884.                 if (MercCast("Kolto Infusion", LHUnit, !LHUnit.HasBuff("Kolto Infusion") && HaveBuffStacks("Tactical Advantage", 2) && Me.ResourceStat>=100f));
  4885.                 if (MercCast("Surgical Probe", LHUnit, HaveBuffStacks("Tactical Advantage", 2)));
  4886.                 if (MercCast("Kolto Probe", LHUnit, !LHUnit.HasBuff("Kolto Probe") && !HaveBuffStacks("Tactical Advantage", 2)));
  4887.                 if (MercCast("Kolto Injection", LHUnit));
  4888.                 if (MercCast("Diagnostic Scan", LHUnit));
  4889.  
  4890.                 Thread.Sleep(250);
  4891.                 WaitForCast();
  4892.  
  4893.                 if (Me.ResourceStat < 16.0f && !Me.HasBuff("Tactical Advantage")) break;
  4894.  
  4895.                 GetGroupLHUnitInfo(minH);
  4896.                 if (LHUnit == null || LHUnit.Distance > 3.0f || !LHUnit.InLineOfSight) break;
  4897.                 if (LHUnit.HealthPercent > minH) break;
  4898.  
  4899.             }
  4900.  
  4901.             Me.ClearTarget();
  4902.             pt = GetGroupTarget();
  4903.             if (pt != null && pt.Toughness != CombatToughness.Player) { pt.Target(); Thread.Sleep(150); }
  4904.  
  4905.             return false;
  4906.         }
  4907.  
  4908.         public static void CheckForDeadComp()
  4909.         {
  4910.             if (Me.Level < 10) return;
  4911.             if (BuddyTor.Me.IsMounted) return;
  4912.             var datStart = DateTime.Now;
  4913.             try
  4914.            {
  4915.                 var CompX = Comp;
  4916.                 if (CompX != null) if (!CompX.IsDeleted) if (CompX.IsDead && CompX.HealthPercent < .20f)
  4917.                 {
  4918.                     Logger.Write("Reviving Comp...");
  4919.                     while (DateTime.Now.Subtract(datStart).TotalSeconds<5 && (CompX.Distance>.50f || !CompX.InLineOfSight))
  4920.                         Buddy.Navigation.Navigator.MoveTo(CompX.Position);
  4921.                     CompX.Interact();
  4922.                     Thread.Sleep(2500);
  4923.                 }
  4924.             } catch {}
  4925.  
  4926.         }
  4927.  
  4928.         // Buggy, not sure why, but always thinks everything is null and returns false
  4929.         //public static bool ValidTarget(TorCharacter theTarget)
  4930.         //{  
  4931.         //    try {
  4932.         //        TorCharacter Targ = null;
  4933.         //        if (theTarget == null) if (!IG) Targ = CT; else Targ = BuddyTor.Me.CurrentTarget;
  4934.  
  4935.         //        if (Targ == null || Targ == BuddyTor.Me) { Logger.Write("ValidTarget: Null target."); return false; }
  4936.         //        //Targ = (TorCharacter)Targ;
  4937.         //        if (Targ.IsDead || Targ.HealthPercent < .2f || Targ.IsFriendly) { Logger.Write("TargetInCombat:  Dead or friendly."); return false; }
  4938.         //        if (!IG || TargetInCombat()) if (Targ.Distance<=3.0f) return true;
  4939.         //    }
  4940.         //    catch {}
  4941.  
  4942.         //    Logger.Write("Error in ValidTarget.");
  4943.         //    return false;
  4944.         //}
  4945.  
  4946.         public static void HandleBuffs(string theBuff, bool req=true)
  4947.         {
  4948.             if (req)
  4949.             {
  4950.                 if (BuddyTor.Me.IsDead || BuddyTor.Me.HealthPercent < .2f) return;
  4951.                 MercBuffSelf(theBuff);
  4952.                 CheckPlayerBuffs(theBuff);
  4953.             }
  4954.         }
  4955.  
  4956.         public static void MyRestAndBuffs()
  4957.         {
  4958.             if (Me.InCombat) return;
  4959.  
  4960.             //if (MySpec == SkillTreeId.None)
  4961.             if (Me.HasBuff("Crouch") || Me.HasBuff("Take Cover"))
  4962.             {
  4963.                 Buddy.Swtor.Movement.Move(MovementDirection.Forward, TimeSpan.FromMilliseconds(100));
  4964.                 if (!MovementAllowed) Buddy.Swtor.Movement.Stop(MovementDirection.Forward);
  4965.                 StopMoving();
  4966.                 StopMoving();
  4967.             }
  4968.  
  4969.             MercCast("Stealth", BuddyTor.Me, Me.HasBuff("Stealth"));
  4970.            
  4971.             {
  4972.                 if (Me.Class == CharacterClass.Warrior)
  4973.                 {
  4974.                     IsRanged = false;
  4975.                     WaitForRest(true, "Channel Hatred", true, 0);
  4976.                     HandleBuffs("Unnatural Might");
  4977.                 }
  4978.                 else if (Me.Class == CharacterClass.Inquisitor)
  4979.                 {
  4980.                     if (Me.AdvancedClass == AdvancedClass.Assassin) IsRanged = false; else IsRanged = true;
  4981.                     WaitForRest(true, "Seethe", true, BuddyTor.Me.ForceMax * .8f);
  4982.                     HandleBuffs("Mark of Power");
  4983.                 }
  4984.                 else if (Me.Class == CharacterClass.Agent)
  4985.                 {
  4986.                     IsRanged = false;
  4987.                     HandleBuffs("Coordination");
  4988.                     WaitForRest(true, "Recuperate", true, 80f);
  4989.                 }
  4990.                 else if (Me.Class == CharacterClass.BountyHunter)
  4991.                 {
  4992.                     IsRanged = true;
  4993.                     WaitForRest(true, "Recharge and Reload", true, 80f);
  4994.                     HandleBuffs("Hunter's Boon");
  4995.                 }
  4996.                 else if (Me.Class == CharacterClass.Knight)
  4997.                 {
  4998.                     IsRanged = false;
  4999.                     WaitForRest(true, "Introspection", true, 0f);
  5000.                     HandleBuffs("Force Might");
  5001.                 }
  5002.                 else if (Me.Class == CharacterClass.Consular)
  5003.                 {
  5004.                     if (Me.AdvancedClass == AdvancedClass.Shadow) IsRanged = false; else IsRanged = true;
  5005.                     WaitForRest(true, "Meditation", true, BuddyTor.Me.ForceMax * .8f);
  5006.                     HandleBuffs("Force Valor");
  5007.                 }
  5008.                 else if (Me.Class == CharacterClass.Smuggler)
  5009.                 {
  5010.                     IsRanged = true;
  5011.                     HandleBuffs("Lucky Shots");
  5012.                     WaitForRest(true, "Recuperate", true, 80f);
  5013.                 }
  5014.                 else if (Me.Class == CharacterClass.Trooper)
  5015.                 {
  5016.                     IsRanged = true;
  5017.                     WaitForRest(true, "Recharge and Reload", true, 80f);
  5018.                     HandleBuffs("Fortification");
  5019.                 }
  5020.                 //else if (Me.Class == CharacterClass.Inquisitor)
  5021.                 //{
  5022.                 //    IsRanged = true;
  5023.                 //    WaitForRest(true, "Seethe", true, .8f * BuddyTor.Me.ForceMax);
  5024.                 //    HandleBuffs("Fortification");
  5025.                 //}
  5026.                 }
  5027.  
  5028.             // Special Handling for Specs (Group Heals, etc)
  5029.             if (MySpec == SkillTreeId.MercenaryBodyguard)
  5030.             {
  5031.                 if (!IG) if (!MyBuffs.Contains("High-Velocity Gas Cylinder")) MercCast("High-Velocity Gas Cylinder", BuddyTor.Me);
  5032.                 if (IG) if (!MyBuffs.Contains("Combat Support Cylinder")) MercCast("Combat Support Cylinder", BuddyTor.Me);
  5033.                 if (IG) BGHeals(95f);
  5034.             }
  5035.             else if (MySpec == SkillTreeId.CommandoCombatMedic)
  5036.             {
  5037.                 if (IG) while(CMHeals(95f));
  5038.                 MercBuffSelf("Combat Support Cell", true);
  5039.             }
  5040.             else if (MySpec == SkillTreeId.ScoundrelSawbones)
  5041.             {
  5042.                 if (IG) while (SawbonesHeals(95f)) ;
  5043.                 //MercBuffSelf("Combat Support Cell", true);
  5044.             }
  5045.             else if (MySpec == SkillTreeId.VanguardShieldSpecialist)
  5046.             {
  5047.                 MercBuffSelf("Ion Cell");
  5048.             }
  5049.             else if (MySpec == SkillTreeId.SageSeer)
  5050.             {
  5051.                 if (IG) SeerHeals(95);
  5052.             }
  5053.             else if (MySpec == SkillTreeId.SorcererCorruption)
  5054.             {
  5055.                 if (IG) CorruptionHeals(95);
  5056.             }
  5057.             else if (MySpec == SkillTreeId.OperativeMedic)
  5058.             {
  5059.                 if (IG) MedicineHeals(95);
  5060.             }
  5061.         }
  5062.  
  5063.         // Since I override the hell out of everything, this is a shell for combat, empty, to say we DO have a Combat Routine in BuddyWing (All actual combat is invoked through Joe's, through OOCPS->OOC)
  5064.         // ... as Combat PrioritySelectors are REQUIRED in BuddyWing, but since per above I override everything, not necessary in the 'BuddyWing Root Declarations'.
  5065.         public static Composite MyCombatPSShell()
  5066.         {
  5067.             return MyCombatPS();
  5068.             //return new PrioritySelector();
  5069.         }
  5070.  
  5071.         // Not sure why, but the .exe seems to definitely prefer a PrioritySelector over an Action, so coded a PrioritySelector for stability-sake.
  5072.         public static Composite MyCombatPS()
  5073.         {
  5074.             if (IAmDead() || !AllowCombat) return new PrioritySelector();
  5075.  
  5076.             return //new PrioritySelector(
  5077.                 //new Action(ret => { if (AllowCombat) while (true) { MyCombat(); ObjectManager.Update(); Thread.Sleep(300); if (!MeOrCompInCombat()) break; } return RunStatus.Failure; });
  5078.             new Action(ret => { if (AllowCombat) MyCombat(); return RunStatus.Failure; });
  5079.             //, Spell.Cast("DoNothing", ret => false)
  5080.                     //);
  5081.         }
  5082.  
  5083.         public static Composite MyOOCPS()
  5084.         {
  5085.             if (IAmDead()) return new PrioritySelector();
  5086.             return new Action(ret =>
  5087.             {
  5088.                 while (true)
  5089.                     try
  5090.                     {
  5091.                         OOC();
  5092.                         if ((!IG && !DoRandomGrind) || (!IG && DoRandomGrind && IAmDead())) return RunStatus.Failure;
  5093.                         Thread.Sleep(200);
  5094.                     }
  5095.                     catch { return RunStatus.Failure; }
  5096.             }
  5097.             );
  5098.         }
  5099.  
  5100.         public static void MyCombat()
  5101.         {
  5102.             if (IAmDead() || !AllowCombat) return;
  5103.  
  5104.             //RunningCombat = true;
  5105.             DateLastPingCombat = DateTime.Now;
  5106.  
  5107.             //return;
  5108.             if (Restarting) return;
  5109.             //Logger.Write("Entered MyCombat Void...");
  5110.  
  5111. //            while (true)
  5112.             {
  5113.                 CT = Me.CurrentTarget;
  5114.  
  5115.                 if (CT != null && CT.Name != Me.Name && !CT.IsFriendly)
  5116.                 {
  5117.                     MovementAllowed = MovementAllowedOrig;
  5118.                     //if (BuddyTor.Me.InCombat && !MovementAllowed) { MovementAllowed = true; MovementToggle(true); }
  5119.                    
  5120.                     if (MySpec == SkillTreeId.None)
  5121.                         switch (BuddyTor.Me.Class)
  5122.                         {
  5123.                             case CharacterClass.BountyHunter: while (!IAmDead() && MercenaryCombat()) ; break;
  5124.                             case CharacterClass.Warrior: while (!IAmDead() && MarauderCombat()) ; break;
  5125.                             case CharacterClass.Sorcerer: while (!IAmDead() && SorcererCombat()) ; break;
  5126.                             case CharacterClass.Agent: while (!IAmDead() && SniperCombat()) ; break;
  5127.                             case CharacterClass.Smuggler: while (!IAmDead() && ScrapperCombat()) ; break;
  5128.                             case CharacterClass.Trooper: while (!IAmDead() && CommandoCombat()) ; break;
  5129.                             case CharacterClass.Knight: while (!IAmDead() && WatchmanCombat()) ; break;
  5130.                             case CharacterClass.Consular: while (!IAmDead() && SageCombat()) ; break;
  5131.                             default: { break; }
  5132.                         }
  5133.  
  5134.                     else switch (MySpec)
  5135.                         {
  5136.                             case SkillTreeId.MercenaryBodyguard: while (!IAmDead() && MercenaryCombat())Thread.Sleep(300); break;
  5137.                             case SkillTreeId.MercenaryArsenal: while (!IAmDead() && MercenaryCombat()); break;
  5138.                             case SkillTreeId.MercenaryFirebug: while (!IAmDead() && MercenaryCombat()); break;
  5139.                             case SkillTreeId.PowertechAdvanced: while (!IAmDead() && PowerTechCombat()); break;
  5140.                             //case SkillTreeId.PowertechFirebug: break; // Bugged - overlapping SkillTreeID on this bug not sure where exactly
  5141.                             case SkillTreeId.PowertechShieldTech: while (!IAmDead() && PowerTechCombat()); break;
  5142.                             case SkillTreeId.MarauderAnnihilation: while (!IAmDead() && MarauderCombat()); break;
  5143.                             case SkillTreeId.MarauderRage: while (!IAmDead() && MarauderCombat()); break;
  5144.                             case SkillTreeId.MarauderCarnage: while (!IAmDead() && MarauderCombat()); break;
  5145.                             case SkillTreeId.JuggernautImmortal: while (!IAmDead() && JuggernautCombat()) ; break;
  5146.                             case SkillTreeId.JuggernautVengeance: while (!IAmDead() && JuggernautCombat()) ; break;
  5147.                             case SkillTreeId.JuggernautRage: while (!IAmDead() && JuggernautCombat()) ; break;
  5148.                             case SkillTreeId.SorcererMadness: while (!IAmDead() && SorcererCombat()); break;
  5149.                             case SkillTreeId.SorcererCorruption: while (!IAmDead() && SorcererCombat()); break;
  5150.                             case SkillTreeId.SorcererLightning: while (!IAmDead() && SorcererCombat()); break;
  5151.                             case SkillTreeId.AssassinDarkness: while (!IAmDead() && AssassinCombat()); break;
  5152.                             case SkillTreeId.AssassinMadness: while (!IAmDead() && AssassinCombat()); break;
  5153.                             case SkillTreeId.AssassinDeception: while (!IAmDead() && AssassinCombat()); break;
  5154.                             case SkillTreeId.OperativeMedic: while (!IAmDead() && OperativeCombat()); break;
  5155.                             case SkillTreeId.OperativeLethality: while (!IAmDead() && OperativeCombat()); break;
  5156.                             case SkillTreeId.OperativeConcealment: while (!IAmDead() && OperativeCombat()); break;
  5157.                             case SkillTreeId.SniperEngineering: while (!IAmDead() && SniperCombat()); break;
  5158.                             case SkillTreeId.SniperMarksmanship: while (!IAmDead() && SniperCombat()); break;
  5159.                             case SkillTreeId.SniperLethality: while (!IAmDead() && SniperCombat()); break;
  5160.  
  5161.                             case SkillTreeId.SentinelWatchman: while (!IAmDead() && SentinelCombat()); break;
  5162.                             case SkillTreeId.SentinelFocus: while (!IAmDead() && SentinelCombat()) ; break;
  5163.                             case SkillTreeId.SentinelCombat: while (!IAmDead() && SentinelCombat()) ; break;
  5164.                             case SkillTreeId.GuardianDefense: while (!IAmDead() && GuardianCombat()); break;
  5165.                             case SkillTreeId.GuardianFocus: while (!IAmDead() && GuardianCombat()); break;
  5166.                             case SkillTreeId.GuardianVigilance: while (!IAmDead() && GuardianCombat()); break;
  5167.                             case SkillTreeId.SageSeer: while (!IAmDead() && SageCombat()); break;
  5168.                             case SkillTreeId.SageTelekinetics: while (!IAmDead() && SageCombat()); break;
  5169.                             case SkillTreeId.SageBalance: while (!IAmDead() && SageCombat()); break;
  5170.                             case SkillTreeId.ShadowCombat: while (!IAmDead() && ShadowCombat()); break;
  5171.                             case SkillTreeId.ShadowBalance: while (!IAmDead() && ShadowCombat()); break;
  5172.                             case SkillTreeId.ShadowInfiltration: while (!IAmDead() && ShadowCombat()); break;
  5173.                             case SkillTreeId.CommandoCombatMedic: while (!IAmDead() && CommandoCombat() ||Me.InCombat); break;
  5174.                             case SkillTreeId.CommandoGunnery: while (!IAmDead() && CommandoCombat()); break;
  5175.                             case SkillTreeId.CommandoAssaultSpecialist: while (!IAmDead() && CommandoCombat()); break;
  5176.                             case SkillTreeId.VanguardShieldSpecialist: while (!IAmDead() && SSCombat()); break;
  5177.                             //case SkillTreeId.VanguardAssaultSpecialist: break;
  5178.                             case SkillTreeId.VanguardTactics: while (!IAmDead() && SSCombat()); break;
  5179.                             case SkillTreeId.GunslingerDirtyFighting: while (!IAmDead() && GunslingerCombat()); break;
  5180.                             case SkillTreeId.GunslingerSaboteur: while (!IAmDead() && GunslingerCombat()); break;
  5181.                             case SkillTreeId.GunslingerSharpshooter: while (!IAmDead() && GunslingerCombat()); break;
  5182.                             case SkillTreeId.ScoundrelDirtyFighting: while (!IAmDead() && ScoundrelCombat()); break;
  5183.                             case SkillTreeId.ScoundrelSawbones: while (!IAmDead() && ScoundrelCombat()); break;
  5184.                             case SkillTreeId.ScoundrelScrapper: while (!IAmDead() && ScoundrelCombat()); break;
  5185.                             default: { break; }
  5186.                         }
  5187.                 }
  5188.             }
  5189.             //Logger.Write("Exiting (Complete?) Combat.");
  5190.             //RunningCombat = false;
  5191.  
  5192.         }
  5193.  
  5194.         // If low on inventory, deploy a Field Repair Droid if we have that legacy ability, and sell all qualified.
  5195.  
  5196.         public static void CheckInventory()
  5197.         {
  5198.             bool LowDur = false;
  5199.             int MinSlots = 5;
  5200.  
  5201.             // Buggy - no use trying on this
  5202.             //foreach (var eq in BuddyTor.Me.InventoryEquipped) if (eq.HasDurability && eq.DurabilityPercent <= 50f) { LowDur = true; break; }
  5203.  
  5204.             if (LowDur || BuddyTor.Me.FreeInventorySlots < MinSlots) if (taDeployFRD.IsValid)
  5205.             {
  5206.                 Logger.Write("Out of inventory slots, trying to deploy Field Repair Droid.");
  5207.  
  5208.                 BuddyTor.Me.AbilityActivate(taDeployFRD, Me, out er);
  5209.                 Thread.Sleep(500); WaitForCast();
  5210.  
  5211.                 var datStart = DateTime.Now;
  5212.  
  5213.                 // FUCKING PAIN IN THE ASS - wish I'd never even posted this 'feature' - as always, nothin ever works 'The Following Week'
  5214.                 while (true)
  5215.                 {
  5216.                     if (DateTime.Now.Subtract(datStart).TotalSeconds >= 300) return;  // Keep trying for FIVE FUCKING MINUTES
  5217.  
  5218.                     BuddyTor.Me.ClearTarget();
  5219.                     Thread.Sleep(3000);
  5220.                     ObjectManager.Update();
  5221.                     TorCharacter TheVendor = null;
  5222.  
  5223.                     // Scan for EVERYTHING UNDER THE SUN until we find SOMETHING
  5224.                     foreach (TorVendor d in ObjectManager.GetObjects<TorVendor>())//.OrderBy(t=>t.Distance))
  5225.                         try
  5226.                         {
  5227.                             if (d != null && d.Name != null && d.Name.Contains("Field Repair")) { TheVendor = d; break; }
  5228.                         } catch {}
  5229.                     if (TheVendor==null) foreach (TorNpc d in ObjectManager.GetObjects<TorNpc>())//.OrderBy(t=>t.Distance))
  5230.                         try
  5231.                         {
  5232.                             if (d != null && d.Name != null && d.Name.Contains("Field Repair")) { TheVendor = d; break; }
  5233.                         } catch {}
  5234.                     if (TheVendor==null) foreach (TorCharacter d in ObjectManager.GetObjects<TorCharacter>())//.OrderBy(t=>t.Distance))
  5235.                         try
  5236.                         {
  5237.                             if (d != null && d.Name != null && d.Name.Contains("Field Repair")) { TheVendor = d; break; }
  5238.                         } catch {}
  5239.  
  5240.                     if (TheVendor == null) foreach (TorObject d in ObjectManager.GetObjects<TorObject>())//.OrderBy(t=>t.Distance))
  5241.                             try
  5242.                             {
  5243.                                 if (d != null && d.Name != null && d.Name.Contains("Field Repair") && d.Distance<=2.0f) { TheVendor = (TorCharacter)d; break; }
  5244.                             }
  5245.                             catch { }
  5246.                     if (TheVendor != null)
  5247.                         try
  5248.                         {
  5249.                             Logger.Write("Vendor " + TheVendor.Name + " found at: " + TheVendor.Position.ToString() + ", trying to interact...");
  5250.                             TheVendor.Target();
  5251.                             Thread.Sleep(1000);
  5252.                             //if (Me.CurrentTarget != null)
  5253.                             {
  5254.                                 TheVendor.Interact();
  5255.                                 TheVendor.Interact();
  5256.                                 Thread.Sleep(2000);
  5257.                                 Buddy.CommonBot.Logic.BrainBehavior.SellAllItems();
  5258.                                 Thread.Sleep(5000);                         // Apparently Asynch - Give it enough time to sell it all
  5259.                                 Buddy.Swtor.GuiApiManager.RepairAllItems();
  5260.                                 Thread.Sleep(2000);
  5261.                                 Buddy.Swtor.GuiApiManager.RepairAllItems(); // Fails 1/2 the time, so reducndant
  5262.                                 Thread.Sleep(2000);
  5263.                                 Me.ClearTarget();
  5264.                             }
  5265.                         }
  5266.                         catch { }
  5267.                     else Logger.Write("I still CANNOT FIND A GODDAMN VENDOR. Sleeping to try again... Give me a moment to delicately smash my keyboard through my monitor.");
  5268.  
  5269.                     if (Me.FreeInventorySlots >= MinSlots) return;
  5270.                     Thread.Sleep(3000);
  5271.                 }
  5272.             }
  5273.         }
  5274.  
  5275.         public static void RunGathering()
  5276.         {
  5277.             if (!IG && MovementAllowed)
  5278.             {
  5279.                 ScanForLootables();
  5280.                 ScanForPlaceables();
  5281.                 HarvestIfNec();
  5282.             }
  5283.         }
  5284.  
  5285.         public static void LoadQuests()
  5286.         {
  5287.             // Xenovirus Prime - Belsavis Daily
  5288.             myHS_XenovirusPrime = new MyQuestDef();
  5289.             var myHS = myHS_XenovirusPrime;
  5290.             myHS.SetProperties(0xE000D987B579F78A, 2,"Handful of Location Markers","", 7000);
  5291.             //myHS.SetItemToUse("Handful of Location Markers");
  5292.             myHS.AddToHSList( -49.04824,10.001,-263.1941);
  5293.             myHS.AddToHSList(-46.53094,10.001,-263.2531 );
  5294.             myHS.AddToHSList(-46.57342,10.001,-258.4337);
  5295.             myHS.AddToHSList( -49.1338,10.001,-258.4071);
  5296.             myHS.AddToHSList( -61.9276,10.001,-263.2448 );
  5297.             myHS.AddToHSList(-59.28479,10.001,-263.2181);
  5298.             myHS.AddToHSList( -61.93335,10.001,-258.3529);
  5299.             myHS.AddToHSList( -59.26503,10.001,-258.3987);
  5300.             //myHS.AddToHSList(-61.95681, 10.001, -263.2149);
  5301.  
  5302.             //Droid Malfunction - Belsavis Daily
  5303.             myHS_DroidMalfunction = new MyQuestDef();
  5304.             myHS = myHS_DroidMalfunction;
  5305.             myHS.SetProperties(0xE000BA9BB7DBB97D, 2);
  5306.             myHS.AddToHSList(-87.60915, 12.50146, -303.4151);
  5307.             myHS.AddToHSList(-88.06365, 12.37658, -307.7879);
  5308.             myHS.AddToHSList(-84.47065, 11.88158, -307.719);
  5309.             myHS.AddToHSList(-82.41384, 11.35196, -309.6615);
  5310.         }
  5311.  
  5312.         public static void CheckQuesting()
  5313.         {
  5314.             if (IG) return;
  5315.  
  5316.             myHS_DroidMalfunction.RunThrough();
  5317.             myHS_XenovirusPrime.RunThrough();
  5318.         }
  5319.  
  5320.         // Somewhat experimental at-the-moment
  5321.         public static void CheckPOI()
  5322.         {
  5323.             if (IG) return;
  5324.             try
  5325.             {
  5326.                 //foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>().Where(obj => obj.Name != null && !obj.DisabledForEveryone && (obj.AlwaysUsable || obj.IsLootable || obj.IsUsable)).OrderBy(t => t.Distance))
  5327.                 foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>().Where(obj => obj.Name != null).OrderBy(t => t.Distance))
  5328.                     //if (!MyBlacklist.Contains(obj.Guid.ToString()) && obj.Harvestable!=null && !obj.Harvestable.CanHarvest && obj.QuestIndication!=null && obj.QuestIndication==QuestIndication.QuestActive)
  5329.                     if (!MyBlacklist.ContainsKey(obj.Guid) && obj.QuestIndication != null && obj.IsUsable && obj.Distance!=null && obj.Distance <= 3.0f && obj.Name!=null && !obj.Name.Contains("Training Dummy"))
  5330.                     //if (!MyBlacklist.ContainsKey(obj.Guid) && obj.QuestIndication != null && obj.QuestIndication == QuestIndication.QuestActive && !obj.DisabledForEveryone)
  5331.                     {
  5332.                         Logger.Write("Questing Object Scan: Found [" + obj.Name + "], working on getting there now.");
  5333.                         MoveToAndInteract(obj, .30f);
  5334.                         MyBlacklist.Add(obj.Guid, DateTime.Now);
  5335.                         if (BuddyTor.Me.InCombat) return;
  5336.                     }
  5337.             }
  5338.             catch { return; }
  5339.             return;
  5340.  
  5341.             //if (Buddy.CommonBot.Poi.Current != null) Logger.Write("POI Type: " + Buddy.CommonBot.Poi.Current.Type + " Loc: " + Buddy.CommonBot.Poi.Current.Location.ToString());
  5342.             // If not in-group, not doing RandomGrind etc, just go ahead and move to the POI hotspot if appropriate (helps w/questing etc a little)
  5343.  
  5344.             Vector3 theLoc = new Vector3(0, 0, 0);
  5345.             string POIName = "";
  5346.             var CurHS = Buddy.CommonBot.HotspotManager.CurrentHotspot;
  5347.  
  5348.             string StatusText = Buddy.CommonBot.BotMain.StatusText;
  5349.             if (StatusText!=null && StatusText.Contains("Using object"))
  5350.             {
  5351.                 int ForPos = StatusText.IndexOf(" for");
  5352.                 POIName = StatusText.Substring(13, ForPos - 13);
  5353.                 //Logger.Write("POIName: " + POIName);
  5354.                 foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>().Where(obj => obj.Name != null && obj.Name.ToLower().Contains(POIName.ToLower())).OrderBy(t => t.Distance))
  5355.                 {
  5356.                     Logger.Write("POI Object Scan: Found [" + POIName + "], working on getting there now.");
  5357.                     MoveToAndInteract(obj, .3);
  5358.                     if (BuddyTor.Me.InCombat) return;
  5359.                     Thread.Sleep(7000);
  5360.                 }
  5361.  
  5362.             }
  5363.  
  5364.             return;
  5365.  
  5366.             if (!IG && !Me.InCombat && !DoRandomGrind && Buddy.CommonBot.Poi.Current != null && Buddy.CommonBot.Poi.Current.Location.X != 0)
  5367.                 Logger.Write("POI Type: " + Buddy.CommonBot.Poi.Current.Type.ToString() + " Name: " + Buddy.CommonBot.Poi.Current.Name + " Loc: " + Buddy.CommonBot.Poi.Current.Location.ToString());
  5368.  
  5369.             if (!IG && !Me.InCombat && !DoRandomGrind && Buddy.CommonBot.Poi.Current != null && Buddy.CommonBot.Poi.Current.Type != PoiType.Kill && Buddy.CommonBot.Poi.Current.Type != PoiType.Loot &&
  5370.                 Buddy.CommonBot.Poi.Current.Location.X != 0)
  5371.             {
  5372.                 theLoc = Buddy.CommonBot.Poi.Current.Location;
  5373.                 POIName = Buddy.CommonBot.Poi.Current.Name;
  5374.             }
  5375.             else if (CurHS != null && CurHS.X != 0)
  5376.             {
  5377.                 theLoc = CurHS.ToVector3();
  5378.                 POIName = CurHS.Name;
  5379.             }
  5380.  
  5381.             if (POIName != "" && theLoc.X != 0)
  5382.                 try
  5383.                 {
  5384.                     //Vector3 theLoc = new Vector3((float)-243.2681, (float)22.03563, (float)28.79927);
  5385.                     //Buddy.CommonBot.Poi.Current.Type==
  5386.                     //theLoc = new Vector3((float)theLoc.X, (float)theLoc.Y, (float)theLoc.Z);
  5387.                     if (theLoc.X != 0)
  5388.                     {
  5389.                         Logger.Write("POI (" + Buddy.CommonBot.Poi.Current.Name + ": " + Buddy.CommonBot.Poi.Current.Type.ToString() + ") Found and set to " + theLoc.ToString() + "... Working on getting there now.");
  5390.                         MountUp();
  5391.                         while (!Me.InCombat && Buddy.Common.Math.Vector3.Distance(Me.Position, theLoc) > .45f)
  5392.                         {
  5393.                             if (BuddyTor.Me.CurrentTarget != null && Me.CurrentTarget.Name != Me.Name) break;
  5394.                             //Buddy.Swtor.Input.MoveTo(theLoc);
  5395.                             Buddy.Navigation.Navigator.MoveTo(theLoc);
  5396.                             Thread.Sleep(200);
  5397.                         }
  5398.                     }
  5399.                     if (!Me.InCombat && Me.CurrentTarget == null && Buddy.Common.Math.Vector3.Distance(Me.Position, theLoc) < .45f)
  5400.                         foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>().Where(obj => obj.Name != null && obj.Name.Contains(POIName)))
  5401.                         {
  5402.                             obj.Interact();
  5403.                             Thread.Sleep(7000);
  5404.                         }
  5405.  
  5406.                     LastPOIName = POIName;
  5407.                 }
  5408.                 catch { }
  5409.             //}
  5410.             //using (BuddyTor.Memory.AcquireFrame()) { }
  5411.  
  5412.         }
  5413.  
  5414.         public static void CheckXP()
  5415.         {
  5416.             if (DateTime.Now.Subtract(LastXPShownTime).TotalSeconds >= 60)
  5417.             {
  5418.                 if (Me.Xp > LastXPCheck)
  5419.                 {
  5420.                     ulong XPGained = Me.Xp - LastXPCheck;
  5421.                     DateTime LocalTime = DateTime.Now.ToLocalTime();  // Time is all F'd up, just goin with ETA Minutes now.
  5422.  
  5423.                     ulong XPRemaining = Me.XpNeeded - Me.Xp;
  5424.                     double XPPerHour = XPGained * 3600 / (DateTime.Now.Subtract(LastXPCheckTime).TotalSeconds);
  5425.                     Logger.Write("XP Per Hour: " + XPPerHour.ToString("0,000") + " XP Needed for Level: " + XPRemaining.ToString("0,000") + " ETA for Level: " + (XPRemaining * 60 / XPPerHour).ToString("0") + " minutes.");
  5426.                 }
  5427.                 else
  5428.                 {
  5429.                     LastXPCheck = Me.Xp;
  5430.                     LastXPCheckTime = DateTime.Now;
  5431.                 }
  5432.                 LastXPShownTime = DateTime.Now;
  5433.             }
  5434.         }
  5435.  
  5436.         public static void CheckForCompTarget()
  5437.         {
  5438.             if (IG) return;
  5439.             try
  5440.             {
  5441.  
  5442.                 var CompX = Comp;
  5443.                 if (!IG && Me.CurrentTarget == null && CompX != null && CompX.InCombat)
  5444.                 {
  5445.                     var CompTargX = CompX.CurrentTarget;
  5446.                     if (CompTargX != null && CompTargX != Me && CompTargX != CompX) { CompTargX.Target(); }
  5447.                 }
  5448.             }
  5449.             catch { }
  5450.         }
  5451.  
  5452.         public static void CheckForQuestingInteract()
  5453.         {
  5454.             try
  5455.             {
  5456.                 var CTx = Me.CurrentTarget;
  5457.                 if (!IG && CTx != null && !CTx.IsDead && CTx.IsFriendly && CTx.Distance <= .50f) CTx.Interact();  // Questing Behavior update - attack a mob, get it to just-about-dead, then talk to it, sketchy in questing profiles
  5458.             }
  5459.             catch { }
  5460.         }
  5461.  
  5462.         public static void OOC()
  5463.         {
  5464.  
  5465.             CheckGC();
  5466.  
  5467.             if (IAmDead()) return;
  5468.             //Logger.Write("Running OOC....");
  5469.            
  5470.             DateLastPingOOC = DateTime.Now;
  5471.  
  5472.             if (Restarting) return;
  5473.  
  5474.             if (EnableMemMon) if (thMonMem == null || !thMonMem.IsAlive)
  5475.             {
  5476.                 thMonMem = null;
  5477.                 thMonMem = new Thread(MonMemory.WatchIt);
  5478.                 thMonMem.Start();
  5479.             }
  5480.  
  5481.             CheckXP();
  5482.  
  5483.             if (!IG && Me.CurrentTarget!=null && Me.CurrentTarget.Name.Contains(CompName)) Me.ClearTarget();
  5484.  
  5485.             if (!Me.InCombat && !IG)
  5486.             {
  5487.                 CheckForDeadComp();
  5488.                 CheckInventory();
  5489.                 CheckForCompTarget();
  5490.             }
  5491.  
  5492.             try
  5493.             {
  5494.                 CT = IG ? GetGroupTarget() : Me.CurrentTarget;
  5495.                 CheckForQuestingInteract();
  5496.                 CheckForCompTarget();
  5497.                 if (IG && CT != null) CT.Target();
  5498.                 if (BuddyTor.Me.InCombat || (CT != null && TargetInCombat()) || (BuddyTor.Me.CurrentTarget != null && !BuddyTor.Me.CurrentTarget.IsDead && BuddyTor.Me.CurrentTarget.Toughness != CombatToughness.Player)) { MyCombat(); return; }
  5499.             }
  5500.  
  5501.             catch { }
  5502.  
  5503.             if (DoRandomGrind && !IG) RunAroundAndKillStuff();
  5504.  
  5505.             if (DateTime.Now.Subtract(datLOOC).TotalSeconds <= 10) return;
  5506.  
  5507.             MyRestAndBuffs();
  5508.  
  5509.             if (!IG)
  5510.             {
  5511.                 ScanForLootables();
  5512.                 HarvestIfNec();
  5513.                 ScanForPlaceables();
  5514.             }
  5515.  
  5516.             if (Me.Level>=10 && !IG && !DoRandomGrind && !Me.IsMounted && Comp == null && !Me.PvpFlagged && DateTime.Now.Subtract(datLSC).TotalMinutes>=2) if (taSummComp != null && taSummComp.IsValid)
  5517.             {
  5518.                 Logger.Write("Trying to summon companion...");
  5519.                 if (BuddyTor.Me.AbilityActivate(taSummComp, Me, out er)) Thread.Sleep(1500);
  5520.                 datLSC = DateTime.Now;
  5521.             }
  5522.             //if (MovementAllowed != MovementAllowedOrig)
  5523.             //{
  5524.             //    MovementAllowed = MovementAllowedOrig;
  5525.             //    MovementToggle(MovementAllowed);
  5526.             //}
  5527.  
  5528.             if (IG && MovementAllowed && TagAlong) TagAlongWithGroup();
  5529.  
  5530.             //while (true)                                                          // Enable this at your own risk - but from what I tested with it worked fairly well - for Bodyguard combat.
  5531.             //{
  5532.             //    while (SageCombatPvP()) ;
  5533.             //    Thread.Sleep(500);
  5534.             //    if (IAmDead()) break;
  5535.             //}
  5536.             //return;
  5537.  
  5538.             //if (BuddyTor.Me.PvpFlagged) return;
  5539.  
  5540.             LoadVars();
  5541.  
  5542.             //CheckQuesting();            
  5543.             try
  5544.             {
  5545.  
  5546.                 if (ReportDurs) Logger.Write("OOC Dur up Thru Time Check: " + DateTime.Now.Subtract(DateLastPingOOC).TotalMilliseconds);
  5547.  
  5548.  
  5549.                
  5550.                 datLOOC = DateTime.Now;
  5551.  
  5552.                 if (Me.InCombat) { return; }
  5553.  
  5554.                 if (Me.IsDead) { Logger.Write("Dead, clearing target and returning."); BuddyTor.Me.ClearTarget(); return; }
  5555.  
  5556.                 LoadVars();
  5557.                 if (!IG && CT == null && CompTarg != null && CompTarg != Me)
  5558.                 {
  5559.                     CT = CompTarg;
  5560.                     CT.Target();
  5561.                     StopMoving();/*Bug with .exe - wants to move within zero meters of the target*/
  5562.                 }
  5563.  
  5564.                 if (!IG) WaitForComp();
  5565.  
  5566.                 if (!BuddyTor.Me.IsMounted) { MountUp(); }
  5567.  
  5568.                 if (ReportDurs) Logger.Write("OOC Duration: " + DateTime.Now.Subtract(datLOOC).TotalMilliseconds.ToString("0ms"));
  5569.  
  5570.             }
  5571.             catch { }
  5572.         }
  5573.  
  5574.  
  5575.         public static bool NeedRestRSMin(float minH, float minRS)
  5576.         {
  5577.             try
  5578.             { if (Comp != null) if ((Comp.Position.X != 0) && Comp.HealthPercent > 0f && Comp.HealthPercent < 85f) return true; }
  5579.             catch { }
  5580.            
  5581.             return (Me.ResourceStat < minRS || Me.HealthPercent < minH);
  5582.             //if (NR) Logger.Write("Need Rest...");
  5583.         }
  5584.  
  5585.         public static bool NeedRestRSMax(float minH, float minRS)
  5586.         {
  5587.             try
  5588.             { if (Comp != null) if (Comp.Position.X != 0 && Comp.HealthPercent < 85f) return true; }
  5589.             catch { }
  5590.  
  5591.             return (Me.ResourceStat > minRS || Me.HealthPercent < minH);
  5592.         }
  5593.  
  5594.         public static void KillStealth()
  5595.         {
  5596.         //Logger.Write("Entering WaitForRest...");
  5597.             while (MyBuffs.Contains("Stealth"))
  5598.             {
  5599.                 if (!MercCast("Stealth")) MercForcedCast("Force Wave", Me);  // Fucking PITA - Trying to cast Stealth while stealthed - WILL NOT WORK (nor will the Stealth ability)
  5600.                 Thread.Sleep(1000);
  5601.                 LoadVars();
  5602.             }
  5603.         }
  5604.  
  5605.         public static void WaitForRest(bool WaitForComp, string theSpell, bool RSIsMinimum, float RSVal)
  5606.         {
  5607.  
  5608.             if (Me.InCombat) return;// false;
  5609.             if (IAmDead()) return;// false;
  5610.  
  5611.             try
  5612.             {
  5613.                 if (WaitForComp) if (!IG && Comp != null && !Comp.IsDeleted) if (Comp.InCombat) return;// false;
  5614.             }
  5615.             catch { }
  5616.  
  5617.             if (RSIsMinimum)if(!NeedRestRSMin(90, RSVal)) return;// false;
  5618.             if (!RSIsMinimum)if(!NeedRestRSMax(90, RSVal)) return;// false;
  5619.  
  5620.             if(Me.CurrentTarget==null)KillStealth();
  5621.  
  5622.             if (IAmDead()) return;
  5623.  
  5624.             StopMoving();
  5625.             StopMoving();
  5626.  
  5627.             //Logger.Write("Starting Rest - HP: " Me.HealthPercent.ToString(".0") +
  5628.             Logger.Write("Starting Rest....");
  5629.             DateTime RestStart = DateTime.Now;
  5630.             while (!Me.IsCasting && !Me.InCombat && !IAmDead() && DateTime.Now.Subtract(RestStart).TotalSeconds<=3)
  5631.             {
  5632.                 Buddy.CommonBot.AbilityManager.Cast(theSpell, BuddyTor.Me);
  5633.                 Thread.Sleep(300);
  5634.             }
  5635.  
  5636.             Thread.Sleep(2000);
  5637.             TorCharacter CompX = Comp;
  5638.  
  5639.             datLCL = DateTime.Now;
  5640.             //ForcePulse();
  5641.  
  5642.             if (RSIsMinimum) while (DateTime.Now.Subtract(datLCL).TotalSeconds < 10 &&  BuddyTor.Me.IsCasting && NeedRestRSMin(90,RSVal) && !BuddyTor.Me.InCombat) Thread.Sleep(1000);
  5643.             if (!RSIsMinimum) while (DateTime.Now.Subtract(datLCL).TotalSeconds < 10 && BuddyTor.Me.IsCasting && NeedRestRSMax(90, RSVal) && !BuddyTor.Me.InCombat) Thread.Sleep(1000);
  5644.             if (CompX!=null && !CompX.IsDead) try
  5645.             {
  5646.                 if (WaitForComp && Comp != null) while (Me.IsCasting && Comp.HealthPercent <= 90f) Thread.Sleep(1000);
  5647.             }
  5648.             catch { }
  5649.  
  5650.             Logger.Write("Done with Rest.");
  5651.             if (BuddyTor.Me.IsCasting) SendMessage(SWTORHWnd, (int)0x100, (IntPtr)(char)0x1b, (IntPtr)0);
  5652.  
  5653.             Thread.Sleep(300);
  5654.  
  5655.         }
  5656.  
  5657.         public static void ForcePulse()
  5658.         {  
  5659.             if (DateTime.Now.Subtract(datLFP).TotalSeconds < 5) return;
  5660.             try { datLFP = DateTime.Now; Buddy.CommonBot.BotMain.CurrentBot.Pulse(); }
  5661.             catch { }
  5662.         }
  5663.  
  5664.         public static void WaitForComp()
  5665.         {
  5666.             var CompX = Comp;
  5667.             datLCL = DateTime.Now;
  5668.             if (CompX != null) { while (CompX.IsCasting && DateTime.Now.Subtract(datLCL).TotalSeconds <= 5) Thread.Sleep(500); }
  5669.         }
  5670.  
  5671.         public static ulong PISkill(string Skill)
  5672.         {
  5673.                 foreach (Buddy.Swtor.Objects.Components.ProfessionInfo pi in BuddyTor.Me.ProfessionInfos)if (pi.Name.Contains(Skill)) return (ulong)pi.CurrentLevel;
  5674.                 return 0;
  5675.         }
  5676.  
  5677.         public static bool CanHarvestCorpse(TorNpc unit)
  5678.         {
  5679.             //Logger.Write("Harvest: " + unit.Name + " UnitType: " + unit.CreatureType.ToString());
  5680.             ulong SkillReq = Math.Max(unit.Level - 11, 0) * 8;
  5681.             if (unit != null) if (!unit.IsDeleted) if (unit.IsDead && unit.Distance <= 4.0f &&
  5682.                         ((HasBio && unit.CreatureType == Buddy.Swtor.CreatureType.Creature && PISkill("Bioanalysis") >= SkillReq) ||
  5683.                          (HasScav && unit.CreatureType == Buddy.Swtor.CreatureType.Droid && PISkill("Scavenging") >= SkillReq)) &&
  5684.                         StrongOrGreater(unit) && !unit.IsFriendly) if (!Buddy.CommonBot.Blacklist.Contains(unit.Guid))
  5685.                         {
  5686.                             //Logger.Write("Can Harvest the corpse.");
  5687.                             return true;
  5688.                         }
  5689.             return false;
  5690.         }
  5691.  
  5692.         public static void MoveToAndInteract(TorNpc unit, double ToWithin = .99f)
  5693.         {
  5694.             if (MyBlacklist.ContainsKey(unit.Guid)) return;//|| !CanHarvestCorpse(unit)) return;
  5695.  
  5696.             datLCL = DateTime.Now;
  5697.             if (unit.Distance >= 3.0f) MountUp();
  5698.  
  5699.             MoveResult MR = MoveResult.Moved;
  5700.             while (unit.Distance > ToWithin && MR != MoveResult.Failed && MR != MoveResult.PathGenerationFailed && DateTime.Now.Subtract(datLCL).TotalSeconds <= 15)
  5701.             {
  5702.                 if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5703.                 MR = Buddy.Navigation.Navigator.MoveTo(unit.Position);
  5704.                 if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5705.                 Thread.Sleep(200);
  5706.             }
  5707.             StopMoving();
  5708.             StopMoving();
  5709.             Thread.Sleep(1500);
  5710.             if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5711.             if (unit.Distance <= ToWithin)
  5712.             {
  5713.                 //if (Comp != null) while (Comp.IsCasting) Thread.Sleep(1000);
  5714.                 if (unit != null) if (unit.Distance <= ToWithin) {
  5715.                     if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5716.                     unit.Interact(); // Loot
  5717.                     Thread.Sleep(2000);
  5718.                     if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5719.                     if (CanHarvestCorpse(unit)) { unit.Interact(); unit.Interact(); Thread.Sleep(3500); while (Me.IsCasting) Thread.Sleep(1000); }
  5720.                     if (BuddyTor.Me.CurrentTarget != null) MyBlacklist.Add(unit.Guid,DateTime.Now);
  5721.                     return;
  5722.                 }
  5723.             }
  5724.             return;
  5725.  
  5726.         }
  5727.  
  5728.         public static int GetLootableCount()
  5729.         {
  5730.             int LC=0;
  5731.  
  5732.             foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>())
  5733.                 try
  5734.                 { if (unit!=null) if (!unit.IsDeleted) if (unit.Distance <= MaxDist && unit.IsDead && unit.IsLootable) LC+=1;
  5735.                 } catch {}
  5736.             Logger.Write("Lootables Count: " + LC.ToString());
  5737.             return LC;
  5738.         }
  5739.  
  5740.         public static bool StrongOrGreater(TorCharacter unit)
  5741.         {
  5742.             if (IG) return EliteOrGreater(unit);
  5743.  
  5744.             if (unit != null) if (unit.Toughness == CombatToughness.Strong || unit.Toughness == CombatToughness.Boss1 || unit.Toughness == CombatToughness.Boss2 || unit.Toughness == CombatToughness.Player) return true;
  5745.             return false;
  5746.         }
  5747.  
  5748.         public static bool EliteOrGreater(TorCharacter unit)
  5749.         {
  5750.             if (unit != null) if (unit.Toughness == CombatToughness.Boss1 || unit.Toughness == CombatToughness.Boss2 || unit.Toughness == CombatToughness.Player || unit.Toughness==CombatToughness.Boss3 || unit.Toughness==CombatToughness.Boss4 || unit.Toughness==CombatToughness.RaidBoss) return true;
  5751.             return false;
  5752.         }
  5753.  
  5754.         public static bool StrongOrElite(TorCharacter unit)
  5755.         {
  5756.             if (unit != null) if (unit.Toughness == CombatToughness.Strong || unit.Toughness == CombatToughness.Boss1) return true;
  5757.             return false;
  5758.         }
  5759.  
  5760.         public static bool HarvestIfNec()
  5761.         {
  5762.             if (!HarvestCorpses) return false;
  5763.             if (!(HasBio || HasScav)) return false;
  5764.  
  5765.             datLCL = DateTime.Now;
  5766.  
  5767.             if (DateTime.Now.Subtract(datLC).TotalSeconds < 10) return false;
  5768.             //Logger.Write("Entering Harvest...");
  5769.             if (BuddyTor.Me.InCombat) return false;
  5770.             if (BuddyTor.Me.Companion != null) if (BuddyTor.Me.Companion.InCombat) return false;
  5771.  
  5772.             int H = 0;
  5773.             //AcquireFrame seems to gen ALOT more crashes when the bot is stopped, so do variable lists used (so I try and use the query directly)
  5774.             //var varObj = ObjectManager.GetObjects<TorNpc>();
  5775.             //IEnumerable<TorNpc> varObj;
  5776.                 //using (BuddyTor.Memory.AcquireFrame())
  5777.                 //{
  5778.                     //varObj =
  5779.                 //}
  5780.             if (BuddyTor.Me.InCombat) return false;
  5781.             if (DateTime.Now.Subtract(datLCL).TotalSeconds >= 2f) return false;
  5782.             float theDist = DoRandomGrind ? 15.0f : MaxNodeDist;
  5783.             foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance))
  5784.                 try {
  5785.                     if(unit != null && !unit.IsDeleted && unit.Distance <= theDist && StrongOrGreater(unit) && !unit.IsFriendly && unit.IsDead &&
  5786.                         (
  5787.                             (HasBio && unit.CreatureType == Buddy.Swtor.CreatureType.Creature) ||
  5788.                             (HasScav && (unit.CreatureType == Buddy.Swtor.CreatureType.Droid  || unit.Name.Contains("Droid")))
  5789.                          ))
  5790.                     if (!MyBlacklist.ContainsKey(unit.Guid) && CanHarvestCorpse(unit))
  5791.                     {
  5792.                         Logger.Write("Harvest:  Moving to " + unit.Name + " Distance: " + unit.Distance.ToString() + " Position: " + unit.Position.ToString());
  5793.                         if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return true; }
  5794.                         MoveToAndInteract(unit);
  5795.                         if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return true; }
  5796.                         H += 1;
  5797.                     }
  5798.                 }
  5799.                 catch
  5800.                 {
  5801.                     //Logger.Write("Error in HarvestIfNec.");
  5802.                     //return false;
  5803.                 }
  5804.  
  5805.             datLC = DateTime.Now;
  5806.             return (H > 0);
  5807.         }
  5808.  
  5809.         public static bool CanHarvestObj(TorPlaceable obj)
  5810.         {
  5811.             try
  5812.             {
  5813.                 if (obj.Name.Contains("Security Chest")) return true;
  5814.                 ulong LR = obj.Harvestable.ProfessionLevelRequired;
  5815.                 //Logger.Write("Skill Level Required for " + obj.Name + ": " + LR.ToString() + " Arch Skill: " + PISkill("Archaeology"));
  5816.  
  5817.                 if (ObjIsArch(obj) && HasArch && LR <= PISkill("Archaeology")) return true;                         // Arch placeables don't (currently) have the Harvestable or other properties from what I can see, so free-ball it
  5818.  
  5819.                 if (obj != null) if (!obj.IsDeleted) if (obj.Harvestable != null)
  5820.                             if (
  5821.                                 (
  5822.                                 (obj.Harvestable.ProfessionRequired == ProfessionType.Archaeology || obj.Name.Contains("Crystal Formation")) && HasArch && LR <= PISkill("Archaeology")) || (obj.Harvestable.ProfessionRequired == ProfessionType.Bioanalysis && HasBio && LR <= PISkill("Bioanalysis")) ||
  5823.                                 (obj.Harvestable.ProfessionRequired == ProfessionType.Scavenging && HasScav && LR <= PISkill("Scavenging")) || (obj.Harvestable.ProfessionRequired == ProfessionType.Slicing && HasSlicing && LR <= PISkill("Slicing"))
  5824.                                )
  5825.                                 return true;
  5826.                 if (obj != null) if (!obj.IsDeleted) if (ObjIsArch(obj) && HasArch && LR <= PISkill("Archaology")) return true;
  5827.             }
  5828.             catch { }
  5829.             return false;
  5830.         }
  5831.  
  5832.         public static int ChampsElitesNearObj(TorObject obj)
  5833.         {
  5834.             try
  5835.             {
  5836.             return (ObjectManager.GetObjects<TorNpc>().Where(d => d!=null && !d.IsDeleted && !d.IsDead && Vector3.Distance(obj.Position,d.Position)<=3.0f &&
  5837.                     (d.Toughness==CombatToughness.Boss3 || d.Toughness==CombatToughness.Boss2 ||d.Toughness==CombatToughness.Boss1)
  5838.                  )
  5839.                 .Count());}
  5840.             catch { Logger.Write("Error in ChampsElitesNearObj()"); return 0; }
  5841.         }
  5842.  
  5843.         public static void MoveToAndInteract(TorObject obj, double ToWithin = .99f, int WaitAfterInteract=4000)
  5844.         {
  5845.             bool IsSecChest=obj.Name.Contains("Security Chest");
  5846.  
  5847.             if (IsSecChest) ToWithin = .30f;
  5848.             if (obj.Distance >= 3.0f) MountUp();
  5849.  
  5850.             MoveResult MR = MoveResult.Moved;
  5851.             datLCL = DateTime.Now;
  5852.             while (obj.Distance > ToWithin && MR != MoveResult.Failed && MR != MoveResult.PathGenerationFailed && DateTime.Now.Subtract(datLCL).TotalSeconds <= 20)
  5853.             {
  5854.                 if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; } // If it's a chest, grab that shit FIRST
  5855.                 MR = Buddy.Navigation.Navigator.MoveTo(obj.Position);
  5856.                 Thread.Sleep(200);
  5857.                 //Buddy.Swtor.Input.MoveTo(obj.Position, MeleeDist); Thread.Sleep(2000);
  5858.             }
  5859.             StopMoving();
  5860.             Thread.Sleep(1000);
  5861.             if (Me.InCombat && !IsSecChest) { BuddyTor.Me.ClearTarget(); return; }
  5862.             if (obj.Distance <= ToWithin)
  5863.             {
  5864.                 obj.Interact();
  5865.                 Thread.Sleep(WaitAfterInteract);
  5866.                 if (obj != null) MyBlacklist.Add(obj.Guid,DateTime.Now);
  5867.                 if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return; }
  5868.             }
  5869.             if (Me.InCombat) return;
  5870.         }
  5871.  
  5872.         public static bool ObjIsChest(TorObject obj)
  5873.         {
  5874.             return (obj.Name.Contains("ity Chest"));
  5875.         }
  5876.  
  5877.         public static bool ObjIsArch(TorObject obj)
  5878.         {
  5879.             return (obj.Name.Contains("eological F") || obj.Name.Contains("Crystal Formation"));
  5880.         }
  5881.  
  5882.         public static bool ScanForPlaceables()
  5883.         {
  5884.             if (IG) return false;
  5885.  
  5886.             if (!ScanForNodes || !MovementAllowed) return false;
  5887.             if (MaxNodesBetweenFights == 0) return false;
  5888.  
  5889.             datLCL = DateTime.Now;
  5890.             int Harv = 0;
  5891.  
  5892.             int intI = 0;
  5893.  
  5894.             //float theDist = DoRandomGrind ? 6.0f : MaxNodeDist;
  5895.  
  5896.             foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>())
  5897.                 try
  5898.                 {   if (obj != null && !obj.IsDeleted && obj.Name!=null && obj.Distance <= MaxNodeDist && CanHarvestObj(obj))
  5899.                     if (ChampsElitesNearObj(obj) < 1)
  5900.                     {
  5901.                         intI += 1;
  5902.  
  5903.                         if (!MyBlacklist.ContainsKey(obj.Guid)) if (CanHarvestObj(obj) || obj.Name.Contains("est"))
  5904.                         {
  5905.                             Logger.Write("Placeable: Moving to " + obj.Name + " Distance: " + obj.Distance.ToString() + " Position: " + obj.Position.ToString());
  5906.                             MoveToAndInteract(obj);
  5907.                             if (Me.InCombat) return true;
  5908.                             Harv += 1;
  5909.                             if (Harv >= MaxNodesBetweenFights) return true;
  5910.                         }
  5911.                     }
  5912.                 }
  5913.                 catch
  5914.                 {
  5915.                     return false;
  5916.                 }
  5917.  
  5918.             if (ReportDurs) Logger.Write("Scan for Nodes: " +intI.ToString() + " Placeables, " + DateTime.Now.Subtract(datLCL).TotalSeconds.ToString("#.00") + "s");
  5919.             return false;
  5920.         }
  5921.  
  5922.         public static void MountUp()
  5923.         {
  5924.             if (!EnableMount || !MovementAllowed || IG || Me.HasBuff("Stealth")) return;
  5925.  
  5926.             if (DateTime.Now.Subtract(datLMC).TotalSeconds < MountCheckFreq || Me.InCombat || BuddyTor.Me.PvpFlagged) return;
  5927.  
  5928.             datLMC = DateTime.Now;
  5929.  
  5930.             if (!BuddyTor.Me.IsMounted)
  5931.             {
  5932.                 Logger.Write("Trying to mount using the [" + chMount + "] key.");                   // SPELL IT OUT FOR THOSE WHO CAN'T READ
  5933.  
  5934.                 StopMoving(); Thread.Sleep(250);
  5935.                 //if (MercCast("Stealth", BuddyTor.Me, Me.HasBuff("Stealth"))) { Thread.Sleep(250); WaitForCast(); }
  5936.                 SendMessage(SWTORHWnd, (int)0x100, (IntPtr)chMount, (IntPtr)0);
  5937.                 SendMessage(SWTORHWnd, (int)0x100, (IntPtr)chMount, (IntPtr)0);
  5938.                 Thread.Sleep(300);
  5939.             }
  5940.             else return;
  5941.             DateTime MountStart = DateTime.Now;
  5942.             while (Me.IsCasting && DateTime.Now.Subtract(MountStart).TotalSeconds <= 1) Thread.Sleep(1000);
  5943.         }
  5944.  
  5945.         public static bool ScanForLootables()
  5946.         {
  5947.             //if (!ScanForLoot || ! MovementAllowed) return false;
  5948.             if (!MovementAllowed) return false;
  5949.             //if (DateTime.Now.Subtract(datLLS).TotalSeconds < 10) return false;
  5950.  
  5951.             DateTime datBeg = DateTime.Now;
  5952.  
  5953.             int Looted = 0;
  5954.  
  5955.             try
  5956.             {
  5957.                 foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance).Where(t => t != null && !t.IsDeleted && t.IsLootable))// !t.IsFriendly && t.IsDead))
  5958.                     if (!MovementAllowed)
  5959.                     {
  5960.                         if (unit.Distance <= .99f) { unit.Interact(); Thread.Sleep(3000); return true; }
  5961.                     }
  5962.                     else
  5963.                         if (unit != null && !unit.IsDeleted && unit.IsDead && unit.IsLootable && unit.Distance <= MaxNodeDist)
  5964.                     {
  5965.                         if (Me.InCombat) { BuddyTor.Me.ClearTarget(); return false; }
  5966.                         Logger.Write("Loot: Moving to " + unit.Name + " Distance: " + unit.Distance.ToString(".0") + " Position: " + unit.Position.ToString());
  5967.                         MoveToAndInteract(unit);
  5968.                         if (Me.InCombat) return true;
  5969.                         Looted += 1;
  5970.                         datLLS = DateTime.Now;
  5971.                         //return true;
  5972.                     }
  5973.                 }
  5974.             catch { return false; }
  5975.  
  5976.             //MountUp();
  5977.  
  5978.             datLLS = DateTime.Now;
  5979.  
  5980.             if (ReportDurs) Logger.Write("Lootables Scan: " + DateTime.Now.Subtract(datBeg).TotalMilliseconds.ToString("0.0") + "ms");
  5981.             return Looted > 0;
  5982.         }
  5983.  
  5984.         public static void GetAttackers()
  5985.         {
  5986.             DateTime datStart = DateTime.Now;
  5987.  
  5988.             if (Attackers != null) Attackers.Clear();
  5989.             Attackers = null;
  5990.             Attackers = new List<TorNpc>();
  5991.             TorCharacter CompX = Comp;
  5992.  
  5993.             MyNameCompName = MyName + CompName;
  5994.  
  5995.             //foreach (TorNpc d in Me.EnemiesAttackers.Where(t => t != null && !t.IsDeleted).OrderBy(t => t.HealthMax))
  5996.             if (!IG)
  5997.                 try
  5998.                 {
  5999.                     //foreach (TorNpc d in ObjectManager.GetObjects<TorNpc>().Where(t => t.InCombat && t.Distance <= 4.5f).OrderBy(t => IsRanged ? t.HealthMax : t.Distance))
  6000.                     var Att = Me.EnemiesAttackers;
  6001.                     foreach (TorNpc d in Att.Where(t => t.InCombat && t.Distance <= 4.5f).OrderBy(t => IsRanged ? t.HealthMax : (int)t.Distance))
  6002.                        if (d != null && !d.IsDeleted && !d.IsDead && d.HealthPercent > .1 && d.CurrentTarget != null &&
  6003.                          d.CurrentTarget.Name!=null && MyNameCompName.Contains(d.CurrentTarget.Name) && d.Distance<=4.5f && !d.IsFriendly)
  6004.                        Attackers.Add(d);
  6005.                 }
  6006.             catch (Exception ex) { Logger.Write("GetAttackers() Error: " + ex.Message); }
  6007.  
  6008.             if (IG)
  6009.                 foreach (TorNpc d in ObjectManager.GetObjects<TorNpc>()
  6010.                     //.Where(t => t != null && !t.IsDeleted && !t.IsDead && t.HealthPercent > .1 && t.CurrentTarget != null &&
  6011.                     //    t.Toughness!=CombatToughness.Player && t.CurrentTarget.Toughness==CombatToughness.Player && !t.IsFriendly).OrderBy(t => t.HealthMax))
  6012.                     .Where(t => t != null && !t.IsDeleted && t.Distance<=4.0f).OrderBy(t => t.HealthMax))
  6013.                     if (d.InCombat && !d.IsDead && d.HealthPercent > .1 && !d.IsFriendly && !d.IsStunned && d.Toughness!=CombatToughness.Player)
  6014.                     try
  6015.                     {
  6016.                         //if (d!=null && !d.IsDeleted && d.InCombat && d.Toughness!=CombatToughness.Player && d.IsHostile && d.Distance<=5.0f)
  6017.                         //if (!d.IsDead && d != Me && d != CompX && !d.IsDead && d.HealthPercent > .2f && d.Distance <= 5.0f)
  6018.                         Attackers.Add(d);
  6019.                     }
  6020.                     catch (Exception ex) { Logger.Write("GetAttackers() Error: " + ex.Message); }
  6021.  
  6022.             if (Attackers == null || Attackers.Count() == 0) if (CompTarg != null && CompTarg != Me && CompTarg.Name != MyName) Attackers.Add((TorNpc)CompTarg);
  6023.             if (Attackers==null || Attackers.Count()==0) if (!IG) { if (Me.CurrentTarget != null && Me.CurrentTarget.Name != Me.Name && !Me.CurrentTarget.IsDead
  6024.               && Me.CurrentTarget.Toughness!=CombatToughness.Player) Attackers.Add((TorNpc)Me.CurrentTarget); }
  6025.  
  6026.             if (!IG && Attackers != null && Attackers.Count() > 0) return;
  6027.  
  6028.             if (ReportDurs) Logger.Write("Attackers List Duration: " + DateTime.Now.Subtract(datStart).TotalMilliseconds.ToString());
  6029.  
  6030.             try
  6031.             {
  6032.                 if (!BuddyTor.Me.InCombat && (!IG || DoRandomGrind)) { if (Me.CurrentTarget != null && Me.CurrentTarget.Name != Me.Name && !Me.CurrentTarget.IsDead)
  6033.                     Attackers.Add((TorNpc)Me.CurrentTarget); }
  6034.                 if (!BuddyTor.Me.PvpFlagged)
  6035.                 {
  6036.                     foreach (TorNpc d in Me.EnemiesAttackers.OrderBy(t=>t.Distance))
  6037.                       if (!d.IsDead && d.HealthPercent > .2f && d.Distance <= 5.0f) Attackers.Add(d);
  6038.  
  6039.                 }
  6040.             }
  6041.             catch { if (Me.CurrentTarget != null && Me.CurrentTarget.HealthPercent > .2) Attackers.Add((TorNpc)Me.CurrentTarget); return; }
  6042.  
  6043.         }
  6044.  
  6045.         public static bool ScanForMobs()
  6046.         {
  6047.             DateTime datStart = DateTime.Now;
  6048.  
  6049.             TorCharacter theUnit = null;
  6050.             float theDist = MaxDist;
  6051.  
  6052.             if (Me.InCombat) return false;
  6053.             Logger.Write("Scanning for mobs....");
  6054.  
  6055.             // Try for LOS Mobs First
  6056.             if (BuddyTor.Me.PvpFlagged)
  6057.               foreach (TorPlayer unit in ObjectManager.GetObjects<TorPlayer>().Where(t => t != null && !t.IsDeleted).OrderBy(t => t.Distance))
  6058.                 try
  6059.                 {
  6060.                     if (unit != BuddyTor.Me && unit.InLineOfSight && unit.IsHostile && !unit.IsDead && (unit.Level >= Me.Level - 6) && unit.Distance <= MaxDist && unit.Toughness >= DRGMinToughness &&
  6061.                     unit.Toughness <= CombatToughness.Boss1 && unit.IsHostile && !unit.InCombat)
  6062.                     { theUnit = (TorCharacter)unit; theDist = unit.Distance; break; }
  6063.                 }
  6064.                 catch
  6065.                 {
  6066.                     return false;
  6067.                 }
  6068.             else
  6069.             foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().Where(t => t != null && !t.IsDeleted && t.InLineOfSight).OrderBy(t => t.Distance))
  6070.                 try {
  6071.                     if (unit!=BuddyTor.Me && !unit.IsFriendly && !unit.IsDead && (unit.Level >= Me.Level-6) && unit.Distance <= MaxDist && unit.Toughness >= DRGMinToughness &&
  6072.                     unit.Toughness <= CombatToughness.Boss1 && unit.IsHostile && !unit.InCombat)
  6073.                     { theUnit = unit; theDist = unit.Distance; break; }
  6074.                 }
  6075.                 catch
  6076.                 {
  6077.                     return false;
  6078.                 }
  6079.  
  6080.             if (theUnit == null)
  6081.                 foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance))
  6082.                 try
  6083.                 {
  6084.                     if (unit != null && !unit.IsDeleted && unit.IsHostile) if (!unit.IsDead && unit!=BuddyTor.Me && unit.Distance <= MaxDist && unit.Toughness>=DRGMinToughness && unit.Toughness <= CombatToughness.Boss1 && unit.IsHostile && !unit.InCombat)
  6085.                             if (unit.Distance < theDist || theUnit == null) { theUnit = unit; theDist = unit.Distance; break; }
  6086.                 }
  6087.                 catch { return false; }
  6088.  
  6089.             // Next, ANYTHING
  6090.             if (theUnit == null)
  6091.                 //foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance))
  6092.                 foreach (TorNpc unit in ObjectManager.GetObjects<TorNpc>().OrderBy(t => t.Distance).Where(unit => unit!=null && !unit.IsDeleted && (unit.IsHostile || unit.IsNeutral) && unit.Distance <= MaxDist &&
  6093.                     !unit.IsDead && unit!=BuddyTor.Me && unit.Toughness <= CombatToughness.Boss1 && !unit.IsFriendly && !unit.InCombat))
  6094.                     if (!MyBlacklist.ContainsKey(unit.Guid) && (unit.Distance < theDist || theUnit == null))
  6095.                     try
  6096.                     {
  6097.                         theUnit = unit; theDist = unit.Distance; break;
  6098.                     }
  6099.                     catch { return false; }
  6100.  
  6101.             if (theUnit == null) return false;
  6102.  
  6103.             if (Me.InCombat) return false;
  6104.  
  6105.             Logger.Write("Targeting:  Moving to " + theUnit.Name + " Distance: " + theUnit.Distance.ToString() + " Position: " + theUnit.Position.ToString());
  6106.             theUnit.Target();
  6107.  
  6108.             if (theUnit.Distance >= 3.0f) MountUp();
  6109.  
  6110.             while (theUnit != null && (theUnit.Distance > 2.8f || !theUnit.InLineOfSight))
  6111.             {
  6112.                 if (Me.InCombat) MyCombat();
  6113.                 Buddy.Navigation.Navigator.MoveTo(theUnit.Position);
  6114.                 Thread.Sleep(500);
  6115.             }
  6116.  
  6117.             if (theUnit.Distance <= 2.8f && theUnit.InLineOfSight)
  6118.             {
  6119.                 CT = theUnit;
  6120.                 StopMoving();
  6121.                 MyCombat();
  6122.                 return true;
  6123.             }
  6124.  
  6125.             StopMoving();
  6126.  
  6127.             datLC = DateTime.Now;
  6128.             theUnit = null;
  6129.             return false;
  6130.         }
  6131.  
  6132.         // Experimental
  6133.         public static bool CheckRelics()
  6134.         {
  6135.             if (HP <= 40f)
  6136.             {
  6137.                 //foreach(TorItem ti in BuddyTor.Me.InventoryEquipped)if(ti.Name.Contains("Relic")
  6138.             }
  6139.  
  6140.             return false;
  6141.         }
  6142.  
  6143.         public static float DRGPathMinDistFromPoint(Vector3 thePoint)
  6144.         {  
  6145.             float MinDist = 999;
  6146.             float Dist = 0;
  6147.             foreach (Vector3 CurrPt in DRGGrindPath)
  6148.             {
  6149.                 Dist = Vector3.Distance(CurrPt, thePoint);
  6150.                 if ( Dist < MinDist) MinDist = Dist;
  6151.             }
  6152.             if (MinDist != 999) return MinDist; else return 0;
  6153.         }
  6154.  
  6155.  
  6156.         private static void DRGUpdateVendor()
  6157.         {
  6158.             try
  6159.             {
  6160.                 if (DRGVendorName == "")
  6161.                 {
  6162.                     foreach (TorVendor t in ObjectManager.GetObjects<TorVendor>().Where(t => t.Distance <= 15f && !t.IsHostile).OrderBy(t => t.Distance))
  6163.                     {
  6164.                         DRGVendorName = t.Name;
  6165.                         DRGVendorPos = t.Position;
  6166.                         Logger.Write("DoRandomGrind:  Last-Closest-Vendor-Info updated to " + t.Name + " at " + t.Position.ToString());
  6167.                         break;
  6168.                     }
  6169.                 }
  6170.             }
  6171.             catch { }
  6172.  
  6173.         }
  6174.  
  6175.         public static bool RunAroundAndKillStuff()
  6176.         {
  6177.             datLCL = DateTime.Now;
  6178.  
  6179.             //Logger.Write("Entering Harvest...");
  6180.             if (MeOrCompInCombat()) return true;
  6181.  
  6182.             MyRestAndBuffs();
  6183.             //RunGathering();
  6184.  
  6185.             //if (DateTime.Now.Subtract(datLCL).TotalSeconds >= 5) return false;
  6186.  
  6187.             bool LootFound = false;
  6188.             bool MobsFound = false;
  6189.  
  6190.             DRGUpdateVendor();
  6191.  
  6192.             if (DRGGrindPath.Count() >= 500) DRGGrindPath.Clear();
  6193.  
  6194.             bool bAdd = false;
  6195.            
  6196.             if (DRGGrindPath.Count() == 0) bAdd = true;
  6197.             if (!bAdd && DRGGrindPath.Count() < 50 &&  DRGPathMinDistFromPoint(Me.Position) >= 5.0f) bAdd = true;
  6198.             if (bAdd)
  6199.             {
  6200.                 DRGGrindPath.Add(new Vector3((float)Me.Position.X, (float)Me.Position.Y, (float)Me.Position.Z));
  6201.                 Logger.Write("DoRandomGrind:  Adding Path Element " + Me.Position.ToString() + " Total Path Elements: " + DRGGrindPath.Count().ToString());
  6202.             }
  6203.  
  6204.             if (ScanForLootables());
  6205.             if (HarvestIfNec());
  6206.             if (ScanForPlaceables());
  6207.             //if (ScanForPlaceables()) return true;
  6208.             if (MeOrCompInCombat()) { MyCombat(); return true; }
  6209.  
  6210.             //CheckPOI();
  6211.             if (ScanForMobs()) return true;
  6212.            
  6213.             CT = null;
  6214.             if (Me.CurrentTarget != null) CT = Me.CurrentTarget;
  6215.  
  6216.             if (CT != null && !CT.IsFriendly && !CT.IsDead) { return true; }
  6217.  
  6218.             //if (LastCombatPt.X != 0 && !(LootFound || MobsFound))
  6219.             if (LastCombatPt.X != 0 && !(LootFound || MobsFound))
  6220.             {
  6221.                 Logger.Write("No mobs or loot found, returning to point of last combat.");
  6222.                 ////while (!Me.InCombat && Buddy.Common.Math.Vector3.Distance(LastCombatPt, Me.Position) >= MeleeDist) { Navigator.MoveTo(LastCombatPt); Thread.Sleep(200); }
  6223.                 try
  6224.                 {
  6225.                     MountUp();
  6226.                         //Logger.Write("DRGGrindPathElements: " + pt.ToString());
  6227.                     if (DRGGrindPath.Count() > 0)
  6228.                         foreach (var pt in DRGGrindPath)
  6229.                         {
  6230.                             while (!Me.InCombat && DRGGrindPath.ElementAt(0).Distance(Me.Position) >= MeleeDist) { Navigator.MoveTo(pt); Thread.Sleep(200); }
  6231.                         }
  6232.                 }
  6233.                 catch { }
  6234.             }
  6235.            
  6236.             return false;
  6237.         }
  6238.     }
  6239.  
  6240.     class NoMovement_MovementProvider : IMovementProvider
  6241.     {
  6242.         public void MoveTowards(Buddy.Common.Math.Vector3 location) { /*empty*/ }
  6243.         public void StopMovement() { /*empty*/ }
  6244.     };
  6245.  
  6246.     class NoMovement_NavigationProvider : INavigationProvider
  6247.     {
  6248.         public void Clear() { /*empty*/ }
  6249.         public MoveResult MoveTo(Buddy.Common.Math.Vector3 destination, string destName, bool useRaycast, bool useStraightLine)
  6250.         {
  6251.             return (MoveResult.Moved);
  6252.         }
  6253.     };
  6254.  
  6255.     class MakebRepublicQuests
  6256.     {
  6257.        
  6258.     }
  6259.  
  6260. }
  6261.  
  6262.  
  6263. public static class MonMemory
  6264. {
  6265.     public static void WatchIt()
  6266.     {
  6267.         Thread.Sleep(30000); // Let the bot 'settle-in'
  6268.         var objBot = BotMain.CurrentBot;
  6269.  
  6270.         while (true)
  6271.         {
  6272.             string ProcName=Process.GetCurrentProcess().ProcessName;
  6273.             long LastMemUsed = Process.GetCurrentProcess().WorkingSet64;
  6274.  
  6275.             if (Process.GetCurrentProcess().WorkingSet64 - LastMemUsed >= 10000000 || Process.GetCurrentProcess().PrivateMemorySize64 >= 100000000)
  6276.             //if (DateTime.Now.Subtract(JoesCombat.MercHelpers.DateLastPingCombat).TotalSeconds >= 20 || DateTime.Now.Subtract(JoesCombat.MercHelpers.DateLastPingOOC).TotalSeconds >= 20)
  6277.             {
  6278.                 try
  6279.                 {
  6280.                     //JoesCombat.Logger.Write("Bot going haywire - stopping and restarting it.");
  6281.                     JoesCombat.MercHelpers.Restarting = true;
  6282.                     Thread.Sleep(8000);
  6283.                     //while (BotMain.IsRunning)
  6284.                     //{
  6285.                     Buddy.CommonBot.BotMain.BotThread.Abort();
  6286.                     Thread.Sleep(1000);
  6287.                     Buddy.CommonBot.BotMain.BotThread.Start();
  6288.                     //BotMain.CurrentBot.Stop();
  6289.                     Thread.Sleep(1000);
  6290.                     //}
  6291.                     //BotMain.CurrentBot.Stop();
  6292.                     //Thread.Sleep(1000);
  6293.                     JoesCombat.MercHelpers.DoRehook();
  6294.                     Thread.Sleep(4000);
  6295.                     LastMemUsed = Process.GetCurrentProcess().PrivateMemorySize64;
  6296.                 }
  6297.                 catch { }
  6298.  
  6299.                 JoesCombat.MercHelpers.Restarting = false;
  6300.                 LastMemUsed = Process.GetCurrentProcess().PrivateMemorySize64;
  6301.             }
  6302.            
  6303.             //if (Process.GetCurrentProcess().ProcessName != ProcName) break;
  6304.             Thread.Sleep(15000);
  6305.         }
  6306.     }
  6307. }
  6308.  
  6309. //namespace Buddy.Swtor
  6310. //{
  6311. //    class Mounts
  6312. //    {
  6313. //        private static string OverrideMount = "";
  6314. //        public static string GetFastestAvailableMount()
  6315. //        {
  6316. //            if (OverrideMount != "") return OverrideMount;
  6317. //            return "";
  6318. //        }
  6319. //    }
  6320.  
  6321. //}
  6322.  
  6323. // Questing, wayyyyy experimental and VERY INCOMPLETE at this point.
  6324. public class MyHotspotList
  6325. {
  6326.     private List<Vector3> theHotSpots = new List<Vector3>();
  6327.     private string HSName = "";
  6328.     private ulong QuestID = 0;
  6329.     private uint QuestStepID = 0;
  6330.  
  6331.     public void DefineName(string theName)
  6332.     {
  6333.         HSName = theName;
  6334.     }
  6335.     public void AddToHSList(Vector3 thePoint)
  6336.     {
  6337.         theHotSpots.Add(thePoint);
  6338.     }
  6339.  
  6340.     public void SetIDAndStep(ulong theID, uint theStep)
  6341.     {
  6342.         QuestID = theID;
  6343.         QuestStepID = theStep;
  6344.     }
  6345. }
  6346.  
  6347. public class MyQuestProfile
  6348. {
  6349.     private string ProfilePath;
  6350.     //private static string ProfileContents;
  6351.     private string[] ProfileLines;
  6352.     private string CurLine;
  6353.     private List<MyHotspotList> Hotspots = new List<MyHotspotList>();
  6354.  
  6355.     private string GetStringStartingAt(string theString, int thePos)
  6356.     {
  6357.         bool bStarted = false;
  6358.         bool bEnded = false;
  6359.         string sIdentifier = "";
  6360.         string sCur = "";
  6361.  
  6362.         for (int i = thePos; i <= theString.Length - 1; i++)
  6363.         {
  6364.             sCur = theString.Substring(i, 1);
  6365.             if (sCur == "\"")
  6366.             {
  6367.                 if (!bStarted) bStarted = true; else bEnded = true;
  6368.             }
  6369.             else
  6370.             {
  6371.                 if (bStarted) sIdentifier += sCur;
  6372.             }
  6373.             if (bEnded) return sIdentifier;
  6374.         }
  6375.         return "";
  6376.     }
  6377.  
  6378.     private bool LoadProfile(string strPath)
  6379.     {
  6380.  
  6381.         ProfileLines = System.IO.File.ReadAllLines(strPath);
  6382.         MyHotspotList CurHS;
  6383.         int i;
  6384.         for (i = 0; i < ProfileLines.Length - 1; i++)
  6385.         {
  6386.             CurLine = ProfileLines[i];
  6387.             if (CurLine.Contains("GrindArea"))
  6388.             {
  6389.                 int NamePos = CurLine.IndexOf("Name");
  6390.                 string sIDVal = GetStringStartingAt(CurLine, NamePos);
  6391.                 if (sIDVal != "")
  6392.                 {
  6393.                     MyHotspotList HS = new MyHotspotList();
  6394.                     CurHS = HS;
  6395.                     HS.DefineName(sIDVal);
  6396.                 }
  6397.             }
  6398.             if (CurLine.Contains("<Hotspot "))
  6399.             {
  6400.             }
  6401.  
  6402.         }
  6403.  
  6404.         return false;
  6405.     }
  6406. }
  6407.  
  6408. public class MyObject
  6409. {
  6410.     object TI;
  6411.  
  6412.     public object DeclareIt(object theItem)
  6413.     {
  6414.         TI = theItem;
  6415.         return TI;
  6416.  
  6417.     }
  6418.  
  6419.     public void DisposeIt(object theItem)
  6420.     {
  6421.         theItem = null;
  6422.     }
  6423.  
  6424. }
  6425. public class MyQuestDef
  6426. {
  6427.     private static List<Vector3> theHotSpots = new List<Vector3>();
  6428.     private static int currIndex = 0;
  6429.     private static string ItemToUse = "";
  6430.     private static ulong QuestID;
  6431.     private static uint StepID;
  6432.     private static string objectToUse = "";
  6433.     private static int WaitAfterUse;
  6434.     private static float DistanceForUse;
  6435.  
  6436.     //public void SetIDs(ulong theQuest, uint theStep)
  6437.     //{
  6438.     //    QuestID = theQuest;
  6439.     //    StepID = theStep;
  6440.     //}
  6441.  
  6442.     public void AddToHSList(double x, double y, double z)
  6443.     { theHotSpots.Add(new Vector3((float)x, (float)y, (float)z)); }
  6444.  
  6445.     public void SetProperties(ulong questID, uint stepID, string theItem = "", string theObject = "", int waitMsAfterUse = 4000, float distForUse = .40f)
  6446.     {
  6447.         QuestID = questID;
  6448.         StepID = stepID;
  6449.         ItemToUse = theItem;
  6450.         objectToUse = theObject;
  6451.         WaitAfterUse = waitMsAfterUse;
  6452.         DistanceForUse = distForUse;
  6453.     }
  6454.  
  6455.     public void RunThrough()
  6456.     {
  6457.  
  6458.         JoesCombat.MercHelpers.RunGathering();
  6459.         if (Buddy.CommonBot.ConditionParser.HasQuest(QuestID) && !Buddy.CommonBot.ConditionParser.IsStepComplete(QuestID, StepID))
  6460.  
  6461.             while (!BuddyTor.Me.InCombat)
  6462.             {
  6463.                 var pt = theHotSpots[currIndex];
  6464.                 JoesCombat.Logger.Write("Quest Hotspot set to " + theHotSpots[currIndex].ToString());
  6465.                 while (!BuddyTor.Me.InCombat && Buddy.Common.Math.Vector3.Distance(BuddyTor.Me.Position, pt) >= .05f)
  6466.                 {
  6467.                     Buddy.Navigation.Navigator.MoveTo(new Vector3(pt.X, pt.Y, pt.Z));
  6468.                     Thread.Sleep(300);
  6469.                 }
  6470.                 if (ItemToUse != "" && !BuddyTor.Me.InCombat)
  6471.                 {
  6472.                     foreach (TorItem o in BuddyTor.Me.InventoryQuest)
  6473.                         if (o.Name.Contains(ItemToUse) && o.MinimumLevel <= BuddyTor.Me.Level)
  6474.                         {
  6475.                             JoesCombat.Logger.Write("Using Quest Item " + o.Name + "...");
  6476.                             o.Interact();
  6477.                             //Thread.Sleep(7000);
  6478.                         }
  6479.                     currIndex += 1;
  6480.                     return;
  6481.                 }
  6482.                 if (objectToUse != "" && !BuddyTor.Me.InCombat)
  6483.                     foreach (TorPlaceable obj in ObjectManager.GetObjects<Buddy.Swtor.Objects.TorPlaceable>().Where(obj => obj.Name.Contains(objectToUse)))
  6484.                     {
  6485.                         JoesCombat.MercHelpers.MoveToAndInteract(obj, .40f, WaitAfterUse);
  6486.                         currIndex += 1;
  6487.                         return;
  6488.                     }
  6489.                 else break;
  6490.                 if (currIndex >= theHotSpots.Count()) currIndex = 0;
  6491.             }
  6492.     }
  6493. }
Add Comment
Please, Sign In to add comment