예제 #1
0
    private void GCDCycle()
    {
        Usefuls.SleepGlobalCooldown();

        try
        {
            Memory.WowMemory.GameFrameLock(); // !!! WARNING - DONT SLEEP WHILE LOCKED - DO FINALLY(GameFrameUnLock()) !!!

            if (MySettings.UseFelRush && FelRush.IsSpellUsable && CombatClass.InSpellRange(ObjectManager.Target, 0, 20 /*FelRush Range*/) &&
                //Keep Recharging
                (FelRush.GetSpellCharges == 2 ||
                 //Generate Fury
                 (FelMastery.HaveBuff && (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 30) ||
                 //Trigger Momentum
                 (Momentum.HaveBuff && !MomentumBuff.HaveBuff)))
            {
                FelRush.Cast();
                return;
            }
            if (MySettings.UseVengefulRetreat && VengefulRetreat.IsSpellUsable && CombatClass.InSpellRange(ObjectManager.Target, 0, 20 /*Vengeful Retreat Range*/) &&
                //Generate Fury
                ((Prepared.HaveBuff && (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 20) ||
                 //Trigger Momentum
                 (Momentum.HaveBuff && !MomentumBuff.HaveBuff)))
            {
                VengefulRetreat.Cast();
                return;
            }
            //Single Target
            if (ObjectManager.GetUnitInSpellRange(5f) == 1)
            {
                if (MySettings.UseNemesis && Nemesis.IsSpellUsable && Nemesis.IsHostileDistanceGood)
                {
                    Nemesis.Cast();
                    return;
                }
                if (Demonic.HaveBuff && MySettings.UseEyeBeam && EyeBeam.IsSpellUsable && EyeBeam.IsHostileDistanceGood)
                {
                    EyeBeam.Cast();
                    return;
                }
                if (MySettings.UseFelEruption && FelEruption.IsSpellUsable && FelEruption.IsHostileDistanceGood)
                {
                    FelEruption.Cast();
                    return;
                }
                if (MySettings.UseFuryoftheIllidari && FuryoftheIllidari.IsSpellUsable && FuryoftheIllidari.IsHostileDistanceGood &&
                    //Only with Momentum
                    (!Momentum.HaveBuff || MomentumBuff.HaveBuff))
                {
                    FuryoftheIllidari.Cast();
                    return;
                }
                if (FirstBlood.HaveBuff && (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    if (MySettings.UseBladeDance && BladeDance.IsSpellUsable && BladeDance.IsHostileDistanceGood)
                    {
                        BladeDance.Cast();
                        return;
                    }
                    if (MySettings.UseDeathSweep && DeathSweep.IsSpellUsable && DeathSweep.IsHostileDistanceGood)
                    {
                        DeathSweep.Cast();
                        return;
                    }
                }
                if (MySettings.UseFelblade && Felblade.IsSpellUsable && Felblade.IsHostileDistanceGood &&
                    //Generate Fury
                    (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 30)
                {
                    Felblade.Cast();
                    return;
                }
                if (Bloodlet.HaveBuff && MySettings.UseThrowGlaive && ThrowGlaive.IsSpellUsable && ThrowGlaive.IsHostileDistanceGood &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    ThrowGlaive.Cast();
                    return;
                }
                if (MySettings.UseFelBarrage && FelBarrage.IsSpellUsable && FelBarrage.IsHostileDistanceGood &&
                    //Keep Recharging
                    FelBarrage.GetSpellCharges == 5 &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    FelBarrage.Cast();
                    return;
                }
                if (MySettings.UseAnnihilation && Annihilation.IsSpellUsable && Annihilation.IsHostileDistanceGood &&
                    //Generate Fury
                    (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 30)
                {
                    Annihilation.Cast();
                    return;
                }
                if (AnguishoftheDeceiver.HaveBuff && MySettings.UseEyeBeam && EyeBeam.IsSpellUsable && EyeBeam.IsHostileDistanceGood)
                {
                    EyeBeam.Cast();
                    return;
                }
                if (MySettings.UseChaosStrike && ChaosStrike.IsSpellUsable && ChaosStrike.IsHostileDistanceGood &&
                    //Generate Fury
                    (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 30)
                {
                    ChaosStrike.Cast();
                    return;
                }
                if (MySettings.UseFelBarrage && FelBarrage.IsSpellUsable && FelBarrage.IsHostileDistanceGood &&
                    //Keep Recharging
                    FelBarrage.GetSpellCharges >= 4 &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    FelBarrage.Cast();
                    return;
                }
                if (!DemonBlades.HaveBuff && MySettings.UseDemonsBite && DemonsBite.IsSpellUsable && DemonsBite.IsHostileDistanceGood)
                {
                    DemonsBite.Cast();
                    return;
                }
                if (MySettings.UseFelRush && FelRush.IsSpellUsable && CombatClass.InSpellRange(ObjectManager.Target, 6, 20 /*FelRush Range*/))
                {
                    FelRush.Cast();
                    return;
                }
                if (MySettings.UseThrowGlaive && ThrowGlaive.IsSpellUsable && (!CombatClass.InMeleeRange(ObjectManager.Target) ||
                                                                               DemonBlades.HaveBuff))
                {
                    ThrowGlaive.Cast();
                    return;
                }
            }
            //Multiple Target
            else
            {
                if (MySettings.UseFuryoftheIllidari && FuryoftheIllidari.IsSpellUsable && FuryoftheIllidari.IsHostileDistanceGood &&
                    //Only with Momentum
                    (!Momentum.HaveBuff || MomentumBuff.HaveBuff))
                {
                    FuryoftheIllidari.Cast();
                    return;
                }
                if (MySettings.UseFelBarrage && FelBarrage.IsSpellUsable && FelBarrage.IsHostileDistanceGood &&
                    //Keep Recharging
                    FelBarrage.GetSpellCharges >= 4 &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    FelBarrage.Cast();
                    return;
                }
                if (MySettings.UseEyeBeam && EyeBeam.IsSpellUsable && EyeBeam.IsHostileDistanceGood &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    EyeBeam.Cast();
                    return;
                }
                if (FirstBlood.HaveBuff && ObjectManager.GetUnitInSpellRange(5f) > 2 &&
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    if (MySettings.UseBladeDance && BladeDance.IsSpellUsable && BladeDance.IsHostileDistanceGood)
                    {
                        BladeDance.Cast();
                        return;
                    }
                    if (MySettings.UseDeathSweep && DeathSweep.IsSpellUsable && DeathSweep.IsHostileDistanceGood)
                    {
                        DeathSweep.Cast();
                        return;
                    }
                }
                if (Bloodlet.HaveBuff && MySettings.UseThrowGlaive && ThrowGlaive.IsSpellUsable && ThrowGlaive.IsHostileDistanceGood &&
                    //Only with Momentum
                    (!MomentumBuff.HaveBuff || MomentumBuff.HaveBuff))
                {
                    ThrowGlaive.Cast();
                    return;
                }
                if (MySettings.UseChaosStrike && ChaosStrike.IsSpellUsable &&
                    ChaosCleave.HaveBuff && ObjectManager.GetUnitInSpellRange(ChaosStrike.MaxRangeHostile) <= 3)
                {
                    ChaosStrike.Cast();
                    return;
                }
                if (MySettings.UseThrowGlaive && ThrowGlaive.IsSpellUsable && ThrowGlaive.IsHostileDistanceGood)
                {
                    ThrowGlaive.Cast();
                    return;
                }
                if (MySettings.UseChaosStrike && ChaosStrike.IsSpellUsable && ChaosStrike.IsHostileDistanceGood &&
                    //Generate Fury
                    (!DemonBlades.HaveBuff || (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 40) &&
                    (ObjectManager.Me.MaxFury - ObjectManager.Me.Fury) < 30)
                {
                    ChaosStrike.Cast();
                    return;
                }
                if (!DemonBlades.HaveBuff && MySettings.UseDemonsBite && DemonsBite.IsSpellUsable && DemonsBite.IsHostileDistanceGood)
                {
                    DemonsBite.Cast();
                    return;
                }
                if (MySettings.UseInfernalStrike && InfernalStrike.IsSpellUsable && InfernalStrike.IsHostileDistanceGood)
                {
                    InfernalStrike.CastAtPosition(ObjectManager.Target.Position);
                    return;
                }
            }
        }
        finally
        {
            Memory.WowMemory.GameFrameUnLock();
        }
    }
예제 #2
0
        public static void Pulse(IEnumerable <WoWUnit> woWUnits)
        {
            try
            {
                woWUnits = woWUnits.OrderBy(x => x.GetDistance);
                foreach (WoWUnit wowUnit in woWUnits)
                {
                    try
                    {
                        if (Products.Products.IsStarted)
                        {
                            if (nManagerSetting.IsBlackListed(wowUnit.Guid))
                            {
                                continue;
                            }

                            MovementManager.StopMove();
                            MovementManager.StopMove();
                            Thread.Sleep(250 + Usefuls.Latency);
                            while (ObjectManager.ObjectManager.Me.IsCast)
                            {
                                Thread.Sleep(200);
                            }

                            if (!wowUnit.IsValid)
                            {
                                continue;
                            }

                            bool looted = false;
                            if (wowUnit.IsLootable)
                            {
                                Logging.Write("Loot " + wowUnit.Name);
                            }
                            else if (wowUnit.IsSkinnable && nManagerSetting.CurrentSetting.ActivateBeastSkinning)
                            {
                                Logging.Write("Skin " + wowUnit.Name);
                            }
                            else
                            {
                                continue;
                            }
                            FarmingTask.CurUnit = wowUnit;

                            // We have no item to loot at range, then go to mob
                            if (!CombatClass.InMeleeRange(wowUnit) && (!nManagerSetting.CurrentSetting.UseLootARange || LootARangeId == 0 ||
                                                                       ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) > 40f || !ItemsManager.IsItemUsable(LootARangeId)))
                            {
                                bool         success;
                                List <Point> points = PathFinder.FindPath(wowUnit.Position, out success);
                                if (points.Count <= 0)
                                {
                                    points.Add(ObjectManager.ObjectManager.Me.Position);
                                    points.Add(wowUnit.Position);
                                }
                                if (!success)
                                {
                                    if ((points.Count == 2 && wowUnit.GetDistance > 6) || points.Count != 2)
                                    {
                                        // we didn't find a valid path and the target is not that close, blacklisting.
                                        // Straightline wont help anyway.
                                        Logging.Write("No path to " + wowUnit.Name + ", blacklisting.");
                                        nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                                    }
                                }
                                MovementManager.Go(points);
                                Timer timer = new Timer((int)(Math.DistanceListPoint(points) / 3 * 1000) + 3000);
                                while (!ObjectManager.ObjectManager.Me.IsDeadMe && wowUnit.IsValid &&
                                       Products.Products.IsStarted &&
                                       ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0 &&
                                       !(ObjectManager.ObjectManager.Me.InCombat &&
                                         !(ObjectManager.ObjectManager.Me.IsMounted &&
                                           (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))) &&
                                       !timer.IsReady)
                                {
                                    if (ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) <= 4.0f)
                                    {
                                        MovementManager.StopMove();
                                        MovementManager.StopMove();
                                        MountTask.DismountMount();
                                        Thread.Sleep(250);
                                        while (ObjectManager.ObjectManager.Me.GetMove)
                                        {
                                            Thread.Sleep(50);
                                        }
                                        break;
                                    }
                                }
                            }
                            // Now loot
                            if (wowUnit.IsLootable)
                            {
                                // Code for 109167 Findle's Loot-A-Range and 60854 Loot-A-Rang
                                if (nManagerSetting.CurrentSetting.UseLootARange && !CombatClass.InMeleeRange(wowUnit) &&
                                    ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) <= 40f && LootARangeId != 0 &&
                                    ItemsManager.IsItemUsable(LootARangeId))
                                {
                                    // Since these items have a CD of only 3 sec, it's worth waiting for the CD to recover
                                    while (ItemsManager.IsItemOnCooldown(LootARangeId))
                                    {
                                        Thread.Sleep(250);
                                    }
                                    FarmingTask.CountThisLoot = true;
                                    FarmingTask.NodeOrUnit    = false;
                                    ItemsManager.UseToy(LootARangeId);
                                    Thread.Sleep(1000 + Usefuls.Latency);
                                    while (ObjectManager.ObjectManager.Me.IsCast)
                                    {
                                        if (ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying)))
                                        {
                                            return;
                                        }
                                        Thread.Sleep(150);
                                    }
                                }
                                else
                                {
                                    FarmingTask.CountThisLoot = true;
                                    FarmingTask.NodeOrUnit    = false;
                                    Interact.InteractWith(wowUnit.GetBaseAddress);
                                    if ((ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))))
                                    {
                                        return;
                                    }
                                    Thread.Sleep(500 + Usefuls.Latency);
                                }
                                if (nManagerSetting.CurrentSetting.ActivateBeastSkinning &&
                                    ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0)
                                {
                                    return;
                                }
                                Statistics.Loots++;

                                if (nManagerSetting.CurrentSetting.ActivateBeastSkinning)
                                {
                                    Thread.Sleep(475 + Usefuls.Latency); // let the client react to unit flag change
                                    looted = true;
                                }
                                else
                                {
                                    WoWUnit unit = wowUnit;
                                    // we blacklist all unit around for a short time to be sure we loot then
                                    foreach (WoWUnit u in woWUnits.Where(u => u != unit).Where(u => u.Position.DistanceTo2D(unit.Position) <= 25f))
                                    {
                                        nManagerSetting.AddBlackList(u.Guid, 475 + Usefuls.Latency);
                                    }
                                    nManagerSetting.AddBlackList(wowUnit.Guid, 475 + Usefuls.Latency);
                                    return;
                                }
                            }
                            if ((looted || !wowUnit.IsLootable) && !wowUnit.IsSkinnable)
                            {
                                continue;
                            }
                            // From here we are sure the unit is skinnable
                            // if this is the unit we just looted, we need to redo check for extra loot
                            // if this is NOT the unit we just looted, then the check is already done at list building time
                            if (nManagerSetting.CurrentSetting.ActivateBeastSkinning &&
                                ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0)
                            {
                                if ((looted || !wowUnit.IsLootable))
                                {
                                    if (wowUnit.ExtraLootType.HasFlag(TypeFlag.HERB_LOOT) || wowUnit.Entry == 112052 || wowUnit.Entry == 113646)
                                    {
                                        int myHerbalismLevel = Skill.GetValue(SkillLine.Herbalism);
                                        if (myHerbalismLevel <= 0)
                                        {
                                            nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                                            continue;
                                        }
                                    }
                                    else if (wowUnit.ExtraLootType.HasFlag(TypeFlag.MINING_LOOT) || wowUnit.Entry == 104895 || wowUnit.Entry == 104877)
                                    {
                                        int myMiningLevel = Skill.GetValue(SkillLine.Mining);
                                        if (myMiningLevel <= 0)
                                        {
                                            nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                                            continue;
                                        }
                                    }
                                    else if (wowUnit.ExtraLootType.HasFlag(TypeFlag.ENGENEERING_LOOT))
                                    {
                                        int myEngineeringLevel = Skill.GetValue(SkillLine.Engineering);
                                        if (myEngineeringLevel <= 0)
                                        {
                                            nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        int mySkinningLevel = Skill.GetValue(SkillLine.Skinning);
                                        if (mySkinningLevel <= 0)
                                        {
                                            nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                                            continue;
                                        }
                                    }
                                }
                                // If we looted at range, we must go to creature to skin it
                                if (!CombatClass.InMeleeRange(wowUnit))
                                {
                                    List <Point> points = PathFinder.FindPath(wowUnit.Position);
                                    if (points.Count <= 0)
                                    {
                                        points.Add(ObjectManager.ObjectManager.Me.Position);
                                        points.Add(wowUnit.Position);
                                    }
                                    MovementManager.Go(points);
                                    Timer timer = new Timer((int)(Math.DistanceListPoint(points) / 3 * 1000) + 3000);
                                    while (!ObjectManager.ObjectManager.Me.IsDeadMe && wowUnit.IsValid &&
                                           Products.Products.IsStarted &&
                                           ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0 &&
                                           !(ObjectManager.ObjectManager.Me.InCombat &&
                                             !(ObjectManager.ObjectManager.Me.IsMounted &&
                                               (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))) &&
                                           !timer.IsReady)
                                    {
                                        if (CombatClass.InMeleeRange(wowUnit))
                                        {
                                            MovementManager.StopMove();
                                            MovementManager.StopMove();
                                            MountTask.DismountMount();
                                            Thread.Sleep(250);
                                            while (ObjectManager.ObjectManager.Me.GetMove)
                                            {
                                                Thread.Sleep(50);
                                            }
                                            break;
                                        }
                                    }
                                }
                                Logging.Write("Skin " + wowUnit.Name);
                                Interact.InteractWith(wowUnit.GetBaseAddress);
                                Thread.Sleep(200 + Usefuls.Latency);
                                while (ObjectManager.ObjectManager.Me.IsCast)
                                {
                                    Thread.Sleep(100);
                                }
                                if ((ObjectManager.ObjectManager.Me.InCombat &&
                                     !(ObjectManager.ObjectManager.Me.IsMounted &&
                                       (nManagerSetting.CurrentSetting.IgnoreFightIfMounted ||
                                        Usefuls.IsFlying))))
                                {
                                    return;
                                }
                                Thread.Sleep(400 + Usefuls.Latency);
                                if (nManagerSetting.CurrentSetting.ActivateBeastSkinning &&
                                    ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0)
                                {
                                    return;
                                }
                                Statistics.Farms++;
                                nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5);
                            }
                        }
                        MovementManager.StopMove();
                        MovementManager.StopMove();
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteError("LootingTask > Pulse(IEnumerable<WoWUnit> woWUnits): " + ex);
            }
        }