Esempio n. 1
0
 /// <summary>
 /// Unequivocally engages mob in combat.
 /// </summary>
 /// <remarks>24Feb2013-08:11UTC chinajade</remarks>
 public Composite UtilityBehaviorPS_SpankMob(ProvideWoWUnitDelegate selectedTargetDelegate)
 {
     return(new PrioritySelector(
                new Action(context =>
     {
         _ubpsSpankMob_Mob = selectedTargetDelegate(context);
         return RunStatus.Failure;       // fall through
     }),
                new Decorator(context => IsViableForFighting(_ubpsSpankMob_Mob),
                              new PrioritySelector(
                                  new Decorator(context => _ubpsSpankMob_Mob.Distance > CharacterSettings.Instance.PullDistance,
                                                UtilityBehaviorPS_MoveTo(context => _ubpsSpankMob_Mob.Location,
                                                                         context => _ubpsSpankMob_Mob.Name)),
                                  new Decorator(context => Me.CurrentTarget != _ubpsSpankMob_Mob,
                                                new Action(context =>
     {
         BotPoi.Current = new BotPoi(_ubpsSpankMob_Mob, PoiType.Kill);
         _ubpsSpankMob_Mob.Target();
         if (Me.Mounted)
         {
             Mount.Dismount();
         }
     })),
                                  new Decorator(context => !_ubpsSpankMob_Mob.IsTargetingMeOrPet,
                                                new PrioritySelector(
                                                    new Decorator(context => RoutineManager.Current.CombatBehavior != null,
                                                                  RoutineManager.Current.CombatBehavior),
                                                    new Action(context => { RoutineManager.Current.Combat(); })
                                                    ))
                                  ))));
 }
Esempio n. 2
0
        /// <summary>
        /// <para>Sends the user's pet to attack the target identified by WOWUNITDELEGATE.</para>
        /// <para>Notes:<list type="bullet">
        /// <item><description><para>* This behavior performs all appropriate checks: pet exists and is alive, target is viable and not friendly, etc.</para></description></item>
        /// <item><description><para>* The 'attack' command will continue to be issued until the pet obeys (by targeting the mob).</para></description></item>
        /// <item><description><para>* The pet's "Attack" command must be hot-barred!  Existence in the spellbook
        /// is insufficient.  This is a limitation of the WoWclient and HB APIs.</para></description></item>
        /// <item><description><para>* The returned Composite is suitable for use in a behavior tree (Priority)Selector container
        /// (i.e., placing it in a Sequence container will not yield the desired results).</para></description></item>
        /// </list></para>
        /// </summary>
        /// <param name="wowUnitDelegate">may not be null</param>
        /// <returns>a behavior tree Composite suitable for use in a (Priority)Selector container</returns>
        public Composite UtilityBehaviorPS_PetActionAttack(ProvideWoWUnitDelegate wowUnitDelegate)
        {
            ContractRequires(wowUnitDelegate != null, context => "wowUnitDelegate may not be null");

            string spellName = "Attack";

            // NB: We can't issue "Attack" directive while mounted, so don't try...
            return(new Decorator(context => Me.GotAlivePet &&
                                 !Me.Mounted &&
                                 IsViableForFighting(wowUnitDelegate(context)) &&
                                 (Me.Pet.CurrentTarget != wowUnitDelegate(context)) &&
                                 CanCastPetAction(spellName),
                                 new Action(context => CastPetAction(spellName, wowUnitDelegate(context)))));
        }
Esempio n. 3
0
        /// <summary>
        /// Simple right-click interaction with the UNITTOINTERACT.
        /// </summary>
        /// <param name="unitToInteract"></param>
        /// <returns></returns>
        // TODO: Convert this to take a WoWObject instead of a WoWUnit
        // 24Feb2013-08:11UTC chinajade
        public Composite UtilityBehaviorPS_InteractWithMob(ProvideWoWUnitDelegate unitToInteract)
        {
            return(new PrioritySelector(
                       new Action(context =>
            {
                _ubpsInteractWithMob_Mob = unitToInteract(context);
                return RunStatus.Failure;       // fall through
            }),
                       new Decorator(context => IsViableForInteracting(_ubpsInteractWithMob_Mob),
                                     new PrioritySelector(
                                         // Show user which unit we're going after...
                                         new Decorator(context => Me.CurrentTarget != _ubpsInteractWithMob_Mob,
                                                       new Action(context => { _ubpsInteractWithMob_Mob.Target(); })),

                                         // If not within interact range, move closer...
                                         new Decorator(context => !_ubpsInteractWithMob_Mob.WithinInteractRange,
                                                       new Sequence(
                                                           new Action(context =>
            {
                LogDeveloperInfo("Moving to interact with {0}", _ubpsInteractWithMob_Mob.Name);
            }),
                                                           UtilityBehaviorPS_MoveTo(interactUnitContext => _ubpsInteractWithMob_Mob.Location,
                                                                                    interactUnitContext => _ubpsInteractWithMob_Mob.Name)
                                                           )),

                                         new Decorator(context => Me.IsMoving,
                                                       new Action(context => { WoWMovement.MoveStop(); })),
                                         new Decorator(context => !Me.IsFacing(_ubpsInteractWithMob_Mob),
                                                       new Action(context => { Me.SetFacing(_ubpsInteractWithMob_Mob); })),

                                         // Blindly interact...
                                         // Ideally, we would blacklist the unit if the interact failed.  However, the HB API
                                         // provides no CanInteract() method (or equivalent) to make this determination.
                                         new Action(context =>
            {
                LogDeveloperInfo("Interacting with {0}", _ubpsInteractWithMob_Mob.Name);
                _ubpsInteractWithMob_Mob.Interact();
                return RunStatus.Failure;
            }),
                                         new Wait(TimeSpan.FromMilliseconds(1000), context => false, new ActionAlwaysSucceed())
                                         ))));
        }
Esempio n. 4
0
 /// <summary>
 /// This behavior quits attacking the mob, once the mob is targeting us.
 /// </summary>
 // 24Feb2013-08:11UTC chinajade
 public Composite UtilityBehaviorPS_GetMobsAttention(ProvideWoWUnitDelegate selectedTargetDelegate)
 {
     return(new PrioritySelector(
                new Action(context =>
     {
         _ubpsGetMobsAttention_Mob = selectedTargetDelegate(context);
         return RunStatus.Failure;     // fall through
     }),
                new Decorator(context => IsViableForFighting(_ubpsGetMobsAttention_Mob),
                              new PrioritySelector(
                                  new Decorator(context => !_ubpsGetMobsAttention_Mob.IsTargetingMeOrPet,
                                                new PrioritySelector(
                                                    new Action(context =>
     {
         LogInfo("Getting attention of {0}", _ubpsGetMobsAttention_Mob.Name);
         return RunStatus.Failure;
     }),
                                                    UtilityBehaviorPS_SpankMob(selectedTargetDelegate)))
                                  ))));
 }
Esempio n. 5
0
        /// <summary>
        /// <para>Sends the user's pet to attack the target identified by WOWUNITDELEGATE.</para>
        /// <para>Notes:<list type="bullet">
        /// <item><description><para>* This behavior performs all appropriate checks: pet exists and is alive, target is viable and not friendly, etc.</para></description></item>
        /// <item><description><para>* The 'attack' command will continue to be issued until the pet obeys (by targeting the mob).</para></description></item>
        /// <item><description><para>* The pet's "Attack" command must be hot-barred!  Existence in the spellbook
        /// is insufficient.  This is a limitation of the WoWclient and HB APIs.</para></description></item>
        /// <item><description><para>* The returned Composite is suitable for use in a behavior tree (Priority)Selector container
        /// (i.e., placing it in a Sequence container will not yield the desired results).</para></description></item>
        /// </list></para>
        /// </summary>
        /// <param name="wowUnitDelegate">may not be null</param>
        /// <returns>a behavior tree Composite suitable for use in a (Priority)Selector container</returns>
        public Composite UtilityBehaviorPS_PetActionAttack(ProvideWoWUnitDelegate wowUnitDelegate)
        {
            ContractRequires(wowUnitDelegate != null, context => "wowUnitDelegate may not be null");

            string spellName = "Attack";

            // NB: We can't issue "Attack" directive while mounted, so don't try...
            return new Decorator(context => Me.GotAlivePet
                                            && !Me.Mounted
                                            && IsViableForFighting(wowUnitDelegate(context))
                                            && (Me.Pet.CurrentTarget != wowUnitDelegate(context))
                                            && CanCastPetAction(spellName),
                new Action(context => CastPetAction(spellName, wowUnitDelegate(context))));
        }
Esempio n. 6
0
 /// <summary>
 /// Unequivocally engages mob in combat.
 /// </summary>
 /// <remarks>24Feb2013-08:11UTC chinajade</remarks>
 public Composite UtilityBehaviorPS_SpankMob(ProvideWoWUnitDelegate selectedTargetDelegate)
 {
     return new PrioritySelector(
         new Action(context =>
         {
             _ubpsSpankMob_Mob = selectedTargetDelegate(context);
             return RunStatus.Failure;   // fall through     
         }),
         new Decorator(context => IsViableForFighting(_ubpsSpankMob_Mob),
             new PrioritySelector(               
                 new Decorator(context => _ubpsSpankMob_Mob.Distance > CharacterSettings.Instance.PullDistance,
                     UtilityBehaviorPS_MoveTo(context => _ubpsSpankMob_Mob.Location,
                                              context => _ubpsSpankMob_Mob.Name)),
                 new Decorator(context => Me.CurrentTarget != _ubpsSpankMob_Mob,
                     new Action(context =>
                     {
                         BotPoi.Current = new BotPoi(_ubpsSpankMob_Mob, PoiType.Kill);
                         _ubpsSpankMob_Mob.Target();
                         if (Me.Mounted)
                             { Mount.Dismount(); }
                     })),
                 new Decorator(context => !_ubpsSpankMob_Mob.IsTargetingMeOrPet,
                     new PrioritySelector(
                         new Decorator(context => RoutineManager.Current.CombatBehavior != null,
                             RoutineManager.Current.CombatBehavior),
                         new Action(context => { RoutineManager.Current.Combat(); })
                     ))
             )));
 }
Esempio n. 7
0
        /// <summary>
        /// Simple right-click interaction with the UNITTOINTERACT.
        /// </summary>
        /// <param name="unitToInteract"></param>
        /// <returns></returns>
        // TODO: Convert this to take a WoWObject instead of a WoWUnit
        // 24Feb2013-08:11UTC chinajade
        public Composite UtilityBehaviorPS_InteractWithMob(ProvideWoWUnitDelegate unitToInteract)
        {
            return new PrioritySelector(
                new Action(context =>
                { 
                    _ubpsInteractWithMob_Mob = unitToInteract(context);
                    return RunStatus.Failure;   // fall through
                }),
                new Decorator(context => IsViableForInteracting(_ubpsInteractWithMob_Mob),
                    new PrioritySelector(
                        // Show user which unit we're going after...
                        new Decorator(context => Me.CurrentTarget != _ubpsInteractWithMob_Mob,
                            new Action(context => { _ubpsInteractWithMob_Mob.Target(); })),

                        // If not within interact range, move closer...
                        new Decorator(context => !_ubpsInteractWithMob_Mob.WithinInteractRange,
                            new Sequence(
                                new Action(context =>
                                {
                                    LogDeveloperInfo("Moving to interact with {0}", _ubpsInteractWithMob_Mob.Name);
                                }),
                                UtilityBehaviorPS_MoveTo(interactUnitContext => _ubpsInteractWithMob_Mob.Location,
                                                         interactUnitContext => _ubpsInteractWithMob_Mob.Name)
                            )),

                        new Decorator(context => Me.IsMoving,
                            new Action(context => { WoWMovement.MoveStop(); })),
                        new Decorator(context => !Me.IsFacing(_ubpsInteractWithMob_Mob),
                            new Action(context => { Me.SetFacing(_ubpsInteractWithMob_Mob); })),

                        // Blindly interact...
                        // Ideally, we would blacklist the unit if the interact failed.  However, the HB API
                        // provides no CanInteract() method (or equivalent) to make this determination.
                        new Action(context =>
                        {
                            LogDeveloperInfo("Interacting with {0}", _ubpsInteractWithMob_Mob.Name);
                            _ubpsInteractWithMob_Mob.Interact();
                            return RunStatus.Failure;
                        }),
                        new Wait(TimeSpan.FromMilliseconds(1000), context => false, new ActionAlwaysSucceed())
                    )));
        }
Esempio n. 8
0
 /// <summary>
 /// This behavior quits attacking the mob, once the mob is targeting us.
 /// </summary>
 // 24Feb2013-08:11UTC chinajade
 public Composite UtilityBehaviorPS_GetMobsAttention(ProvideWoWUnitDelegate selectedTargetDelegate)
 {
     return new PrioritySelector(
         new Action(context =>
         {
             _ubpsGetMobsAttention_Mob = selectedTargetDelegate(context);
             return RunStatus.Failure; // fall through
         }),
         new Decorator(context => IsViableForFighting(_ubpsGetMobsAttention_Mob),
             new PrioritySelector(
                 new Decorator(context => !_ubpsGetMobsAttention_Mob.IsTargetingMeOrPet,
                     new PrioritySelector(
                         new Action(context =>
                         {
                             LogInfo("Getting attention of {0}", _ubpsGetMobsAttention_Mob.Name);
                             return RunStatus.Failure;
                         }),
                         UtilityBehaviorPS_SpankMob(selectedTargetDelegate)))
             )));
 }