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; } } })); }
public static Composite OpenAndEnterTownPortal() { return(new Sequence( new Action(delegate { InputWrapper.ResetMouseButtons(); CommonBehavior.CloseOpenPanels(); return RunStatus.Success; }), OpenTownPortal(), EnterTownPortal(), new Action(delegate { WillBot.Mover.RemoveNavigationDataForCurrentZone(); ControlTimer.Restart(); while (ControlTimer.ElapsedMilliseconds < 10000 && !WillBot.Plugin.TreeHelper.CanTickTown() && !WillBot.Plugin.TreeHelper.CanTickHideout()) { Thread.Sleep(500); } if (WillBot.Plugin.TreeHelper.CanTickMap()) { return RunStatus.Failure; } return RunStatus.Success; }) )); }
public IEnumerator MainWorkCoroutine() { while (true) { if (runTestMove) { InputWrapper.ResetMouseButtons(); WillBot.LogMessageCombo($"Running test move"); runTestMove = false; // yield return mover.MovePlayerToGridPos(testMovePosition); } yield return(new WaitTime(1)); } }
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; })); }
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; }) )); }
public override Job Tick() { //ingameStateIngameUi = GameController.Game.IngameState.IngameUi; screentCenterCache = screenCenter; k = camera.Width < 1024f ? 1120f : 1024f; scale = k / camera.Height * camera.Width * 3f / 4f / mapWindow.LargeMapZoom; string soulCatcher = "unique_flask_no_recovery_and_soul_gain"; //string soulCatcher = "unique_flask_soul_catcher"; // //if (WillBot.Plugin.TreeHelper.CanTickMap() == true) //{ // if (Settings.VaalAttackKey.PressedDown()) // { // var playerBuffs = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<ExileCore.PoEMemory.Components.Buffs>(); // var soulCatcherBuffs = playerBuffs?.BuffsList?.Where(x => x.Name?.Contains(soulCatcher) ?? false)?.ToList(); // var soulCatcherBuff = soulCatcherBuffs.FirstOrDefault(); // if (soulCatcherBuff != null && soulCatcherBuff.Timer > 0.2) // { // InputWrapper.KeyDown(Keys.A); // } // else // { // if (DateTime.Now.Subtract(lastActivatedFlaskTime).TotalMilliseconds > 100) // { // InputWrapper.KeyPress(Keys.D2); // lastActivatedFlaskTime = DateTime.Now; // } // } // } // else // { // InputWrapper.KeyUp(Keys.A); // } //} if (Settings.PauseAbilityUsage.PressedOnce()) { if (BuffTreeCoroutine.Running) { Console.WriteLine("Ability paused"); BuffTreeCoroutine.AutoResume = false; BuffTreeCoroutine.Pause(); } else { Console.WriteLine("Abilities resumed"); BuffTreeCoroutine.AutoResume = true; BuffTreeCoroutine.Resume(); } } if (Settings.TestKey1.PressedOnce()) { if (TreeCoroutine.Running) { WillBot.isBotPaused = true; Console.WriteLine("Bot paused"); InputWrapper.ResetMouseButtons(); TreeCoroutine.AutoResume = false; TreeCoroutine.Pause(); } else { WillBot.Mover.UpdateTerrainData(doNotUpdateIfAlreadyExists: true); WillBot.isBotPaused = false; Console.WriteLine("Bot resumed"); TreeCoroutine.AutoResume = true; TreeCoroutine.Resume(); } } if (Settings.TestKey2.PressedOnce()) { //ChaosRecipeBehavior.MapChaosRecipeItems(); //ChaosRecipeBehavior.GetNumberOfCrRecipeSetsInStash(); var gameControllerEntities = GameController.EntityListWrapper; var labelOnGrounds = GameController.IngameState.IngameUi.ItemsOnGroundLabels; var pause = 5; } //if (Settings.TryLootNearbykey.PressedOnce()) //{ // AutoLootCoroutine.AutoResume = true; // AutoLootCoroutine.Resume(); // Console.WriteLine("Looting nearby"); //} //if (autoLootingDone == true) //{ // AutoLootCoroutine.AutoResume = false; // AutoLootCoroutine.Pause(); // Console.WriteLine("Looting done"); // autoLootingDone = false; //} //Debug check for seed cache //var nearestEntities = GameController.Entities.Where(x => x.DistancePlayer < 15).ToList(); //foreach (var entity in nearestEntities) //{ // WillBot.WillBot.LogMessageComboCombo($"Distance player: {entity.DistancePlayer}, name: {entity.ToString()}"); //} if (WillBot.isBotPaused == false) { WillBot.Mover.UpdateExplored(); StuckTracker.Update(); pickit.UpdateItemsToPickUp(); } return(null); }
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(); }) )); }