Пример #1
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)
                        )
                    )
                );
        }
Пример #2
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) + " ";
                    }
                }
            }
        }
Пример #3
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);
 }
Пример #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)
                    )
                );
        }
Пример #5
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));
                 })
                 )
             )
         );
 }