public static bool ItemOnCooldown(string itemname) { bool retval = false; string fnname = "FTWCore.ItemOnCooldown"; MyTimer.Start(fnname); using (StyxWoW.Memory.AcquireFrame()) { WoWItem item = StyxWoW.Me.CarriedItems.FirstOrDefault(i => i != null && i.Name == itemname); if (item == null) { FTWLogger.debug("Don't have {0}", itemname); retval = true; } else { int cnt = Convert.ToInt32(Lua.GetReturnValues(String.Format("return GetItemCount(\"{0}\")", item.Name), "HasItem.lua")[0]); if (cnt == 0) { FTWLogger.debug("Have 0 of {0}", item.Name); retval = true; } else if (item.Cooldown > 0) { FTWLogger.debug("Item {0} on cooldown. Time left: {1}", item.Name, item.Cooldown); retval = true; } } } MyTimer.Stop(fnname); return(retval); }
public static bool On_DumpAuras(WoWUnit target) { FTWLogger.debug(Color.PaleVioletRed, "DUMPAURAS: {0} auras:", target.SafeName()); foreach (WoWAura aura in target.Auras.Values) { FTWLogger.debug(Color.PaleVioletRed, " {0} {1} {2} ms", aura.Name, aura.StackCount, aura.TimeLeft.TotalMilliseconds); } return(false); }
public static bool On_DumpParty() { FTWLogger.debug(Color.Yellow, "{0} close party members:", FTWProps.closePeople.Count); foreach (WoWPlayer p in FTWProps.closePeople) { FTWLogger.debug(Color.Yellow, " {0,-16} {1:00.0} {2:000.0}% ({3:000000} total health)", p.SafeName(), p.Distance, p.HealthPercent, p.MaxHealth); } FTWLogger.debug(Color.Yellow, "Tank is {0}", FTWProps.tank == null ? "<none>" : FTWProps.tank.SafeName()); FTWLogger.debug(Color.Yellow, "Healer is {0}", FTWProps.healer == null ? "<none>" : FTWProps.healer.SafeName()); return(false); }
public static void Face(WoWUnit mob) { DateTime stoptime = DateTime.Now.AddSeconds(1); if (StyxWoW.Me.Location == mob.Location) { KeyboardManager.PressKey((char)Keys.Back); Thread.Sleep(50); KeyboardManager.ReleaseKey((char)Keys.Back); return; } while (!StyxWoW.Me.IsSafelyFacing(mob) && DateTime.Now < stoptime) { FTWLogger.debug(Color.Violet, "Facing {0}", mob.SafeName()); mob.Face(); Thread.Sleep(10); } }
public static WoWItem GetInventoryItem(string origname) { string fnname = "FTWCore.GetInventoryItem"; MyTimer.Start(fnname); string name = origname.ToLower(); foreach (WoWItem item in StyxWoW.Me.CarriedItems) { if (item != null && item.Name.ToLower() == name) { MyTimer.Stop(fnname); return(item); } } FTWLogger.debug(" Didn't find {0}", name); MyTimer.Stop(fnname); return(null); }
public static bool Macro(string macrotext) { double cooldown = 0; int c = macrotext.IndexOf(' '); if (c >= 0) { string s = macrotext.Substring(0, c); if (Double.TryParse(s, out cooldown)) { macrotext = macrotext.Substring(c + 1); } } if (FTWCoreStatus.OnCooldown(macrotext, cooldown, false)) { return(false); } FTWLogger.debug(" Macro: {0}", macrotext); Lua.DoString(string.Format("RunMacroText(\"{0}\");", macrotext)); FTWCoreStatus.SaveCooldown(macrotext); return(false); }
public static bool On_PetCast(string spellname, WoWUnit target, bool castnow) { string fnname = "FTWCore.On_PetCast"; MyTimer.Start(fnname); LocalPlayer Me = StyxWoW.Me; WoWPetSpell spell = null; // Don't even try to cast if I don't have a pet. if (!Me.GotAlivePet) { MyTimer.Stop(fnname); return(false); } foreach (WoWPetSpell sp in StyxWoW.Me.PetSpells) { if (sp.Action.ToString() == spellname) { Lua.DoString("CastPetAction({0})", sp.ActionBarIndex + 1); FTWLogger.log("[Pet] Action = {0}", sp.Action.ToString()); break; } else if (sp.Spell != null && sp.Spell.Name == spellname) { spell = sp; break; } } if (spell == null) { FTWLogger.debug(Color.Gray, "[Pet] Unknown spell {0}", spellname); MyTimer.Stop(fnname); return(false); } if (FTWCoreStatus.OnPetCooldown(spellname)) { MyTimer.Stop(fnname); return(false); } if (!castnow && (Me.Pet.IsCasting || Me.Pet.IsChanneling)) { MyTimer.Stop(fnname); return(false); } if (spell.Spell.MinRange > 0 && target.DistanceCalc() < spell.Spell.MinRange) { FTWLogger.debug(Color.Yellow, "[Pet] Too close to {0} to cast {1}.", target.SafeName(), spell.Spell.Name); MyTimer.Stop(fnname); return(false); } if (spell.Spell.MaxRange > 0 && target.DistanceCalc() > spell.Spell.MaxRange) { FTWLogger.debug(Color.Yellow, "[Pet] Too far away to {0} to cast {1}.", target.SafeName(), spell.Spell.Name); MyTimer.Stop(fnname); return(false); } string strTarget; if (target.Guid == StyxWoW.Me.Guid) { strTarget = "player"; } else if (target.Guid == StyxWoW.Me.Pet.Guid) { strTarget = "pet"; } else if (target.Guid == StyxWoW.Me.CurrentTargetGuid) { strTarget = "target"; } else { strTarget = null; } if (strTarget == null) { Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1); FTWLogger.log(" [Pet] Cast {0}", spell.Spell.Name); } else { Lua.DoString("CastPetAction({0}, {1})", spell.ActionBarIndex + 1, strTarget); FTWLogger.log(" [Pet] Cast {0} on {1} health {2:0.0} dist {3:0.0}", spell.Spell.Name, strTarget, target.HealthPercent, target.DistanceCalc()); } if (spell.Spell.IsAreaSpell()) { // Area spell WoWPoint loc; if (spell.Spell.IsSelfOnlySpell) { loc = StyxWoW.Me.Location; } else { loc = target.Location; } DateTime stoptime = DateTime.Now.AddMilliseconds(500); while (DateTime.Now < stoptime) { if (StyxWoW.Me.CurrentPendingCursorSpell != null) { break; } Thread.Sleep(10); } SpellManager.ClickRemoteLocation(loc); stoptime = DateTime.Now.AddMilliseconds(500); while (DateTime.Now < stoptime) { // Clear target spell, if one is up if (StyxWoW.Me.CurrentPendingCursorSpell == null) { break; } Thread.Sleep(10); } // Clear target spell, if one is up if (StyxWoW.Me.CurrentPendingCursorSpell != null) { Lua.DoString("SpellStopTargeting()"); } } FTWCoreStatus.SaveCooldown(spell.Spell.Name); MyTimer.Stop(fnname); // We have no way of knowing if this spell was successfully cast or not. // Therefore, return false so it doesn't stop the action sequence. return(false); }
public static bool On_Cast(string firstpart, string spellname, WoWUnit target, bool castnow, bool castonce, bool debugspell = false) { string fnname = "FTWCore.On_Cast"; MyTimer.Start(fnname); LocalPlayer Me = StyxWoW.Me; WoWSpell spell = null; bool retval = true; Color ds = Color.Magenta; if (target != null && !target.IsFriendly && target.IsDead) { if (debugspell) { FTWLogger.log(ds, "Target is hostile and dead"); } MyTimer.Stop(fnname); return(false); } if (FTWCoreStatus.OnCooldown(spellname, debugspell)) { MyTimer.Stop(fnname); return(false); } if (target != null && !target.IsFriendly && !FTWUtils.MovementDisabled()) { FTWCoreMovement.Face(target); } // Clear out expired CastOnce entries (older than CastOnceTime seconds) foreach (KeyValuePair <String, DateTime> kvp in FTWProps.CastOnce.ToList()) { if (DateTime.Now > kvp.Value) { FTWProps.CastOnce.Remove(kvp.Key); } } // Leave early if CastOnce contains unexpired entry for this unit if (FTWProps.CastOnce.ContainsKey(spellname + target.Guid.ToString())) { if (debugspell) { FTWLogger.log(ds, "Already cast {0} on {1}", spellname, target.Name); } MyTimer.Stop(fnname); return(false); } if (SpellManager.GlobalCooldown) { if (debugspell) { FTWLogger.log(ds, "..."); } MyTimer.Stop(fnname); return(false); } try { if (FTWProps.fakecooldowns.ContainsKey(spellname)) { spell = WoWSpell.FromId(FTWProps.fakecooldowns[spellname].SpellID); } else if (SpellManager.Spells.ContainsKey(spellname)) { spell = SpellManager.Spells[spellname]; } else { FTWLogger.debug(Color.Gray, "Unknown spell {0}", spellname); MyTimer.Stop(fnname); return(false); } } catch (Exception ex) { FTWLogger.log(Color.Pink, "Error when getting spell {0}: {1}", spellname, ex.Message); MyTimer.Stop(fnname); return(false); } if (spell == null) { FTWLogger.debug(Color.Gray, "Unknown spell '{0}'", spellname); MyTimer.Stop(fnname); return(false); } // Check whether or not you know the spell according to WoW if (false) // leave commented out for now { List <string> known = Lua.GetReturnValues(String.Format("return IsSpellKnown({0})", spell.Id), "SpellKnown.lua"); int knownspell = Int32.Parse(known[0]); if (knownspell == 0) { FTWLogger.log(Color.Gray, "GetSpellInfo says you don't know spell {0} ({1})", spellname, known[0]); MyTimer.Stop(fnname); return(false); } } if (false) { // Check power requirements List <string> values = Lua.GetReturnValues(String.Format("return GetSpellInfo({0})", spell.Id), "SpellInfo.lua"); //string[] vars = {"name", "rank", "icon", "cost", "isFunnel", "powerType", "castTime", "minRange", "maxRange"}; int powerType = Int32.Parse(values[5]); int powerCost = Int32.Parse(values[3]); string[] powertypes = { "mana", "rage", "focus", "energy", "happiness", "runes", "runic power", "soul shards", "eclipse", "holy power", "alternate power", "dark force", "chi", "shadow orbs", "burning embers", "demonic fury" }; if (StyxWoW.Me.UnitPower(powerType) < powerCost) { FTWLogger.log(Color.Orange, "NOT ENOUGH {0} - Requires: {1}, but I have: {2}", powertypes[powerType], powerCost, StyxWoW.Me.UnitPower(powerType)); MyTimer.Stop(fnname); return(false); } } if (!spell.IsSelfOnlySpell) { if (target == null) { FTWLogger.log(Color.Orange, "Can't cast {0} on null target!", spell.Name); if (debugspell) { FTWLogger.log(ds, "Null target"); } MyTimer.Stop(fnname); return(false); } double dist = target.Distance; // target.DistanceCalc(); if ((spell.MinRange > 0 || spell.MaxRange > 0) && !(dist >= spell.MinRange && dist <= spell.MaxRange)) { FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} minrange {5} maxrange {6}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc(), spell.MinRange, spell.MaxRange); if (debugspell) { FTWLogger.log(ds, "Out of range"); } MyTimer.Stop(fnname); return(false); } if (!target.InLineOfSight) { FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} (not in line of sight)", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc()); if (debugspell) { FTWLogger.log(ds, "Not in line of sight. Attempts = {0}.", FTWProps.not_in_los_attempts); } MyTimer.Stop(fnname); FTWProps.not_in_los_attempts += 1; Navigator.MoveTo(target.Location); Thread.Sleep(2000); return(false); } if (spellname == "Death Pact" && Me.GotAlivePet) { Me.Pet.Target(); for (int l = 0; l < 2; l++) { Thread.Sleep(10); } } if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname)) { retval = true; } else if (spell.IsSelfOnlySpell) { retval = SpellManager.CanCast(spell, true); } else { retval = SpellManager.CanCast(spell, target, true); } if (FTWProps.IgnoreCanCast.Contains(spellname)) { if (debugspell) { FTWLogger.log(ds, "Ignoring cancast for {0}", spellname); } retval = true; } if (retval == false) { if (spell.IsSelfOnlySpell) { FTWLogger.debug(Color.Orange, "CanCast returned false for {0} {1} on me", spellname, spell.Id); } else { FTWLogger.debug(Color.Orange, "CanCast returned false for {0} {1} on {2} health {3:0.0} dist {4:0.0}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc()); } MyTimer.Stop(fnname); if (debugspell) { FTWLogger.log(ds, "CanCast returned false"); } return(false); } } // Leave early if still casting if (!castnow && (Me.IsCasting || Me.IsChanneling)) { if (debugspell) { FTWLogger.log(ds, "Still casting"); } return(false); } // Definitely going to cast - Stop casting if (Me.IsCasting || Me.IsChanneling) { if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname)) { FTWLogger.log("Currently casting {0} - casting over it with {1}", FTWProps.lastspellcastname, spellname); } else if (castnow) { SpellManager.StopCasting(); } } // Stop moving if (spell.CastTime > 0 && !FTWUtils.MovementDisabled()) { WoWMovement.MoveStop(); } // Clear target spell, if one is up if (StyxWoW.Me.CurrentPendingCursorSpell != null) { Lua.DoString("SpellStopTargeting()"); } if (spell.IsTankOnlySpell() == true) { // Spells that are only ever cast on tanks, such as Misdirection and Tricks of the Trade. if (FTWProps.people.Count > 1 && FTWProps.tank.Guid != Me.Guid && FTWProps.tank.IsDead == false) { FTWLogger.log("cast tank-only spell {0} on {1}", spell.Name, FTWProps.tank.SafeName()); if (SpellManager.CanCast(spell, FTWProps.tank)) { FTWLogger.log("nope - failed cancast check."); retval = SpellManager.Cast(spell, FTWProps.tank); } } else if (StyxWoW.Me.GotAlivePet && Me.Pet.IsDead == false) { FTWLogger.log("cast tank-only spell {0} on pet", spell.Name); if (SpellManager.CanCast(spell, Me.Pet)) { FTWLogger.log("nope - failed cancast check."); retval = SpellManager.Cast(spell, Me.Pet); } } else { retval = false; } } else if (spell.IsAreaSpell() == false) { // Most normal spells if (spell.IsSelfOnlySpell) { retval = SpellManager.Cast(spell); } else { retval = SpellManager.Cast(spell, target); } // Post-spell processing if (spellname == "Feign Death") { while (Me.HasAura("Feign Death")) { List <WoWUnit> mobs = (List <WoWUnit>)FTWCoreUnits.GetNearbyUnfriendlyUnits(); if (mobs.Count == 0 && StyxWoW.Me.HealthPercent > 95) { break; } Thread.Sleep(10); } } } else { // Area spell WoWPoint loc; if (spell.IsSelfOnlySpell && !spell.Name.EndsWith(" Trap")) { loc = StyxWoW.Me.Location; } else { loc = target.Location; } retval = SpellManager.Cast(spell); DateTime stoptime = DateTime.Now.AddMilliseconds(500); while (DateTime.Now < stoptime) { if (StyxWoW.Me.CurrentPendingCursorSpell != null) { break; } Thread.Sleep(10); } SpellManager.ClickRemoteLocation(loc); stoptime = DateTime.Now.AddMilliseconds(500); while (DateTime.Now < stoptime) { // Clear target spell, if one is up if (StyxWoW.Me.CurrentPendingCursorSpell == null) { break; } Thread.Sleep(10); } // Clear target spell, if one is up if (StyxWoW.Me.CurrentPendingCursorSpell != null) { Lua.DoString("SpellStopTargeting()"); } } // Add current spell to CastOnce dictionary if (castonce == true) { FTWProps.CastOnce[spellname + target.Guid.ToString()] = DateTime.Now.AddSeconds(FTWProps.CastOnceTime); } // Wait until spell starts casting if (spell.CastTime > 0) { DateTime dt = DateTime.Now.AddSeconds(1.5); while (DateTime.Now < dt && !StyxWoW.Me.IsCasting && !StyxWoW.Me.IsChanneling) { Thread.Sleep(10); } } // Save spell cooldown if (retval == true) { FTWLogger.log(" {0} {1} on {2} {3} health {4:0} dist {5:0.0} aggro {6} {7} (addscount {8})", firstpart, spellname, target.SafeName(), target.ShortGuid(), target.HealthPercent, target.DistanceCalc(), (int)target.ThreatInfo.ThreatStatus, target.ThreatInfo.ThreatStatus, FTWProps.adds.Count); FTWCoreStatus.SaveCooldown(spellname); FTWProps.MovementCooldown = DateTime.Now.Add(TimeSpan.FromMilliseconds(Math.Min(1500, spell.CastTime))); FTWProps.not_in_los_attempts = 0; } else { FTWLogger.log(Color.Gray, " - Couldn't cast spell {0} on {1} {2} at dist {3:0.0}", spellname, target.SafeName(), target.ShortGuid(), target.DistanceCalc()); } if (FTWProps.Stuns.Contains(spellname)) { // Don't attack again for 3 seconds - hb is slow in noticing cc's. Blacklist.Add(target.Guid, BlacklistFlags.Combat, TimeSpan.FromSeconds(3)); if (target.Guid == StyxWoW.Me.CurrentTargetGuid) { StyxWoW.Me.ClearTarget(); } } MyTimer.Stop(fnname); return(retval); }
public override void Pulse() { string fnname = "FTWRev.Pulse"; MyTimer.Start(fnname); // Display startup message if (FTWProps.firstpulse == true) { FTWProps.firstpulse = false; // Eh, I don't like it. Uncomment if you really want it. //Mount.OnMountUp += UseTravelForm; FTWProps.core.Initialize(); FTWLogger.log("FTW starting at {0}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")); FTWLogger.log("Current bot: {0}", Styx.CommonBot.BotManager.Current.Name); } // Unstick ourselves if necessary. CheckForStuck.Pulse(); // Display last red text if (StyxWoW.LastRedErrorMessage != FTWProps.redtext) { FTWProps.redtext = StyxWoW.LastRedErrorMessage; FTWLogger.debug(Color.Red, "Red text: {0}", FTWProps.redtext); } // Leave early if not in valid state if (!FTWUtils.ValidState()) { //FTWLogger.debug(Color.Red, "Invalid state: {0}", FTWUtils.printState()); } else { // Save current class and spec //FTWProps.ClassAndSpec = StyxWoW.Me.ClassAndSpec(); // List aura changes AuraWatcher.Pulse(); // Load rules if they're not loaded //if (!FTWProps.rules.ContainsKey(FTWProps.ClassAndSpec)) // FTWProps.LoadRules(); FTWProps.core.Pulse(); if (FTWUtils.MeOrPartyMemberInCombat()) { //if (BotPoi.Current.Type == PoiType.Loot) //{ // debug("Not done with combat, clearing loot flag"); // BotPoi.Clear(); //} // Force combat because me OR party/raid members in combat) Combat(); } } // Perform dungeon stuff DungeonWatcher.Pulse(); // Perform UI stuff UI.Pulse(); MyTimer.Stop(fnname); MyTimer.Pulse(); }
public static bool On_Use(string itemname, WoWUnit target) { string fnname = "FTWCore.On_Use"; MyTimer.Start(fnname); bool retval = false; using (StyxWoW.Memory.AcquireFrame()) { if (itemname.ToLower() == "trinket1" && StyxWoW.Me.Inventory.Equipped.Trinket1 != null) { WoWItem trinket = StyxWoW.Me.Inventory.Equipped.Trinket1; if (trinket.Cooldown == 0 && trinket.Usable == true && trinket.TriggersSpell == true) { FTWLogger.log("Using trinket {0}", StyxWoW.Me.Inventory.Equipped.Trinket1.Name); StyxWoW.Me.Inventory.Equipped.Trinket1.Use(); } } else if (itemname.ToLower() == "trinket2" && StyxWoW.Me.Inventory.Equipped.Trinket2 != null) { WoWItem trinket = StyxWoW.Me.Inventory.Equipped.Trinket2; if (trinket.Cooldown == 0 && trinket.Usable == true && trinket.TriggersSpell == true) { FTWLogger.log("Using trinket {0}", StyxWoW.Me.Inventory.Equipped.Trinket2.Name); StyxWoW.Me.Inventory.Equipped.Trinket2.Use(); } } else { WoWItem item = GetInventoryItem(itemname); if (item == null) { FTWLogger.debug("Couldn't find item {0}", itemname); } else if (item.Usable == false) { FTWLogger.debug("Item {0} is not usable", item.Name); } else if (item.Cooldown > 0) { FTWLogger.debug("Item {0} is on cooldown. Time remaining: {1}", item.Name, item.CooldownTimeLeft.TotalSeconds); } else if (FTWCoreStatus.OnCooldown(item.Name)) { FTWLogger.debug("Item {0} is on cooldown.", item.Name); } else { if (target != null && target.Guid != StyxWoW.Me.Guid) { target.Target(); Thread.Sleep(100); } FTWLogger.log("Using item '{0}'", item.Name); item.Use(); retval = false; } } } MyTimer.Stop(fnname); return(retval); }
public static bool On_UsePotion(HashSet <String> spellnames) { bool retval = true; string fnname = "FTWCore.On_UsePotion"; MyTimer.Start(fnname); using (StyxWoW.Memory.AcquireFrame()) { if (!FTWUtils.ValidState()) { retval = false; } else { WoWItem potion = (from i in StyxWoW.Me.CarriedItems let spells = i.ItemSpells where i.ItemInfo != null && spells != null && spells.Count != 0 && i.Usable && i.Cooldown == 0 && i.ItemInfo.RequiredLevel <= StyxWoW.Me.Level && spells.Any(s => s.IsValid && s.ActualSpell != null && spellnames.Contains(s.ActualSpell.Name)) orderby i.ItemInfo.Level descending select i).FirstOrDefault(); if (FTWProps.debugitems.Count > 0) { foreach (WoWItem item in StyxWoW.Me.CarriedItems) { if (FTWProps.debugitems.Contains(item.Name)) { List <WoWItem.WoWItemSpell> spells = item.ItemSpells; ItemInfo inf = item.ItemInfo; FTWLogger.debug(string.Format("{0} {1} {2}", item.Name, item.Usable, item.Cooldown)); if (spells != null) { foreach (WoWItem.WoWItemSpell itemspell in spells) { FTWLogger.debug(string.Format(" {0} {1}", itemspell.Id, itemspell.ToString())); WoWSpell actualspell = itemspell.ActualSpell; if (actualspell != null) { FTWLogger.debug(string.Format(" {0} {1} {2}", actualspell.Id, actualspell.Name, actualspell.IsValid)); } } } } } } if (potion == null) { retval = false; } else { potion.UseContainerItem(); FTWLogger.log(Color.SkyBlue, "Using {0}", potion.Name); retval = true; } } } MyTimer.Stop(fnname); return(retval); }
public static List <WoWUnit> GetAdds() { string fnname = "FTWCore.GetAdds"; MyTimer.Start(fnname); WoWUnit pettarget = null; WoWUnit mytarget = null; // Get pet target if (StyxWoW.Me.GotAlivePet && StyxWoW.Me.PetInCombat && StyxWoW.Me.Pet.IsDead == false && StyxWoW.Me.Pet.CurrentTarget.IsValidUnit() && StyxWoW.Me.Pet.CurrentTarget.Combat) { pettarget = StyxWoW.Me.Pet.CurrentTarget; } // Get my target if (StyxWoW.Me.CurrentTarget != null) { WoWUnit target = StyxWoW.Me.CurrentTarget; if (target.IsValidUnit() && (target.Combat || target.Name == "Training Dummy") && target.IsDead == false) { mytarget = target; } } // Get all eligible units List <WoWUnit> allunits = ( from u in ObjectManager.GetObjectsOfType <WoWUnit>(false, false) where !u.IsFriendly where !(FTWProps.mode == "@PULL" && u.TaggedByOther == true) where u.Combat where !u.IsDead where u.DistanceSqr < 50 * 50 where (!(Battlegrounds.IsInsideBattleground && FTWProps.IgnoreMobsBattleground.Contains(u.Name))) where !u.Mounted where !u.OnTaxi where !u.IsOnTransport select u).ToList(); // Add current targets if (pettarget != null && !allunits.Contains(pettarget)) { allunits.Add(pettarget); } if (mytarget != null && !allunits.Contains(mytarget)) { allunits.Add(mytarget); } if (false) { if (allunits.Count > 0) { FTWLogger.debug(Color.Magenta, "{0} adds in all units:", allunits.Count); foreach (WoWUnit wu in allunits) { string s = " "; s += string.Format("level {0} ", wu.Level); s += string.Format("{0} ", wu.SafeName()); s += string.Format("health={0} ({1:0}%) ", wu.CurrentHealth, wu.HealthPercent); s += string.Format("dist={0:0.0} ", wu.Distance); s += string.Format("targetweight={0} ", wu.TargetWeight()); s += string.Format("crowdcontrolled={0} ", wu.IsDead || wu.IsCrowdControlled()); s += string.Format("isplayer={0} ", wu.IsPlayer); s += string.Format("blacklisted={0} ", Blacklist.Contains(wu)); FTWLogger.debug(Color.Magenta, s); } } } bool bg = Battlegrounds.IsInsideBattleground; // Get preferrred list (allunits but only those attacking us) List <WoWUnit> attackingus = ( from u in allunits where u.IsValidUnit() where (bg || (u.Combat && (u.IsTargetingMeOrPet || u.IsTargetingMyPartyMember || u.IsTargetingAnyMinion || u.IsTargetingMyRaidMember || IsTargetingPartyPets(u) ))) select u).ToList(); // Add current targets if (pettarget != null && !attackingus.Contains(pettarget)) { attackingus.Add(pettarget); } if (mytarget != null && !attackingus.Contains(mytarget)) { attackingus.Add(mytarget); } // Try to use preferred list List <WoWUnit> units = attackingus; // But if it's empty, kill everyone close by. if (false) { if (StyxWoW.Me.Combat == true && units.Count == 0 && FTWProps.closePeople.Count <= 1) { FTWLogger.debug(Color.Yellow, "No adds but I'm in combat, looking at all nearby targets."); units = allunits; } } units = (from u in units orderby u.TargetWeight() descending, u.IsCrowdControlled() ascending, u.IsAttackingHealer() descending, u.Guid == StyxWoW.Me.CurrentTargetGuid descending, u.Guid == FTWProps.tank.CurrentTargetGuid descending, u.DistanceSqr ascending select u).ToList(); if (false) { if (units.Count > 0) { FTWLogger.debug(Color.Yellow, "{0} adds:", units.Count); foreach (WoWUnit wu in units) { string s = " "; s += string.Format("level {0} ", wu.Level); s += string.Format("{0} ", wu.SafeName()); s += string.Format("health={0} ({1:0}%) ", wu.CurrentHealth, wu.HealthPercent); s += string.Format("dist={0:0.0} ", wu.Distance); s += string.Format("targetweight={0} ", wu.TargetWeight()); s += string.Format("crowdcontrolled={0} ", wu.IsDead || wu.IsCrowdControlled()); s += string.Format("isplayer={0} ", wu.IsPlayer); s += string.Format("blacklisted={0} ", Blacklist.Contains(wu)); FTWLogger.debug(Color.Yellow, s); } } } MyTimer.Stop(fnname); return(units); }