Ejemplo n.º 1
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(

                                     new Decorator(ret => Counter >= NumOfTimes || (Existing && CurrentObject == null),
                                                   new Action(ret => _isBehaviorDone = true)),

                                     new PrioritySelector(
                                         new Decorator(ret => (CurrentObject != null && lastunit != CurrentObject.Guid) || timer.Elapsed.Seconds > 100,
                                                       new Sequence(
                                                           new Action(ret => timer.Reset()),
                                                           new Action(ret => timer.Start()),
                                                           new Action(ret => lastunit = CurrentObject.Guid)
                                                           )
                                                       ),
                                         new Decorator(ret => CurrentObject != null && (!Navigator.CanNavigateFully(Me.Location, CurrentObject.Location) || timer.Elapsed.Seconds > 90),
                                                       new Sequence(
                                                           new Action(ret => { TreeRoot.StatusText = "Can't navigate to " + CurrentObject.Name; }),
                                                           new Action(ret => _npcBlacklist.Add(CurrentObject.Guid))
                                                           )
                                                       ),
                                         new Decorator(ret => CurrentObject != null && CurrentObject.Location.DistanceSqr(Me.Location) > Range * Range,
                                                       new Sequence(
                                                           new Action(ret => { TreeRoot.StatusText = timer.Elapsed.Seconds + " Moving to interact with - " + CurrentObject.Name; }),
                                                           new Action(ret => Navigator.MoveTo(CurrentObject.Location))
                                                           )
                                                       ),

                                         new Decorator(ret => CurrentObject != null && CurrentObject.Location.DistanceSqr(Me.Location) <= Range * Range,
                                                       new Sequence(
                                                           new Action(ret =>
            {
                TreeRoot.StatusText = "Interacting with - " + CurrentObject.Name;
                WoWMovement.MoveStop();
                Thread.Sleep(100);
                CurrentObject.Interact();
                _npcBlacklist.Add(CurrentObject.Guid);

                Thread.Sleep(2000);
                Counter++;
            }),

                                                           new DecoratorContinue(
                                                               ret => GossipOptions.Length > 0,
                                                               new Action(ret =>
            {
                foreach (var gos in GossipOptions)
                {
                    GossipFrame.Instance.SelectGossipOption(gos);
                    Thread.Sleep(1000);
                }
            })),

                                                           new DecoratorContinue(
                                                               ret => Loot && LootFrame.Instance.IsVisible,
                                                               new Action(ret => LootFrame.Instance.LootAll())),

                                                           new DecoratorContinue(
                                                               ret => BuyItemId != 0 && MerchantFrame.Instance.IsVisible,
                                                               new Action(ret =>
            {
                var items = MerchantFrame.Instance.GetAllMerchantItems();
                var item = items.FirstOrDefault(i => i.ItemId == BuyItemId && (i.BuyPrice * (ulong)BuyItemCount) <= Me.Copper && (i.NumAvailable >= BuyItemCount || i.NumAvailable == -1));

                if (item != null)
                {
                    MerchantFrame.Instance.BuyItem(item.Index, BuyItemCount);
                    Thread.Sleep(1500);
                }
            })),

                                                           new DecoratorContinue(
                                                               ret => BuySlot != -1 && BuyItemId == 0 && MerchantFrame.Instance.IsVisible,
                                                               new Action(ret =>
            {
                var item = MerchantFrame.Instance.GetMerchantItemByIndex(BuySlot);
                if (item != null && (item.BuyPrice * (ulong)BuyItemCount) <= Me.Copper && (item.NumAvailable >= BuyItemCount || item.NumAvailable == -1))
                {
                    MerchantFrame.Instance.BuyItem(BuySlot, BuyItemCount);
                    Thread.Sleep(1500);
                }
            })),
                                                           new DecoratorContinue(
                                                               ret => Me.CurrentTarget != null && Me.CurrentTarget == CurrentObject,
                                                               new Action(ret => Me.ClearTarget())),

                                                           new Action(ret => Thread.Sleep(WaitTime))

                                                           )),
                                         new Decorator(ret => !Path.Any(),
                                                       new Action(delegate
            {
                ParsePath();
            })
                                                       ),
                                         new Decorator(ret => Path.Peek().Distance(Me.Location) <= 5,
                                                       new Action(delegate
            {
                Path.Dequeue();
            })
                                                       ),
                                         new Decorator(ret => Me.GetSkill(Styx.SkillLine.Riding).CurrentValue != 0 && canmount && !Me.Mounted && !Me.IsCasting && Path.Peek().Distance(Me.Location) > 100,
                                                       new Action(delegate
            {
                TreeRoot.StatusText = "Mounting";
                WoWMovement.MoveStop();
                Thread.Sleep(100);
                Styx.Logic.Mount.MountUp();
            })
                                                       ),
                                         new Decorator(
                                             ret => Path.Peek().Distance(Me.Location) > 5,
                                             new Sequence(
                                                 new Action(ret => { TreeRoot.StatusText = "Moving towards - " + Path.Peek(); }),
                                                 new Action(ret => Navigator.MoveTo(Path.Peek())))),

                                         new Decorator(
                                             ret => !WaitForNpcs && CurrentObject == null,
                                             new Action(ret => _isBehaviorDone = true)),

                                         new Action(ret => TreeRoot.StatusText = "Waiting for object to spawn")

                                         ))));
        }