示例#1
0
        public static Composite IdentifyUniquesInPlayerInventory()
        {
            // Until_x_  return success . Watch out in priorityselectors

            return(new Inverter(new UntilFailure(
                                    new Sequence(
                                        OpenStash(),
                                        new Action(delegate
            {
                var ret = TryGetDataForUnidUniqueInInventory();
                if (ret.Item1 == false)
                {
                    WillBot.LogMessageCombo("Unable to find more unique items to identify");
                    return RunStatus.Failure;
                }
                tempUniqueItemInInventory = ret.Item3;
                return RunStatus.Success;
            }),
                                        MapPrepBehavior.ApplyCurrencyItemToItem(() => ItemStrings.ScrollOfWisdom, () => tempUniqueItemInInventory.GetClientRect()),
                                        new Action(delegate
            {
                Thread.Sleep(300);
                return RunStatus.Success;
            })
                                        )

                                    )));
        }
示例#2
0
        public (bool, Vector2) FindPositionToExplore(Vector2 currentPosition)
        {
            // Check current grid first to see if it can be explored further
            var gridIAmInside = grids.Find(x => x.IsPositionInside(currentPosition));

            if (gridIAmInside.GetExploredFactor() < maxExploredFactor && gridIAmInside.RemainingToExploreSum > remainingExploreSumThreshold)
            {
                WillBot.LogMessageCombo($"Exploring inside current grid. Remaining explore sum: {gridIAmInside.RemainingToExploreSum}");
                // Find unexplored position inside this grid.
                return(gridIAmInside.FindUnexploredPosition());
            }
            // FindClosesGrid with explored factor below a certain x
            var testGrids = grids.OrderBy(x => x.DistanceToCenterFromPos(currentPosition)).ToList().Where(
                x => x.GetExploredFactor() < maxExploredFactor && x.RemainingToExploreSum > remainingExploreSumThreshold)?.ToList();

            if (testGrids == null || testGrids.Count == 0)
            {
                WillBot.LogMessageCombo($"Unable to find a grid to explore that satisfies exploration factor { maxExploredFactor}, and remaining explore sum: {remainingExploreSumThreshold}");
                return(false, new Vector2());
            }
            else
            {
                var unexploredPosition = testGrids.First().FindUnexploredPosition();
                WillBot.LogMessageCombo($"Found new grid to explore. Remaining explore sum: {testGrids.First().RemainingToExploreSum}");

                return(unexploredPosition);
            }
        }
示例#3
0
        public RunStatus FollowPath()
        {
            //Console.WriteLine("following path");
            var nextPath = pathFindingWrapper.GetNextPositionInCurrentPath(gameController.Player.GridPos);

            if (nextPath.Item1 == false)
            {
                // No more path points
                WillBot.LogMessageCombo($"Finished following path");
                //MoverHelper.ClickToStopCharacter();
                return(RunStatus.Failure);
            }
            //Vector3 worldPositionCharacter = gameController.Player.Pos;
            //var worldPositionOfPoint = point.GridToWorld();
            var    delta        = nextPath.Item2 - gameController.Player.GridPos;
            double angleToPoint = 0;

            delta.GetPolarCoordinates(out angleToPoint);
            MoverHelper.MouseAsJoystickNonSmooth(gameController, (float)(angleToPoint * 180 / Math.PI) + 45);
            while (WillBot.Me.TownPortal?.ItemOnGround?.GetComponent <Targetable>().isTargeted == true)
            {
                Console.WriteLine("Town portal is targeted. Adjusting angle to avoid");
                angleToPoint += 0.1;
                MoverHelper.MouseAsJoystickNonSmooth(gameController, (float)(angleToPoint * 180 / Math.PI) + 45);
            }
            InputWrapper.LeftMouseButtonDown();
            return(RunStatus.Running);
        }
示例#4
0
        public void TryAddAreaTransition(Vector2 playerPosition, LabelOnGround label)
        {
            try
            {
                int    currentIslandId    = GetSubMap(playerPosition).IslandId;
                var    keyTuple           = new Tuple <int, int>((int)label.ItemOnGround.GridPos.X, (int)label.ItemOnGround.GridPos.Y);
                string areaTransitionText = label?.Label?.Text?.ToLower() ?? "";
                foreach (var blackListedTransition in blackListedTransitions)
                {
                    if (areaTransitionText.Contains(blackListedTransition))
                    {
                        WillBot.LogMessageCombo($"Area transition is blacklisted {blackListedTransition}");
                        return;
                    }
                }

                WillBot.LogMessageCombo($"Area transition text: {areaTransitionText}");
                if (FoundAreaTransitions.ContainsKey(keyTuple) == false)
                {
                    var areaTransitionComponent = label.ItemOnGround.GetComponent <AreaTransition>();
                    var newAreaTransition       = new AreaTransitionInfo(label.Label.Text, label.ItemOnGround.GridPos, currentIslandId);
                    newAreaTransition.transitionType = areaTransitionComponent.TransitionType;

                    WillBot.LogMessageCombo("added area transition to zonemap");
                    FoundAreaTransitions.Add(keyTuple, new AreaTransitionInfo(label.Label.Text, label.ItemOnGround.GridPos, currentIslandId));
                }
            }
            catch (Exception ex)
            {
                WillBot.LogMessageCombo("Failed adding area transition " + ex.ToString());
            }
        }
示例#5
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;
     })
                ));
 }
示例#6
0
        public bool SetPath(Vector2 end)
        {
            ZoneMap zoneMap;
            var     areaHash      = gameController.Area.CurrentArea.Hash;
            bool    didGetZoneMap = zoneMaps.TryGetValue(areaHash, out zoneMap);

            if (didGetZoneMap == false)
            {
                WillBot.LogMessageCombo($"Unable to get zonemap with areaHash {areaHash}");
                return(false);
            }
            bool didFindPath = pathFindingWrapper.TryToFindPathWithGraph(gameController.Player.GridPos, end, zoneMap);

            // bool didFindPath = pathFindingWrapper.TryToFindPath(gameController.Player.GridPos, end, zoneMap);

            if (didFindPath == false)
            {
                WillBot.LogMessageCombo($"Unable to find a path to {end}"); //. Trying to update terrain data");
                                                                            // UpdateTerrainData();
                                                                            //return RunStatus.Failure;
                return(false);
            }
            else
            {
                WillBot.LogMessageCombo($"Found a path to {end}");
                //return RunStatus.Success;
                return(true);
            }
        }
示例#7
0
 public static void UpdateAreaTransitions()
 {
     if (Me.ClosestAreaTransitionLabel != null)
     {
         WillBot.LogMessageCombo("There is an area transition. Proceeding to trying to add it");
         WillBot.Mover.GetZoneMap()?.TryAddAreaTransition(GameController.Player.GridPos, Me.ClosestAreaTransitionLabel);
     }
 }
示例#8
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()
                ));
 }
示例#9
0
 private static void LoadChestWhiteListIfNotLoaded()
 {
     if (hasLoadedChestWhitelist == false)
     {
         hasLoadedChestWhitelist = true;
         try
         {
             chestWhitelist = File.ReadAllLines(WillBot.Plugin.DirectoryFullName + "\\chestWhitelist.txt").ToList();
         }
         catch (Exception)
         {
             WillBot.LogMessageCombo("Exception when loading chest white list. Recursive");
             File.Create(WillBot.Plugin.DirectoryFullName + "\\chestWhitelist.txt");
             hasLoadedChestWhitelist = false;
             LoadChestWhiteListIfNotLoaded();
         }
     }
 }
示例#10
0
        public static Composite Stashie()
        {
            return(new Decorator(x => DoStashing(),
                                 new Sequence(
                                     OpenStash(),
                                     new Action(delegate
            {
                // Thread.Sleep(3000);
                var inventory = WillBot.gameController.Game.IngameState.IngameUi.InventoryPanel[InventoryIndex.PlayerInventory];
                var invItems = inventory.VisibleInventoryItems;

                numberOfItemsInInventoryBeforeRunningStashing = (invItems == null) ? 0 : invItems.Count;
                WillBot.Me.StashieHasCompletedStashing = false;
                WillBot.LogMessageCombo($"Stashie: getting ready to press stashie hotkey");

                //InputWrapper.KeyPress(Keys.F6);
                //InputWrapper.KeyPress(Keys.F6);
                Input.KeyDown(Keys.F6);
                Thread.Sleep(40);
                Input.KeyUp(Keys.F6);
                ControlTimer.Restart();
                return RunStatus.Success;
            }),
                                     new Action(delegate
            {
                // Just set a timer ?
                while (ControlTimer.ElapsedMilliseconds < 15000 && WillBot.Me.StashieHasCompletedStashing == false)
                {
                    return RunStatus.Running;
                }
                Thread.Sleep(1000);
                Input.KeyUp(Keys.LControlKey);
                var inventory = WillBot.gameController.Game.IngameState.IngameUi.InventoryPanel[InventoryIndex.PlayerInventory];
                var invItems = inventory.VisibleInventoryItems;

                int numberOfInventoryItemsLeft = invItems == null ? 0 : invItems.Count;
                WillBot.Me.HasStashedItemsThisTownCycle = true;
                return RunStatus.Success;
            })
                                     )));
        }
示例#11
0
        public static Composite GetFirstPossibleMap()
        {
            return(new Action(delegate
            {
                WillBot.LogMessageCombo("Trying to get first possible map");
                int index = GetIndexOfFirstMapwithMaps(GameController.IngameState.IngameUi.MapStashMapIconsBox.Children);
                if (index == -1)
                {
                    WillBot.LogMessageCombo($"No maps. Tier finding function must have failed.");
                    Thread.Sleep(200);
                    return RunStatus.Failure;
                }
                var mapButtonRect = GameController.IngameState.IngameUi.MapStashMapIconsBox.GetChildAtIndex(index)?.GetChildAtIndex(0)?.GetChildAtIndex(0)?.GetClientRect();
                WillBot.LogMessageCombo($"Found map button rect: {mapButtonRect}");
                if (mapButtonRect == null)
                {
                    return RunStatus.Failure;
                }
                else
                {
                    EnsureMapStashMapButtonVisible((RectangleF)mapButtonRect);
                    Mouse.SetCursorPosAndLeftOrRightClick((RectangleF)mapButtonRect, Latency, randomClick: true);
                }
                Thread.Sleep(600);

                var mapRect = GameController.IngameState.IngameUi?.StashElement?.VisibleStash?.VisibleInventoryItems?.FirstOrDefault()?.GetClientRect();
                if (mapRect == null)
                {
                    return RunStatus.Failure;
                }
                Input.KeyDown(Keys.LControlKey);
                Thread.Sleep(10);
                Mouse.SetCursorPosAndLeftOrRightClick((RectangleF)mapRect, Latency, randomClick: true);
                Thread.Sleep(15);
                Input.KeyUp(Keys.LControlKey);
                Thread.Sleep(350);
                return RunStatus.Success;
            }));
        }
示例#12
0
 public static Composite ClickStash()
 {
     return(new Action(
                delegate
     {
         int latency = (int)GameController.IngameState.CurLatency;
         Mouse.SetCursorPosAndLeftOrRightClick(WillBot.Me.StashLabel.Label.GetClientRect(), latency);
         ControlTimer.Restart();
         while (ControlTimer.ElapsedMilliseconds < 4000 && WillBot.gameController.IngameState.IngameUi.StashElement.IsVisible == false)
         {
             Thread.Sleep(200);
         }
         if (WillBot.gameController.IngameState.IngameUi.StashElement.IsVisible == true)
         {
             WillBot.LogMessageCombo($"Clicked stash. StashElement is visible");
             return RunStatus.Success;
         }
         WillBot.LogMessageCombo($"Unable to click stash. Stashelement is not visible");
         return RunStatus.Failure;
     }
                ));
 }
示例#13
0
 public static Composite ClickMapDevice()
 {
     return(new Action(
                delegate
     {
         Thread.Sleep(400);     // If moving, wait to stop
         int latency = (int)GameController.IngameState.CurLatency;
         Mouse.SetCursorPosAndLeftOrRightClick(WillBot.Me.MapDeviceLabelOnGround.Label.GetClientRect(), latency);
         ControlTimer.Restart();
         while (ControlTimer.ElapsedMilliseconds < 3000 && WillBot.gameController.IngameState.IngameUi.MapDevice.IsVisible == false)
         {
             Thread.Sleep(200);
         }
         if (WillBot.gameController.IngameState.IngameUi.MapDevice.IsVisible == true)
         {
             WillBot.LogMessageCombo($"Successfully clicked mapdevice");
             return RunStatus.Success;
         }
         return RunStatus.Failure;
     }
                ));
 }
示例#14
0
        public static Composite SwitchToTab(StashIndexDelegate stashIndexDelegate)
        {
            return(new DecoratorContinue(delegate(object context)
            {
                visibleStashIndex = GetIndexOfCurrentVisibleTab();
                var tabIndex = stashIndexDelegate(context);
                WillBot.LogMessageCombo($"Switching to stash tab index: {tabIndex} from index {visibleStashIndex}");
                travelDistance = Math.Abs(tabIndex - visibleStashIndex);
                if (travelDistance == 0)
                {
                    WillBot.LogMessageCombo("Already on correct stash tab");
                    return false;
                }
                return true;
            }, new Sequence(

                                             //new Decorator(delegate (object context)
                                             //    {
                                             //        var tabIndex = stashIndexDelegate(context);
                                             //        travelDistance = Math.Abs(tabIndex - visibleStashIndex);
                                             //        if (travelDistance > 3)
                                             //        {
                                             //            WillBot.LogMessageCombo("Switching with dropdown menu");
                                             //            return true;
                                             //        }
                                             //        WillBot.LogMessageCombo("Switching with arrow keys");
                                             //        return false;


                                             //    }, SwitchToTabViaDropdownMenu(stashIndexDelegate)),
                                             SwitchToTabViaArrowKeys(stashIndexDelegate),
                                             new Action(delegate
            {
                Thread.Sleep(500);
                return RunStatus.Success;
            }))
                                         ));
        }
示例#15
0
 public static (bool, RectangleF, NormalInventoryItem) GetRectangleFForCurrencyItem(string currencyItemString)
 {
     try
     {
         var currencyStashTabItems = GameController?.Game?.IngameState?.IngameUi?.StashElement?.AllInventories[WillBot.Settings.CurrencyStashTabIndex]?.VisibleInventoryItems;
         if (currencyStashTabItems == null || currencyStashTabItems.Count == 0)
         {
             return(false, new RectangleF(), null);
         }
         //var currencyItem = currencyStashTabItems.Where(x => x?.Item?.Path?.Contains(currencyItemString) == true)?.FirstOrDefault();
         var currencyItem = currencyStashTabItems.Where(x => x?.Item?.GetComponent <Base>()?.Name?.ToLower()?.Contains(currencyItemString) == true)?.FirstOrDefault();
         if (currencyItem != null)
         {
             return(true, currencyItem.GetClientRect(), currencyItem);
         }
         return(false, new RectangleF(), null);
     }
     catch (Exception ex)
     {
         WillBot.LogMessageCombo(ex.ToString());
         return(false, new RectangleF(), null);
     }
 }
示例#16
0
        public static Composite OpenMapStashTier(IntDelegate minimumTierToRunDelegate, IntDelegate maximumTierToRunDelegate)
        {
            return(new Action(delegate(object context)
            {
                Thread.Sleep(300);
                int minimumMapTier = minimumTierToRunDelegate(context);
                int maximumMapTier = maximumTierToRunDelegate(context);
                // Amount of maps in tier is at: tierbar-> child(x) -> child(1) -> child(0).Text

                for (int i = minimumMapTier; i <= maximumMapTier; i++)
                {
                    int index = i > 9 ? i - 10 : i - 1;
                    var validTierBar = i > 9 ? GameController.IngameState.IngameUi.MapStashBottomTierBar : GameController.IngameState.IngameUi.MapStashTopTierBar;
                    if (validTierBar?.IsVisible == false)
                    {
                        WillBot.LogMessageCombo($"tier bar is null or is visible == false");
                        return RunStatus.Failure;
                    }
                    int amountOfMapsForCurrentTier = 0;

                    int.TryParse(validTierBar.GetChildAtIndex(index)?.GetChildAtIndex(1)?.GetChildAtIndex(0)?.Text ?? "0", out amountOfMapsForCurrentTier);

                    if (amountOfMapsForCurrentTier != 0)
                    {
                        var tierButtonRect = validTierBar?.GetChildAtIndex(index)?.GetChildAtIndex(2)?.GetClientRect();
                        if (tierButtonRect != null)
                        {
                            WillBot.LogMessageCombo($"Trying to open map stash tier { i}");
                            Mouse.SetCursorPosAndLeftOrRightClick((RectangleF)tierButtonRect, Latency);
                            Thread.Sleep(400);
                            return RunStatus.Success;
                        }
                    }
                }
                return RunStatus.Failure;
            }));
        }
示例#17
0
        public static (bool, AreaTransitionInfo) HasValidAreaTransitionByType(AreaTransitionType transitionType)
        {
            int currentIslandId = WillBot.Mover.GetZoneMap()?.GetSubMap(GameController.Player.GridPos)?.IslandId ?? -1;

            if (currentIslandId == -1)
            {
                WillBot.LogMessageCombo($"Unable to get any island id when trying to get area transition.");
                return(false, null);
            }
            var closestAreaTransitionsWithinCurrentIsland = WillBot.Mover.GetZoneMap().FoundAreaTransitions.Where(x => x.Value.locatedInIslandWithId == currentIslandId)?.
                                                            OrderBy(x => x.Value.areaTransitionGridPosition.DistanceSquared(GameController.Player.GridPos))?.ToList();

            if (closestAreaTransitionsWithinCurrentIsland == null)
            {
                return(false, null);
            }

            foreach (var transition in closestAreaTransitionsWithinCurrentIsland)
            {
                switch (transitionType)
                {
                case AreaTransitionType.Normal:
                    break;

                case AreaTransitionType.Local:
                    if (transition.Value.hasBeenEntered == false && transition.Value.leadsToIslandWithId < 1)
                    {
                        WillBot.LogMessageCombo($"Found transition which has not been entered and no valid leads to island id");
                        return(true, transition.Value);
                    }
                    // if transition leads to island with less explored than current -> go
                    else if (transition.Value.leadsToIslandWithId > 0 && transition.Value.leadsToIslandWithId != currentIslandId)
                    {
                        float currentSubMapExploration = WillBot.Mover.GetPercentOfCurrentSubMapExplored();
                        //   float currentSubMapExploration = WillBot.Mover.GetZoneMap().GetSubMap(currentIslandId)?.Exploration?.ExploredFactor ?? 0;
                        float transitionSubMapExploration = WillBot.Mover.GetZoneMap().GetSubMap(transition.Value.leadsToIslandWithId)?.Exploration?.ExploredFactor ?? 0;

                        if (transitionSubMapExploration < currentSubMapExploration && currentSubMapExploration > 80)
                        {
                            WillBot.LogMessageCombo($"Found transition that leads to a less exlored submap {transitionSubMapExploration}  than current {currentSubMapExploration} ");
                            return(true, transition.Value);
                        }
                    }
                    break;

                case AreaTransitionType.NormalToCorrupted:

                    if (transition.Value.hasBeenEntered == false)
                    {
                        WillBot.LogMessageCombo($"Entering corrupted zone which has not been entered before");
                        return(true, transition.Value);
                    }
                    break;

                case AreaTransitionType.CorruptedToNormal:
                    // Exit the corrupted zone after some goals have been accomplished...
                    // Perhaps check for monsters remaining == 0 ?
                    float currentZoneExplored = WillBot.Mover.GetPercentOfZoneExplored();
                    if (currentZoneExplored > 94)
                    {
                        return(true, transition.Value);
                    }
                    break;
                }
            }
            return(false, null);
        }
示例#18
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;
                       //    }
                       //})

                       ));
        }
示例#19
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;
            })));
        }
示例#20
0
        private static Composite SwitchToTabViaDropdownMenu(StashIndexDelegate stashIndexDelegate)
        {
            return(new Action(delegate(object context)
            {
                var tabIndex = stashIndexDelegate(context);
                var viewAllTabsButton = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashButton;
                var dropdownMenu = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashPanel;
                var allTabsButton = viewAllTabsButton.GetClientRect();
                var slider = stashcount > MAXSHOWN_SIDEBARSTASHTABS;
                if (!dropdownMenu.IsVisible)
                {
                    Thread.Sleep(100);
                    Mouse.SetCursorPosAndLeftOrRightClick(allTabsButton, Latency);
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 1500 && !dropdownMenu.IsVisible)
                    {
                        //WillBot.LogMessageCombo("Waiting for dropdownmenu visible. Waited for {0}", ControlTimer.ElapsedMilliseconds);
                        Thread.Sleep(50);
                    }
                    //wait for the dropdown menu to become visible
                    if (!dropdownMenu.IsVisible)
                    {
                        WillBot.basePlugin.LogError($"Error in opening DropdownMenu.", 5);
                        return RunStatus.Failure;
                    }
                }
                RectangleF tabPos;
                // Make sure that we are scrolled to the top in the menu.
                if (slider)
                {
                    for (int i = 0; i < stashcount - MAXSHOWN_SIDEBARSTASHTABS + 1; ++i)
                    {
                        Input.KeyDown(Keys.Left);
                        Thread.Sleep(1);
                        Input.KeyUp(Keys.Left);
                        Thread.Sleep(1);
                    }
                }
                //get clickposition of tab label
                for (int i = 0; i <= tabIndex; i++)
                {
                    Input.KeyDown(Keys.Right);
                    Thread.Sleep(2);
                    Input.KeyUp(Keys.Right);
                    Thread.Sleep(2);
                }
                //enter-key Method  (There is a bug where the stash rect does not highlight (not possible to enter press))
                //Input.KeyDown(Keys.Enter);
                //Thread.Sleep(1);
                //Input.KeyUp(Keys.Enter);
                //Thread.Sleep(1);

                //reset Sliderposition
                if (slider)
                {
                    if (!dropdownMenu.IsVisible)
                    {
                        //opening DropdownMenu
                        Input.SetCursorPos(allTabsButton.Center);
                        Thread.Sleep(10);
                        Input.MouseMove();
                        Input.LeftDown();
                        Thread.Sleep(1);
                        Input.LeftUp();
                        Thread.Sleep(10);
                        // wait for the dropdown menu to become visible.
                        for (int count = 0; !dropdownMenu.IsVisible && count <= 20; ++count)
                        {
                            Thread.Sleep(50);
                        }
                        if (!dropdownMenu.IsVisible)
                        {
                            WillBot.basePlugin.LogError($"Error in Scrolling back to the top.", 5);
                            return RunStatus.Failure;
                        }
                    }
                    //"scrolling" back up
                    for (int i = 0; i < stashcount - MAXSHOWN_SIDEBARSTASHTABS + 1; ++i)
                    {
                        Input.KeyDown(Keys.Left);
                        Thread.Sleep(1);
                        Input.KeyUp(Keys.Left);
                        Thread.Sleep(1);
                    }
                }
                if (GetIndexOfCurrentVisibleTab() == tabIndex)
                {
                    WillBot.LogMessageCombo("Switched to correct tab via drop down");
                    return RunStatus.Success;
                }
                return RunStatus.Failure;
            }));
        }