Example #1
0
            /// <summary>
            /// Do we have a suitable unit to apply a crowd control spell to?
            /// </summary>
            /// <param name="crowdControlSpellName">Name of the spell to cast on the target</param>
            /// <param name="maximumDistance">Maximum distance of the target</param>
            /// <param name="creatureType">Type of creature to apply our CC spell to</param>
            /// <returns></returns>
            public static bool CanCrowdControlUnit(string crowdControlSpellName,double maximumDistance,WoWCreatureType creatureType)
            {
                WoWUnit wUnit = (from o in ObjectManager.ObjectList
                                 where o is WoWUnit
                                 let p = o.ToUnit()
                                 where
                                     p.Distance2D < maximumDistance && !p.Dead && p.IsTargetingMeOrPet &&
                                     p.CreatureType == creatureType && !p.Auras.ContainsKey(crowdControlSpellName) &&
                                     p.HealthPercent > 95 &&
                                     p.Attackable
                                 select p).FirstOrDefault();

                return wUnit != null;
            }
Example #2
0
            /// <summary>
            /// Do it! Apply our crowd control spell to the appropriate unit. 
            /// </summary>
            /// <param name="crowdControlSpellName"></param>
            /// <param name="maximumDistance"></param>
            /// <param name="creatureType"></param>
            public static void CrowdControlUnit(string crowdControlSpellName, double maximumDistance, WoWCreatureType creatureType)
            {
                WoWUnit ccUnit = (from o in ObjectManager.ObjectList
                                 where o is WoWUnit
                                 let p = o.ToUnit()
                                 where
                                     p.Distance2D < maximumDistance && !p.Dead && p.IsTargetingMeOrPet &&
                                     p.CreatureType == creatureType && !p.Auras.ContainsKey(crowdControlSpellName) &&
                                     p.HealthPercent > 95 &&
                                     p.Attackable
                                 select p).FirstOrDefault();

                if (ccUnit != null)
                {
                    // Cast the CC spell on the appropriate target
                    Spell.Cast(crowdControlSpellName, ccUnit);
                    Utils.LagSleep();
                    Utils.WaitWhileCasting();
                    while (Spell.IsGCD) Thread.Sleep(250);
                    ObjectManager.Update();

                    // Now retarget (if we need to) a mob without our CC spell
                    if (Me.CurrentTarget.Auras.ContainsKey(crowdControlSpellName))
                    {
                        ObjectManager.Update();
                        WoWUnit attackUnit = (from o in ObjectManager.ObjectList
                                              where o is WoWUnit
                                              let p = o.ToUnit()
                                              where
                                                  p.Distance2D < 40 && !p.Dead && p.IsTargetingMeOrPet &&
                                                  !p.Auras.ContainsKey(crowdControlSpellName) && p.Attackable
                                              orderby p.HealthPercent ascending
                                              select p).FirstOrDefault();
                        Debug.Assert(attackUnit != null, "attackUnit != null");
                        attackUnit.Target();
                        Thread.Sleep(1000);
                    }

                }
            }