Beispiel #1
0
        public static Composite CloseOpenPanelsIfOpenPanels()
        {
            return(new Action(delegate
            {
                while (true)
                {
                    bool leftPanelOpen = GameController.Game.IngameState.IngameUi.OpenLeftPanel?.Address != 0;
                    bool rightPanelOpen = GameController.Game.IngameState.IngameUi.OpenRightPanel?.Address != 0;
                    bool inventoryPanelOpen = GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible == true;
                    bool vendorPanelOpen = WillBot.gameController.IngameState.IngameUi.VendorPanelSellOption != null;

                    bool betralWindowOpen = GameController.Game.IngameState.IngameUi.BetrayalWindow?.IsVisible == true;

                    if (leftPanelOpen || rightPanelOpen || inventoryPanelOpen || vendorPanelOpen || betralWindowOpen)
                    {
                        InputWrapper.KeyPress(WillBot.Settings.CloseAllPanelsKey.Value);
                        Thread.Sleep(350);
                    }
                    else
                    {
                        return RunStatus.Success;
                    }
                }
            }));
        }
Beispiel #2
0
 public static Composite TownToHideout()
 {
     return(new Action(delegate
     {
         InputWrapper.KeyPress(Keys.Enter);
         Thread.Sleep(100);
         Input.KeyDown(Keys.LControlKey);
         InputWrapper.KeyPress(Keys.A);
         Input.KeyUp(Keys.LControlKey);
         Thread.Sleep(50);
         SendKeys.SendWait("/hideout");
         InputWrapper.KeyPress(Keys.Enter);
         Thread.Sleep(2000);
         return RunStatus.Success;
     }));
 }
Beispiel #3
0
 public static Composite OpenInventory()
 {
     return(new DecoratorContinue(x => GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible == false,
                                  new Action(delegate
     {
         InputWrapper.KeyPress(Keys.I);
         ControlTimer.Restart();
         while (ControlTimer.ElapsedMilliseconds < 3000)
         {
             if (GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible == true)
             {
                 return RunStatus.Success;
             }
             Thread.Sleep(50);
         }
         return RunStatus.Failure;
     })
                                  ));
 }
Beispiel #4
0
        public static Composite MoveTo(PositionDelegate positionDelegate, XyzPositionDelegate xyzPositionDelegate = null, MovementSpec spec = null)
        {
            return(new Sequence(
                       new Action(delegate(object context)
            {
                var position = positionDelegate(context);
                if (position == null)
                {
                    WillBot.LogMessageCombo($"Unable to set path to null position");
                    return RunStatus.Failure;
                }
                bool didSetPath = WillBot.Mover.SetPath((Vector2)position);
                if (didSetPath == false)
                {
                    WillBot.LogMessageCombo($"Unable to set path to {position}");
                    return RunStatus.Failure;
                }
                else
                {
                    WillBot.LogMessageCombo($"Successfully found path to {position}");
                    ControlTimer.Restart();
                    return RunStatus.Success;
                }
            }),
                       new Action(delegate(object context)
            {
                bool isZDifferenceOk = true;
                var entityPos = xyzPositionDelegate?.Invoke(context);
                var entityGridPos = positionDelegate?.Invoke(context);
                if (entityPos != null)
                {
                    isZDifferenceOk = Math.Abs(GameController.Player.Pos.Z - entityPos.GetValueOrDefault().Z) < WillBot.Settings.MovementCancelingForLootZThreshold;
                }
                // if zdifferencenotOk, but the path is relatively straight to the object and close -> use movement skill
                WillBot.LogMessageCombo($"Remaining path distance squared : {WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget}");
                var airDistanceSquared = entityGridPos.GetValueOrDefault().DistanceSquared(WillBot.gameController.Player.GridPos);
                if (isZDifferenceOk == false && (WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1300) &&
                    WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1.07 * airDistanceSquared)
                {
                    WillBot.LogMessageCombo($"Using movement skill to most likely jump a cliff which incorrectly is set to walkable");
                    InputWrapper.ResetMouseButtons();
                    var screenPos = Camera.WorldToScreen((Vector3)entityPos);
                    Mouse.SetCursorPosAndLeftOrRightClick(screenPos, 10, clickType: Mouse.MyMouseClicks.NoClick);
                    InputWrapper.KeyPress(Keys.E);
                    //MoverHelper.ClickToStopCharacter();
                    return RunStatus.Failure;
                }
                switch (spec.cancelReason)
                {
                case CancelReason.None:
                    break;

                case CancelReason.PathDistanceLessThanRange:
                    if ((WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < (spec.cancelRangeSquared)) && isZDifferenceOk)
                    {
                        WillBot.LogMessageCombo($"Canceled movement in range to object {spec.cancelRange}");
                        InputWrapper.ResetMouseButtons();
                        //MoverHelper.ClickToStopCharacter();
                        return RunStatus.Failure;
                    }
                    break;

                case CancelReason.PathDistanceLessThanRangeIfStraightPath:
                    /* Cancel pathfinding if path distance to object is less than X and distance to object and path distance are roughly equal
                     * use 1: Looting, avoid having to pathfind really close to loot before clicking the label.
                     */
                    //var airDistanceSquared = entityGridPos.GetValueOrDefault().DistanceSquared(WillBot.gameController.Player.GridPos);

                    if ((WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < spec.cancelRangeSquared) &&
                        WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1.07 * airDistanceSquared)
                    {
                        WillBot.LogMessageCombo($"Canceled movement in range to object with straight line {spec.cancelRange}");
                        InputWrapper.ResetMouseButtons();
                        //MoverHelper.ClickToStopCharacter();
                        return RunStatus.Failure;
                    }
                    break;
                }

                if (spec.cancelForMonster && DoCombat())
                {
                    WillBot.LogMessageCombo($"Canceled movement to do combat");
                    InputWrapper.ResetMouseButtons();
                    return RunStatus.Failure;
                }
                if (spec.cancelForLoot && DoLooting())
                {
                    WillBot.LogMessageCombo($"Canceled movement to do looting");
                    InputWrapper.ResetMouseButtons();
                    return RunStatus.Failure;
                }
                if (spec.cancelForOpenables && (WillBot.Me.StrongBox != null || WillBot.Me.HarvestChest != null || WillBot.Me.EssenceMonsterMonolith != null))
                {
                    InputWrapper.ResetMouseButtons();
                    WillBot.LogMessageCombo($"Canceled movement to do openables");
                    return RunStatus.Failure;
                }
                if (ControlTimer.ElapsedMilliseconds > 3500 && StuckTracker.GetDistanceMoved() < 40)
                {
                    InputWrapper.ResetMouseButtons();
                    WillBot.LogMessageCombo($"Canceled movement due to being stuck!. Using movement ability");
                    InputWrapper.KeyPress(WillBot.Settings.MovementAbilityKey);
                    return RunStatus.Failure;
                }
                // If movement last x duration less than .. return
                return WillBot.Mover.FollowPath();
            })
                       ));
        }