Exemplo n.º 1
0
 public static Composite OpenStash()
 {
     // Do a minimum sleep of x seconds here
     // due to some issues with memory loading stash
     return(new PrioritySelector(
                new Action(delegate
     {
         if (GameController.IngameState.IngameUi.StashElement?.IsVisible == false)
         {
             WillBot.LogMessageCombo($"Stash element is not visible");
             return RunStatus.Failure;
         }
         WillBot.LogMessageCombo($"Stash element is visible");
         Thread.Sleep(1000);
         return RunStatus.Success;
     }),
                new Decorator(x => WillBot.Me.StashLabel.ItemOnGround.DistancePlayer > 60,
                              CommonBehavior.MoveTo(x => WillBot.Me.StashLabel.ItemOnGround.GridPos, spec: CommonBehavior.DefaultMovementSpec)),
                ClickStash(),
                new Action(delegate
     {
         Thread.Sleep(2000);
         return RunStatus.Success;
     })
                ));
 }
Exemplo n.º 2
0
        public static Composite OpenDeliriumMirror()
        {
            return(new Decorator(x => DoOpenDeliriumMirror(),
                                 CommonBehavior.MoveTo(x => Me.DeliriumMirror?.GridPos, x => Me.DeliriumMirror?.Pos, CommonBehavior.ActivateProximityMovementSpec)

                                 ));
        }
Exemplo n.º 3
0
 public static Composite MoveToAndOpenVendor()
 {
     return(new PrioritySelector(
                new Decorator(x => vendorLabelOnGround.ItemOnGround.DistancePlayer < 70,
                              ClickVendorLabelAction()),
                CommonBehavior.MoveTo(x => vendorLabelOnGround.ItemOnGround.GridPos, spec: CommonBehavior.DefaultMovementSpec),
                ClickVendorLabelAction()
                ));
 }
Exemplo n.º 4
0
        public static Composite InteractWithLabelOnGroundOpenable(Func <LabelOnGround> labelToOpenDel)
        {
            return(new Decorator(delegate
            {
                var labelOnGround = labelToOpenDel();

                if (labelOnGround != null && !CommonBehavior.DoCombat() && !CommonBehavior.DoLooting())
                {
                    return true;
                }
                return false;
            },
                                 new PrioritySelector(
                                     CommonBehavior.MoveTo(x => labelToOpenDel()?.ItemOnGround?.GridPos, x => labelToOpenDel()?.ItemOnGround?.Pos,
                                                           CommonBehavior.OpenablesMovementSpec),
                                     new Action(delegate
            {
                var label = labelToOpenDel();
                var chestComponent = label?.ItemOnGround.GetComponent <Chest>();
                if (chestComponent != null && chestComponent.IsStrongbox == true && chestComponent.IsLocked == true)
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && chestComponent?.IsLocked == true)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
                else if (chestComponent != null && chestComponent.IsStrongbox == false && chestComponent.DestroyingAfterOpen == true)
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && label != null)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
                else
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && label != null)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
            }))));
        }
Exemplo n.º 5
0
 public static Composite OpenMapDevice()
 {
     return(new PrioritySelector(
                new Action(delegate
     {
         if (GameController.IngameState.IngameUi.MapDevice.IsVisible == false)
         {
             WillBot.LogMessageCombo($"Map device is not visible");
             return RunStatus.Failure;
         }
         WillBot.LogMessageCombo($"Map device is visible");
         return RunStatus.Success;
     }),
                new Decorator(x => WillBot.Me.MapDeviceLabelOnGround.ItemOnGround.DistancePlayer > 60,
                              CommonBehavior.MoveTo(x => WillBot.Me.MapDeviceLabelOnGround.ItemOnGround.GridPos, spec: CommonBehavior.DefaultMovementSpec)),
                ClickMapDevice()
                ));
 }
Exemplo n.º 6
0
 public static Composite DoOpenNearbyChest()
 {
     return(new Decorator(delegate
     {
         LoadChestWhiteListIfNotLoaded();
         var chestToOpen = Me?.ClosestChest;
         if (chestToOpen == null)
         {
             return false;
         }
         var whitelisted = chestWhitelist != null && chestWhitelist.Contains(chestToOpen?.Path) == true;
         if (whitelisted)
         {
             return true;
         }
         return false;
         //var playerPos = GameController.Player.Pos;
         //var entityDistanceToPlayer =
         //    Math.Sqrt(Math.Pow(playerPos.X - entityPos.X, 2) + Math.Pow(playerPos.Y - entityPos.Y, 2));
         //var isTargetable = chestToOpen.GetComponent<Targetable>().isTargetable;
         //var isTargeted = chestToOpen.GetComponent<Targetable>().isTargeted;
         //return false;
     }, new PrioritySelector(
                              CommonBehavior.MoveTo(x => Me.ClosestChest?.GridPos, xyzPositionDelegate: x => Me.ClosestChest?.Pos,
                                                    spec: CommonBehavior.OpenablesMovementSpec),
                              new Action(delegate
     {
         var chestToOpen = Me.ClosestChest;
         var chestComponent = chestToOpen.GetComponent <Chest>();
         ControlTimer.Restart();
         while (ControlTimer.ElapsedMilliseconds < 3500 && chestComponent?.IsOpened == false)
         {
             var entityPos = chestToOpen.Pos;
             var entityScreenPos = Camera.WorldToScreen(entityPos.Translate(0, 0, 0));
             Mouse.SetCursorPosAndLeftOrRightClick(entityScreenPos, 80);
             Thread.Sleep(100);
         }
         return RunStatus.Failure;
     })
                              )));
 }
Exemplo n.º 7
0
        public static Composite DoLocalAreaTransition()
        {
            //sepearte between local, to corrupted etc. Handle accordingly.
            return(new Sequence(
                       new Inverter(CommonBehavior.MoveTo(x => areaTransitionBeforeTransition.areaTransitionGridPosition, spec: CommonBehavior.OpenablesMovementSpec)),

                       new Action(delegate
            {
                // Test if were actually close to the area transition
                if (GameController.Player.GridPos.Distance(areaTransitionBeforeTransition.areaTransitionGridPosition) > 35)
                {
                    WillBot.LogMessageCombo($"In trying to complete area transition. Movement to area transition must have been canceled");
                    return RunStatus.Failure;
                }
                areaHashBeforeTransition = GameController.Area.CurrentArea.Hash;

                islandIdBeforeTransition = areaTransitionBeforeTransition.locatedInIslandWithId;
                var closestAreaTransitionLabel = Me.ClosestAreaTransitionLabel;
                if (closestAreaTransitionLabel == null)
                {
                    WillBot.LogMessageCombo($"No area transition nearby");
                    return RunStatus.Failure;
                }
                labelTextOfAreaTransition = closestAreaTransitionLabel.Label.Text;
                ControlTimer.Restart();

                Vector2 prevGridPos = GameController.Player.GridPos;
                while (ControlTimer.ElapsedMilliseconds < 4000)
                {
                    Mouse.SetCursorPosAndLeftOrRightClick(closestAreaTransitionLabel.Label.GetClientRect(), Latency);
                    // Try to detect a jump in player gridpos
                    var currentGridPos = GameController.Player.GridPos;
                    if (currentGridPos.Distance(prevGridPos) > 20)
                    {
                        WillBot.LogMessageCombo($"detected large enough jump in grid pos. success");
                        Thread.Sleep(400);

                        // if local get zone map
                        // else initialize zone.. and add areatransition.
                        var zoneMapAfterTransition = WillBot.Mover.GetZoneMap();
                        var subMapAfterTransition = zoneMapAfterTransition.GetSubMap(GameController.Player.GridPos);
                        int islandIdAfterTransition = subMapAfterTransition.IslandId;
                        areaTransitionBeforeTransition.leadsToIslandWithId = islandIdAfterTransition;
                        areaTransitionBeforeTransition.hasBeenEntered = true;

                        if (Me.ClosestAreaTransitionLabel != null)
                        {
                            // verify that this is another area transition
                            var newKeyTuple = Me.ClosestAreaTransitionLabel.ItemOnGround.GridPos.ToIntTuple();
                            if (zoneMapAfterTransition.FoundAreaTransitions.ContainsKey(newKeyTuple))
                            {
                                //Already registered this area transition
                                WillBot.LogMessageCombo($"already have this area transition");
                            }
                            else
                            {
                                var transition = new AreaTransitionInfo(Me.ClosestAreaTransitionLabel.Label.Text, Me.ClosestAreaTransitionLabel.ItemOnGround.GridPos, islandIdAfterTransition);
                                transition.leadsToIslandWithId = islandIdBeforeTransition;
                                zoneMapAfterTransition.FoundAreaTransitions.Add(newKeyTuple, transition);
                            }
                        }
                        return RunStatus.Success;
                    }
                    prevGridPos = currentGridPos;
                    Thread.Sleep(100);
                }
                // time out can mean area transition that disappears + no movement during the transition
                // if it timed out but the area transition is gone
                return RunStatus.Failure;
            })

                       //new Action(delegate
                       //{
                       //    if (areaHashBeforeTransition != GameController.Area.CurrentArea.Hash)
                       //    {
                       //        areaTransitionBeforeTransition.isZoneTransition = true;
                       //        return RunStatus.Success;
                       //    }
                       //    else
                       //    {
                       //        var zoneMapAfterTransition = WillBot.Mover.GetZoneMap();
                       //        var subMapAfterTransition = zoneMapAfterTransition.GetSubMap(GameController.Player.GridPos);
                       //        int islandIdAfterTransition = subMapAfterTransition.IslandId;
                       //        areaTransitionBeforeTransition.leadsToIslandWithId = islandIdAfterTransition;
                       //        areaTransitionBeforeTransition.hasBeenEntered = true;

                       //        // Wait and try to add the area transition
                       //        ControlTimer.Restart();
                       //        while (ControlTimer.ElapsedMilliseconds < 6000)
                       //        {
                       //            areaTransitionAfterTransition = zoneMapAfterTransition.TryGetAreaTransition(Me.ClosestAreaTransitionLabel);
                       //            if (areaTransitionAfterTransition != null)
                       //            {
                       //                break;
                       //            }
                       //            Thread.Sleep(200);
                       //        }
                       //        if (areaTransitionAfterTransition == null) return RunStatus.Failure;
                       //        areaTransitionAfterTransition.hasBeenEntered = true;

                       //        areaTransitionAfterTransition.leadsToIslandWithId = islandIdBeforeTransition;

                       //        return RunStatus.Success;
                       //    }
                       //})

                       ));
        }
Exemplo n.º 8
0
        public static Composite DoCorruptedZoneTransition()
        {
            return(new Sequence(
                       new Inverter(CommonBehavior.MoveTo(x => areaTransitionBeforeTransition.areaTransitionGridPosition,
                                                          spec: CommonBehavior.OpenablesMovementSpec)),

                       new Action(delegate
            {
                // Test if were actually close to the area transition
                if (GameController.Player.GridPos.Distance(areaTransitionBeforeTransition.areaTransitionGridPosition) > 35)
                {
                    WillBot.LogMessageCombo($"In trying to complete area transition. Movement to area transition must have been canceled");
                    return RunStatus.Failure;
                }
                areaHashBeforeTransition = GameController.Area.CurrentArea.Hash;

                islandIdBeforeTransition = areaTransitionBeforeTransition.locatedInIslandWithId;
                var closestAreaTransitionLabel = Me.ClosestAreaTransitionLabel;
                if (closestAreaTransitionLabel == null)
                {
                    WillBot.LogMessageCombo($"No area transition nearby");
                    return RunStatus.Failure;
                }
                labelTextOfAreaTransition = closestAreaTransitionLabel.Label.Text;
                ControlTimer.Restart();

                Vector2 prevGridPos = GameController.Player.GridPos;
                while (ControlTimer.ElapsedMilliseconds < 4000)
                {
                    Mouse.SetCursorPosAndLeftOrRightClick(closestAreaTransitionLabel.Label.GetClientRect(), Latency);
                    // Try to detect a jump in player gridpos
                    var currentGridPos = GameController.Player.GridPos;
                    if (currentGridPos.Distance(prevGridPos) > 20)
                    {
                        WillBot.LogMessageCombo($"detected large enough jump in grid pos. success");
                        Thread.Sleep(400);
                        lock (MyLocks.UpdateTerrainDataLock)
                        {
                            //Issue is that AreaChange function run on another thread and will updateterraindata too..
                            // Just wait until this can be aquired since that should mean its done updating terrain data
                        }
                        var zoneMapAfterTransition = WillBot.Mover.GetZoneMap();
                        var subMapAfterTransition = zoneMapAfterTransition.GetSubMap(GameController.Player.GridPos);
                        int islandIdAfterTransition = subMapAfterTransition.IslandId;
                        areaTransitionBeforeTransition.leadsToIslandWithId = islandIdAfterTransition;
                        areaTransitionBeforeTransition.hasBeenEntered = true;

                        if (Me.ClosestAreaTransitionLabel != null)
                        {
                            // verify that this is another area transition
                            var newKeyTuple = Me.ClosestAreaTransitionLabel.ItemOnGround.GridPos.ToIntTuple();
                            if (zoneMapAfterTransition.FoundAreaTransitions.ContainsKey(newKeyTuple))
                            {
                                //Already registered this area transition
                                WillBot.LogMessageCombo($"already have this area transition");
                            }
                            else
                            {
                                var transition = new AreaTransitionInfo(Me.ClosestAreaTransitionLabel.Label.Text, Me.ClosestAreaTransitionLabel.ItemOnGround.GridPos, islandIdAfterTransition);
                                transition.leadsToIslandWithId = islandIdBeforeTransition;
                                transition.leadsToZoneWithAreaHash = areaHashBeforeTransition;
                                transition.transitionType = Me.ClosestAreaTransitionLabel.ItemOnGround.GetComponent <AreaTransition>().TransitionType;
                                zoneMapAfterTransition.FoundAreaTransitions.Add(newKeyTuple, transition);
                            }
                        }
                        return RunStatus.Success;
                    }
                    prevGridPos = currentGridPos;
                    Thread.Sleep(100);
                }
                // time out can mean area transition that disappears + no movement during the transition
                // if it timed out but the area transition is gone
                return RunStatus.Failure;
            })));
        }