Beispiel #1
0
 private bool IsPortalTargeted(LabelOnGround portalLabel)
 {
     return(GameController.IngameState.UIHoverElement.Address ==
            portalLabel.Label.Address || // this is the right one
            portalLabel?.ItemOnGround?.HasComponent <Targetable>() == true &&
            portalLabel?.ItemOnGround?.GetComponent <Targetable>()?.isTargeted == true);
 }
Beispiel #2
0
        private void DrawBorder(LabelOnGround entityLabel)
        {
            IngameUIElements ui = GameController.Game.IngameState.IngameUi;

            if (entityLabel.IsVisible)
            {
                RectangleF rect = entityLabel.Label.GetClientRect();
                if ((ui.OpenLeftPanel.IsVisible && ui.OpenLeftPanel.GetClientRect().Intersects(rect)) ||
                    (ui.OpenRightPanel.IsVisible && ui.OpenRightPanel.GetClientRect().Intersects(rect)))
                {
                    return;
                }


                ColorNode borderColor = Settings.BorderSettings.BorderColor;
                if (!entityLabel.CanPickUp)
                {
                    borderColor = Settings.BorderSettings.NotMyItemBorderColor;
                    TimeSpan timeLeft = entityLabel.TimeLeft;
                    if (Settings.BorderSettings.ShowTimer && timeLeft.TotalMilliseconds > 0)
                    {
                        borderColor = Settings.BorderSettings.CantPickUpBorderColor;
                        Graphics.DrawText(timeLeft.ToString(@"mm\:ss"), Settings.BorderSettings.TimerTextSize, rect.TopRight.Translate(4, 0));
                    }
                }
                Graphics.DrawFrame(rect, Settings.BorderSettings.BorderWidth, borderColor);
            }
        }
Beispiel #3
0
        private IEnumerator PickItem(LabelOnGround itemToPick, RectangleF window, bool onlyMoveMouse)
        {
            var centerOfLabel = itemToPick?.Label?.GetClientRect().Center + window.TopLeft;

            if (!centerOfLabel.HasValue)
            {
                yield break;
            }
            if (centerOfLabel.Value.X == 0 || centerOfLabel.Value.Y == 0)
            {
                yield break;
            }
            if (float.IsNaN(centerOfLabel.Value.X) || float.IsNaN(centerOfLabel.Value.Y))
            {
                yield break;
            }

            Input.SetCursorPos(centerOfLabel.Value);

            if (onlyMoveMouse)
            {
                yield break;
            }
            Input.Click(MouseButtons.Left);

            DebugWindow.LogDebug($"SimplePickIt.PickItem -> {DateTime.Now:mm:ss.fff} clicked position x: {centerOfLabel.Value.X} y: {centerOfLabel.Value.Y}");
        }
Beispiel #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());
            }
        }
Beispiel #5
0
        public static bool SetCursorPosAndLeftOrRightClick(LabelOnGround labelOnGround, int extraDelay, MyMouseClicks clickType = MyMouseClicks.LeftClick, bool useCache = true, bool randomClick = false)
        {
            try
            {
                var label = labelOnGround?.Label;
                if (label == null)
                {
                    return(false);
                }

                RectangleF clientRect;
                if (useCache)
                {
                    clientRect = label.GetClientRectCache;
                }
                else
                {
                    clientRect = label.GetClientRect();
                }
                return(SetCursorPosAndLeftOrRightClick(clientRect, extraDelay, clickType: clickType, randomClick: randomClick));
            }
            catch
            {
                return(false);
            }
        }
Beispiel #6
0
        private bool IsPortalNearby(LabelOnGround portalLabel, LabelOnGround pickItItem)
        {
            if (portalLabel == null || pickItItem == null)
            {
                return(false);
            }
            var rect1 = portalLabel.Label.GetClientRectCache;
            var rect2 = pickItItem.Label.GetClientRectCache;

            rect1.Inflate(100, 100);
            rect2.Inflate(100, 100);
            return(rect1.Intersects(rect2));
        }
Beispiel #7
0
 public AreaTransitionInfo TryGetAreaTransition(LabelOnGround label)
 {
     try
     {
         var gridPosition = label.ItemOnGround.GridPos;
         var keyTuple     = new Tuple <int, int>((int)gridPosition.X, (int)gridPosition.Y);
         return(FoundAreaTransitions[keyTuple]);
     }
     catch
     {
         return(null);
     }
 }
Beispiel #8
0
 public static Composite FindVendor()
 {
     return(new PrioritySelector(
                new Action(delegate
     {
         if (WillBot.Me.ZanaHideoutVendor == null)
         {
             return RunStatus.Failure;
         }
         vendorLabelOnGround = WillBot.Me.ZanaHideoutVendor;
         return RunStatus.Success;
     }),
                new Action(delegate
     {
         if (WillBot.Me.NavaliHideoutVendor == null)
         {
             return RunStatus.Failure;
         }
         vendorLabelOnGround = WillBot.Me.NavaliHideoutVendor;
         return RunStatus.Success;
     })));
 }
Beispiel #9
0
        public CustomItem(LabelOnGround item, FilesContainer fs, float distance, Dictionary <string, int> weightsRules, bool isMetamorphItem = false)
        {
            if (isMetamorphItem)
            {
                IsMetaItem    = true;
                LabelOnGround = item;
                Distance      = distance;
                var itemItemOnGround = item.ItemOnGround;
                var worldIcon        = itemItemOnGround?.GetComponent <MinimapIcon>();
                if (worldIcon == null)
                {
                    return;
                }
                //var groundItem = worldItem.ItemEntity;
                WorldIcon  = worldIcon;
                GroundItem = itemItemOnGround;
                Path       = GroundItem?.Path;

                if (Path != null && Path.Length < 1)
                {
                    DebugWindow.LogMsg($"World2: {worldIcon.Address:X} P: {Path}", 2);
                    DebugWindow.LogMsg($"Ground2: {GroundItem.Address:X} P {Path}", 2);
                    return;
                }

                IsTargeted = () =>
                {
                    var isTargeted = itemItemOnGround.GetComponent <Targetable>()?.isTargeted;
                    return(isTargeted != null && (bool)isTargeted);
                };

                var baseItemType = fs.BaseItemTypes.Translate(Path);

                if (baseItemType != null)
                {
                    ClassName = baseItemType.ClassName;
                    BaseName  = baseItemType.BaseName;
                    Width     = baseItemType.Width;
                    Height    = baseItemType.Height;
                    if (weightsRules.TryGetValue(BaseName, out var w))
                    {
                        Weight = w;
                    }
                }

                IsValid = true;
            }
            else
            {
                isMetamorphItem = false;
                LabelOnGround   = item;
                Distance        = distance;
                var itemItemOnGround = item.ItemOnGround;
                var worldItem        = itemItemOnGround?.GetComponent <WorldItem>();
                if (worldItem == null)
                {
                    return;
                }
                var groundItem = worldItem.ItemEntity;
                GroundItem = groundItem;
                Path       = groundItem?.Path;
                if (GroundItem == null)
                {
                    return;
                }

                if (Path != null && Path.Length < 1)
                {
                    DebugWindow.LogMsg($"World: {worldItem.Address:X} P: {Path}", 2);
                    DebugWindow.LogMsg($"Ground: {GroundItem.Address:X} P {Path}", 2);
                    return;
                }

                IsTargeted = () =>
                {
                    var isTargeted = itemItemOnGround.GetComponent <Targetable>()?.isTargeted;
                    return(isTargeted != null && (bool)isTargeted);
                };

                var baseItemType = fs.BaseItemTypes.Translate(Path);

                if (baseItemType != null)
                {
                    ClassName = baseItemType.ClassName;
                    BaseName  = baseItemType.BaseName;
                    Width     = baseItemType.Width;
                    Height    = baseItemType.Height;
                    if (weightsRules.TryGetValue(BaseName, out var w))
                    {
                        Weight = w;
                    }
                }

                var WeaponClass = new List <string>
                {
                    "One Hand Mace",
                    "Two Hand Mace",
                    "One Hand Axe",
                    "Two Hand Axe",
                    "One Hand Sword",
                    "Two Hand Sword",
                    "Thrusting One Hand Sword",
                    "Bow",
                    "Claw",
                    "Dagger",
                    "Sceptre",
                    "Staff",
                    "Wand"
                };

                if (GroundItem.HasComponent <Quality>())
                {
                    var quality = GroundItem.GetComponent <Quality>();
                    Quality = quality.ItemQuality;
                }

                if (GroundItem.HasComponent <Base>())
                {
                    var @base = GroundItem.GetComponent <Base>();
                    IsElder  = @base.isElder;
                    IsShaper = @base.isShaper;
                }

                if (GroundItem.HasComponent <Mods>())
                {
                    var mods = GroundItem.GetComponent <Mods>();
                    Rarity       = mods.ItemRarity;
                    IsIdentified = mods.Identified;
                    ItemLevel    = mods.ItemLevel;
                    IsFractured  = mods.HaveFractured;
                }

                if (GroundItem.HasComponent <Sockets>())
                {
                    var sockets = GroundItem.GetComponent <Sockets>();
                    IsRGB       = sockets.IsRGB;
                    Sockets     = sockets.NumberOfSockets;
                    LargestLink = sockets.LargestLinkSize;
                }

                if (WeaponClass.Any(ClassName.Equals))
                {
                    IsWeapon = true;
                }

                MapTier = GroundItem.HasComponent <Map>() ? GroundItem.GetComponent <Map>().Tier : 0;
                IsValid = true;
            }
        }
Beispiel #10
0
        private IEnumerator TryToPickV2(CustomItem pickItItem, LabelOnGround portalLabel)
        {
            if (!pickItItem.IsValid)
            {
                _fullWork = true;
                //LogMessage("PickItem is not valid.", 5, Color.Red);
                yield break;
            }

            var centerOfItemLabel     = pickItItem.LabelOnGround.Label.GetClientRectCache.Center;
            var rectangleOfGameWindow = GameController.Window.GetWindowRectangleTimeCache;

            _clickWindowOffset = rectangleOfGameWindow.TopLeft;
            rectangleOfGameWindow.Inflate(-36, -36);
            centerOfItemLabel.X += rectangleOfGameWindow.Left;
            centerOfItemLabel.Y += rectangleOfGameWindow.Top;
            if (!rectangleOfGameWindow.Intersects(new RectangleF(centerOfItemLabel.X, centerOfItemLabel.Y, 3, 3)))
            {
                _fullWork = true;
                //LogMessage($"Label outside game window. Label: {centerOfItemLabel} Window: {rectangleOfGameWindow}", 5, Color.Red);
                yield break;
            }

            var tryCount = 0;

            while (tryCount < 3)
            {
                var completeItemLabel = pickItItem.LabelOnGround?.Label;

                if (completeItemLabel == null)
                {
                    if (tryCount > 0)
                    {
                        //LogMessage("Probably item already picked.", 3);
                        yield break;
                    }

                    //LogError("Label for item not found.", 5);
                    yield break;
                }

                Vector2 vector2;
                if (IsPortalNearby(portalLabel, pickItItem.LabelOnGround))
                {
                    vector2 = completeItemLabel.GetClientRect().ClickRandom() + _clickWindowOffset;
                }
                else
                {
                    vector2 = completeItemLabel.GetClientRect().Center + _clickWindowOffset;
                }

                if (!rectangleOfGameWindow.Intersects(new RectangleF(vector2.X, vector2.Y, 3, 3)))
                {
                    _fullWork = true;
                    //LogMessage($"x,y outside game window. Label: {centerOfItemLabel} Window: {rectangleOfGameWindow}", 5, Color.Red);
                    yield break;
                }

                Input.SetCursorPos(vector2);
                yield return(_wait2Ms);

                if (pickItItem.IsTargeted())
                {
                    // in case of portal nearby do extra checks with delays
                    if (IsPortalNearby(portalLabel, pickItItem.LabelOnGround) && !IsPortalTargeted(portalLabel))
                    {
                        yield return(new WaitTime(25));

                        if (IsPortalNearby(portalLabel, pickItItem.LabelOnGround) && !IsPortalTargeted(portalLabel))
                        {
                            Input.Click(MouseButtons.Left);
                        }
                    }
                    else if (!IsPortalNearby(portalLabel, pickItItem.LabelOnGround))
                    {
                        Input.Click(MouseButtons.Left);
                    }
                }

                yield return(_toPick);

                tryCount++;
            }

            tryCount = 0;

            while (GameController.Game.IngameState.IngameUi.ItemsOnGroundLabelsVisible.FirstOrDefault(
                       x => x.Address == pickItItem.LabelOnGround.Address) != null && tryCount < 6)
            {
                tryCount++;
            }
        }
Beispiel #11
0
 public TaskNode(LabelOnGround labelOnGround, int bounds, TaskNodeType type = TaskNodeType.Movement)
 {
     LabelOnGround = labelOnGround;
     Type          = type;
     Bounds        = bounds;
 }
Beispiel #12
0
        private IEnumerator PickItems()
        {
            var           window      = GameController.Window.GetWindowRectangle();
            Stopwatch     waitingTime = new Stopwatch();
            int           highlight   = 0;
            int           limit       = 0;
            LabelOnGround nextItem    = null;

            var itemList = GetItemToPick();

            if (itemList == null)
            {
                yield break;
            }

            do
            {
                if (GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible)
                {
                    yield break;
                }

                if (Settings.MinLoop.Value != 0)
                {
                    if (Settings.MaxLoop.Value < Settings.MinLoop.Value)
                    {
                        int temp = Settings.MaxLoop.Value;
                        Settings.MaxLoop.Value = Settings.MinLoop.Value;
                        Settings.MinLoop.Value = temp;
                    }
                    if (highlight == 0)
                    {
                        limit = Random.Next(Settings.MinLoop.Value, Settings.MaxLoop.Value + 1);
                    }
                    if (highlight == limit - 1)
                    {
                        Input.KeyDown(Settings.HighlightToggle.Value);
                        Thread.Sleep(Random.Next(20, 25));
                        Input.KeyUp(Settings.HighlightToggle.Value);
                        Thread.Sleep(Random.Next(20, 25));
                        Input.KeyDown(Settings.HighlightToggle.Value);
                        Thread.Sleep(Random.Next(20, 25));
                        Input.KeyUp(Settings.HighlightToggle.Value);
                        Thread.Sleep(Random.Next(20, 25));
                        highlight = -1;
                    }
                    highlight++;
                }

                if (itemList.Count() > 1)
                {
                    itemList = itemList.Where(label => label != null).Where(label => label.ItemOnGround != null).OrderBy(label => label.ItemOnGround.DistancePlayer).ToList();
                }

                nextItem = itemList[0];

                if (nextItem.ItemOnGround.DistancePlayer > Settings.Range.Value)
                {
                    yield break;
                }

                var centerOfLabel = nextItem?.Label?.GetClientRect().Center
                                    + window.TopLeft
                                    + new Vector2(Random.Next(0, 2), Random.Next(0, 2));
                if (!centerOfLabel.HasValue)
                {
                    yield break;
                }

                Input.SetCursorPos(centerOfLabel.Value);
                Thread.Sleep(Random.Next(15, 20));
                Input.Click(MouseButtons.Left);

                waitingTime.Start();
                while (nextItem.ItemOnGround.IsTargetable && waitingTime.ElapsedMilliseconds < Settings.MaxWaitTime.Value)
                {
                    ;
                }
                waitingTime.Reset();

                if (!nextItem.ItemOnGround.IsTargetable)
                {
                    itemList.RemoveAt(0);
                }
            } while (Input.GetKeyState(Settings.PickUpKey.Value) && itemList.Any());

            yield break;
        }
Beispiel #13
0
        public CustomItem(LabelOnGround item, FilesContainer fs, float distance, Dictionary <string, int> weightsRules)
        {
            LabelOnGround = item;
            Distance      = distance;
            var itemItemOnGround = item.ItemOnGround;
            var worldItem        = itemItemOnGround?.GetComponent <WorldItem>();

            if (worldItem == null)
            {
                return;
            }
            var groundItem = worldItem.ItemEntity;

            GroundItem = groundItem;
            Path       = groundItem?.Path;
            if (GroundItem == null)
            {
                return;
            }

            if (Path != null && Path.Length < 1)
            {
                DebugWindow.LogMsg($"World: {worldItem.Address:X} P: {Path}", 2);
                DebugWindow.LogMsg($"Ground: {GroundItem.Address:X} P {Path}", 2);
                return;
            }

            IsTargeted = () => itemItemOnGround?.GetComponent <Targetable>()?.isTargeted == true;

            var baseItemType = fs.BaseItemTypes.Translate(Path);

            if (baseItemType != null)
            {
                ClassName = baseItemType.ClassName;
                BaseName  = baseItemType.BaseName;
                Width     = baseItemType.Width;
                Height    = baseItemType.Height;
                if (weightsRules.TryGetValue(BaseName, out var w))
                {
                    Weight = w;
                }
                if (ClassName.StartsWith("Heist"))
                {
                    IsHeist = true;
                }
            }

            var WeaponClass = new List <string>
            {
                "One Hand Mace",
                "Two Hand Mace",
                "One Hand Axe",
                "Two Hand Axe",
                "One Hand Sword",
                "Two Hand Sword",
                "Thrusting One Hand Sword",
                "Bow",
                "Claw",
                "Dagger",
                "Rune Dagger",
                "Sceptre",
                "Staff",
                "Wand"
            };

            if (GroundItem.HasComponent <Quality>())
            {
                var quality = GroundItem.GetComponent <Quality>();
                Quality = quality.ItemQuality;
            }

            if (GroundItem.HasComponent <Base>())
            {
                var @base = GroundItem.GetComponent <Base>();
                IsElder    = @base.isElder;
                IsShaper   = @base.isShaper;
                IsHunter   = @base.isHunter;
                IsRedeemer = @base.isRedeemer;
                IsCrusader = @base.isCrusader;
                IsWarlord  = @base.isWarlord;
            }

            if (GroundItem.HasComponent <Mods>())
            {
                var mods = GroundItem.GetComponent <Mods>();
                Rarity       = mods.ItemRarity;
                IsIdentified = mods.Identified;
                ItemLevel    = mods.ItemLevel;
                IsFractured  = mods.HaveFractured;
                IsVeiled     = mods.ItemMods.Any(m => m.DisplayName.Contains("Veil"));
            }

            if (GroundItem.HasComponent <Sockets>())
            {
                var sockets = GroundItem.GetComponent <Sockets>();
                IsRGB       = sockets.IsRGB;
                Sockets     = sockets.NumberOfSockets;
                LargestLink = sockets.LargestLinkSize;
            }

            if (GroundItem.HasComponent <Weapon>())
            {
                IsWeapon = true;
            }

            MapTier = GroundItem.HasComponent <Map>() ? GroundItem.GetComponent <Map>().Tier : 0;
            IsValid = true;
        }
Beispiel #14
0
        public CustomItem(LabelOnGround item)
        {
            CompleteItem = item;
            var groundItem = item.ItemOnGround.GetComponent <WorldItem>().ItemEntity;

            GroundItem = groundItem;
            Path       = groundItem.Path;
            var baseItemType = BasePlugin.API.GameController.Files.BaseItemTypes.Translate(Path);

            ClassName = baseItemType.ClassName;
            BaseName  = baseItemType.BaseName;
            Width     = baseItemType.Width;
            Height    = baseItemType.Height;
            var WeaponClass = new List <string>
            {
                "One Hand Mace",
                "Two Hand Mace",
                "One Hand Axe",
                "Two Hand Axe",
                "One Hand Sword",
                "Two Hand Sword",
                "Thrusting One Hand Sword",
                "Bow",
                "Claw",
                "Dagger",
                "Sceptre",
                "Staff",
                "Wand"
            };

            if (groundItem.HasComponent <Quality>())
            {
                var quality = groundItem.GetComponent <Quality>();
                Quality = quality.ItemQuality;
            }

            if (groundItem.HasComponent <Base>())
            {
                var @base = groundItem.GetComponent <Base>();
                IsElder  = @base.isElder;
                IsShaper = @base.isShaper;
            }


            if (groundItem.HasComponent <Mods>())
            {
                var mods = groundItem.GetComponent <Mods>();
                Rarity        = mods.ItemRarity;
                IsIdentified  = mods.Identified;
                ItemLevel     = mods.ItemLevel;
                FracturedMods = mods.FracturedMods;
                IsVeiled      = false;
                foreach (ItemMod m in mods.ItemMods)
                {
                    IsVeiled = IsVeiled | m.Name.Contains("Veiled");
                }
            }

            if (groundItem.HasComponent <Sockets>())
            {
                try
                {
                    var sockets = groundItem.GetComponent <Sockets>();
                    IsRGB       = sockets.IsRGB;
                    Sockets     = sockets.NumberOfSockets;
                    LargestLink = sockets.LargestLinkSize;
                }
                catch { }
            }

            if (groundItem.HasComponent <Stack>())
            {
                var stack = groundItem.GetComponent <Stack>();
                Stack = stack.Size;
            }

            if (ClassName.Contains("Incubator"))
            {
                IsIncubator = true;
            }

            if (WeaponClass.Any(ClassName.Equals))
            {
                IsWeapon = true;
            }

            MapTier = groundItem.HasComponent <Map>() ? groundItem.GetComponent <Map>().Tier : 0;
        }