public static int AuraExpiring(this WoWUnit unit, string auraname) { string fnname = "FTWExtensionMethods.AuraExpiring"; MyTimer.Start(fnname); // Return my aura if it exists, first. foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname && aura.CreatorGuid == StyxWoW.Me.Guid) { MyTimer.Stop(fnname); return((int)aura.TimeLeft.TotalMilliseconds); } } // Otherwise any aura of this name foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname) { MyTimer.Stop(fnname); return((int)aura.TimeLeft.TotalMilliseconds); } } // No aura found MyTimer.Stop(fnname); return(0); }
public static bool IsAttackingHealer(this WoWUnit unit) { string fnname = "FTWExtensionMethods.IsAttackingHealer"; MyTimer.Start(fnname); bool retval = false; if (!(unit.IsAlive && unit.IsHostile && unit.CurrentTarget != null)) { retval = false; } else if (!unit.CurrentTarget.IsPlayer) { retval = false; } else if (!unit.IsTargetingMyPartyMember) { retval = false; } else if (!unit.IsTargetingMyRaidMember) { retval = false; } else { WoWPlayer target = (WoWPlayer)unit.CurrentTarget; if (target.Role().Contains("Healer")) { retval = true; } } MyTimer.Stop(fnname); return(retval); }
public static bool HasItem(this WoWPlayer p, string itemname) { bool retval; string fnname = "FTWExtensionMethods.HasItem"; MyTimer.Start(fnname); using (StyxWoW.Memory.AcquireFrame()) { WoWItem item = StyxWoW.Me.CarriedItems.FirstOrDefault(i => i != null && i.Name == itemname); if (item == null) { retval = false; } else { int cnt = Convert.ToInt32(Lua.GetReturnValues(String.Format("return GetItemCount(\"{0}\")", item.Name), "HasItem.lua")[0]); if (cnt == 0) { retval = false; } else { retval = true; } } } MyTimer.Stop(fnname); return(retval); }
public static int StackCount(this WoWUnit unit, string auraname) { // Return my aura if it exists, first. string fnname = "FTWExtensionMethods.StackCount"; MyTimer.Start(fnname); foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname && aura.CreatorGuid == StyxWoW.Me.Guid) { MyTimer.Stop(fnname); return((int)aura.StackCount); } } // Otherwise any aura of this name foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname) { MyTimer.Stop(fnname); return((int)aura.StackCount); } } // No aura found MyTimer.Stop(fnname); return(0); }
public static bool IsCrowdControlled(this WoWUnit unit) { string fnname = "FTWExtensionMethods.IsCrowdControlled"; bool retval = false; MyTimer.Start(fnname); if (unit == null) { MyTimer.Stop(fnname); return(false); } foreach (WoWAura aura in unit.Debuffs.Values) { try { if (FTWProps.Stuns.Contains(aura.Name)) { retval = true; } else if (aura.Spell == null) { continue; } else if (( aura.Spell.Mechanic == WoWSpellMechanic.Asleep || aura.Spell.Mechanic == WoWSpellMechanic.Banished || aura.Spell.Mechanic == WoWSpellMechanic.Frozen || aura.Spell.Mechanic == WoWSpellMechanic.Horrified || aura.Spell.Mechanic == WoWSpellMechanic.Invulnerable2 || aura.Spell.Mechanic == WoWSpellMechanic.Incapacitated || aura.Spell.Mechanic == WoWSpellMechanic.Polymorphed || aura.Spell.Mechanic == WoWSpellMechanic.Rooted || aura.Spell.Mechanic == WoWSpellMechanic.Sapped || aura.Spell.Mechanic == WoWSpellMechanic.Shackled || aura.Spell.Mechanic == WoWSpellMechanic.Stunned || aura.Spell.Mechanic == WoWSpellMechanic.Turned || aura.Spell.Mechanic == WoWSpellMechanic.Fleeing) && aura.TimeLeft.TotalMilliseconds > 0) { retval = true; } } catch (Exception ex) { FTWLogger.log(Color.Red, "Error when examining aura {0} : {1}", aura.Name, ex.Message); retval = false; } if (retval == true) { break; } } if (retval) { FTWLogger.log(Color.GreenYellow, "{0} IS INCAPACITATED", unit.SafeName()); } MyTimer.Stop(fnname); return(retval); }
public static bool CheckPull() { string fnname = "Evade.CheckPull"; MyTimer.Start(fnname); // Check for botpoi not being something else if (!(BotPoi.Current.Type == PoiType.Kill || BotPoi.Current.Type == PoiType.None)) { return(false); } // Check for pull taking too long WoWUnit target = StyxWoW.Me.CurrentTarget; if (target == null || target.IsFriendly) { MyTimer.Stop(fnname); return(false); } if (StyxWoW.Me.HealthPercent < 50 || StyxWoW.Me.ManaPercent < 50) { FTWLogger.log(Color.Red, "Health or mana is below 50%, not pulling!"); StyxWoW.Me.ClearTarget(); MyTimer.Stop(fnname); return(false); } //if (!target.IsValidUnit()) //{ // log("Blacklisting {0} for 60 seconds in CheckPull", target.SafeName()); // Blacklist.Add(target, TimeSpan.FromSeconds(60)); // StyxWoW.Me.ClearTarget(); // MyTimer.Stop(fnname); // return false; //} int clustersize = target.ClusterSize(); FTWLogger.log(Color.Violet, "PULL: Target = {0} at {1} ({2}) ({3} mobs surrounding)", target.SafeName(), target.DistanceCalc(), target.FactionId, clustersize); if (target.Guid != PullTargetGuid) { // New pull target - reset timer for maxPullTime seconds PullStopTime = DateTime.Now.AddSeconds(MaxPullTime); PullTargetGuid = target.Guid; } else if (DateTime.Now > PullStopTime) { // Still pulling after maxPullTime seconds FTWLogger.log(Color.Red, "Can't pull {0} after {1} seconds - blacklist for 5 minutes.", target.SafeName(), MaxPullTime); Blacklist.Add(target.Guid, TimeSpan.FromMinutes(5)); StyxWoW.Me.ClearTarget(); MyTimer.Stop(fnname); return(false); } MyTimer.Stop(fnname); return(true); }
public static bool EligibleForRevive(this WoWPlayer p) { string fnname = "FTWExtensionMethods.EligibleForRevive"; MyTimer.Start(fnname); bool retval = p.IsDead || p.IsGhost; MyTimer.Stop(fnname); return(retval); }
public static bool EligibleForCleanse(this WoWPlayer p) { string fnname = "FTWExtensionMethods.EligibleForCleanse"; MyTimer.Start(fnname); bool retval = !p.IsDead && !p.IsGhost && p.InLineOfSight && p.HealthPercent < 90 && p.IsDiseased(); MyTimer.Stop(fnname); return(retval); }
public static void Pulse() { string fnname = "CheckForChest.Pulse"; MyTimer.Start(fnname); if (BotPoi.Current.Type == PoiType.Loot) { // Black list loot if it's taking too long FTWLogger.log(color, "LOOT CHESTS: Moving towards {0} ({1:X}) at {2} yards away", BotPoi.Current.Name, BotPoi.Current.Guid, BotPoi.Current.Location.Distance(StyxWoW.Me.Location)); if (BotPoi.Current.Guid == lastguid && DateTime.Now > stoptime) { FTWLogger.log(color, "LOOT CHESTS: Blacklisting {0} ({1:X}) - didn't get it after {2} seconds.", BotPoi.Current.Name, BotPoi.Current.Guid, blacklistMinutes); Blacklist.Add(lastguid, BlacklistFlags.All, TimeSpan.FromMinutes(60)); Clear(); } } else { // Look for new loot if (DateTime.Now < nexttime) { MyTimer.Stop(fnname); return; } // OMG DON'T run for a chest in a dungeon! // 'Tap tool' on beer keg in Stormstout causes you to pull multiple rooms of mobs. if (StyxWoW.Me.IsInInstance) { return; } nexttime = DateTime.Now.AddSeconds(checkInterval); List <WoWGameObject> chests = (from c in ObjectManager.GetObjectsOfType <WoWGameObject>(false, false) where c.Distance < Styx.CommonBot.LootTargeting.LootRadius where c.Type != WoWObjectType.Corpse && c.SubType == WoWGameObjectType.Chest && !Blacklist.Contains(c.Guid, BlacklistFlags.All) && c.CanLoot == true where c.IsHerb == false && c.IsMineral == false orderby c.Distance select c).ToList(); if (chests.Count > 0) { lastguid = chests[0].Guid; BotPoi.Current = new BotPoi(chests[0], PoiType.Loot); FTWLogger.log(color, "LOOT CHESTS: Going after {0} ({1:X}) at {2} yards away", chests[0].Name, chests[0].Guid, chests[0].Distance); stoptime = DateTime.Now.AddSeconds(pullSeconds); } } MyTimer.Stop(fnname); }
public static int MyAuraExpiring(this WoWUnit unit, string auraname) { string fnname = "FTWExtensionMethods.MyAuraExpiring"; MyTimer.Start(fnname); foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname && aura.CreatorGuid == StyxWoW.Me.Guid) { MyTimer.Stop(fnname); return((int)aura.TimeLeft.TotalMilliseconds); } } MyTimer.Stop(fnname); return(0); }
public static int MyStackCount(this WoWUnit unit, string auraname) { string fnname = "FTWExtensionMethods.MyStackCount"; MyTimer.Start(fnname); foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname && aura.CreatorGuid == StyxWoW.Me.Guid) { MyTimer.Stop(fnname); return((int)aura.StackCount); } } MyTimer.Stop(fnname); return(0); }
public static bool HasMyAura(this WoWUnit unit, string auraname) { string fnname = "FTWExtensionMethods.HasMyAura"; MyTimer.Start(fnname); foreach (WoWAura aura in unit.Auras.Values) { if (aura.Name == auraname && aura.CreatorGuid == StyxWoW.Me.Guid) { MyTimer.Stop(fnname); return(true); } } MyTimer.Stop(fnname); return(false); }
public static bool IsDiseased(this WoWUnit unit) { string fnname = "FTWExtensionMethods.IsDiseased"; MyTimer.Start(fnname); if (unit == null) { MyTimer.Stop(fnname); return(false); } WoWAura aura = (from debuff in unit.Debuffs.Values where debuff.Spell != null && FTWProps.dispels.Contains(debuff.Spell.DispelType) select debuff).FirstOrDefault(); MyTimer.Stop(fnname); return(aura != null); }
public static int UnitPower(this WoWPlayer p, int powertype) { string fnname = "FTWExtensionMethods.UnitPower"; MyTimer.Start(fnname); int cnt = 0; try { cnt = Convert.ToInt32(Lua.GetReturnValues(string.Format("return UnitPower('player', {0})", powertype), "PowerType.lua")[0]); } catch (Exception ex) { FTWLogger.log(Color.Red, "Error when getting UnitPower - {0}", ex.Message); cnt = 0; } MyTimer.Stop(fnname); return(cnt); }
public static bool HasAuraWithMechanic(this WoWUnit unit, params WoWSpellMechanic[] mechanics) { string fnname = "FTWExtensionMethods.HasAuraWithMechanic"; MyTimer.Start(fnname); foreach (KeyValuePair <string, WoWAura> kvp in unit.Auras) { foreach (WoWSpellMechanic mech in mechanics) { if (kvp.Value.Spell.Mechanic == mech) { MyTimer.Stop(fnname); return(true); } } } MyTimer.Stop(fnname); return(false); }
public static bool CheckCombat() { // Check for combat taking too long string fnname = "Evade.CheckCombat"; MyTimer.Start(fnname); WoWUnit target = StyxWoW.Me.CurrentTarget; if (target == null || target.IsFriendly) { MyTimer.Stop(fnname); return(true); } if (target.IsDead == true && !target.IsFriendly) { StyxWoW.Me.ClearTarget(); return(true); } if (target.Guid != CurrentTargetGuid) { // New target CurrentTargetStopTime = DateTime.Now.AddSeconds(MaxCurrentTargetTime); CurrentTargetGuid = target.Guid; FTWLogger.log("Starting combat with {0} {1}", target.SafeName(), target.ShortGuid()); if (!FTWUtils.MovementDisabled()) { WoWMovement.MoveStop(); } } else if (DateTime.Now > CurrentTargetStopTime && target.HealthPercent > 99 && !target.Name.Contains("Training Dummy") && !StyxWoW.Me.GroupInfo.IsInParty && !StyxWoW.Me.GroupInfo.IsInRaid) { // I've been fighting the same target by myself for too long - blacklist FTWLogger.log("Combat with {0} has gone on {1} seconds with no health reduction - adding to blacklist", target.SafeName(), MaxCurrentTargetTime); Blacklist.Add(target.Guid, TimeSpan.FromMinutes(5)); StyxWoW.Me.ClearTarget(); MyTimer.Stop(fnname); return(false); } MyTimer.Stop(fnname); return(true); }
public static int ClusterSize(this WoWUnit unit) { string fnname = "FTWExtensionMethods.ClusterSize"; MyTimer.Start(fnname); List <WoWUnit> units = (from u in ObjectManager.GetObjectsOfType <WoWUnit>(false, false) where u.Guid != unit.Guid where u.Location.Distance(unit.Location) < 6 where u.CanSelect || u.Attackable where !u.IsFriendly where !u.IsDead where !u.IsPet where !u.IsNonCombatPet where !u.IsCritter where !u.Mounted select u).ToList(); MyTimer.Stop(fnname); return(units.Count); }
public static string Role(this WoWPlayer p) { string fnname = "FTWExtensionMethods.Role"; MyTimer.Start(fnname); IEnumerable <WoWPartyMember> wpms = StyxWoW.Me.GroupInfo.RaidMembers.Union(StyxWoW.Me.GroupInfo.PartyMembers).Distinct(); WoWPartyMember wpm = (from member in wpms let x = member.ToPlayer() where x != null && p.Guid == x.Guid select member).FirstOrDefault(); MyTimer.Stop(fnname); if (wpm == null) { return(""); } else { return(wpm.Role.ToString()); } }
public static bool HasSpell(this WoWPlayer p, String spellname) { string fnname = "FTWExtensionMethods.HasSpell"; MyTimer.Start(fnname); WoWSpell spell = null; try { spell = SpellManager.Spells[spellname]; } catch (KeyNotFoundException ex) { } MyTimer.Stop(fnname); if (spell == null) { return(false); } else { return(true); } }
public static string ClassAndSpec(this WoWPlayer p) { string fnname = "FTWExtensionMethods.ClassAndSpec"; MyTimer.Start(fnname); string s = ""; using (StyxWoW.Memory.AcquireFrame()) { string _myclass = p.Class.ToString(); string _myspec = "talentless"; // Get class int talentTabId = Lua.GetReturnVal <int>("return GetSpecialization()", 0); // Returns 1 to 3 for primary talent tab id, or 0 if no talent tree chosen yet. if (talentTabId != 0) { // Get spec var GetTalentTabInfo = Lua.GetReturnValues(string.Format("return GetSpecializationInfo({0},false,false)", talentTabId)); _myspec = GetTalentTabInfo[1].Replace(" ", "_"); } s = string.Format("{0}_{1}", _myclass, _myspec); } MyTimer.Stop(fnname); return(s); }
public static void Pulse() { string fnname = "CheckForStuck.Pulse"; if (! (StyxWoW.IsInGame && StyxWoW.Me != null && StyxWoW.Me.IsValid && !StyxWoW.Me.IsDead && !StyxWoW.Me.IsGhost && !StyxWoW.Me.IsOnTransport && !StyxWoW.Me.OnTaxi) ) { return; } // Anti-AFK logic if (DateTime.Now > antiafk) { antiafk = DateTime.Now.AddMilliseconds(antiafkinterval + random.Next(3000, 5000)); KeyboardManager.PressKey((Char)System.Windows.Forms.Keys.Right); Thread.Sleep(random.Next(10, 20)); KeyboardManager.ReleaseKey((Char)System.Windows.Forms.Keys.Right); } if (!(",Gatherbuddy2,ArchaeologyBuddy,".Contains("," + Styx.CommonBot.BotManager.Current.Name + ","))) { return; } // Stuck logic MyTimer.Start(fnname); int numJumps; if (NotStuck() || DateTime.Now < stuckNextTime) { MyTimer.Stop(fnname); return; } stuckCtr += 1; FTWLogger.log(Color.Tomato, "Stuck for the {0} time - moving about a bit.", stuckCtr); // Just press the space bar first numJumps = random.Next(1, 3); for (int i = 0; i < numJumps; i++) { PressSpace(); if (NotStuck()) { MyTimer.Stop(fnname); return; } } // Back up numJumps = random.Next(1, 3); for (int i = 0; i < numJumps; i++) { WoWMovement.Move(WoWMovement.MovementDirection.Backwards); Thread.Sleep(random.Next(1000, 2000)); WoWMovement.MoveStop(); if (NotStuck()) { MyTimer.Stop(fnname); return; } } // Long jumps numJumps = random.Next(2, 4); for (int i = 0; i < numJumps; i++) { KeyboardManager.PressKey((char)Keys.Space); Thread.Sleep(random.Next(2000, 3000)); KeyboardManager.ReleaseKey((char)Keys.Space); Thread.Sleep(random.Next(250, 750)); if (NotStuck()) { MyTimer.Stop(fnname); return; } } // Up + space numJumps = random.Next(1, 3); for (int i = 0; i < numJumps; i++) { KeyboardManager.PressKey((char)Keys.Up); Thread.Sleep(random.Next(30, 50)); KeyboardManager.PressKey((char)Keys.Space); Thread.Sleep(random.Next(500, 750)); KeyboardManager.ReleaseKey((char)Keys.Up); KeyboardManager.ReleaseKey((char)Keys.Space); Thread.Sleep(random.Next(250, 750)); if (NotStuck()) { MyTimer.Stop(fnname); return; } } // Space + up numJumps = random.Next(1, 3); for (int i = 0; i < numJumps; i++) { KeyboardManager.PressKey((char)Keys.Space); Thread.Sleep(random.Next(30, 50)); KeyboardManager.PressKey((char)Keys.Up); Thread.Sleep(random.Next(500, 750)); KeyboardManager.ReleaseKey((char)Keys.Up); KeyboardManager.ReleaseKey((char)Keys.Space); Thread.Sleep(random.Next(250, 750)); if (NotStuck()) { MyTimer.Stop(fnname); return; } } MyTimer.Stop(fnname); }
public static bool IsValidUnit(this WoWUnit unit) { string fnname = "FTWExtensionMethods.IsValidUnit"; if (unit == null) { return(false); } MyTimer.Start(fnname); bool retval = true; string ispet = unit.IsPet.ToString(); string owner = "<none>"; string reason = ""; if (Blacklist.Contains(unit.Guid)) { if (unit.Combat && ( unit.IsTargetingMeOrPet || unit.IsTargetingMyPartyMember || unit.IsTargetingAnyMinion || unit.IsTargetingMyRaidMember || FTWCoreUnits.IsTargetingPartyPets(unit) )) { // ignore blacklist // HB will keep feeding you that target anyway. } else { reason = "{0} is blacklisted"; } } else if (!unit.CanSelect || !unit.Attackable) { reason = "can't select or attack {0}"; } else if (unit.IsFriendly) { reason = "{0} is friendly"; } else if (unit.IsDead) { reason = "{0} is dead"; } // The following line causes you to ignore mobs your party is fighting. //else if (unit.TaggedByOther) reason = "{0} is tagged by other."; else if (unit.HealthPercent == 0) { reason = "{0}'s health is 0"; } else if ((unit.IsPet && ((unit.OwnedByUnit != null && unit.OwnedByUnit.IsPlayer == true) || unit.OwnedByRoot == null || unit.OwnedByRoot.IsDead == false))) { reason = "{0} is pet"; } else if (unit.IsNonCombatPet) { reason = "{0} is noncombat pet"; } else if (unit.IsCritter) { reason = "{0} is critter"; } else if (Battlegrounds.IsInsideBattleground && FTWProps.IgnoreMobsBattleground.Contains(unit.Name)) { reason = "{0} is in ignored battleground mobs"; } MyTimer.Stop(fnname); if (reason == "") { retval = true; if (false && unit.IsPet) { if (unit.OwnedByRoot != null) { string prefix = "npc"; if (unit.OwnedByRoot.IsPlayer) { prefix = "player"; } owner = string.Format("pet {0} owned by {1} {2}", unit.Name, prefix, unit.OwnedByRoot.Name); } else { owner = string.Format("pet {0} owned by no one", unit.Name); } FTWLogger.debug(Color.MediumVioletRed, owner); } } else { FTWLogger.debug(Color.MediumVioletRed, reason, unit.Name); retval = false; } return(retval); }