Ejemplo n.º 1
0
            public static void Start(Func<Object,Task<bool>> task, Func<object,bool> stopCondition = null)
            {
                var isStarted = false;

                Worker.Start(() =>
                {                   
                    using (new MemoryHelper())
                    {
                        try
                        {
                            if (!isStarted)
                            {
                                Logger.Log("Starting new Bot Thread Id={0}", Thread.CurrentThread.ManagedThreadId);
                                _logic = new ActionRunCoroutine(task);
                                _logic.Start(null);
                                isStarted = true;
                            }
                            Tick();
                        }
                        catch (InvalidOperationException ex)
                        {                            
                            Logger.LogDebug("CheckInCoroutine() Derp {0}", ex);
                        }

                    }

                    if (stopCondition != null && stopCondition.Invoke(null))
                    {
                        Logger.Log("Bot Thread Finished Id={0}", Thread.CurrentThread.ManagedThreadId);
                        return true;
                    }
                        
                    return false;
                });
            }
Ejemplo n.º 2
0
	// 
	void UnitTest () {

		// 根節點
		IComponent theRoot = new Composite("Root");
		// 加入兩個最終節點
		theRoot.Add ( new Leaf("Leaf1"));
		theRoot.Add ( new Leaf("Leaf2"));

		// 子節點1
		IComponent theChild1 = new Composite("Child1");
		// 加入兩個最終節點
		theChild1.Add ( new Leaf("Child1.Leaf1"));
		theChild1.Add ( new Leaf("Child1.Leaf2"));
		theRoot.Add (theChild1);

		// 子節點2
		// 加入3個最終節點
		IComponent theChild2 = new Composite("Child2");
		theChild2.Add ( new Leaf("Child2.Leaf1"));
		theChild2.Add ( new Leaf("Child2.Leaf2"));
		theChild2.Add ( new Leaf("Child2.Leaf3"));
		theRoot.Add (theChild2);

		// 顯示
		theRoot.Operation();	


	}
Ejemplo n.º 3
0
 public ClipPath(double[] xValue, double[] yValue, bool clip, bool fillPath, bool drawPath)
 {
   int num1 = clip ? 1 : 0;
   int num2 = fillPath ? 1 : 0;
   int num3 = drawPath ? 1 : 0;
   base.\u002Ector();
   ClipPath clipPath = this;
   this.xValue = (double[]) null;
   this.yValue = (double[]) null;
   this.clip = true;
   this.drawPath = false;
   this.fillPath = false;
   this.fillPaint = (Paint) null;
   this.drawPaint = (Paint) null;
   this.drawStroke = (Stroke) null;
   this.composite = (Composite) null;
   this.xValue = xValue;
   this.yValue = yValue;
   this.clip = num1 != 0;
   this.fillPath = num2 != 0;
   this.drawPath = num3 != 0;
   this.fillPaint = (Paint) Color.gray;
   this.drawPaint = (Paint) Color.blue;
   this.drawStroke = (Stroke) new BasicStroke(1f);
   this.composite = (Composite) AlphaComposite.Src;
 }
Ejemplo n.º 4
0
        protected override Composite CreateBehavior()
        {
            return _root ?? (_root =
                new PrioritySelector(
					
                    new Decorator(ret => (me.QuestLog.GetQuestById(14243) != null && me.QuestLog.GetQuestById(14243).IsCompleted),
                        new Sequence(
                            new Action(ret => TreeRoot.StatusText = "Finished!"),
							new Action(ret => Lua.DoString("VehicleExit()")),
							new Action(ret => Thread.Sleep(15000)),
                            new WaitContinue(120,
                            new Action(delegate
                            {
                                _isDone = true;
                                return RunStatus.Success;
                                }))
                            )),
							
					new Decorator(ret => mobList.Count > 0,
                        new Sequence(
                            new Action(ret => TreeRoot.StatusText = "Bombing - " + mobList[0].Name),
							new Action(ret => Lua.DoString("RunMacroText('/click VehicleMenuBarActionButton1','0')")),
							new Action(ret => LegacySpellManager.ClickRemoteLocation(mobList[0].Location)),
                            new Action(ret => Thread.Sleep(2000))
                        )
					)
                )
			);
        }
Ejemplo n.º 5
0
        public static void RunCleanStash()
        {
            if (!BotMain.IsRunning)
            {
                TaskDispatcher.Start(ret => CleanTask(), ret => !IsCleaning);
                return;
            }

            try
            {
                GoldInactivity.Instance.ResetCheckGold();
                XpInactivity.Instance.ResetCheckXp();

                if (!_hookInserted)
                {
                    _cleanBehavior = CreateCleanBehavior();
                    TreeHooks.Instance.InsertHook(HookName, 0, _cleanBehavior);
                    _hookInserted = true;
                    BotMain.OnStop += bot => RemoveBehavior("Bot stopped");
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("Error running clean stash: " + ex);
                RemoveBehavior("Exception");
            }

        }
    private static void Main()
    {
        // Create a tree structure
        Composite root = new Composite("root");
        root.Add(new Leaf("Leaf A"));
        root.Add(new Leaf("Leaf B"));

        Composite comp = new Composite("Composite X");
        comp.Add(new Leaf("Leaf XA"));
        comp.Add(new Leaf("Leaf XB"));

        root.Add(comp);
        root.Add(new Leaf("Leaf C"));

        // Add and remove a leaf
        Leaf leaf = new Leaf("Leaf D");
        root.Add(leaf);
        root.Remove(leaf);

        // Recursively display tree
        root.Display(1);

        // Wait for user
        Console.Read();
    }
Ejemplo n.º 7
0
    /// Entry point into console application.
    static void Main()
    {
        // Create a tree structure
        Composite root = new Composite("root");
        root.Add(new Leaf("Leaf A"));
        root.Add(new Leaf("Leaf B"));

        Composite comp1 = new Composite("Composite X");
        comp1.Add(new Leaf("Leaf XA"));
        comp1.Add(new Leaf("Leaf XB"));
        root.Add(comp1);

        Composite comp2 = new Composite("Composite Y");
        comp2.Add(new Leaf("Leaf YA"));
        comp2.Add(new Leaf("Leaf YB"));
        root.Add(comp2);

        Composite comp3 = new Composite("Composite Z");
        comp3.Add(new Leaf("Leaf ZA"));
        comp3.Add(new Leaf("Leaf ZB"));
        comp2.Add(comp3);

        root.Add(new Leaf("Leaf C"));

        // Add and remove a leaf
        Leaf leaf = new Leaf("Leaf D");
        root.Add(leaf);
        root.Remove(leaf);

        // Recursively display tree
        root.Display(1);

        // Wait for user
        Console.ReadKey();
    }
Ejemplo n.º 8
0
        public void Activate()
        {
            if (IsActive)
                return;

            Log.Info("Activated {0}", Name);

            _outGameHook = new ActionRunCoroutine(ret => OutOfGameTask());
            _inGameHook = new ActionRunCoroutine(ret => InGameTask());          
            TreeHooks.Instance.OnHooksCleared += Instance_OnHooksCleared;
            InsertHooks();

            EventManager.WorldAreaChanged += OnWorldAreaChanged;
            EventManager.EngagedElite += OnEngagedElite;
            EventManager.LeftGame += OnLeftGame;
            EventManager.JoinedGame += OnJoinedGame;
            EventManager.Died += OnPlayerDied;
            EventManager.InTrouble += OnInTrouble;
            EventManager.UsedPortal += OnUsedPortal;
            EventManager.InviteRequest += OnInviteRequest;
            EventManager.LeavingGame += OnLeavingGame;
            EventManager.GemUpgraded += OnGemUpgraded;

            Pulsator.OnPulse += Pulsator_OnPulse;
            LastActivated = DateTime.UtcNow;
            IsActive = true;
            OnActivated();
        }
Ejemplo n.º 9
0
 public CompositeThrottle(TimeSpan throttleTime, Composite composite)
     : base(composite)
 {
     _throttle.WaitTime = throttleTime;
     // _throttle was created with "0" time--this makes it "good to go" 
     // on first visit to CompositeThrottle node
 }
Ejemplo n.º 10
0
 public GMHauntedMines(string name, string loadingMatchPath, int[] laneRule, Rectangle minimapRectangle,
     Point leftFountain, Point rightFountain, Composite mapChallengeBehavior, Point leftBasePoint,
     Point rightBasePoint, Point[] topLane, Point[] midLane, Point[] botLane)
     : base(name, loadingMatchPath, laneRule, minimapRectangle, leftFountain, rightFountain, mapChallengeBehavior,
         leftBasePoint, rightBasePoint, topLane, midLane, botLane)
 {
 }
Ejemplo n.º 11
0
 public static Composite CreateLootBehavior(Composite child)
 {
     return
     new PrioritySelector(
         CreateUseHoradricCache(),
         child
     );
 }
Ejemplo n.º 12
0
 public virtual void AddChild(Composite child)
 {
     if (child != null)
     {
         child.Parent = this;
         this.Children.Add(child);
     }
 }
Ejemplo n.º 13
0
 public override void Initialize()
 {
     _hookedCorpseRun = null;
     if (_Initialized) return;
     _Initialized = true;
     BotEvents.OnBotStarted += BotEvent_OnBotStarted;
     BotEvents.OnBotStopped += BotEvent_OnBotStopped;
 }
Ejemplo n.º 14
0
        private static void Tick(Composite tree)
        {
            if (tree.LastStatus != RunStatus.Running)
                tree.Start(null);

            if (tree.Tick(null) != RunStatus.Running)
                tree.Stop(null);
        }
Ejemplo n.º 15
0
        public static void Test()
        {
            var root = new Composite<Component> { Node = new Component("Component A") };

            root.Add(new Component("Component A - 1"));
            root.Add(new Component("Component A - 2"));
            root.Add(new Component("Component A - 3"));
        }
Ejemplo n.º 16
0
 public static Composite CreateDeathHandler(Composite original)
 {
     return
         new PrioritySelector(
             new Action(ret => TrinityDeathSafetyCheck()),
             original
         );
 }
Ejemplo n.º 17
0
 public virtual void InsertChild(int index, Composite child)
 {
     if (child != null)
     {
         child.Parent = this;
         this.Children.Insert(index, child);
     }
 }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            Composite comp = new Composite();
            comp.Text = "first";
            Leaf leaf = new Leaf();

            comp.add(leaf);
            comp.draw();
        }
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private static string GetMessage(Composite composite, MethodInfo method, IEnumerable<ConstraintViolation> violations)
 {
     string message = string.Format("{0}.{1} caused parameter constraint violations", composite.GetType().Name, method.Name);
     foreach (ConstraintViolation violation in violations)
     {
         string violationMessage = string.Format("Parameter: '{0}' Value: '{1}' Constraint: '{2}'", violation.Name, violation.Value ?? "{null}", violation.Constraint.GetConstraintName());
         message += Environment.NewLine + violationMessage;
     }
     return message;
 }
		public override void createPartControl(Composite parent) {
			super.createPartControl(parent);
			
			textInputListener = new TextInputListener(this);
			backgroundCompiler = new BackgroundCompiler(this);
			
			var window = getSite().getWorkbenchWindow();
			partListener = new PartListener(this);
			window.getPartService().addPartListener(partListener);
		}
Ejemplo n.º 21
0
 public LogEntry(Composite.Core.Logging.LogEntry fileLogEntry)
 {
     TimeStamp = fileLogEntry.TimeStamp;
     ApplicationDomainId = fileLogEntry.ApplicationDomainId;
     ThreadId = fileLogEntry.ThreadId;
     Severity = fileLogEntry.Severity;
     Title = fileLogEntry.Title;
     DisplayOptions = fileLogEntry.DisplayOptions;
     Message = fileLogEntry.Message;
 }
Ejemplo n.º 22
0
        /// <summary>
        ///   Creates a 'throttle' composite. This composite limits the number of times the child 
        ///   returns RunStatus.Success within a given time span.  Returns cappedStatus if limit reached, 
        ///   otherwise returns result of child
        /// </summary>
        /// <param name = "limit">max number of occurrences</param>
        /// <param name = "timeFrame">time span for occurrences</param>
        /// <param name="limitStatus">RunStatus to return when limit reached</param>
        /// <param name = "child">composite children to tick (run)</param>
        public Throttle(int limit, TimeSpan timeFrame, RunStatus limitStatus, Composite child)
            : base(child)
        {
            TimeFrame = timeFrame;
            Limit = limit;

            _end = DateTime.MinValue;
            _count = 0;
            _limitStatus = limitStatus;
        }
Ejemplo n.º 23
0
        public CompositeThrottle(TimeSpan throttleTime,
                                 Composite composite)
            : base(composite)
        {
            _hasRunOnce = false;
            _throttle = new Stopwatch();
            _throttleTime = throttleTime;

            _throttle.Reset();
            _throttle.Start();
        }
Ejemplo n.º 24
0
        public override void Pulse()
        {
            var me = StyxWoW.Me;
            var value = me.GetMirrorTimerInfo(MirrorTimerType.Breath).CurrentTime;
            if (value < 60000 && me.IsAlive && me.IsSwimming && (value != 0) || (value > 900001))
            {
                if (_root == null)
                    _root = new Action(ctx => DoCheck(ctx));

                Tick(_root);
            }
        }
Ejemplo n.º 25
0
	void UnitTest2 () {
		
		// 根節點
		IComponent theRoot = new Composite("Root");

		// 產生一最終節點
		IComponent theLeaf1 = new Leaf("Leaf1");

		// 加入節點
		theLeaf1.Add ( new Leaf("Leaf2") );  // 錯誤

			
	}
Ejemplo n.º 26
0
 protected override Composite CreateBehavior()
 {
     var children=new Composite[2];
     var compositeArray=new Composite[2];
     compositeArray[0]=new Action(new ActionSucceedDelegate(FlagTagAsCompleted));
     children[0]=new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray));
     ActionDelegate actionDelegateMove=GilesMoveToLocation;
     var sequenceblank=new Sequence(
         new Action(actionDelegateMove)
         );
     children[1]=sequenceblank;
     return new PrioritySelector(children);
 }
Ejemplo n.º 27
0
        protected override Composite CreateBehavior()
        {
            return _root ?? (_root =
                new Decorator(ret => _counter == 0,
                    new Action(delegate
                        {
							Lua.DoString("UseItemByName(\"" + ItemId + "\")");
							Thread.Sleep(300);
                            Styx.Logic.Combat.LegacySpellManager.ClickRemoteLocation(FirePoint);
                            Thread.Sleep(300);
							_counter++;
                        }))
                    );
        }
Ejemplo n.º 28
0
        protected override Composite CreateBehavior()
        {
            Composite[] children=new Composite[2];

            ActionDelegate actionDelegateCast=new ActionDelegate(Funky.FunkyTPBehavior);
            Sequence sequenceblank=new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateCast)
                );

            children[0]=new Zeta.TreeSharp.Decorator(new CanRunDecoratorDelegate(Funky.FunkyTPOverlord), sequenceblank);
            children[1]=new Zeta.TreeSharp.Action(new ActionSucceedDelegate(FlagTagAsCompleted));

            return new PrioritySelector(children);
        }
Ejemplo n.º 29
0
 public Hero(Composite combatOverride, Composite restOverride, Composite pushOverride, string name, int chooseX,
     int chooseY, int attackRange, int siegeCampLevel, List<Skill> skills, Talent[] talents)
 {
     this.combatOverride = combatOverride;
     this.restOverride = restOverride;
     this.pushOverride = pushOverride;
     Name = name;
     ChooseX = chooseX;
     ChooseY = chooseY;
     AttackRange = attackRange;
     SiegeCampLevel = siegeCampLevel;
     Skills = skills;
     Talents = talents;
 }
Ejemplo n.º 30
0
        public override void Pulse()
        {
            if (_Initialized && _hookedCorpseRun == null && isDead() && !_isBehaviorDone && nearSupportedArea())
            {
                OGlog("Hooked");
                _hookedCorpseRun = CreateBehaviorCorpseRun();
                TreeHooks.Instance.ReplaceHook("Death_Main", _hookedCorpseRun);
            }

            if (!isDead())
            {
                _isBehaviorDone = false;
            }
        }
Ejemplo n.º 31
0
        protected override Composite CreateBehavior()
        {
            return(_root ??
                   (_root = new PrioritySelector(
                        new Decorator(c => Counter > NumOfTimes,
                                      new Action(c =>
            {
                TreeRoot.StatusText = "Finished!";
                if (GoHomeButton > 0)
                {
                    Lua.DoString("CastPetAction({0})", GoHomeButton);
                }
                _isBehaviorDone = true;
                return RunStatus.Success;
            })
                                      ),

                        new Decorator(c => NpcVehicleList.Count > 0 && !InVehicle,
                                      new Action(c =>
            {
                if (!NpcVehicleList[0].WithinInteractRange)
                {
                    Navigator.MoveTo(NpcVehicleList[0].Location);
                    TreeRoot.StatusText = "Moving To Vehicle - " + NpcVehicleList[0].Name + " Yards Away: " + NpcVehicleList[0].Location.Distance(Me.Location);
                }
                else
                {
                    NpcVehicleList[0].Interact();
                    MountedPoint = Me.Location;
                }
            })
                                      ),
                        new Decorator(c => InVehicle && SpellType == 1,
                                      new Action(c =>
            {
                if (NpcList.Count == 0 || NpcList[0].Location.Distance(VehicleList[0].Location) > 15)
                {
                    TreeRoot.StatusText = "Waiting for Mob to Come Into Range or Appear.";
                    return RunStatus.Running;
                }
                else if (NpcList.Count >= 1 && NpcList[0].Location.Distance(VehicleList[0].Location) <= 15)
                {
                    TreeRoot.StatusText = "Attacking: " + NpcList[0].Name + ", AttackButton: " + AttackButton;
                    NpcList[0].Target();
                    Lua.DoString("CastPetAction({0})", AttackButton);
                    Thread.Sleep(WaitTime);
                    Counter++;
                    return RunStatus.Success;
                }
                return RunStatus.Running;
            })),

                        new Decorator(c => InVehicle && SpellType == 2,
                                      new Action(c =>
            {
                if (NpcList.Count >= 1)
                {
                    Thread.Sleep(OftenToUse);

                    TreeRoot.StatusText = "Attacking: " + NpcList[0].Name + ", AttackButton: " + AttackButton + ", Times Used: " + Counter;

                    if ((Counter > NumOfTimes && QuestId == 0) || (Me.QuestLog.GetQuestById((uint)QuestId) != null && Me.QuestLog.GetQuestById((uint)QuestId).IsCompleted&& QuestId > 0))
                    {
                        Lua.DoString("VehicleExit()");
                        _isBehaviorDone = true;
                        return RunStatus.Success;
                    }
                    NpcList[0].Target();
                    Lua.DoString("CastPetAction({0})", AttackButton);
                    SpellManager.ClickRemoteLocation(NpcList[0].Location);
                    Thread.Sleep(WaitTime);
                    Counter++;
                    return RunStatus.Running;
                }
                return RunStatus.Running;
            })),

                        new Decorator(c => InVehicle && SpellType == 3,
                                      new PrioritySelector(
                                          ret => NpcList.OrderBy(u => u.DistanceSqr).FirstOrDefault(u => Me.Transport.IsSafelyFacing(u)),
                                          new Decorator(
                                              ret => ret != null,
                                              new PrioritySelector(
                                                  new Decorator(
                                                      ret => Me.CurrentTarget == null || Me.CurrentTarget != (WoWUnit)ret,
                                                      new Action(ret => ((WoWUnit)ret).Target())),
                                                  new Decorator(
                                                      ret => !Me.Transport.IsSafelyFacing(((WoWUnit)ret), 10),
                                                      new Action(ret => Me.CurrentTarget.Face())),
                                                  new Action(ret =>
            {
                Vector3 v = Me.CurrentTarget.Location - StyxWoW.Me.Location;
                v.Normalize();
                Lua.DoString(string.Format(
                                 "local pitch = {0}; local delta = pitch - VehicleAimGetAngle(); VehicleAimIncrement(delta); CastPetAction({1});",
                                 Math.Asin(v.Z).ToString(CultureInfo.InvariantCulture), AttackButton));

                Thread.Sleep(WaitTime);
                Counter++;
                return RunStatus.Success;
            }))))),

                        new Decorator(c => InVehicle && SpellType == 4,
                                      new Action(c =>
            {
                if (NpcList.Count >= 1)
                {
                    if ((Counter > NumOfTimes && QuestId == 0) || (Me.QuestLog.GetQuestById((uint)QuestId) != null && Me.QuestLog.GetQuestById((uint)QuestId).IsCompleted&& QuestId > 0))
                    {
                        Lua.DoString("VehicleExit()");
                        _isBehaviorDone = true;
                        return RunStatus.Success;
                    }
                    NpcList[0].Target();
                    WoWMovement.ClickToMove(NpcList[0].Location);
                    Lua.DoString("CastPetAction({0})", AttackButton);
                    SpellManager.ClickRemoteLocation(NpcList[0].Location);
                    Counter++;
                    return RunStatus.Running;
                }
                return RunStatus.Running;
            })),

                        new Decorator(c => InVehicle && SpellType == 5,
                                      new Action(c =>
            {
                if (NpcList.Count >= 1 || NpcListSecondary.Count >= 1)
                {
                    if ((Counter > NumOfTimes && QuestId == 0) || (Me.QuestLog.GetQuestById((uint)QuestId) != null && Me.QuestLog.GetQuestById((uint)QuestId).IsCompleted&& QuestId > 0))
                    {
                        Lua.DoString("VehicleExit()");
                        _isBehaviorDone = true;
                        return RunStatus.Success;
                    }

                    if (NpcList.Count > 0)
                    {
                        NpcList[0].Target();
                        WoWMovement.ConstantFace(Me.CurrentTargetGuid);
                        Lua.DoString("CastPetAction({0})", AttackButton);
                    }

                    if (NpcListSecondary.Count > 0)
                    {
                        NpcListSecondary[0].Target();
                        WoWMovement.ConstantFace(Me.CurrentTargetGuid);
                        Lua.DoString("CastPetAction({0})", AttackButton);
                    }

                    Lua.DoString("CastPetAction({0})", AttackButton2);

                    if (QuestId == 0)
                    {
                        Counter++;
                    }

                    return RunStatus.Running;
                }
                return RunStatus.Running;
            }))
                        )));
        }
Ejemplo n.º 32
0
 public PrioritizedBehavior(int p, string s, Composite bt)
 {
     Priority = p;
     Name     = s;
     behavior = bt;
 }
 protected Composite CreateBehavior_QuestbotMain()
 {
     return(_root ?? (_root = new Decorator(ret => !_isBehaviorDone, new PrioritySelector(DoneYet, DpsHim, Boom, new ActionAlwaysSucceed()))));
 }
Ejemplo n.º 34
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =

                                 new PrioritySelector(
                                     // If we've arrived at the destination, we're done...
                                     new Decorator(ret => ((EscortUntil == EscortUntilType.DestinationReached) &&
                                                           (Me.Location.Distance(EscortDestination) <= DestinationTolerance)),
                                                   new Action(delegate
            {
                TreeRoot.StatusText = "Finished!";
                _isBehaviorDone = true;
            })),

                                     // If quest is completed, we're done...
                                     new Decorator(ret => ((EscortUntil == EscortUntilType.QuestComplete) && IsQuestComplete()),
                                                   new Sequence(
                                                       new Action(ret => TreeRoot.StatusText = "Finished!"),
                                                       new WaitContinue(120,
                                                                        new Action(delegate
            {
                _isBehaviorDone = true;
                return RunStatus.Success;
            }))
                                                       )),

                                     new Decorator(ret => MobList.Count == 0,
                                                   new Sequence(
                                                       new Action(ret => TreeRoot.StatusText = "Moving To Location - X: " + Location.X + " Y: " + Location.Y),
                                                       new Action(ret => Navigator.MoveTo(Location)),
                                                       new Action(ret => Thread.Sleep(300))
                                                       )
                                                   ),

                                     new Decorator(ret => Me.CurrentTarget != null && Me.CurrentTarget.IsFriendly,
                                                   new Action(ret => Me.ClearTarget())),

                                     new Decorator(
                                         ret => MobList.Count > 0 && MobList[0].IsHostile,
                                         new PrioritySelector(
                                             new Decorator(
                                                 ret => Me.CurrentTarget != MobList[0],
                                                 new Action(ret =>
            {
                MobList[0].Target();
                StyxWoW.SleepForLagDuration();
            })),
                                             new Decorator(
                                                 ret => !Me.Combat,
                                                 new PrioritySelector(
                                                     new Decorator(
                                                         ret => RoutineManager.Current.PullBehavior != null,
                                                         RoutineManager.Current.PullBehavior),
                                                     new Action(ret => RoutineManager.Current.Pull()))))),


                                     new Decorator(
                                         ret => MobList.Count > 0 && (!Me.Combat || Me.CurrentTarget == null || Me.CurrentTarget.Dead) &&
                                         MobList[0].CurrentTarget == null && MobList[0].DistanceSqr > 5f * 5f,
                                         new Sequence(
                                             new Action(ret => TreeRoot.StatusText = "Following Mob - " + MobList[0].Name + " At X: " + MobList[0].X + " Y: " + MobList[0].Y + " Z: " + MobList[0].Z),
                                             new Action(ret => Navigator.MoveTo(MobList[0].Location)),
                                             new Action(ret => Thread.Sleep(100))
                                             )
                                         ),

                                     new Decorator(ret => MobList.Count > 0 && (Me.Combat || MobList[0].Combat),
                                                   new PrioritySelector(
                                                       new Decorator(
                                                           ret => Me.CurrentTarget == null && MobList[0].CurrentTarget != null,
                                                           new Sequence(
                                                               new Action(ret => MobList[0].CurrentTarget.Target()),
                                                               new Action(ret => StyxWoW.SleepForLagDuration()))),
                                                       new Decorator(
                                                           ret => !Me.Combat,
                                                           new PrioritySelector(
                                                               new Decorator(
                                                                   ret => RoutineManager.Current.PullBehavior != null,
                                                                   RoutineManager.Current.PullBehavior),
                                                               new Action(ret => RoutineManager.Current.Pull())))))

                                     )
                             ));
        }
Ejemplo n.º 35
0
 public void SetValue(ref TRecord record, Composite <T1, T2> value)
 {
     throw new InvalidOperationException();
 }
        protected Composite CreateBehavior_QuestbotMain()
        {
            return(_root ?? (_root =
                                 new Decorator(ctx => !_isBehaviorDone && (!Me.IsActuallyInCombat || IgnoreCombat),
                                               new PrioritySelector(

                                                   new Decorator(ret => Counter > NumOfTimes && QuestId == 0,
                                                                 new Action(ret => _isBehaviorDone = true)),

                                                   new Decorator(
                                                       ret => UseType == QBType.Current,
                                                       new PrioritySelector(
                                                           new Decorator(
                                                               new Sequence(
                                                                   new Action(ret => TreeRoot.StatusText = "Using Pet Ability:" + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                                   new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                                   new SleepForLagDuration(),
                                                                   new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                                   new SleepForLagDuration(),
                                                                   new Action(ret => Counter++),
                                                                   new Sleep(WaitTime))
                                                               ))),

                                                   new Decorator(
                                                       ret => UseType == QBType.Location,
                                                       new PrioritySelector(
                                                           new Decorator(
                                                               ret => Me.Location.Distance(MoveToLocation) > 3,
                                                               new Sequence(
                                                                   new Action(ret => TreeRoot.StatusText = "Moving To Use Ability at Location, Distance: " + MoveToLocation.Distance(Me.Location)),
                                                                   new Action(ret => Navigator.MoveTo(MoveToLocation)))),
                                                           new Sequence(
                                                               new Action(ret => TreeRoot.StatusText = "Using Pet Ability At Location:" + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                               new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                               new SleepForLagDuration(),
                                                               new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                               new SleepForLagDuration(),
                                                               new Action(ret => Counter++),
                                                               new Sleep(WaitTime))
                                                           )),

                                                   new Decorator(
                                                       ret => UseType == QBType.ToObject,
                                                       new PrioritySelector(
                                                           new Decorator(
                                                               ret => UseObject == null && Me.Location.DistanceSqr(MoveToLocation) >= 2 * 2,
                                                               new Sequence(
                                                                   new Action(ret => TreeRoot.StatusText = "Moving To Use Ability around Location. Distance: " + MoveToLocation.Distance(Me.Location)),
                                                                   new Action(ret => Navigator.MoveTo(MoveToLocation)))),
                                                           new Decorator(
                                                               ret => UseObject != null,
                                                               new PrioritySelector(
                                                                   new Decorator(
                                                                       ret => UseObject.DistanceSqr >= Range * Range,
                                                                       new Sequence(
                                                                           new Action(ret => TreeRoot.StatusText = "Moving closer to the Target, Distance: " + MoveToLocation.Distance(Me.Location)),
                                                                           new Action(ret => Navigator.MoveTo(UseObject.Location)))),
                                                                   new Decorator(
                                                                       ret => UseObject.DistanceSqr < MinRange * MinRange,
                                                                       new Sequence(
                                                                           new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"),
                                                                           new Action(ret => Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f)))
                                                                           )),
                                                                   new Sequence(
                                                                       new Action(ret => TreeRoot.StatusText = "Using Pet Ability On Target : " + UseObject.SafeName + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                                       new Action(ret => UseObject.Target()),
                                                                       new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                                       new Action(ret => UseObject.Face()),
                                                                       new SleepForLagDuration(),
                                                                       new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                                       new Action(ret => Counter++),
                                                                       new SleepForLagDuration(),
                                                                       new Action(ret => _npcBlacklist.Add(UseObject.Guid)),
                                                                       new Sleep(WaitTime)))),
                                                           new Action(ret => TreeRoot.StatusText = "No objects around. Waiting")
                                                           ))
                                                   ))));
        }
Ejemplo n.º 37
0
 protected Composite CreateBehavior_MainCombat()
 {
     return(_root ?? (_root = new Decorator(ret => !_isBehaviorDone, new PrioritySelector(DoneYet, Aoe, Obj1, Obj2, new ActionAlwaysSucceed()))));
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Write instruction operands into bytecode stream.
 /// </summary>
 /// <param name="writer">Bytecode writer.</param>
 public override void WriteOperands(WordWriter writer)
 {
     Composite.Write(writer);
     Indexes.Write(writer);
 }
Ejemplo n.º 39
0
 public void OnInitialize()
 {
     _coroutine        = new ActionRunCoroutine(r => ChangeZone());
     _enabled          = true;
     _disabledForLevel = null;
 }
Ejemplo n.º 40
0
 public Composite GetComposite(Composite composite, string subCompositeName)
 {
     return((Composite)composite.GetLeaf(subCompositeName));
 }
Ejemplo n.º 41
0
 protected override Composite CreateMainBehavior()
 {
     return(_root ?? (_root = new ActionRunCoroutine(ctx => MainCoroutine())));
 }
Ejemplo n.º 42
0
        public Composite Create(string compositetag)
        {
            Composite item = null;

            if (_server == null)
            {
                return(null);
            }

            string tag = String.Format(String.Format(@"SCEC.SCEC_Kuzbass.{0}.EmergencyResponsePlan", compositetag));

            try
            {
                var tags = new List <string>
                {
                    "Period.Start",
                    "Period.End",
                    "NumberOfPosition.AtTheBegining",
                    "NumberOfPosition.ForToday",
                    "Involved",
                    "Changes.AddedChanges",
                    "Changes.AddedPosition",
                    "Changes.ExtractedPosition"
                };

                var propertyTags = tags.Select(t => String.Format("{0}.{1}", tag, t)).ToList();

                DateTime periodstart;
                DateTime.TryParse(Read(propertyTags[0]), out periodstart);
                DateTime periodend;
                DateTime.TryParse(Read(propertyTags[1]), out periodend);
                int atTheBegining;
                Int32.TryParse(Read(propertyTags[2]), out atTheBegining);
                int forToday;
                Int32.TryParse(Read(propertyTags[3]), out forToday);
                int involved;
                Int32.TryParse(Read(propertyTags[4]), out involved);
                int changesAddedChanges;
                Int32.TryParse(Read(propertyTags[5]), out changesAddedChanges);
                int changesAddedPosition;
                Int32.TryParse(Read(propertyTags[6]), out changesAddedPosition);
                int changesExtractedPosition;
                Int32.TryParse(Read(propertyTags[7]), out changesExtractedPosition);

                item = new Composite
                {
                    PeriodStart = periodstart,
                    PeriodEnd   = periodend,
                    NumberOfPositionAtBegining = atTheBegining,
                    NumberOfPositionForToday   = forToday,
                    ExtractedPosition          = changesExtractedPosition,
                    AddedPosition = changesAddedPosition,
                    AddedChanges  = changesAddedChanges,
                    Involved      = involved,
                    MineTag       = compositetag
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"Невозможно считать события" + ex);
            }
            if (item == null)
            {
                throw new Exception("Объект мероприятия не сформирован");
            }
            return(item);
        }
Ejemplo n.º 43
0
 public void Save(DbConnection connection, DbTransaction transaction, Composite composite)
 {
     Save(connection, transaction, composite, true);
 }
Ejemplo n.º 44
0
 protected override Composite CreateBehavior()
 {
     return(_root ?? (_root = new Decorator(ret => !_isBehaviorDone, new PrioritySelector(DoneYet, TargetHim, Scare2, JumporNot))));
 }
Ejemplo n.º 45
0
 private static void InsertHook()
 {
     _hook     = CreateUnstuckBehavior();
     IsRunning = true;
     TreeHooks.Instance.InsertHook("BotBehavior", 0, _hook);
 }
Ejemplo n.º 46
0
 public override void Stop()
 {
     _root = null;
 }
Ejemplo n.º 47
0
 public override void Start()
 {
     _root = TradeAcceptBehavior;
 }
Ejemplo n.º 48
0
 public override void Start()
 {
     _root = new ActionRunCoroutine(r => Run());
 }
Ejemplo n.º 49
0
 protected override Composite CreateBehavior_QuestbotMain()
 {
     return(_root ?? (_root = new ActionRunCoroutine(ctx => MainLogic())));
 }
Ejemplo n.º 50
0
        public void Save(DbConnection connection, DbTransaction transaction, Composite composite, bool shouldUpdateInsertedIds)
        {
            var newComposites = new List <Composite>();

            composite.TraverseDepthFirst((c) =>
            {
                CompositeContainerAttribute compositeContainerAttribute;

                var compositeType = c.GetType();
                CompositeModelAttribute compositeModelAttribute;

                if ((compositeContainerAttribute = compositeType.FindCustomAttribute <CompositeContainerAttribute>()) != null)
                {
                    var removedIdsProperty = compositeType
                                             .GetProperty(compositeContainerAttribute.CompositeContainerDictionaryPropertyName)
                                             .GetValue(c)
                                             .GetType().GetProperty(nameof(CompositeDictionary <object, Composite> .RemovedIds));

                    var compositeDictionary = compositeType
                                              .GetProperty(compositeContainerAttribute.CompositeContainerDictionaryPropertyName)
                                              .GetValue(c);

                    dynamic deletedIds = removedIdsProperty.GetValue(compositeDictionary);

                    if (deletedIds.Count > 0)
                    {
                        var deletedCompositeType = compositeDictionary.GetType().GetGenericArguments()[1];
                        var deletedModelType     = deletedCompositeType.GetField(deletedCompositeType.GetCustomAttribute <CompositeModelAttribute>().ModelFieldName, BindingFlags.Instance | BindingFlags.NonPublic).FieldType;
                        if (deletedModelType.GetCustomAttribute <NoDbAttribute>() == null)
                        {
                            var tableName            = deletedModelType.GetCustomAttribute <DataContractAttribute>().Name ?? deletedModelType.Name;
                            var tableKeyPropertyName = deletedModelType.GetCustomAttribute <KeyPropertyAttribute>().KeyPropertyName;
                            OnDelete(connection, transaction, tableName, tableKeyPropertyName, deletedIds);
                        }

                        dynamic internalCompositeDictionary = compositeType.GetField(compositeType.GetCustomAttribute <CompositeContainerAttribute>().InternalCompositeContainerDictionaryPropertyName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(c);
                        internalCompositeDictionary.ClearRemovedIds();
                    }
                }

                if ((compositeModelAttribute = compositeType.FindCustomAttribute <CompositeModelAttribute>()) != null)
                {
                    var modelFieldInfo = compositeType.GetField(compositeModelAttribute.ModelFieldName, BindingFlags.Instance | BindingFlags.NonPublic);
                    if (modelFieldInfo == null)
                    {
                        throw new MemberAccessException(Resources.CannotFindCompositeModelProperty);
                    }

                    switch (c.State)
                    {
                    case CompositeState.Modified:

                        if (modelFieldInfo.FieldType.GetCustomAttribute <NoDbAttribute>() == null)
                        {
                            var dataContractAttribute       = modelFieldInfo.FieldType.GetCustomAttribute <DataContractAttribute>();
                            var modelKeyPropertyAttribute   = modelFieldInfo.FieldType.GetCustomAttribute <KeyPropertyAttribute>();
                            var modelKeyProperty            = modelFieldInfo.FieldType.GetProperty(modelKeyPropertyAttribute.KeyPropertyName);
                            var modelKeyDataMemberAttribute = modelKeyProperty?.GetCustomAttribute <DataMemberAttribute>();

                            if (dataContractAttribute == null)
                            {
                                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.MustHaveDataContractAttribute, modelFieldInfo.FieldType.Name));
                            }

                            if (modelKeyPropertyAttribute == null)
                            {
                                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.MustHaveKeyPropertyAttribute, modelFieldInfo.FieldType.Name));
                            }

                            if (modelKeyProperty == null)
                            {
                                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidPropertyName, modelKeyPropertyAttribute.KeyPropertyName));
                            }

                            if (modelKeyDataMemberAttribute == null)
                            {
                                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.MustHaveDataMemberAttribute, modelKeyPropertyAttribute.KeyPropertyName));
                            }

                            var dataRow      = new Composite[] { c }.ToDataTable().Rows[0];
                            var columnValues = dataRow.Table.Columns.Cast <DataColumn>().Where(column => column.ColumnName != "__model").ToDictionary(column => column.ColumnName, column => dataRow[column]);

                            var keyColumnName = modelKeyDataMemberAttribute.Name ?? modelKeyProperty.Name;
                            var keyValue      = dataRow[keyColumnName];

                            var tableName            = dataContractAttribute.Name ?? modelFieldInfo.FieldType.Name;
                            var tableKeyPropertyName = modelKeyDataMemberAttribute.Name ?? modelKeyProperty.Name;

                            if (!Regex.IsMatch(tableName, @"^[A-Za-z0-9_]+$"))
                            {
                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidTableName, tableName));
                            }

                            if (!Regex.IsMatch(tableKeyPropertyName, @"^[A-Za-z0-9_]+$"))
                            {
                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidColumnName, tableKeyPropertyName));
                            }

                            string invalidColumnName = null;
                            if ((invalidColumnName = columnValues.Keys.FirstOrDefault(column => !Regex.IsMatch(column, @"^[A-Za-z0-9_]+$"))) != null)
                            {
                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidColumnName, invalidColumnName));
                            }

                            OnUpdate(connection, transaction, tableName, tableKeyPropertyName, keyValue, columnValues);
                            c.State = CompositeState.Unchanged;
                        }

                        break;

                    case CompositeState.New:
                        if (modelFieldInfo.FieldType.GetCustomAttribute <NoDbAttribute>() == null)
                        {
                            newComposites.Add(c);
                        }
                        break;

                    default:
                        break;
                    }
                }
            });

            if (newComposites.Count() > 0)
            {
                SaveNewComposites(connection, transaction, newComposites, shouldUpdateInsertedIds);
                if (shouldUpdateInsertedIds)
                {
                    UpdateNewKeyValues(composite);
                }
            }
        }
Ejemplo n.º 51
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gapCloser"></param>
        /// <returns></returns>
        public static Composite CreateRangedHealerMovementBehavior(Composite gapCloser = null)
        {
            int moveNearTank;
            int stopNearTank;

            if (SingularRoutine.CurrentWoWContext != WoWContext.Instances)
            {
                return(new ActionAlwaysFail());
            }

            if (!SingularSettings.Instance.StayNearTank)
            {
                return(Movement.CreateMoveBehindTargetBehavior());
            }

            if (gapCloser == null)
            {
                gapCloser = new ActionAlwaysFail();
            }

            bool incombat = (Dynamics.CompositeBuilder.CurrentBehaviorType & BehaviorType.InCombat) != (BehaviorType)0;

            if (incombat)
            {
                moveNearTank = Math.Max(5, SingularSettings.Instance.StayNearTankRangeCombat);
                stopNearTank = Math.Max(moveNearTank / 2, moveNearTank - 5);
            }
            else
            {
                moveNearTank = Math.Max(5, SingularSettings.Instance.StayNearTankRangeRest);
                stopNearTank = Math.Max(moveNearTank / 2, moveNearTank - 5);
            }

            return(new PrioritySelector(
                       ctx => (Me.Combat && Me.GotTarget() && Unit.ValidUnit(Me.CurrentTarget))
                    ? Me.CurrentTarget
                    : null,
                       new Decorator(
                           ret => ret != null,
                           new Sequence(
                               new PrioritySelector(
                                   gapCloser,
                                   Movement.CreateMoveToLosBehavior(),
                                   Movement.CreateMoveToUnitBehavior(on => Me.CurrentTarget, 30, 25),
                                   Movement.CreateEnsureMovementStoppedBehavior(25f),
                                   // to account for Mistweaver Monks facing Soothing Mist target automatically
                                   new Decorator(
                                       req => !Spell.IsChannelling(),
                                       Movement.CreateFaceTargetBehavior()
                                       )
                                   ),
                               new ActionAlwaysFail()
                               )
                           ),
                       new Decorator(
                           ret => ret == null,
                           new Sequence(
                               CreateStayNearTankBehavior(gapCloser),
                               new ActionAlwaysFail()
                               )
                           )
                       ));
        }
Ejemplo n.º 52
0
 public override void OnInitialize()
 {
     startCoroutine = new ActionRunCoroutine(ctx => Start());
     deathCoroutine = new ActionRunCoroutine(ctx => HandleDeath());
 }
Ejemplo n.º 53
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(


                                     new Decorator(ret => me.QuestLog.GetQuestById(24695) != null && me.QuestLog.GetQuestById(24695).IsCompleted,
                                                   new Sequence(
                                                       new Action(ret => TreeRoot.StatusText = "Finished!"),
                                                       new WaitContinue(120,
                                                                        new Action(delegate
            {
                _isDone = true;
                return RunStatus.Success;
            }))
                                                       )),
                                     new Decorator(ret => !Obj1Done,
                                                   new Action(ret =>
            {
                if (Obj1Done)
                {
                    return RunStatus.Success;
                }
                if (!InVehicle)
                {
                    if (obj1lever.Count > 0 && obj1lever[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj1lever[0].Location);
                        return RunStatus.Running;
                    }
                    WoWMovement.MoveStop();
                    obj1lever[0].Interact();
                    Thread.Sleep(5000);
                    return RunStatus.Running;
                }
                if (InVehicle)
                {
                    if (obj1mob.Count > 0 && obj1mob[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj1mob[0].Location);
                        obj1mob[0].Target();
                        return RunStatus.Running;
                    }
                    if (obj1mob.Count > 0 && obj1mob[0].Location.Distance(me.Location) <= 5)
                    {
                        WoWMovement.MoveStop();
                        if (!OnCooldown2)
                        {
                            Lua.DoString("UseAction(122, 'target', 'LeftButton')");
                        }
                        if (!obj1mob[0].HasAura("Bloodpetal Poison"))
                        {
                            Lua.DoString("UseAction(123, 'target', 'LeftButton')");
                        }
                        return RunStatus.Running;
                    }
                    return RunStatus.Running;
                }
                return RunStatus.Running;
            }
                                                              )),
                                     new Decorator(ret => !Obj2Done,
                                                   new Action(ret =>
            {
                if (Obj2Done)
                {
                    return RunStatus.Success;
                }
                if (!InVehicle)
                {
                    if (obj2lever.Count > 0 && obj2lever[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj2lever[0].Location);
                        return RunStatus.Running;
                    }
                    WoWMovement.MoveStop();
                    obj2lever[0].Interact();
                    Thread.Sleep(5000);
                    return RunStatus.Running;
                }
                if (InVehicle)
                {
                    if (!me.HasAura("Bony Armor"))
                    {
                        Lua.DoString("UseAction(123, 'target', 'LeftButton')");
                    }
                    if (obj2mob.Count > 0 && obj2mob[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj2mob[0].Location);
                        return RunStatus.Running;
                    }
                    if (obj2mob.Count > 0 && obj2mob[0].Location.Distance(me.Location) <= 5)
                    {
                        obj2mob[0].Target();
                        WoWMovement.MoveStop();
                        Lua.DoString("UseAction(122, 'target', 'LeftButton')");
                        return RunStatus.Running;
                    }
                    return RunStatus.Running;
                }
                return RunStatus.Running;
            }
                                                              )),
                                     new Decorator(ret => !Obj3Done,
                                                   new Action(ret =>
            {
                if (Obj3Done)
                {
                    return RunStatus.Success;
                }
                if (!InVehicle)
                {
                    if (obj3lever.Count > 0 && obj3lever[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj3lever[0].Location);
                        return RunStatus.Running;
                    }
                    WoWMovement.MoveStop();
                    obj3lever[0].Interact();
                    Thread.Sleep(5000);
                    return RunStatus.Running;
                }
                if (InVehicle)
                {
                    if (obj3mob.Count == 0)
                    {
                        if (me.Location.Distance(obj3loc1) < 5)
                        {
                            locreached = true;
                        }
                        if (me.Location.Distance(obj3loc2) < 5)
                        {
                            locreached = false;
                        }
                        if (!locreached)
                        {
                            Navigator.MoveTo(obj3loc1);
                            return RunStatus.Running;
                        }
                        if (locreached)
                        {
                            Navigator.MoveTo(obj3loc2);
                        }
                    }

                    if (obj3mob.Count > 0 && ((me.HasAura("Stomper Knowledge") && obj3mob[0].Entry == 6513 ||
                                               me.HasAura("Thunderer Knowledge") && obj3mob[0].Entry == 6516 ||
                                               me.HasAura("Gorilla Knowledge") && obj3mob[0].Entry == 6514)))
                    {
                        LocalBlacklist.Add(obj3mob[0].Entry);
                        return RunStatus.Running;
                    }
                    if (obj3mob.Count > 0 && obj3mob[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj3mob[0].Location);
                        return RunStatus.Running;
                    }
                    if (obj3mob.Count > 0 && obj3mob[0].Location.Distance(me.Location) <= 5)
                    {
                        obj3mob[0].Target();
                        Thread.Sleep(100);
                        obj3mob[0].Interact();
                        Thread.Sleep(2000);
                        Lua.DoString("SelectGossipOption(1)");
                        Thread.Sleep(2000);
                        Lua.DoString("SelectGossipOption(1)");
                        Thread.Sleep(2000);
                        return RunStatus.Running;
                    }
                    return RunStatus.Running;
                }
                return RunStatus.Running;
            }
                                                              )),
                                     new Decorator(ret => !Obj4Done,
                                                   new Action(ret =>
            {
                if (Obj4Done)
                {
                    return RunStatus.Success;
                }
                if (!InVehicle)
                {
                    if (obj4lever.Count > 0 && obj4lever[0].Location.Distance(me.Location) > 5)
                    {
                        Navigator.MoveTo(obj4lever[0].Location);
                        return RunStatus.Running;
                    }
                    WoWMovement.MoveStop();
                    obj4lever[0].Interact();
                    Thread.Sleep(5000);
                    return RunStatus.Running;
                }
                if (InVehicle)
                {
                    WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend);
                    if (!OnCooldown2)
                    {
                        Lua.DoString("UseAction(122, 'target', 'LeftButton')");
                    }
                    return RunStatus.Running;
                }
                return RunStatus.Success;
            }
                                                              ))

                                     )
                             ));
        }
Ejemplo n.º 54
0
 public IRegister Register(Composite leaf)
 {
     builder.Composites.Add(leaf);
     return(this);
 }
Ejemplo n.º 55
0
        /// <summary>
        /// stays within range of Tank as they move.  settings configurable by user.
        /// </summary>
        /// <param name="gapCloser">ability to close distance more quickly than running (such as Roll)</param>
        /// <returns></returns>
        public static Composite CreateStayNearTankBehavior(Composite gapCloser = null)
        {
            int moveNearTank;
            int stopNearTank;

            if (gapCloser == null)
            {
                gapCloser = new ActionAlwaysFail();
            }

            if (!SingularSettings.Instance.StayNearTank)
            {
                return(new ActionAlwaysFail());
            }

            if (SingularRoutine.CurrentWoWContext != WoWContext.Instances)
            {
                return(new ActionAlwaysFail());
            }

            if (IsThisBehaviorCalledDuringCombat())
            {
                moveNearTank = Math.Max(5, SingularSettings.Instance.StayNearTankRangeCombat);
                stopNearTank = (moveNearTank * 7) / 10;
            }
            else
            {
                moveNearTank = Math.Max(5, SingularSettings.Instance.StayNearTankRangeRest);
                stopNearTank = (moveNearTank * 6) / 10;     // be slightly more elastic at rest
            }

            Logger.WriteDebug("StayNearTank in {0}: will move towards at {1} yds and stop if within {2} yds", Dynamics.CompositeBuilder.CurrentBehaviorType, moveNearTank, stopNearTank);
            return(new PrioritySelector(
                       ctx => HealerManager.TankToStayNear,

                       // no healing needed, then move within heal range of tank
                       new ThrottlePasses(
                           1,
                           TimeSpan.FromSeconds(5),
                           RunStatus.Failure,
                           new Action(t => {
                if (SingularSettings.Debug)
                {
                    WoWUnit tankToStayNear = (WoWUnit)t;
                    if (t != null)
                    {
                        ;
                    }
                    else if (!Group.Tanks.Any())
                    {
                        Logger.WriteDiagnostic(Color.HotPink, "TankToStayNear: no group members with Role=Tank");
                    }
                    else
                    {
                        Logger.WriteDebug(Color.HotPink, "TankToStayNear:  {0} tanks in group", Group.Tanks.Count());
                        int i = 0;
                        foreach (var tank in Group.Tanks.OrderByDescending(gt => gt == RaFHelper.Leader).ThenBy(gt => gt.DistanceSqr))
                        {
                            Logger.WriteDebug(Color.HotPink, "TankToStayNear[{0}]: {1} Health={2:F1}%, Dist={3:F1}, TankPt={4}, MePt={5}, TankMov={6}, MeMov={7}, LoS={8}, LoSS={9}, Combat={10}, MeCombat={11}, ",
                                              i++,
                                              tank.SafeName(),
                                              tank.HealthPercent,
                                              tank.SpellDistance(),
                                              tank.Location,
                                              Me.Location,
                                              tank.IsMoving.ToYN(),
                                              Me.IsMoving.ToYN(),
                                              tank.InLineOfSight.ToYN(),
                                              tank.InLineOfSpellSight.ToYN(),
                                              tank.Combat.ToYN(),
                                              Me.Combat.ToYN()
                                              );
                        }

                        Logger.WriteDebug(Color.HotPink, "TankToStayNear: current TargetList has {0} units", Targeting.Instance.TargetList.Count());
                        i = 0;
                        foreach (var target in Targeting.Instance.TargetList)
                        {
                            Logger.WriteDebug(Color.HotPink, "CurrentTargets[{0}]: {1} {2:F1}% @ {3:F1}",
                                              i++,
                                              target.SafeName(),
                                              target.HealthPercent,
                                              target.SpellDistance()
                                              );
                        }
                    }
                }
                return RunStatus.Failure;
            })
                           ),
                       new Decorator(
                           ret => ((WoWUnit)ret) != null,
                           new Sequence(
                               new PrioritySelector(
                                   gapCloser,
                                   Movement.CreateMoveToLosBehavior(unit => ((WoWUnit)unit)),
                                   Movement.CreateMoveToUnitBehavior(unit => ((WoWUnit)unit), moveNearTank, stopNearTank)
                                   // , Movement.CreateEnsureMovementStoppedBehavior(stopNearTank, unit => (WoWUnit)unit, "in heal range of tank")
                                   ),
                               new ActionAlwaysFail()
                               )
                           )
                       ));
        }
Ejemplo n.º 56
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(


                                     new Decorator(ret => me.QuestLog.GetQuestById(25066) != null && me.QuestLog.GetQuestById(25066).IsCompleted,
                                                   new Sequence(
                                                       new Action(ret => TreeRoot.StatusText = "Finished!"),
                                                       new WaitContinue(120,
                                                                        new Action(delegate
            {
                _isDone = true;
                return RunStatus.Success;
            })))),
                                     new Decorator(ret => !InVehicle,
                                                   new Action(ret =>
            {
                if (flylist.Count == 0)
                {
                    Navigator.MoveTo(flyloc);
                    Thread.Sleep(1000);
                }
                if (flylist.Count > 0 && flylist[0].Location.Distance(me.Location) > 5)
                {
                    Navigator.MoveTo(flylist[0].Location);
                    Thread.Sleep(1000);
                }
                if (flylist.Count > 0 && flylist[0].Location.Distance(me.Location) <= 5)
                {
                    WoWMovement.MoveStop();
                    flylist[0].Interact();
                    Thread.Sleep(1000);
                    Lua.DoString("SelectGossipOption(1)");
                    Thread.Sleep(1000);
                }
            })),
                                     new Decorator(ret => InVehicle,
                                                   new Action(ret =>
            {
                if (!InVehicle)
                {
                    return RunStatus.Success;
                }
                if (me.QuestLog.GetQuestById(25066).IsCompleted)
                {
                    while (me.Location.Distance(endloc) > 10)
                    {
                        WoWMovement.ClickToMove(endloc);
                        Thread.Sleep(1000);
                    }
                    Lua.DoString("VehicleExit()");
                    return RunStatus.Success;
                }
                if (objmob.Count == 0)
                {
                    WoWMovement.ClickToMove(startloc);
                    Thread.Sleep(1000);
                }
                if (objmob.Count > 0)
                {
                    objmob[0].Target();
                    WoWMovement.ClickToMove(objmob[0].Location);
                    Thread.Sleep(100);
                    Lua.DoString("UseAction(122, 'target', 'LeftButton')");
                    Lua.DoString("UseAction(121, 'target', 'LeftButton')");
                }
                return RunStatus.Running;
            }
                                                              ))


                                     )
                             ));
        }
Ejemplo n.º 57
0
        public async Task IComposite_PostAsync_T_Args(string apiVersion, CompositeResponse <string> expected, Composite request)
        {
            using var handler = MockHttpMessageHandler.SetupHandler(expected);
            var api    = handler.SetupApi <IComposite>();
            var result = await api.PostAsync <string>(request, CancellationToken.None, apiVersion);

            result.Should().BeEquivalentTo(expected);
            handler.ConfirmPath($"/services/data/{apiVersion}/composite");
        }
Ejemplo n.º 58
0
 public override void Start()
 {
     Navigator.PlayerMover        = new SlideMover();
     Navigator.NavigationProvider = new ServiceNavigationProvider();
     _root = new ActionRunCoroutine(r => RetainerTest());
 }
Ejemplo n.º 59
0
        private Decorator CreateCurableDebuffDecorator(Dictionary <string, int> dictionary, Composite child, Func <int> minCharges = null)
        {
            return(new Decorator((x =>
            {
                //var buffs = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Life>().Buffs;
                var buffs = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <ExileCore.PoEMemory.Components.Buffs>();

                foreach (var buff in buffs.BuffsList)
                {
                    if (float.IsInfinity(buff.Timer) && buff.Name.Contains("curse_") == false)
                    {
                        continue;
                    }

                    int filterId = 0;
                    if (dictionary.TryGetValue(buff.Name, out filterId))
                    {
                        // I'm not sure what the values are here, but this is the effective logic from the old plugin
                        return (filterId == 0 || filterId != 1) && (minCharges == null || buff.Charges >= minCharges());
                    }
                }
                return false;
            }), child));
        }
Ejemplo n.º 60
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(

                                     new Decorator(ret => Counter >= NumOfTimes,
                                                   new Action(ret => _isBehaviorDone = true)),

                                     new PrioritySelector(

                                         new Decorator(ret => CurrentObject != null && CurrentObject.Location.DistanceSqr(Me.Location) > Range * Range,
                                                       new Sequence(
                                                           new Action(ret => { TreeRoot.StatusText = "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 DecoratorContinue(ret => StyxWoW.Me.IsMoving,
                                                                                 new Action(ret =>
            {
                WoWMovement.MoveStop();
                StyxWoW.SleepForLagDuration();
            })),

                                                           new Action(ret =>
            {
                TreeRoot.StatusText = "Interacting with - " + CurrentObject.Name;
                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 => Location.DistanceSqr(Me.Location) > 2 * 2,
                                             new Sequence(
                                                 new Action(ret => { TreeRoot.StatusText = "Moving towards - " + Location; }),
                                                 new Action(ret => Navigator.MoveTo(Location)))),

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

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

                                         ))));
        }