Ejemplo n.º 1
0
 /// <summary>
 ///  Creates a behavior to cast a pet action by name of the pet spell on specified location, if extra conditions are met
 ///  (like Freeze of Water Elemental)
 /// </summary>
 /// <param name="action"> The name of the pet spell that will be casted. </param>
 /// <param name="location"> The point to click. </param>
 /// <param name="extra"> Extra conditions that will be checked. </param>
 /// <returns></returns>
 public static Composite CreateCastPetActionOnLocation(string action, LocationRetriever location, SimpleBooleanDelegate extra)
 {
     return(new Decorator(
                ret => extra(ret) && PetManager.CanCastPetAction(action),
                new Sequence(
                    new Action(ret => PetManager.CastPetAction(action)),
                    new ActionSleep(250),
                    new Action(ret => LegacySpellManager.ClickRemoteLocation(location(ret))))));
 }
Ejemplo n.º 2
0
 /// <summary>
 ///  Creates a behavior to cast a pet action by name of the pet spell on specified location, if extra conditions are met
 ///  (like Freeze of Water Elemental)
 /// </summary>
 /// <param name="action"> The name of the pet spell that will be casted. </param>
 /// <param name="location"> The point to click. </param>
 /// <param name="extra"> Extra conditions that will be checked. </param>
 /// <returns></returns>
 public static Composite CreateCastPetActionOnLocation(string action, LocationRetriever location, SimpleBooleanDelegate extra)
 {
     return(new Decorator(
                ret => extra(ret) && PetManager.CanCastPetAction(action),
                new Sequence(
                    new Action(ret => PetManager.CastPetAction(action)),
                    new WaitContinue(System.TimeSpan.FromMilliseconds(250), ret => false, new ActionAlwaysSucceed()),
                    new Action(ret => SpellManager.ClickRemoteLocation(location(ret))))));
 }
Ejemplo n.º 3
0
        /// <summary>
        ///  Creates a behavior to cast a pet action by name of the pet spell on specified location, if extra conditions are met
        ///  (like Freeze of Water Elemental)
        /// </summary>
        /// <param name="action"> The name of the pet spell that will be casted. </param>
        /// <param name="location"> The point to click. </param>
        /// <param name="extra"> Extra conditions that will be checked. </param>
        /// <returns></returns>
        public static Composite CastPetActionOnLocation(string action, SimpleLocationRetriever location, SimpleBooleanDelegate extra)
        {
            return(new Decorator(
                       ret => StyxWoW.Me.GotAlivePet && extra(ret) && PetManager.CanCastPetAction(action),
                       new Sequence(
                           new Action(ret => PetManager.CastPetAction(action)),

                           new WaitContinue(TimeSpan.FromMilliseconds(500),
                                            ret => Spell.GetPendingCursorSpell != null, // && Spell.GetPendingOnCursor().Name == spell,
                                            new ActionAlwaysSucceed()
                                            ),

                           new Action(ret => SpellManager.ClickRemoteLocation(location(ret))),

                           // check for we are done via either success (no spell on cursor) or failure (cursor remains targeting)
                           new PrioritySelector(

                               // wait and if cursor clears, then Success!!!!
                               new Wait(TimeSpan.FromMilliseconds(500),
                                        ret => Spell.GetPendingCursorSpell == null,
                                        new ActionAlwaysSucceed()
                                        ),

                               // otherwise cancel spell and fail ----
                               new Action(ret =>
            {
                Logger.Write("pet:/cancel {0} - click {1} failed?  distance={2:F1} yds, loss={3}, face={4}",
                             action,
                             location(ret),
                             StyxWoW.Me.Location.Distance(location(ret)),
                             GameWorld.IsInLineOfSpellSight(StyxWoW.Me.Pet.GetTraceLinePos(), location(ret)),
                             StyxWoW.Me.Pet.IsSafelyFacing(location(ret))
                             );
                Lua.DoString("SpellStopTargeting()");
                return RunStatus.Failure;
            })
                               )
                           )
                       ));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///  Creates a behavior to start auto attacking to current target.
        /// </summary>
        /// <remarks>
        ///  Created 23/05/2011
        /// </remarks>
        /// <param name="includePet"> This will also toggle pet auto attack. </param>
        /// <returns></returns>
        public static Composite CreateAutoAttack(bool includePet)
        {
            const int spellIdAutoShot = 75;

            return(new PrioritySelector(
                       new Decorator(
                           ret => !StyxWoW.Me.IsAutoAttacking && StyxWoW.Me.AutoRepeatingSpellId != spellIdAutoShot,
                           new Action(ret =>
            {
                Lua.DoString("StartAttack()");
                return RunStatus.Failure;
            })),
                       new Decorator(
                           ret => includePet && StyxWoW.Me.GotAlivePet && (StyxWoW.Me.Pet.CurrentTarget == null || StyxWoW.Me.Pet.CurrentTarget != StyxWoW.Me.CurrentTarget),
                           new Action(
                               delegate
            {
                PetManager.CastPetAction("Attack");
                return RunStatus.Failure;
            }))
                       ));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///  Creates a behavior to start auto attacking to current target.
        /// </summary>
        /// <remarks>
        ///  Created 23/05/2011
        /// </remarks>
        /// <param name="includePet"> This will also toggle pet auto attack. </param>
        /// <returns></returns>
        public static Composite CreateAutoAttack(bool includePet)
        {
            var prio = new PrioritySelector();

            var autoAttack = Me.Class == WoWClass.DeathKnight ||
                             (Me.Class == WoWClass.Druid && Me.Specialization != WoWSpec.DruidRestoration) ||
                             Me.Class == WoWClass.Monk ||
                             (Me.Class == WoWClass.Paladin && Me.Specialization != WoWSpec.PaladinHoly) ||
                             Me.Class == WoWClass.Rogue ||
                             (Me.Class == WoWClass.Shaman && Me.Specialization != WoWSpec.ShamanRestoration) ||
                             Me.Class == WoWClass.Warrior;

            if (autoAttack)
            {
                prio.AddChild(
                    new Throttle(TimeSpan.FromMilliseconds(500),
                                 new Decorator(
                                     ret => !StyxWoW.Me.IsAutoAttacking,
                                     new Action(ret =>
                {
                    Lua.DoString("StartAttack()");
                    return(RunStatus.Failure);
                })
                                     )
                                 )
                    );
            }

            if (includePet)
            {
                // pet assist: always keep pet on my target
                prio.AddChild(
                    new ThrottlePasses(TimeSpan.FromMilliseconds(500),
                                       new Decorator(
                                           // check pet targeting same target as Me
                                           ret => Me.GotAlivePet && (!Me.Pet.GotTarget || Me.Pet.CurrentTargetGuid != Me.CurrentTargetGuid),
                                           new Action(delegate
                {
                    PetManager.CastPetAction("Attack", Me.CurrentTarget);
                    return(RunStatus.Failure);
                })
                                           )
                                       )
                    );
            }

            if (includePet)
            {
                // pet tank: if pet's target isn't targeting Me, check if we should switch to one that is targeting Me
                prio.AddChild(
                    new ThrottlePasses(TimeSpan.FromMilliseconds(500),
                                       new Decorator(
                                           ret => Me.GotAlivePet && (!Me.Pet.GotTarget || Me.Pet.CurrentTarget.CurrentTargetGuid != Me.Guid),
                                           new PrioritySelector(
                                               ctx => Unit.NearbyUnfriendlyUnits.FirstOrDefault(u => u.Combat && u.GotTarget && u.CurrentTarget.IsMe) ?? Me.CurrentTarget,
                                               new Decorator(
                                                   ret => ret != null && Me.Pet.CurrentTargetGuid != ((WoWUnit)ret).Guid,
                                                   new Action(r =>
                {
                    PetManager.CastPetAction("Attack", (WoWUnit)r);
                    return(RunStatus.Failure);
                })
                                                   )
                                               )
                                           )
                                       )
                    );
            }

            return(prio);
        }
Ejemplo n.º 6
0
 /// <summary>
 ///  Creates a behavior to cast a pet action by name of the pet spell on the specified unit, if the extra conditions are met.
 /// </summary>
 /// <param name="action"> The name of the pet spell that will be casted. </param>
 /// <param name="onUnit"> The unit to cast the spell on. </param>
 /// <param name="extra"> Extra conditions that will be checked. </param>
 /// <returns></returns>
 public static Composite CreateCastPetActionOn(string action, UnitSelectionDelegate onUnit, SimpleBooleanDelegate extra)
 {
     return(new Decorator(
                ret => extra(ret) && PetManager.CanCastPetAction(action),
                new Action(ret => PetManager.CastPetAction(action, onUnit(ret)))));
 }