Example #1
0
        private IEnumerator FindItemToPick()
        {
            if (!GameController.Window.IsForeground())
            {
                yield break;
            }
            if (UpdateCacheList.Value == null)
            {
                yield break;
            }
            var window    = GameController.Window.GetWindowRectangleTimeCache;
            var rect      = new RectangleF(window.X, window.X, window.X + window.Width, window.Y + window.Height);
            var playerPos = GameController.Player.GridPos;

            GameController.Debug["PickIt"] = UpdateCacheList?.Value;
            var rectangleOfGameWindow = GameController.Window.GetWindowRectangleTimeCache;

            rectangleOfGameWindow.Inflate(-36, -36);
            var pickUpThisItem = UpdateCacheList?.Value.FirstOrDefault(x =>
                                                                       DoWePickThis(x) && x.Distance < Settings.PickupRange && x.GroundItem != null &&
                                                                       rectangleOfGameWindow.Intersects(new RectangleF(x.LabelOnGround.Label.GetClientRectCache.Center.X,
                                                                                                                       x.LabelOnGround.Label.GetClientRectCache.Center.Y, 3, 3)) && Misc.CanFitInventory(x));

            if (Input.GetKeyState(Settings.PickUpKey.Value) ||
                CanLazyLoot() && ShouldLazyLoot(pickUpThisItem))
            {
                yield return(TryToPickV2(pickUpThisItem));

                FullWork = true;
            }
        }
Example #2
0
        public override Job Tick()
        {
            SetFollowerModeValues();
            _currentTime = DateTime.UtcNow;

            if (Input.GetKeyState(Keys.Escape))
            {
                _followerCoroutine.Pause();
                _networkActivityCoroutine.Pause();
                _followerShouldWork         = false;
                _networkCoroutineShouldWork = false;
                if (_httpListener.IsListening)
                {
                    LogMessage($"****** Tick: stopping the listener ", 1);
                    _httpListener.Stop();
                }
            }

            ;

            if (Input.GetKeyState(Settings.NetworkActivityPropagateWorkingChangeKey.Value))
            {
                ChangeNetworkActivityPropagateWorking();
            }

            if (Input.GetKeyState(Settings.NetworkActivityPropagateAggressivenessModeChangeKey.Value))
            {
                ChangeAggressivenessModeToPropagate();
            }

            if (Input.GetKeyState(Settings.NetworkActivityPropagateEnterInstanceKey.Value))
            {
                EnterInstancePropagate();
            }

            if (Input.GetKeyState(Settings.NetworkActivityActivateKey.Value))
            {
                // LogMessage($"****** Tick: resuming _networkActivityCoroutine", 1);
                _networkCoroutineShouldWork = true;
                _networkActivityCoroutine.Resume();
            }

            if (Input.GetKeyState(Settings.FollowerActivateKey.Value))
            {
                if (_networkActivityCoroutine.Running)
                {
                    LogMessage(
                        $"****** You tried to start the follower activity when network activity is running. Stop network activity first",
                        1);
                    LogMessage($"****** Skipping starting the follower activity ", 1);
                    return(null);
                }

                _debugTimer.Restart();
                _followerCoroutine.Resume();
                _followerShouldWork = true;
            }

            return(null);
        }
Example #3
0
        public override bool Initialise()
        {
            base.Initialise();

            Input.RegisterKey(Settings.UnstackHotkey.Value);

            Settings.Enable.OnValueChanged += (sender, value) => { _SaveSettings(); };
            Settings.PreserveOriginalCursorPosition.OnValueChanged += (sender, value) => { _SaveSettings(); };
            Settings.ReverseMouseButtons.OnValueChanged            += (sender, value) => { _SaveSettings(); };

            Settings.UnstackHotkey.OnValueChanged += () =>
            {
                Input.RegisterKey(Settings.UnstackHotkey);
                _SaveSettings();
            };

            _WaitBetweenClicks = new WaitTime(Clamp(Settings.TimeBetweenClicks.Value, 50, 200));
            Settings.TimeBetweenClicks.OnValueChanged += (sender, i) =>
            {
                _WaitBetweenClicks = new WaitTime(Clamp(Settings.TimeBetweenClicks, 50, 200));
                _SaveSettings();
            };

            return(true);
        }
        public override bool Initialise()
        {
            Input.RegisterKey(Keys.F10);

            Input.ReleaseKey += (sender, keys) =>
            {
                if (keys == Keys.F10)
                {
                    Settings.Enable.Value = !Settings.Enable;
                }
            };

            GameController.LeftPanel.WantUse(() => Settings.Enable);
            CalcXp = new TimeCache <bool>(() =>
            {
                partytime += time;
                time       = 0;
                CalculateXp();
                var areaCurrentArea = GameController.Area.CurrentArea;

                if (areaCurrentArea == null)
                {
                    return(false);
                }

                timeSpan = DateTime.UtcNow - areaCurrentArea.TimeEntered;

                // Time = $"{timeSpan.TotalMinutes:00}:{timeSpan.Seconds:00}";
                Time            = AreaInstance.GetTimeString(timeSpan);
                xpReceivingText = $"{xpRate}  *{levelXpPenalty * partyXpPenalty:p0}";

                xpGetLeft =
                    $"Got: {ConvertHelper.ToShorten(getXp, "0.00")} ({percentGot:P3})  Left: {ConvertHelper.ToShorten(xpLeftQ, "0.00")}";

                maxX = MathHepler.Max(Graphics.MeasureText(fps).X, Graphics.MeasureText(ping).X, Graphics.MeasureText(latency).X,
                                      Graphics.MeasureText(areaName).X, Graphics.MeasureText(xpReceivingText).X) * 1.5f;

                if (partytime > 4900)
                {
                    var levelPenaltyValue = LevelPenalty.Value;
                }

                return(true);
            }, 1000);

            LevelPenalty = new TimeCache <bool>(() =>
            {
                partyXpPenalty = PartyXpPenalty();
                levelXpPenalty = LevelXpPenalty();
                return(true);
            }, 5000);

            GameController.EntityListWrapper.PlayerUpdate += OnEntityListWrapperOnPlayerUpdate;
            OnEntityListWrapperOnPlayerUpdate(this, GameController.Player);

            debugInformation = new DebugInformation("Game FPS", "Collect game fps", false);
            return(true);
        }
Example #5
0
        private IEnumerator ClickSlot(RectangleF slotRect, MouseButtons buttonToClick, int msBetweenClicks)
        {
            Input.SetCursorPos(slotRect.ClickRandom());
            yield return(new WaitTime(msBetweenClicks));

            Input.Click(buttonToClick);
            Input.MouseMove();
            yield return(new WaitTime(10));
        }
Example #6
0
        public override Job Tick()
        {
            if (GameController.Game.IngameState.ServerData.PlayerInventories.Count == 0)
            {
                return(null);
            }

            InventoryItems = GameController.Game.IngameState.ServerData.PlayerInventories[0].Inventory;
            inventorySlots = Misc.GetContainer2DArray(InventoryItems);
            DrawIgnoredCellsSettings();
            if (Input.GetKeyState(Settings.LazyLootingPauseKey))
            {
                DisableLazyLootingTill = DateTime.Now.AddSeconds(2);
            }
            if (Input.GetKeyState(Keys.Escape))
            {
                pickItCoroutine.Pause();
            }

            if (Input.GetKeyState(Settings.PickUpKey.Value) ||
                CanLazyLoot())
            {
                DebugTimer.Restart();

                if (pickItCoroutine.IsDone)
                {
                    var firstOrDefault = Core.ParallelRunner.Coroutines.FirstOrDefault(x => x.OwnerName == nameof(PickIt));

                    if (firstOrDefault != null)
                    {
                        pickItCoroutine = firstOrDefault;
                    }
                }

                pickItCoroutine.Resume();
                FullWork = false;
            }
            else
            {
                if (FullWork)
                {
                    pickItCoroutine.Pause();
                    DebugTimer.Reset();
                }
            }

            if (DebugTimer.ElapsedMilliseconds > 300)
            {
                FullWork = true;
                //LogMessage("Error pick it stop after time limit 300 ms", 1);
                DebugTimer.Reset();
            }
            //Graphics.DrawText($@"PICKIT :: Debug Tick Timer ({DebugTimer.ElapsedMilliseconds}ms)", new Vector2(100, 100), FontAlign.Left);
            //DebugTimer.Reset();

            return(null);
        }
Example #7
0
        private IEnumerator FindItemToPick()
        {
            if (!GameController.Window.IsForeground())
            {
                yield break;
            }
            var window    = GameController.Window.GetWindowRectangleTimeCache;
            var rect      = new RectangleF(window.X, window.X, window.X + window.Width, window.Y + window.Height);
            var playerPos = GameController.Player.GridPos;

            List <CustomItem> currentLabels;
            var morphPath = "Metadata/MiscellaneousObjects/Metamorphosis/MetamorphosisMonsterMarker";

            if (Settings.UseWeight)
            {
                currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                .Where(x => x.Address != 0 &&
                                       x.ItemOnGround?.Path != null &&
                                       x.IsVisible && x.Label.GetClientRectCache.Center.PointInRectangle(rect) &&
                                       x.CanPickUp && (x.MaxTimeForPickUp.TotalSeconds <= 0) || x.ItemOnGround?.Path == morphPath)
                                .Select(x => new CustomItem(x, GameController.Files,
                                                            x.ItemOnGround.DistancePlayer, _weightsRules, x.ItemOnGround?.Path == morphPath))
                                .OrderByDescending(x => x.Weight).ThenBy(x => x.Distance).ToList();
            }
            else
            {
                currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                .Where(x => x.Address != 0 &&
                                       x.ItemOnGround?.Path != null &&
                                       x.IsVisible && x.Label.GetClientRectCache.Center.PointInRectangle(rect) &&
                                       x.CanPickUp && (x.MaxTimeForPickUp.TotalSeconds <= 0) || x.ItemOnGround?.Path == morphPath)
                                .Select(x => new CustomItem(x, GameController.Files,
                                                            x.ItemOnGround.DistancePlayer, _weightsRules, x.ItemOnGround?.Path == morphPath))
                                .OrderBy(x => x.Distance).ToList();
            }

            GameController.Debug["PickIt"] = currentLabels;
            var rectangleOfGameWindow = GameController.Window.GetWindowRectangleTimeCache;

            rectangleOfGameWindow.Inflate(-36, -36);
            var pickUpThisItem = currentLabels.FirstOrDefault(x =>
                                                              DoWePickThis(x) && x.Distance < Settings.PickupRange && x.GroundItem != null &&
                                                              rectangleOfGameWindow.Intersects(new RectangleF(x.LabelOnGround.Label.GetClientRectCache.Center.X,
                                                                                                              x.LabelOnGround.Label.GetClientRectCache.Center.Y, 3, 3)) && Misc.CanFitInventory(x));

            if (Input.GetKeyState(Settings.PickUpKey.Value) ||
                CanLazyLoot() && ShouldLazyLoot(pickUpThisItem))
            {
                yield return(TryToPickV2(pickUpThisItem));

                FullWork = true;
            }
        }
Example #8
0
        private IEnumerator AttackEntity(Entity closestMonster)
        {
            LogMessage(" ------ AttackEntity called", 1);

            List <SkillSettings> skills = new List <SkillSettings>()
            {
                Settings.SkillOne,
                Settings.SkillTwo,
                Settings.SkillThree,
            };

            SkillSettings availableSkill = null;

            try
            {
                availableSkill = skills
                                 .Where(o =>
                {
                    long delta = GetDeltaInMilliseconds(o.LastTimeUsed);
                    return(delta > Int32.Parse(o.CooldownBetweenCasts.Value));
                })
                                 .Where(o =>
                {
                    var distance = FollowerHelpers.EntityDistance(closestMonster, GameController.Player) / 10;
                    LogMessage($"DISTANCE: {distance}");
                    LogMessage($"o.Range.Value: {o.Range.Value}");
                    return(distance < o.Range.Value);
                })
                                 .OrderBy(o => o.Priority.Value)
                                 .First();

                availableSkill.LastTimeUsed = DateTime.UtcNow;
            }
            catch (Exception e)
            {
                LogError(" ------ Error during filtering an available skill");
            }

            if (availableSkill != null)
            {
                yield return(HoverTo(closestMonster));

                Input.KeyPressRelease(availableSkill.SkillHotkey.Value);
            }
            else
            {
                yield return(DoFollow());
            }

            yield break;
        }
Example #9
0
        /// <summary>
        /// LazyLoot item independent checks
        /// </summary>
        /// <returns></returns>
        private bool CanLazyLoot()
        {
            if (!Settings.LazyLooting)
            {
                return(false);
            }
            if (Settings.LazyLooting && !Input.GetKeyState(Settings.LazyLootingPauseKey))
            {
                return(true);
            }
            // if (DisableLazyLootingTill > DateTime.Now) return false;

            return(true);
        }
Example #10
0
        static public IEnumerator MouseAsJoystick(GameController gameController, float desiredAngle)
        {
            var gameWindowRect = gameController.Window.GetWindowRectangle();
            var centerOfScreen = gameController.Game.IngameState.Camera.WorldToScreen(gameController.Player.Pos);

            float mouseDistance = 0.2f * gameWindowRect.Height;
            float xPos          = mouseDistance * (float)Math.Cos(desiredAngle * Math.PI / 180);
            float yPos          = -mouseDistance * (float)Math.Sin(desiredAngle * Math.PI / 180);

            Vector2 mousePositionClient = new Vector2(centerOfScreen.X + xPos,
                                                      centerOfScreen.Y + yPos);
            Vector2 mousePositionToClick = gameWindowRect.TopLeft + mousePositionClient;

            yield return(Input.SetCursorPositionSmooth(mousePositionToClick));
        }
Example #11
0
        private IEnumerator FindItemToPick()
        {
            if (!Input.GetKeyState(Settings.PickUpKey.Value) || !GameController.Window.IsForeground())
            {
                yield break;
            }
            var window    = GameController.Window.GetWindowRectangleTimeCache;
            var rect      = new RectangleF(window.X, window.X, window.X + window.Width, window.Y + window.Height);
            var playerPos = GameController.Player.GridPos;

            List <CustomItem> currentLabels;

            if (Settings.UseWeight)
            {
                currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                .Where(x => x.Address != 0 &&
                                       x.ItemOnGround?.GetComponent <WorldItem>()?.ItemEntity.Path != null &&
                                       x.IsVisible && x.Label.GetClientRectCache.Center.PointInRectangle(rect) &&
                                       (x.CanPickUp || x.MaxTimeForPickUp.TotalSeconds <= 0))
                                .Select(x => new CustomItem(x, GameController.Files,
                                                            x.ItemOnGround.GetComponent <Positioned>().GridPos
                                                            .Distance(playerPos), _weightsRules))
                                .OrderByDescending(x => x.Weight).ThenBy(x => x.Distance).ToList();
            }
            else
            {
                currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                .Where(x => x.Address != 0 &&
                                       x.ItemOnGround?.GetComponent <WorldItem>()?.ItemEntity.Path != null &&
                                       x.IsVisible &&
                                       (x.CanPickUp || x.MaxTimeForPickUp.TotalSeconds <= 0))
                                .Select(x => new CustomItem(x, GameController.Files,
                                                            x.ItemOnGround.GetComponent <Positioned>().GridPos
                                                            .Distance(playerPos), _weightsRules))
                                .OrderBy(x => x.Distance).ToList();
            }

            GameController.Debug["PickIt"] = currentLabels;
            var pickUpThisItem = currentLabels.FirstOrDefault(x => DoWePickThis(x) && x.Distance < Settings.PickupRange);

            if (pickUpThisItem?.GroundItem != null)
            {
                yield return(TryToPickV2(pickUpThisItem));
            }
            FullWork = true;
        }
Example #12
0
        /*public override void DrawSettings()
         * {
         *  ImGui.BulletText($"v{PluginVersion}");
         *  ImGui.BulletText($"Last Updated: {buildDate}");
         *  Settings.PickUpKey = ImGuiExtension.HotkeySelector("Pickup Key", Settings.PickUpKey);
         *  Settings.LeftClickToggleNode.Value = ImGuiExtension.Checkbox("Mouse Button: " + (Settings.LeftClickToggleNode ? "Left" : "Right"), Settings.LeftClickToggleNode);
         *  Settings.LeftClickToggleNode.Value = ImGuiExtension.Checkbox("Return Mouse To Position Before Click", Settings.ReturnMouseToBeforeClickPosition);
         *  Settings.GroundChests.Value = ImGuiExtension.Checkbox("Click Chests If No Items Around", Settings.GroundChests);
         *  Settings.PickupRange.Value = ImGuiExtension.IntSlider("Pickup Radius", Settings.PickupRange);
         *  Settings.ChestRange.Value = ImGuiExtension.IntSlider("Chest Radius", Settings.ChestRange);
         *  Settings.ExtraDelay.Value = ImGuiExtension.IntSlider("Extra Click Delay", Settings.ExtraDelay);
         *  Settings.MouseSpeed.Value = ImGuiExtension.FloatSlider("Mouse speed", Settings.MouseSpeed);
         *  Settings.TimeBeforeNewClick.Value = ImGuiExtension.IntSlider("Time wait for new click", Settings.TimeBeforeNewClick);
         *  //Settings.OverrideItemPickup.Value = ImGuiExtension.Checkbox("Item Pickup Override", Settings.OverrideItemPickup); ImGui.SameLine();
         *  //ImGuiExtension.ToolTip("Override item.CanPickup\n\rDO NOT enable this unless you know what you're doing!");
         *
         *  var tempRef = false;
         *  if (ImGui.CollapsingHeader("Pickit Rules", TreeNodeFlags.Framed | TreeNodeFlags.DefaultOpen))
         *  {
         *      if (ImGui.Button("Reload All Files")) LoadRuleFiles();
         *      Settings.NormalRuleFile = ImGuiExtension.ComboBox("Normal Rules", Settings.NormalRuleFile, PickitFiles, out tempRef);
         *      if (tempRef) _normalRules = LoadPickit(Settings.NormalRuleFile);
         *      Settings.MagicRuleFile = ImGuiExtension.ComboBox("Magic Rules", Settings.MagicRuleFile, PickitFiles, out tempRef);
         *      if (tempRef) _magicRules = LoadPickit(Settings.MagicRuleFile);
         *      Settings.RareRuleFile = ImGuiExtension.ComboBox("Rare Rules", Settings.RareRuleFile, PickitFiles, out tempRef);
         *      if (tempRef) _rareRules = LoadPickit(Settings.RareRuleFile);
         *      Settings.UniqueRuleFile = ImGuiExtension.ComboBox("Unique Rules", Settings.UniqueRuleFile, PickitFiles, out tempRef);
         *      if (tempRef) _uniqueRules = LoadPickit(Settings.UniqueRuleFile);
         *  }
         *
         *  if (ImGui.CollapsingHeader("Item Logic", TreeNodeFlags.Framed | TreeNodeFlags.DefaultOpen))
         *  {
         *      Settings.ShaperItems.Value = ImGuiExtension.Checkbox("Pickup Shaper Items", Settings.ShaperItems);
         *      ImGui.SameLine();
         *      Settings.ElderItems.Value = ImGuiExtension.Checkbox("Pickup Elder Items", Settings.ElderItems);
         *      if (ImGui.TreeNode("Links/Sockets/RGB"))
         *      {
         *          Settings.RGB.Value = ImGuiExtension.Checkbox("RGB Items", Settings.RGB);
         *          Settings.TotalSockets.Value = ImGuiExtension.IntSlider("##Sockets", Settings.TotalSockets);
         *          ImGui.SameLine();
         *          Settings.Sockets.Value = ImGuiExtension.Checkbox("Sockets", Settings.Sockets);
         *          Settings.LargestLink.Value = ImGuiExtension.IntSlider("##Links", Settings.LargestLink);
         *          ImGui.SameLine();
         *          Settings.Links.Value = ImGuiExtension.Checkbox("Links", Settings.Links);
         *          ImGui.Separator();
         *          ImGui.TreePop();
         *      }
         *
         *      if (ImGui.TreeNode("Overrides"))
         *      {
         *          Settings.PickUpEverything.Value = ImGuiExtension.Checkbox("Pickup Everything", Settings.PickUpEverything);
         *          Settings.AllDivs.Value = ImGuiExtension.Checkbox("All Divination Cards", Settings.AllDivs);
         *          Settings.AllCurrency.Value = ImGuiExtension.Checkbox("All Currency", Settings.AllCurrency);
         *          Settings.AllUniques.Value = ImGuiExtension.Checkbox("All Uniques", Settings.AllUniques);
         *          Settings.QuestItems.Value = ImGuiExtension.Checkbox("Quest Items", Settings.QuestItems);
         *          Settings.Maps.Value = ImGuiExtension.Checkbox("##Maps", Settings.Maps);
         *          ImGui.SameLine();
         *          if (ImGui.TreeNode("Maps"))
         *          {
         *              Settings.MapTier.Value = ImGuiExtension.IntSlider("Lowest Tier", Settings.MapTier);
         *              Settings.UniqueMap.Value = ImGuiExtension.Checkbox("All Unique Maps", Settings.UniqueMap);
         *              Settings.MapFragments.Value = ImGuiExtension.Checkbox("Fragments", Settings.MapFragments);
         *              ImGui.Spacing();
         *              ImGui.TreePop();
         *          }
         *
         *          Settings.GemQuality.Value = ImGuiExtension.IntSlider("##Gems", "Lowest Quality", Settings.GemQuality);
         *          ImGui.SameLine();
         *          Settings.Gems.Value = ImGuiExtension.Checkbox("Gems", Settings.Gems);
         *          ImGui.Separator();
         *          ImGui.TreePop();
         *      }
         *
         *      Settings.Rares.Value = ImGuiExtension.Checkbox("##Rares", Settings.Rares);
         *      ImGui.SameLine();
         *      if (ImGui.TreeNode("Rares##asd"))
         *      {
         *          Settings.RareJewels.Value = ImGuiExtension.Checkbox("Jewels", Settings.RareJewels);
         *          Settings.RareRingsilvl.Value = ImGuiExtension.IntSlider("##RareRings", "Lowest iLvl", Settings.RareRingsilvl);
         *          ImGui.SameLine();
         *          Settings.RareRings.Value = ImGuiExtension.Checkbox("Rings", Settings.RareRings);
         *          Settings.RareAmuletsilvl.Value = ImGuiExtension.IntSlider("##RareAmulets", "Lowest iLvl", Settings.RareAmuletsilvl);
         *          ImGui.SameLine();
         *          Settings.RareAmulets.Value = ImGuiExtension.Checkbox("Amulets", Settings.RareAmulets);
         *          Settings.RareBeltsilvl.Value = ImGuiExtension.IntSlider("##RareBelts", "Lowest iLvl", Settings.RareBeltsilvl);
         *          ImGui.SameLine();
         *          Settings.RareBelts.Value = ImGuiExtension.Checkbox("Belts", Settings.RareBelts);
         *          Settings.RareGlovesilvl.Value = ImGuiExtension.IntSlider("##RareGloves", "Lowest iLvl", Settings.RareGlovesilvl);
         *          ImGui.SameLine();
         *          Settings.RareGloves.Value = ImGuiExtension.Checkbox("Gloves", Settings.RareGloves);
         *          Settings.RareBootsilvl.Value = ImGuiExtension.IntSlider("##RareBoots", "Lowest iLvl", Settings.RareBootsilvl);
         *          ImGui.SameLine();
         *          Settings.RareBoots.Value = ImGuiExtension.Checkbox("Boots", Settings.RareBoots);
         *          Settings.RareHelmetsilvl.Value = ImGuiExtension.IntSlider("##RareHelmets", "Lowest iLvl", Settings.RareHelmetsilvl);
         *          ImGui.SameLine();
         *          Settings.RareHelmets.Value = ImGuiExtension.Checkbox("Helmets", Settings.RareHelmets);
         *          Settings.RareArmourilvl.Value = ImGuiExtension.IntSlider("##RareArmours", "Lowest iLvl", Settings.RareArmourilvl);
         *          ImGui.SameLine();
         *          Settings.RareArmour.Value = ImGuiExtension.Checkbox("Armours", Settings.RareArmour);
         *          ImGui.Spacing();
         *          Settings.RareWeaponilvl.Value = ImGuiExtension.IntSlider("##RareWeapons", "Lowest iLvl", Settings.RareWeaponilvl);
         *          ImGui.SameLine();
         *          Settings.RareWeapon.Value = ImGuiExtension.Checkbox("Weapons", Settings.RareWeapon);
         *          Settings.RareShieldilvl.Value = ImGuiExtension.IntSlider("##Shields", "Lowest iLvl", Settings.RareWeaponilvl);
         *          ImGui.SameLine();
         *          Settings.RareShield.Value = ImGuiExtension.Checkbox("Shields", Settings.RareWeapon);
         *          Settings.RareWeaponWidth.Value = ImGuiExtension.IntSlider("Maximum Width##RareWeaponWidth", Settings.RareWeaponWidth);
         *          Settings.RareWeaponHeight.Value = ImGuiExtension.IntSlider("Maximum Height##RareWeaponHeight", Settings.RareWeaponHeight);
         *          Settings.ItemCells.Value = ImGuiExtension.IntSlider("Maximum Cells##RareWeaponCell", Settings.ItemCells);
         *          ImGui.TreePop();
         *      }
         *  }
         * }*/

        public override Job Tick()
        {
            if (Input.GetKeyState(Keys.Escape))
            {
                pickItCoroutine.Pause();
            }

            if (Input.GetKeyState(Settings.PickUpKey.Value))
            {
                DebugTimer.Restart();

                if (pickItCoroutine.IsDone)
                {
                    var firstOrDefault = Core.ParallelRunner.Coroutines.FirstOrDefault(x => x.OwnerName == nameof(PickIt));

                    if (firstOrDefault != null)
                    {
                        pickItCoroutine = firstOrDefault;
                    }
                }

                pickItCoroutine.Resume();
                FullWork = false;
            }
            else
            {
                if (FullWork)
                {
                    pickItCoroutine.Pause();
                    DebugTimer.Reset();
                }
            }

            if (DebugTimer.ElapsedMilliseconds > 2000)
            {
                FullWork = true;
                LogMessage("Error pick it stop after time limit 2000 ms", 1);
                DebugTimer.Reset();
            }

            return(null);
        }
Example #13
0
        private IEnumerator TryToClickOnLeader(Entity leaderPlayer)
        {
            //LogMessage(" ;;;;;;;;; TryToClickOnLeader called", 1);

            yield return(HoverTo(leaderPlayer));

            if (CanUseMovementSkill())
            {
                _lastTimeMovementSkillUsed = DateTime.UtcNow;
                yield return(Input.KeyPress(Settings.MovementSkillKey));
            }
            else
            {
                yield return(Input.KeyPress(Keys.T));
                //yield return Mouse.LeftClick();
            }

            //yield return CanUseMovementSkill() ? Input.KeyPress(Settings.MovementSkillKey) : Mouse.LeftClick();
            yield return(CanUseMovementSkill() ? Input.KeyPress(Settings.MovementSkillKey) : Input.KeyPress(Keys.T));
        }
Example #14
0
        public override void Render()
        {
            base.Render();

            if (_UnstackCoroutine != null && _UnstackCoroutine.IsDone)
            {
                _UnstackCoroutine = null;
            }

            var requiredPanelsOpen = GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible;

            if (_UnstackCoroutine != null && _UnstackCoroutine.Running)
            {
                if (_DebugTimer.ElapsedMilliseconds > 15000)
                {
                    DebugWindow.LogError(
                        "Unstacking the current stacked deck has reached the time limit for an operation.");
                    StopCoroutine();
                }

                if (!requiredPanelsOpen || Input.GetKeyState(Keys.Escape))
                {
                    StopCoroutine();
                }

                return;
            }

            if (!Settings.UnstackHotkey.PressedOnce())
            {
                return;
            }
            if (!requiredPanelsOpen)
            {
                return;
            }

            _UnstackCoroutine = new Coroutine(UnstackTheDecks(), this, Name);

            Core.ParallelRunner.Run(_UnstackCoroutine);
        }
Example #15
0
        public override bool Initialise()
        {
            base.Initialise();

            Input.RegisterKey(Settings.UnstackHotkey);

            Settings.Enable.OnValueChanged += (sender, value) => { _SaveSettings(); };
            Settings.PreserveOriginalCursorPosition.OnValueChanged += (sender, value) => { _SaveSettings(); };
            Settings.ReverseMouseButtons.OnValueChanged            += (sender, value) => { _SaveSettings(); };

            Settings.UnstackHotkey.OnValueChanged += () =>
            {
                Input.RegisterKey(Settings.UnstackHotkey);
                _SaveSettings();
            };
            Settings.TurnInDivCardsHotkey.OnValueChanged += () =>
            {
                Input.RegisterKey(Settings.TurnInDivCardsHotkey);
                _SaveSettings();
            };
            return(true);
        }
Example #16
0
        private IEnumerator UnstackTheDecks()
        {
            _DebugTimer.Restart();
            yield return(ParseInventory());

            var originalCursorPosition = Input.ForceMousePosition;

            if (_SlotsWithStackedDecks.Count > 0)
            {
                _DebugTimer.Restart();
                yield return(PopTheStacks());
            }

            if (Settings.PreserveOriginalCursorPosition)
            {
                _DebugTimer.Restart();
                Input.SetCursorPos(originalCursorPosition);
                Input.MouseMove();
            }

            _UnstackCoroutine = Core.ParallelRunner.FindByName(Name);
            _UnstackCoroutine?.Done();
            _DebugTimer.Stop();
        }
Example #17
0
 private void CastSkill()
 {
     //default constant delay 10ms?
     Input.KeyPressRelease(Settings.SkillHotkey, GameController.Window.Process.MainWindowHandle);
 }
Example #18
0
        private IEnumerator TryToPickV2(CustomItem pickItItem)
        {
            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;
            var oldMousePosition      = Mouse.GetCursorPositionVector();

            _clickWindowOffset = rectangleOfGameWindow.TopLeft;
            rectangleOfGameWindow.Inflate(-55, -55);
            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 (!pickItItem.IsTargeted() && tryCount < 5)
            {
                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;
                }

                /*while (GameController.Player.GetComponent<Actor>().isMoving)
                 * {
                 *  yield return waitPlayerMove;
                 * }*/
                var clientRect = completeItemLabel.GetClientRect();

                var clientRectCenter = clientRect.Center;

                var vector2 = clientRectCenter + _clickWindowOffset;

                Mouse.MoveCursorToPosition(vector2);
                yield return(wait3ms);

                Mouse.MoveCursorToPosition(vector2);
                yield return(wait3ms);

                yield return(Mouse.LeftClick());

                yield return(toPick);

                tryCount++;
            }

            if (pickItItem.IsTargeted())
            {
                Input.Click(MouseButtons.Left);
            }

            tryCount = 0;

            while (GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels.FirstOrDefault(
                       x => x.Address == pickItItem.LabelOnGround.Address) != null && tryCount < 6)
            {
                tryCount++;
                yield return(waitForNextTry);
            }

            //yield return waitForNextTry;

            //   Mouse.MoveCursorToPosition(oldMousePosition);
        }
Example #19
0
        private IEnumerator PopAStack(ServerInventory.InventSlotItem item)
        {
            //DebugWindow.LogError("Test in PopAStack", 5);
            var invSlot        = item.InventoryPosition; //initial invslot
            var openSlotPos    = Point.Zero;
            var stacksize      = item.Item.GetComponent <Stack>()?.Size ?? 0;
            var slotRectCenter = item.GetClientRect().Center;
            var cursorInv      = GameController.Game.IngameState.ServerData.PlayerInventories[12].Inventory;
            int latency        = (int)GameController.IngameState.ServerData.Latency;
            int maxWaitTime    = Settings.MaxWatitTime.Value;

            while (stacksize > 0)
            {
                //check profile requirements
                if (!Settings.DropToGround && !Settings.DropToDivTab && !_InventoryLayout.GetNextOpenSlot(ref openSlotPos))
                {
                    DebugWindow.LogError(
                        "UnstackDecks => Inventory doesn't have space to place the next div card.");
                    StopCoroutine(Name);
                    yield break;
                }
                else if (!areRequirementsMet())
                {
                    LogError("Requirements not met!");
                    StopCoroutine(Name);
                    yield break;
                }
                //click the stackdeck stack
                yield return(Input.SetCursorPositionAndClick(slotRectCenter, Settings.ReverseMouseButtons ? MouseButtons.Left : MouseButtons.Right, Settings.TimeBetweenClicks));

                //check if MouseInventory contains an item and waits for it
                yield return(new WaitFunctionTimed(() => cursorInv.CountItems > 0, true, maxWaitTime));

                if (cursorInv.TotalItemsCounts == 0)
                {
                    //LogError("Cursorinventory not filled");
                    //StopCoroutine();
                    yield break;
                }

                //click at the dropoff location
                yield return(Input.SetCursorPositionAndClick(chooseDestination(openSlotPos), Settings.ReverseMouseButtons ? MouseButtons.Right : MouseButtons.Left, Settings.TimeBetweenClicks));

                //wait for item on cursor to be dropped off
                yield return(new WaitFunctionTimed(() => cursorInv.CountItems == 0, true, maxWaitTime));

                if (cursorInv.TotalItemsCounts != 0)
                {
                    //LogError("Cursorinventory not empty");
                    //StopCoroutine();
                    yield break;
                }
                if (!Settings.DropToGround && !Settings.DropToDivTab)
                {
                    yield return(MarkSlotUsed(openSlotPos));
                }
                //update item and the stacksize more safely
                //find the item by invslot
                item = GameController.IngameState.ServerData.PlayerInventories[0].Inventory.InventorySlotItems.ToList().Find(x => x.InventoryPosition == invSlot); //the item object is rebuilt completely by the game after removing a card from the stack
                yield return(new WaitFunctionTimed(() => item.Item.HasComponent <Stack>(), true, maxWaitTime));                                                    //the game doesnt seem to like it when you unstack too fast and gives ingame chat error messages. The caching of the stacksize and simply decrementing brought other problems

                if (!item.Item.HasComponent <Stack>())
                {
                    //LogError("No Stack component of current item found");
                    //StopCoroutine();
                    yield break;
                }
                stacksize = item.Item.GetComponent <Stack>().Size;
            }
        }