private static bool InLFDQueue() { string s = GetLFDMode(); FTWLogger.log(Color.SandyBrown, "LFDMode: {0}", s); return(s == "queued" || s == "proposal"); }
public static void Display() { Color c = Color.Yellow; List <KeyValuePair <string, int> > list = elapseds.ToList(); list.Sort( delegate(KeyValuePair <string, int> p1, KeyValuePair <string, int> p2) { int compareDate = p2.Value.CompareTo(p1.Value); if (compareDate == 0) { return(p1.Key.CompareTo(p2.Key)); } ; return(compareDate); } ); FTWLogger.debug(c, "Timings:"); int total = 0; foreach (KeyValuePair <string, int> kvp in list) { total += kvp.Value; } foreach (KeyValuePair <string, int> kvp in list) { FTWLogger.debug(c, " {0}: total time {1} ms, ({2:0.0}%), loops {3}, avgtime {4:0} ms", kvp.Key, kvp.Value, kvp.Value * 100 / total, count[kvp.Key], kvp.Value / count[kvp.Key]); } }
public static void printAuras(this WoWUnit unit) { foreach (WoWAura aura in unit.Auras.Values) { FTWLogger.debug(aura.Name + ' ' + aura.CreatorGuid); } }
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 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 void HandleDungeonInvite(object sender, LuaEventArgs args) { if (AutoAcceptDungeon) { FTWLogger.log(Color.SandyBrown, "Accepting dungeon invite"); Lua.DoString("AcceptProposal()"); } }
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 void Stop(string s, bool displaynow = false) { int elapsedtime = (int)(DateTime.Now - starts[s]).TotalMilliseconds; if (!elapseds.ContainsKey(s)) { elapseds.Add(s, elapsedtime); count.Add(s, 1); } else { elapseds[s] += elapsedtime; count[s] += 1; } if (displaynow && elapsedtime > 0) { FTWLogger.debug(Color.SeaShell, string.Format("-------------------- {0} ({1}) {2}", s, elapsedtime, BotPoi.Current.ToString())); } }
public static void Pulse() { int currenthealth = (int)StyxWoW.Me.HealthPercent; DateTime currenttime = DateTime.Now; double healthchange = currenthealth - lasthealth; double elapsedms = (currenttime - lastauraupdate).TotalMilliseconds; double r = healthchange * 1000 / elapsedms; //if (r < 0) // debug(Color.Orange, "Current health: {0:0.0}, Last health: {1:0.0}, Diff: {2:0.0}, Ms: {3:0.0}, Rate: {4:0.0} ", currenthealth, lasthealth, healthchange, elapsedms, r); lasthealth = currenthealth; lastauraupdate = currenttime; foreach (WoWAura aura in StyxWoW.Me.Auras.Values.ToList()) { if (!auras.ContainsKey(aura.Name)) { if (aura.TimeLeft.TotalSeconds > 0) { if (aura.IsHarmful) { FTWLogger.debug(Color.Pink, "+++ {0} - {1} stacks, {2:0.0} seconds remaining", aura.Name, aura.StackCount, aura.TimeLeft.TotalSeconds); } else { FTWLogger.debug(Color.LightGreen, "+++ {0} - {1} stacks, {2:0.0} seconds remaining", aura.Name, aura.StackCount, aura.TimeLeft.TotalSeconds); } auras[aura.Name] = aura; } } } foreach (WoWAura aura in auras.Values.ToList()) { if (!StyxWoW.Me.Auras.ContainsKey(aura.Name)) { FTWLogger.debug(Color.Gray, "----- {0}", aura.Name); auras.Remove(aura.Name); } } }
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 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 void UseTravelForm(object sender, MountUpEventArgs e) { float traveldist = 30; float dist = StyxWoW.Me.Location.Distance(e.Destination); string errmsg = string.Empty; while (SpellManager.GlobalCooldown || StyxWoW.Me.IsCasting || StyxWoW.Me.ChanneledSpell != null) { Thread.Sleep(10); } if (!SpellManager.HasSpell("Travel Form")) { errmsg = "Don't have travel form."; } else if (e.Destination == WoWPoint.Zero) { errmsg = "Destination is WoWPoint.Zero"; } else if (dist > traveldist) { errmsg = string.Format("Dist {0} > traveldist {1}", dist, traveldist); } else if (Battlegrounds.IsInsideBattleground && DateTime.Now < Battlegrounds.BattlefieldStartTime) { errmsg = "Battle hasn't started yet."; } if (errmsg != string.Empty) { FTWLogger.log("Not using travel form because {0}", errmsg); } else { e.Cancel = true; FTWLogger.log("Using travel form for point {0} yards away (MountDistance: {1})", dist, Styx.Helpers.CharacterSettings.Instance.MountDistance); if (!StyxWoW.Me.HasAura("Travel Form")) { SpellManager.Cast("Travel Form"); } } }
public static void Pulse() { string s = Lua.GetReturnVal <string>("local m,s = GetLFGMode(LE_LFG_CATEGORY_LFD); return m;", 0); if (s == null) { s = "<null>"; } //debug(Color.SandyBrown, "LFGMode: {0}", s); if (StyxWoW.Me.Level < 15 || AutoQueueDungeon == false || StyxWoW.Me.IsInInstance == true || IsLFGDeserter() == true || InLFDQueue() == true) { return; } FTWLogger.log(Color.SandyBrown, "Queuing for dungeon"); Lua.DoString("LFDQueueFrame_Join()"); }
private static void LoadRules() { fakecooldowns = LoadFakeCooldowns(gen_rules_path + "\\Spell_Overrides.txt"); AOESpells = LoadList(gen_rules_path + "\\Spell_Target_Circle.txt"); Stuns = LoadList(gen_rules_path + "\\Spell_Stuns.txt"); TankOnlySpells = LoadList(gen_rules_path + "\\Spell_Tank_Only.txt"); CastOver = LoadList(gen_rules_path + "\\Spell_Cast_Over.txt"); IgnoreMobsBattleground = LoadList(gen_rules_path + "\\Ignore_Mobs_Battleground.txt"); PropertyNames = File.ReadAllLines(gen_rules_path + "\\Properties.txt"); IgnoreCanCast = LoadList(gen_rules_path + "\\Spell_Ignore_CanCast.txt"); MobWeights = LoadWeights(gen_rules_path + "\\Mob_Weights.txt"); try { FTWLogger.log("Loading rules for {0}", ClassAndSpec); string filename = FTWProps.class_rules_path + "\\" + ClassAndSpec + ".txt"; rules[ClassAndSpec] = File.ReadAllText(filename); } catch (Exception ex) { FTWLogger.log(Color.Red, "Couldn't find a data file for {0}! {1}", ClassAndSpec, ex.Message); } }
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); }