Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
        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);
        }
Example #11
0
        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);
        }
Example #12
0
        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());
            }
        }
Example #13
0
        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);
            }
        }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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);
        }