private Composite SubBehavior_BombTarget(ProvideIntDelegate questObjectiveIndexDelegate,
                                                 ProvideIntDelegate mobIdDelegate)
        {
            Contract.Requires(questObjectiveIndexDelegate != null, context => "questObjectiveIndexDelegate != null");
            Contract.Requires(mobIdDelegate != null, context => "mobIdDelegate != null");

            return(new Decorator(context =>
            {
                var questObjectiveIndex = questObjectiveIndexDelegate(context);
                var mobId = mobIdDelegate(context);

                if (Me.IsQuestObjectiveComplete(QuestId, questObjectiveIndex))
                {
                    return false;
                }

                SelectedTarget = ObjectManager.ObjectList.FirstOrDefault(o => o.Entry == mobId);
                if (!Query.IsViable(SelectedTarget))
                {
                    return false;
                }

                return Me.Location.Distance(SelectedTarget.Location) <= _bombRange;
            },
                                 new Action(context =>
            {
                QBCLog.DeveloperInfo("Bombing {0}", SelectedTarget.SafeName);
                Bomb.Use();
                // NB: The "FanOutRandom()" simulates imperfect human aim.
                SpellManager.ClickRemoteLocation(SelectedTarget.Location.FanOutRandom(7.5));
            })));
        }
Example #2
0
        private Composite SubBehavior_BombTarget(ProvideIntDelegate questObjectiveIndexDelegate,
                                                 ProvideIntDelegate mobIdDelegate)
        {
            Contract.Requires(questObjectiveIndexDelegate != null, context => "questObjectiveIndexDelegate != null");
            Contract.Requires(mobIdDelegate != null, context => "mobIdDelegate != null");

            return(new Decorator(context =>
            {
                var questObjectiveIndex = questObjectiveIndexDelegate(context);
                var mobId = mobIdDelegate(context);

                if (Me.IsQuestObjectiveComplete(GetQuestId(), questObjectiveIndex))
                {
                    return false;
                }

                SelectedTarget =
                    (from wowObject in Query.FindMobsAndFactions(Utility.ToEnumerable((int)mobId))
                     let wowUnit = wowObject as WoWUnit
                                   where
                                   Query.IsViable(wowUnit) &&
                                   wowUnit.IsAlive
                                   orderby wowUnit.DistanceSqr
                                   select wowUnit)
                    .FirstOrDefault();

                if (!Query.IsViable(SelectedTarget))
                {
                    return false;
                }

                return Me.Location.Distance(SelectedTarget.Location) <= _bombRange;
            },
                                 new Action(context =>
            {
                QBCLog.DeveloperInfo("Bombing {0}", SelectedTarget.SafeName);
                Bomb.Use();
                SpellManager.ClickRemoteLocation(SelectedTarget.Location);
            })));
        }