Beispiel #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 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;
            })
                               )
                           )
                       ));
        }
Beispiel #2
0
        public static Composite CreateHunterTrapBehavior(string trapName, SimpleLocationRetriever locrtrv, SimpleBooleanDelegate require = null)
        {
            if (locrtrv == null || require == null)
                return new ActionAlwaysFail();

            return new PrioritySelector(
                new Decorator(
                    ret => require(ret)
                        && Me.Location.DistanceSqr(locrtrv(ret)) < (40 * 40)
                        && SpellManager.HasSpell(trapName) && Spell.GetSpellCooldown(trapName) == TimeSpan.Zero
                        && Me.HasAura("Trap Launcher"),
                    new Sequence(
                        ctx => locrtrv(ctx),
                        Spell.CastOnGround( trapName, locrtrv, require)
                        )
                    )
                );
        }
Beispiel #3
0
        // always create passing the existing context so it is preserved for delegate usage
        internal CogContext(object ctx, SpellFindDelegate ssd, SimpleLocationRetriever locrtrv, SimpleStringDelegate descrtrv)
        {

            if (ssd(ctx, out sfr))
            {
                spell = sfr.Override ?? sfr.Original;
                name = spell.Name;
                context = ctx;

                loc = WoWPoint.Empty;
                targetDesc = "";
                if (locrtrv != null)
                {
                    loc = locrtrv(ctx);
                    if (descrtrv != null)
                    {
                        targetDesc = descrtrv(ctx) + " ";
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        ///   Creates a behavior to cast a spell by name, on the ground at the specified location. Returns RunStatus.Success if successful, RunStatus.Failure otherwise.
        /// </summary>
        /// <remarks>
        ///   Created 5/2/2011.
        /// </remarks>
        /// <param name = "spell">The spell.</param>
        /// <param name = "onLocation">The on location.</param>
        /// <param name = "requirements">The requirements.</param>
        /// <param name="waitForSpell">Waits for spell to become active on cursor if true. </param>
        /// <returns>.</returns>
        public static Composite CastOnGround(string spellName, SimpleLocationRetriever onLocRtrv,
            SimpleBooleanDelegate requirements, bool waitForSpell = true, SimpleStringDelegate tgtDescRtrv = null)
        {
            if (spellName == null || onLocRtrv == null || requirements == null)
                return new ActionAlwaysFail();

            SpellFindDelegate ssd =
                (object ctx, out SpellFindResults sfr) =>
                {
                    if (!SpellManager.FindSpell(spellName, out sfr))
                    {
                        AddUndefinedSpell(spellName);
                        return false;
                    }
                    return true;
                };

            return new Decorator(
                req => requirements(req),
                new PrioritySelector(
                    ctx => new CogContext( ctx, ssd, onLocRtrv, tgtDescRtrv),
                    ContextCastOnGround(null, waitForSpell)
                    )
                );
        }
Beispiel #5
0
 /// <summary>
 ///   Creates a behavior to cast a spell by name, on the ground at the specified location. Returns
 ///   RunStatus.Success if successful, RunStatus.Failure otherwise.
 /// </summary>
 /// <remarks>
 ///   Created 5/2/2011.
 /// </remarks>
 /// <param name = "spell">The spell.</param>
 /// <param name = "onLocation">The on location.</param>
 /// <returns>.</returns>
 public static Composite CastOnGround(string spell, SimpleLocationRetriever onLocation)
 {
     return CastOnGround(spell, onLocation, ret => true);
 }
Beispiel #6
0
 /// <summary>
 ///  Creates a behavior to cast a pet action by name of the pet spell on specified location.  (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>
 /// <returns></returns>
 public static Composite CastPetActionOnLocation(string action, SimpleLocationRetriever location)
 {
     return(CastPetActionOnLocation(action, location, ret => true));
 }
Beispiel #7
0
 /// <summary>
 ///   Creates a move to location behavior. Will return RunStatus.Success if it has reached the location, or stopped in range. Best used at the end of a rotation.
 /// </summary>
 /// <remarks>
 ///   Created 5/1/2011.
 /// </remarks>
 /// <param name = "location">The location.</param>
 /// <param name = "stopInRange">true to stop in range.</param>
 /// <param name = "range">The range.</param>
 /// <returns>.</returns>
 public static Composite CreateMoveToLocationBehavior(SimpleLocationRetriever location, bool stopInRange, DynamicRangeRetriever range)
 {
     return new Decorator(
         ret => !MovementManager.IsMovementDisabled,
         new PrioritySelector(
             new Decorator(
                 req => stopInRange,
                 new PrioritySelector(
                     new Action( r => {
                         if (StopMoving.Type != StopMoving.StopType.RangeOfLocation || location(r) != StopMoving.Point || range(r) != StopMoving.Range )
                             StopMoving.InRangeOfLocation(location(r), range(r));
                         return RunStatus.Failure;
                     }),
                     new Decorator(
                         req => Me.Location.Distance(location(req)) < range(req),
                         CreateEnsureMovementStoppedBehavior()
                         )
                     )
                 ),
             new Decorator(
                 req => Me.Location.Distance(location(req)) > range(req),
                 new Action(r => {
                     string s = stopInRange ? string.Format("MoveInRangeOfLoc({0:F1} yds)", range(r)) : "MoveToLocation";
                     Logger.WriteDebug(Color.White, s + ": towards {0} @ {1:F1} yds", location(r),  range(r));
                     Navigator.MoveTo(location(r));
                 })
                 )
             )
         );
 }