public override bool Initialise() { Player = GameController.Player; ingameUI = GameController.IngameState.IngameUi; PlayerBar = new HealthBar(Player, Settings); GameController.EntityListWrapper.PlayerUpdate += (sender, args) => { Player = GameController.Player; PlayerBar = new HealthBar(Player, Settings); }; ingameUICheckVisible = new TimeCache <bool>(() => { windowRectangle = GameController.Window.GetWindowRectangleReal(); windowSize = new Size2F(windowRectangle.Width / 2560, windowRectangle.Height / 1600); camera = GameController.Game.IngameState.Camera; return(ingameUI.BetrayalWindow.IsVisibleLocal || ingameUI.SellWindow.IsVisibleLocal || ingameUI.DelveWindow.IsVisibleLocal || ingameUI.IncursionWindow.IsVisibleLocal || ingameUI.UnveilWindow.IsVisibleLocal || ingameUI.TreePanel.IsVisibleLocal || ingameUI.AtlasPanel.IsVisibleLocal || ingameUI.CraftBench.IsVisibleLocal); }, 250); ReadIgnoreFile(); return(true); }
public override void Render() { if (!Settings.Enable) { return; } ingameUiElements = GameController.Game.IngameState.IngameUi; if (ingameUiElements.OpenLeftPanel.IsVisible || ingameUiElements.OpenRightPanel.IsVisible) { if (ingameUiElements.InventoryPanel.IsVisible) { cells = new CellData[CELLS_Y_COUNT, CELLS_X_COUNT]; AddItems(); } return; } RectangleF rect = GameController.Window.GetWindowRectangle(); float xPos = rect.Width * Settings.PositionX * .01f; float yPos = rect.Height * Settings.PositionY * .01f; var startDrawPoint = new Vector2(xPos, yPos); for (int i = 0; i < cells.GetLength(0); i++) { for (int j = 0; j < cells.GetLength(1); j++) { Vector2 d = startDrawPoint.Translate(j * Settings.CellSize, i * Settings.CellSize); float cellWidth = GetCellSize(cells[i, j].ExtendsX); float cellHeight = GetCellSize(cells[i, j].ExtendsY); var rectangleF = new RectangleF(d.X, d.Y, cellWidth, cellHeight); Graphics.DrawImage("cell.png", rectangleF, cells[i, j].Used ? Settings.CellUsedColor : Settings.CellFreeColor); } } }
private void TickLogic() { _ingameStateIngameUi = GameController.Game.IngameState.IngameUi; if (_ingameStateIngameUi.Map.SmallMiniMap.IsVisibleLocal) { var mapRectangle = _ingameStateIngameUi.Map.SmallMiniMap.GetClientRectCache; screentCenterCache = new Vector2(mapRectangle.X + mapRectangle.Width / 2, mapRectangle.Y + mapRectangle.Height / 2); largeMap = false; } else if (_ingameStateIngameUi.Map.LargeMap.IsVisibleLocal) { screentCenterCache = ScreenCenter; largeMap = true; } k = Camera.Width < 1024f ? 1120f : 1024f; scale = k / Camera.Height * Camera.Width * 3.06f / 4f / MapWindow.LargeMapZoom; playerPos = GameController.Player.GetComponent <Positioned>().GridPos; playerPosZ = GameController.Player.GetComponent <Render>().Pos.Z; while (EntityAddedQueue.Count > 0) { var e = EntityAddedQueue.Dequeue(); e.SetHudComponent(new HeistChest(e)); } foreach (var e in GameController.EntityListWrapper.ValidEntitiesByType[EntityType.Chest]) { var drawCmd = e.GetHudComponent <HeistChest>(); drawCmd?.Update(); } }
private void TickLogic() { try { ingameStateIngameUi = GameController.Game.IngameState.IngameUi; if (ingameStateIngameUi.Map.SmallMiniMap.IsVisibleLocal) { var mapRect = ingameStateIngameUi.Map.SmallMiniMap.GetClientRectCache; screentCenterCache = new Vector2(mapRect.X + mapRect.Width / 2, mapRect.Y + mapRect.Height / 2); largeMap = false; } else if (ingameStateIngameUi.Map.LargeMap.IsVisibleLocal) { screentCenterCache = screenCenter; largeMap = true; } k = camera.Width < 1024f ? 1120f : 1024f; scale = k / camera.Height * camera.Width * 3f / 4f / mapWindow.LargeMapZoom; } catch (Exception e) { DebugWindow.LogError($"MinimapIcons.TickLogic: {e.Message}"); } }
public override void Render() { base.Render(); if (!Settings.Enable.Value) { return; } if (stopwatch.IsRunning && stopwatch.ElapsedMilliseconds < 5000) { if (highlightSkill == -1) { var pos = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Render>().Pos; DrawEllipseToWorld(pos, Settings.NearbyMonsterRange.Value, 50, 2, Color.Yellow); } else { IngameUIElements ingameUiElements = GameController.Game.IngameState.IngameUi; Graphics.DrawFrame(ingameUiElements.SkillBar[highlightSkill].GetClientRect(), 3f, Color.Yellow); } } else { stopwatch.Stop(); } }
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); } }
private void TickLogic() { try { _ingameStateIngameUi = GameController.Game.IngameState.IngameUi; if (_ingameStateIngameUi.Map.SmallMiniMap.IsVisibleLocal) { var mapRect = _ingameStateIngameUi.Map.SmallMiniMap.GetClientRectCache; _screenCenterCache = new Vector2(mapRect.X + mapRect.Width / 2, mapRect.Y + mapRect.Height / 2); _largeMap = false; } else if (_ingameStateIngameUi.Map.LargeMap.IsVisibleLocal) { _screenCenterCache = ScreenCenter; _largeMap = true; } _k = Camera.Width < 1024f ? 1120f : 1024f; _scale = _k / Camera.Height * Camera.Width * 3f / 4f / MapWindow.LargeMapZoom; } catch (Exception e) { DebugWindow.LogError($"Terrain.TickLogic: {e.Message}"); } }
public override void Render() { ingameUiElements = GameController.Game.IngameState.IngameUi; if (!Initialised || ingameUiElements.InventoryPanel.IsVisible) { Initialised = true; cells = new CellData[CELLS_X_COUNT, CELLS_Y_COUNT]; AddItems(); return; } RectangleF rect = GameController.Window.GetWindowRectangle(); float xPos = rect.Width * Settings.PositionX * .01f; float yPos = rect.Height * Settings.PositionY * .01f; var startDrawPoint = new Vector2(xPos, yPos); /* * if (!Initialised) * { * Graphics.DrawText("Open inventory for initial synchronisation...", 15, startDrawPoint - new Vector2(-10, 20), SharpDX.Color.Red); * } */ CellDrawFlag = !CellDrawFlag; for (int x = 0; x < CELLS_X_COUNT; x++) { for (int y = 0; y < CELLS_Y_COUNT; y++) { DrawItem(x, y, startDrawPoint); } } }
public override void Render() { base.Render(); if (!Settings.Enable.Value) { return; } if (stopwatch.IsRunning && stopwatch.ElapsedMilliseconds < 5000) { IngameUIElements ingameUiElements = GameController.Game.IngameState.IngameUi; Graphics.DrawFrame(ingameUiElements.SkillBar[highlightSkill].GetClientRect(), 3f, Color.Yellow); } else { stopwatch.Stop(); } }
public void UpdateCommonlyUsedData() { //reset RarityContainerItems = new List <RarityContainer>(); _hoverElementRec = new RectangleF(0, 0, 0, 0); _IngameUiElements = GameController.Game.IngameState.IngameUi; _InventoryElement = _IngameUiElements.InventoryPanel; _StashElement = _IngameUiElements.StashElement; _VisibleStash = _StashElement.VisibleStash; _hoverElement = GameController.Game.IngameState.UIHover; if (_hoverElement.Tooltip != null && _hoverElement.Tooltip.IsVisibleLocal) { _hoverElementRec = _hoverElement.Tooltip.GetClientRect(); } }
private void AddItems() { IngameUIElements ui = GameController.Game.IngameState.IngameUi; var inventoryZone = ui.ReadObject <Element>(ui.InventoryPanel.Address + 0x808 + 0x248); RectangleF inventoryZoneRectangle = inventoryZone.GetClientRect(); var oneCellSize = new Size2F(inventoryZoneRectangle.Width / CELLS_X_COUNT, inventoryZoneRectangle.Height / CELLS_Y_COUNT); foreach (Element itemElement in inventoryZone.Children) { RectangleF itemElementRectangle = itemElement.GetClientRect(); var x = (int)((itemElementRectangle.X - inventoryZoneRectangle.X) / oneCellSize.Width + 0.5); var y = (int)((itemElementRectangle.Y - inventoryZoneRectangle.Y) / oneCellSize.Height + 0.5); var itemSize = new Size2((int)(itemElementRectangle.Width / oneCellSize.Width + 0.5), (int)(itemElementRectangle.Height / oneCellSize.Height + 0.5)); AddItem(x, y, itemSize); } }
private void TickLogic() { ingameStateIngameUi = GameController.Game.IngameState.IngameUi; if (ingameStateIngameUi.Map.SmallMiniMap.IsVisibleLocal) { var mapRect = ingameStateIngameUi.Map.SmallMiniMap.GetClientRectCache; screentCenterCache = new Vector2(mapRect.X + mapRect.Width / 2, mapRect.Y + mapRect.Height / 2); largeMap = false; } else if (ingameStateIngameUi.Map.LargeMap.IsVisibleLocal) { screentCenterCache = screenCenter; largeMap = true; } k = camera.Width < 1024f ? 1120f : 1024f; scale = k / camera.Height * camera.Width * 3f / 4f / mapWindow.LargeMapZoom; }
private bool DrawBorder(int entityAddress) { IngameUIElements ui = GameController.Game.IngameState.IngameUi; ItemsOnGroundLabelElement entityLabel; bool shouldUpdate = false; if (currentLabels.TryGetValue(entityAddress, out entityLabel)) { 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(false); } 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); } } else { shouldUpdate = true; } return(shouldUpdate); }
private void DrawBorder(int entityAddres) { IngameUIElements ui = GameController.Game.IngameState.IngameUi; if (currentLabels.ContainsKey(entityAddres)) { ItemsOnGroundLabelElement entitylabel = currentLabels[entityAddres]; 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); } } else { currentLabels = ui.ItemsOnGroundLabels.ToDictionary(y => y.ItemOnGround.Address, y => y); } }
private void GolemMain() { if (GameController == null || GameController.Window == null || GameController.Game.IngameState.Data.LocalPlayer == null || GameController.Game.IngameState.Data.LocalPlayer.Address == 0x00) { return; } if (!GameController.Window.IsForeground()) { return; } if (!GameController.Game.IngameState.Data.LocalPlayer.IsValid) { return; } var playerLife = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Life>(); if (playerLife == null || isTown) { return; } try { IngameUIElements ingameUiElements = GameController.Game.IngameState.IngameUi; List <int> golems = data.LocalPlayer.GetComponent <Actor>().Minions; int countChaosGolem = 0; int countFireGolem = 0; int countIceGolem = 0; int countLightningGolem = 0; int countStoneGolem = 0; foreach (var golemId in golems) { if (data.EntityList.EntitiesAsDictionary.ContainsKey(golemId)) { var golemPathString = data.EntityList.EntitiesAsDictionary[golemId].Path; if (golemPathString.Contains("ChaosElemental")) { countChaosGolem++; } if (golemPathString.Contains("FireElemental")) { countFireGolem++; } if (golemPathString.Contains("IceElemental")) { countIceGolem++; } if (golemPathString.Contains("LightningGolem")) { countLightningGolem++; } if (golemPathString.Contains("RockGolem")) { countStoneGolem++; } } } if (Settings.ChaosGolem.Value && countChaosGolem < Settings.ChaosGolemMax.Value && ingameUiElements.SkillBar[Settings.ChaosGolemConnectedSkill.Value - 1].SkillIconPath.Contains("ChaosElementalSummon")) { keyboard.KeyPressRelease(Settings.ChaosGolemKeyPressed.Value); } if (Settings.FireGolem.Value && countFireGolem < Settings.FireGolemMax.Value && ingameUiElements.SkillBar[Settings.FireGolemConnectedSkill.Value - 1].SkillIconPath.Contains("FireElementalSummon")) { keyboard.KeyPressRelease(Settings.FireGolemKeyPressed.Value); } if (Settings.IceGolem.Value && countIceGolem < Settings.IceGolemMax.Value && ingameUiElements.SkillBar[Settings.IceGolemConnectedSkill.Value - 1].SkillIconPath.Contains("IceElementalSummon")) { keyboard.KeyPressRelease(Settings.IceGolemKeyPressed.Value); } if (Settings.LightningGolem.Value && countLightningGolem < Settings.LightningGolemMax.Value && ingameUiElements.SkillBar[Settings.LightningGolemConnectedSkill.Value - 1].SkillIconPath.Contains("LightningGolem")) { keyboard.KeyPressRelease(Settings.LightningGolemKeyPressed.Value); } if (Settings.StoneGolem.Value && countStoneGolem < Settings.StoneGolemMax.Value && ingameUiElements.SkillBar[Settings.StoneGolemConnectedSkill.Value - 1].SkillIconPath.Contains("RockGolemSummon")) { keyboard.KeyPressRelease(Settings.StoneGolemKeyPressed.Value); } } catch (Exception) { } }
public override bool Initialise() { //PluginName = "Q40Picker"; ingameUI = GameController.IngameState.IngameUi; return(true); }
private void GolemMain() { if (isTown) { return; } if (GameController == null || GameController.Window == null || GameController.Game.IngameState.Data.LocalPlayer == null || GameController.Game.IngameState.Data.LocalPlayer.Address == 0x00) { return; } if (!GameController.Window.IsForeground()) { return; } if (!GameController.Game.IngameState.Data.LocalPlayer.IsValid) { return; } var playerLife = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Life>(); if (playerLife == null) { return; } try { List <int> golems = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Actor>().Minions; // Don't cast if number of golems is superior or equal to the targetNumber if (golems.Count >= targetNumber) { return; } if (Settings.DontCastOnNearbyMonster.Value) { Vector3 positionPlayer = GameController.Game.IngameState.Data.LocalPlayer.GetComponent <Render>().Pos; foreach (EntityWrapper monster in nearbyMonsters) { if (monster.IsValid && monster.IsAlive) { Render positionMonster = monster.GetComponent <Render>(); int distance = (int)Math.Sqrt(Math.Pow((double)(positionPlayer.X - positionMonster.X), 2.0) + Math.Pow((double)(positionPlayer.Y - positionMonster.Y), 2.0)); if (distance <= Settings.NearbyMonsterRange.Value) { return; //don't cast if monsters are nearby } } } } IngameUIElements ingameUiElements = GameController.Game.IngameState.IngameUi; int countChaosGolem = 0; int countFireGolem = 0; int countIceGolem = 0; int countLightningGolem = 0; int countStoneGolem = 0; foreach (var golemId in golems) { if (GameController.Game.IngameState.Data.EntityList.EntitiesAsDictionary.ContainsKey(golemId)) { var golemPathString = GameController.Game.IngameState.Data.EntityList.EntitiesAsDictionary[golemId].Path; if (golemPathString.Contains("ChaosElemental")) { countChaosGolem++; } if (golemPathString.Contains("FireElemental")) { countFireGolem++; } if (golemPathString.Contains("IceElemental")) { countIceGolem++; } if (golemPathString.Contains("LightningGolem")) { countLightningGolem++; } if (golemPathString.Contains("RockGolem")) { countStoneGolem++; } } } if (Settings.ChaosGolem.Value && countChaosGolem < Settings.ChaosGolemMax.Value && ingameUiElements.SkillBar[Settings.ChaosGolemConnectedSkill.Value - 1].SkillIconPath.Contains("ChaosElementalSummon")) { keyboard.KeyPressRelease(Settings.ChaosGolemKeyPressed.Value); } if (Settings.FireGolem.Value && countFireGolem < Settings.FireGolemMax.Value && ingameUiElements.SkillBar[Settings.FireGolemConnectedSkill.Value - 1].SkillIconPath.Contains("FireElementalSummon")) { keyboard.KeyPressRelease(Settings.FireGolemKeyPressed.Value); } if (Settings.IceGolem.Value && countIceGolem < Settings.IceGolemMax.Value && ingameUiElements.SkillBar[Settings.IceGolemConnectedSkill.Value - 1].SkillIconPath.Contains("IceElementalSummon")) { keyboard.KeyPressRelease(Settings.IceGolemKeyPressed.Value); } if (Settings.LightningGolem.Value && countLightningGolem < Settings.LightningGolemMax.Value && ingameUiElements.SkillBar[Settings.LightningGolemConnectedSkill.Value - 1].SkillIconPath.Contains("LightningGolem")) { keyboard.KeyPressRelease(Settings.LightningGolemKeyPressed.Value); } if (Settings.StoneGolem.Value && countStoneGolem < Settings.StoneGolemMax.Value && ingameUiElements.SkillBar[Settings.StoneGolemConnectedSkill.Value - 1].SkillIconPath.Contains("RockGolemSummon")) { keyboard.KeyPressRelease(Settings.StoneGolemKeyPressed.Value); } } catch (Exception err) { BasePlugin.LogError(err, 5); } }
public override void AreaChange(AreaInstance area) { ingameUI = GameController.IngameState.IngameUi; ReadIgnoreFile(); }
public override void AreaChange(AreaInstance area) => ingameUI = GameController.IngameState.IngameUi;
public override bool Initialise() { _inGameUi = GameController.IngameState.IngameUi; return(true); }
public override Job Tick() { try { if (Settings.ToggleFollower.PressedOnce()) { Settings.IsFollowEnabled.SetValueNoEvent(!Settings.IsFollowEnabled.Value); _tasks = new List <TaskNode>(); } // Close ritual window if opened if (GameController.Game.IngameState.IngameUi.RitualWindow.IsVisible) { Input.KeyUp(System.Windows.Forms.Keys.V); Thread.Sleep(random.Next(25) + 30); Input.KeyDown(System.Windows.Forms.Keys.V); Thread.Sleep(random.Next(25) + 30); Input.KeyUp(System.Windows.Forms.Keys.V); } // Dont run logic if ultimatum panel is visible int ultimatumPanelIndex = 93; IngameUIElements igu = GameController?.Game?.IngameState?.IngameUi; if (igu?.Children != null && igu.Children.Count > ultimatumPanelIndex && igu.Children[ultimatumPanelIndex].IsVisible) { Input.KeyUp(Settings.MovementKey); Input.KeyUp(Settings.DashKey); return(null); } //Dont run logic if we're dead! if (!GameController.Player.IsAlive) { Input.KeyUp(Settings.MovementKey); Input.KeyUp(Settings.DashKey); return(null); } if (!Settings.IsFollowEnabled.Value) { Input.KeyUp(Settings.MovementKey); Input.KeyUp(Settings.DashKey); return(null); } var _pathfindingDistance = Settings.PathfindingNodeDistance.Value; var _dt = Settings.PathfindingNodeDistance.Value * 3; if (Settings.ClearTasksTransitionKey.PressedOnce()) { _tasks = new List <TaskNode>(); var transOptions = _areaTransitions.Values. Where(I => Vector3.Distance(_lastTargetPosition, I.Pos) < Settings.ClearPathDistance). OrderBy(I => Vector3.Distance(_lastTargetPosition, I.Pos)).ToArray(); var _portalsCount = 0; foreach (Entity _to in transOptions) { if (_to.Type == ExileCore.Shared.Enums.EntityType.Portal || _to.Type == ExileCore.Shared.Enums.EntityType.TownPortal) { _portalsCount++; } } if (transOptions.Length > 0 && _portalsCount >= 4) { int transNumber = 0; transNumber = Settings.SlotNumber + 1; if (transNumber >= transOptions.Length) { transNumber = transOptions.Length - 1; } _tasks.Add(new TaskNode(transOptions[transNumber].Pos, _pathfindingDistance, TaskNodeType.Transition)); } else { var transition = _areaTransitions.Values.OrderBy(I => Vector3.Distance(GameController.Player.Pos, I.Pos)).FirstOrDefault(); var dist = Vector3.Distance(GameController.Player.Pos, transition.Pos); if (dist < Settings.ClearPathDistance.Value) { _tasks.Add(new TaskNode(transition.Pos, 200, TaskNodeType.Transition)); } } } foreach (var _t in _areaTransitions) { if (_t.Value?.Pos != null && GameController?.Player?.Pos != null) { if (Vector3.Distance(_t.Value.Pos, GameController.Player.Pos) <= _dt) { _pathfindingDistance = (int)((float)_pathfindingDistance * 3); break; } } } //Cache the current follow target (if present) _followTarget = GetFollowingTarget(); if (_followTarget != null) { var distanceFromFollower = Vector3.Distance(GameController.Player.Pos, _followTarget.Pos); //We are NOT within clear path distance range of leader. Logic can continue if (distanceFromFollower >= Settings.ClearPathDistance.Value) { //Leader moved VERY far in one frame. Check for transition to use to follow them. var distanceMoved = Vector3.Distance(_lastTargetPosition, _followTarget.Pos); if (_lastTargetPosition != Vector3.Zero && distanceMoved > Settings.ClearPathDistance.Value) { /*var transition = _areaTransitions.Values.OrderBy(I => Vector3.Distance(_lastTargetPosition, I.Pos)).FirstOrDefault(); * var dist = Vector3.Distance(_lastTargetPosition, transition.Pos); * if (dist < Settings.ClearPathDistance.Value) * _tasks.Add(new TaskNode(transition.Pos, 200, TaskNodeType.Transition));*/ } //We have no path, set us to go to leader pos. else if (_tasks.Count == 0) { _tasks.Add(new TaskNode(_followTarget.Pos, Settings.PathfindingNodeDistance)); } //We have a path. Check if the last task is far enough away from current one to add a new task node. else { var distanceFromLastTask = Vector3.Distance(_tasks.Last().WorldPosition, _followTarget.Pos); if (distanceFromLastTask >= Settings.PathfindingNodeDistance) { _tasks.Add(new TaskNode(_followTarget.Pos, Settings.PathfindingNodeDistance)); } } } else { //Clear all tasks except for looting/claim portal (as those only get done when we're within range of leader. if (_tasks.Count > 0) { for (var i = _tasks.Count - 1; i >= 0; i--) { if (_tasks[i].Type == TaskNodeType.Movement || _tasks[i].Type == TaskNodeType.Transition) { _tasks.RemoveAt(i); } } } else if (Settings.IsCloseFollowEnabled.Value) { //Close follow logic. We have no current tasks. Check if we should move towards leader if (distanceFromFollower >= _pathfindingDistance) { _tasks.Add(new TaskNode(_followTarget.Pos, Settings.PathfindingNodeDistance)); } } //Check if we should add quest loot logic. We're close to leader already var questLoot = GetLootableQuestItem(); if (Settings.IsLootQuestItemsEnabled && questLoot != null && Vector3.Distance(GameController.Player.Pos, questLoot.Pos) < Settings.ClearPathDistance.Value && _tasks.FirstOrDefault(I => I.Type == TaskNodeType.Loot) == null) { _tasks.Add(new TaskNode(questLoot.Pos, Settings.ClearPathDistance, TaskNodeType.Loot)); } else if (Settings.IsAutoPickUpWaypointEnabled && !_hasUsedWP) { //Check if there's a waypoint nearby var waypoint = GameController.EntityListWrapper.Entities.SingleOrDefault(I => I.Type == ExileCore.Shared.Enums.EntityType.Waypoint && Vector3.Distance(GameController.Player.Pos, I.Pos) < Settings.ClearPathDistance); if (waypoint != null) { _hasUsedWP = true; _tasks.Add(new TaskNode(waypoint.Pos, Settings.ClearPathDistance, TaskNodeType.ClaimWaypoint)); } } } _lastTargetPosition = _followTarget.Pos; } //Leader is null but we have tracked them this map. //Try using transition to follow them to their map else if (_tasks.Count == 0 && _lastTargetPosition != Vector3.Zero) { // dont auto use portal (happens randomly on laggy map /* * var transOptions = _areaTransitions.Values. * Where(I => Vector3.Distance(_lastTargetPosition, I.Pos) < Settings.ClearPathDistance). * OrderBy(I => Vector3.Distance(_lastTargetPosition, I.Pos)).ToArray(); * if (transOptions.Length > 0) * { * int transNumber = 0; * * if (transOptions.Length > 2) * { * transNumber = Settings.SlotNumber + 1; * * if (transNumber >= transOptions.Length) * { * transNumber = transOptions.Length - 1; * } * * } * _tasks.Add(new TaskNode(transOptions[transNumber].Pos, _pathfindingDistance, TaskNodeType.Transition)); * }*/ } //Don't run tasks if looting if (Input.GetKeyState(Settings.LootKey)) { Input.KeyUp(Settings.MovementKey); return(null); } //We have our tasks, now we need to perform in game logic with them. if (DateTime.Now > _nextBotAction && _tasks.Count > 0) { var currentTask = _tasks.First(); var taskDistance = Vector3.Distance(GameController.Player.Pos, currentTask.WorldPosition); var playerDistanceMoved = Vector3.Distance(GameController.Player.Pos, _lastPlayerPosition); //We are using a same map transition and have moved significnatly since last tick. Mark the transition task as done. if (currentTask.Type == TaskNodeType.Transition && playerDistanceMoved >= Settings.ClearPathDistance.Value) { _tasks.RemoveAt(0); if (_tasks.Count > 0) { currentTask = _tasks.First(); } else { _lastPlayerPosition = GameController.Player.Pos; return(null); } } switch (currentTask.Type) { case TaskNodeType.Movement: if (Vector3.Distance(currentTask.WorldPosition, GameController.Player.Pos) > Settings.ClearPathDistance.Value * 1.5) { Input.KeyUp(Settings.MovementKey); _tasks.RemoveAt(0); break; } _nextBotAction = DateTime.Now.AddMilliseconds(Settings.BotInputFrequency + random.Next(Settings.BotInputFrequency)); Vector3 direction; Vector3 normal; // Follow offsets direction = GameController.Player.Pos - currentTask.WorldPosition; direction.Normalize(); normal = new Vector3(-direction.Y, direction.X, direction.Z); direction *= Settings.FollowOffsetDirection; normal *= Settings.FollowOffsetNormal; Vector3 corrected = currentTask.WorldPosition + direction + normal; Mouse.SetCursorPosHuman2(WorldToValidScreenPosition(corrected)); Thread.Sleep(random.Next(25) + 30); if (!Input.GetKeyState(Settings.MovementKey)) { Input.KeyDown(Settings.MovementKey); } // dashing if enabled and far from target if (_followTarget != null && Settings.IsDashEnabled && Vector3.Distance(_followTarget.Pos, GameController.Player.Pos) > _pathfindingDistance * 3.5) { Input.KeyDown(Settings.DashKey); Thread.Sleep(random.Next(25) + 30); Input.KeyUp(Settings.DashKey); } //Within bounding range. Task is complete //Note: Was getting stuck on close objects... testing hacky fix. if (taskDistance <= _pathfindingDistance * 1.5) { _tasks.RemoveAt(0); } break; case TaskNodeType.Loot: { _nextBotAction = DateTime.Now.AddMilliseconds(Settings.BotInputFrequency + random.Next(Settings.BotInputFrequency)); currentTask.AttemptCount++; var questLoot = GetLootableQuestItem(); if (questLoot == null || currentTask.AttemptCount > 2 || Vector3.Distance(GameController.Player.Pos, questLoot.Pos) >= Settings.ClearPathDistance.Value) { _tasks.RemoveAt(0); } Input.KeyUp(Settings.MovementKey); Thread.Sleep(Settings.BotInputFrequency); //Pause for long enough for movement to hopefully be finished. var targetInfo = questLoot.GetComponent <Targetable>(); if (!targetInfo.isTargeted) { MouseoverItem(questLoot); } if (targetInfo.isTargeted) { Input.KeyUp(Settings.MovementKey); Thread.Sleep(25); Mouse.LeftMouseUp(); Thread.Sleep(25); Mouse.LeftMouseDown(); Thread.Sleep(25 + random.Next(Settings.BotInputFrequency)); Mouse.LeftMouseUp(); _nextBotAction = DateTime.Now.AddSeconds(1); } break; } case TaskNodeType.Transition: { _nextBotAction = DateTime.Now.AddMilliseconds(Settings.BotInputFrequency * 2 + random.Next(Settings.BotInputFrequency)); //if (taskDistance <= Settings.ClearPathDistance.Value) //{ if (currentTask.AttemptCount == 3) { Vector3 backDirection = _lastPlayerPosition - currentTask.WorldPosition; backDirection.Normalize(); backDirection *= 130; var stepBackScreenPos = WorldToValidScreenPosition(currentTask.WorldPosition + backDirection); Input.KeyUp(Settings.MovementKey); Mouse.SetCursorPosHuman2(stepBackScreenPos); Thread.Sleep(random.Next(25) + 30); Input.KeyDown(Settings.MovementKey); Thread.Sleep(random.Next(25) + 30); _nextBotAction = DateTime.Now.AddSeconds(1); Thread.Sleep(random.Next(25) + 600); Input.KeyUp(Settings.MovementKey); } else { var zOffset = -30; if (currentTask.AttemptCount <= 3) { zOffset = currentTask.AttemptCount * -40; } var screenPos = WorldToValidScreenPosition(currentTask.WorldPosition, zOffset); Input.KeyUp(Settings.MovementKey); if (currentTask.AttemptCount == 0) { // Use Phase run Input.KeyDown(Settings.PhaseRunKey); Thread.Sleep(random.Next(25) + 30); Input.KeyUp(Settings.PhaseRunKey); } //Click the transition Mouse.SetCursorPosAndLeftClickHuman(screenPos, 100); // _nextBotAction = DateTime.Now.AddSeconds(1); } /*} * else * { * //Walk towards the transition * Input.KeyUp(Settings.MovementKey); * Thread.Sleep(random.Next(25) + 30); * Mouse.SetCursorPosHuman2(screenPos); * Thread.Sleep(random.Next(25) + 30); * Input.KeyDown(Settings.MovementKey); * Thread.Sleep(random.Next(25) + 30); * Input.KeyUp(Settings.MovementKey); * }*/ currentTask.AttemptCount++; if (currentTask.AttemptCount > 5) { _tasks.RemoveAt(0); Input.KeyUp(Settings.MovementKey); } break; } case TaskNodeType.ClaimWaypoint: { if (Vector3.Distance(GameController.Player.Pos, currentTask.WorldPosition) > 150) { var screenPos = WorldToValidScreenPosition(currentTask.WorldPosition); Input.KeyUp(Settings.MovementKey); Thread.Sleep(Settings.BotInputFrequency); Mouse.SetCursorPosAndLeftClickHuman(screenPos, 100); _nextBotAction = DateTime.Now.AddSeconds(1); } currentTask.AttemptCount++; if (currentTask.AttemptCount > 3) { _tasks.RemoveAt(0); Input.KeyUp(Settings.MovementKey); } break; } } } else { if (GameController?.Player?.Pos == null || _followTarget?.Pos == null) { Input.KeyUp(Settings.MovementKey); } else { var recheckDistance = Vector3.Distance(GameController.Player.Pos, _followTarget.Pos); if (recheckDistance <= _pathfindingDistance * 1.3) { Input.KeyUp(Settings.MovementKey); } } } _lastPlayerPosition = GameController.Player.Pos; return(null); } catch (NullReferenceException) { return(null); } }