private bool AdjustNextPointToClosest() { if (wayPoints.Count < 2) { return(false); } var A = wayPoints.Pop(); var B = wayPoints.Peek(); var result = GetClosestPointOnLineSegment(A.Vector2(), B.Vector2(), new Vector2((float)this.playerReader.XCoord, (float)this.playerReader.YCoord)); var newPoint = new WowPoint(result.X, result.Y); if (WowPoint.DistanceTo(newPoint, wayPoints.Peek()) >= 4) { wayPoints.Push(newPoint); logger.LogInformation($"Adjusted resume point"); return(false); } else { logger.LogInformation($"Skipped next point in path"); // skiped next point return(true); } }
private void RefillWaypoints(bool findClosest = false) { if (firstLoad) { // start path at closest point firstLoad = false; var closestPoint = pointsList.OrderBy(p => WowPoint.DistanceTo(playerReader.PlayerLocation, p)).FirstOrDefault(); for (int i = 0; i < pointsList.Count; i++) { wayPoints.Push(pointsList[i]); if (pointsList[i] == closestPoint) { break; } } } else { if (findClosest) { pointsList.ForEach(p => wayPoints.Push(p)); AdjustNextPointToClosest(); } else { pointsList.ForEach(p => wayPoints.Push(p)); } } }
public async Task SetDirection(double desiredDirection, WowPoint point, string source, int ignoreDistance) { var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, point); if (!string.IsNullOrEmpty(source)) { Log($"SetDirection:- {source} Desired: {desiredDirection.ToString("0.000")}, Current: {playerReader.Direction.ToString("0.000")}, distance: {distance.ToString("0.000")}"); } if (distance < ignoreDistance) { Log("Too close, ignoring direction change."); return; } var key = GetDirectionKeyToPress(desiredDirection); TurnUsingTimedPress(desiredDirection, key); //await TurnAndReadActualDirection(desiredDirection, key); await Task.Delay(1); LastSetDirection = DateTime.Now; }
private async Task RefillRouteToNextWaypoint(bool forceUsePathing) { if (wayPoints.Count == 0) { RefillWaypoints(); } this.routeToWaypoint.Clear(); var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var heading = DirectionCalculator.CalculateHeading(location, wayPoints.Peek()); await playerDirection.SetDirection(heading, wayPoints.Peek(), "Reached waypoint").ConfigureAwait(false); //Create path back to route var distance = WowPoint.DistanceTo(location, wayPoints.Peek()); if (forceUsePathing || distance > 200) { await this.stopMoving.Stop(); var path = await this.pather.FindRouteTo(this.playerReader, wayPoints.Peek()); path.Reverse(); path.ForEach(p => this.routeToWaypoint.Push(p)); } this.ReduceRoute(); if (this.routeToWaypoint.Count == 0) { this.routeToWaypoint.Push(this.wayPoints.Peek()); } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); }
public override async Task PerformAction() { var targetLocation = this.classConfiguration.WrongZone.ExitZoneLocation; SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); await Task.Delay(200); input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 5"); if (this.playerReader.Bits.PlayerInCombat) { return; } if ((DateTime.Now - LastActive).TotalSeconds > 10) { this.stuckDetector.SetTargetLocation(targetLocation); } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, targetLocation); var heading = DirectionCalculator.CalculateHeading(location, targetLocation); if (lastDistance < distance) { await playerDirection.SetDirection(heading, targetLocation, "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 6"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN; var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN; if (Math.Min(diff1, diff2) > 0.3) { await playerDirection.SetDirection(heading, targetLocation, "Correcting direction"); } } lastDistance = distance; LastActive = DateTime.Now; }
private async Task BlinkIfMage() { var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40 && distance > 200 ) { await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name); } }
private void ReduceRoute() { if (routeToWaypoint.Any()) { var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); while (distance < PointReachedDistance() && routeToWaypoint.Any()) { routeToWaypoint.Pop(); if (routeToWaypoint.Any()) { distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); } } } }
private async Task MoveCloserToTarget(int pressDuration) { var distance = WowPoint.DistanceTo(playerReader.PlayerLocation, this.GetTargetLocation()); var lastDistance = distance; while (distance <= lastDistance && distance > 5) { logger.LogInformation($"Distance to vendor spot = {distance}"); lastDistance = distance; var heading = DirectionCalculator.CalculateHeading(playerReader.PlayerLocation, this.GetTargetLocation()); await playerDirection.SetDirection(heading, this.GetTargetLocation(), "Correcting direction", 0); await this.wowProcess.KeyPress(ConsoleKey.UpArrow, pressDuration); await this.stopMoving.Stop(); distance = WowPoint.DistanceTo(playerReader.PlayerLocation, this.GetTargetLocation()); } }
internal bool IsMoving() { var currentDistanceToTarget = WowPoint.DistanceTo(this.playerReader.PlayerLocation, targetLocation); if (Math.Abs(currentDistanceToTarget - previousDistanceToTarget) > 1) { ResetStuckParameters(); previousDistanceToTarget = currentDistanceToTarget; return(true); } if ((DateTime.Now - timeOfLastSignificantMovement).TotalSeconds > 3) { logger.LogInformation("We seem to be stuck!"); return(false); } return(true); }
public async Task PressKey(ConsoleKey key, string description = "", int duration = 300) { if (lastKeyPressed == classConfiguration.Interact.ConsoleKey) { var distance = WowPoint.DistanceTo(classConfiguration.Interact.LastClickPostion, this.playerReader.PlayerLocation); if (distance > 1) { logger.LogInformation($"Stop moving: We have moved since the last interact: {distance}"); await wowProcess.TapStopKey(); classConfiguration.Interact.SetClicked(); await Task.Delay(300); } } await wowProcess.KeyPress(key, duration, description); lastKeyPressed = key; }
public WowPoint?GetNearestVendor(WowPoint playerLocation) { if (CurrentArea == null || CurrentArea.vendor.Count == 0) { return(null); } NPC nearest = CurrentArea.vendor[0]; double dist = WowPoint.DistanceTo(nearest.points[0], playerLocation); CurrentArea.vendor.ForEach(npc => { var d = WowPoint.DistanceTo(npc.points[0], playerLocation); if (d < dist) { dist = d; nearest = npc; } }); return(nearest.points[0]); }
public override async Task PerformAction() { SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); if (this.classConfiguration.Mode == Mode.AttendedGather && this.lastGatherClick.AddSeconds(3) < DateTime.Now && this.classConfiguration.GatherFindKeyConfig.Count > 0) { lastGatherKey++; if (lastGatherKey >= this.classConfiguration.GatherFindKeyConfig.Count) { lastGatherKey = 0; } await wowProcess.KeyPress(classConfiguration.GatherFindKeyConfig[lastGatherKey].ConsoleKey, 200, "Gatherkey 1"); lastGatherClick = DateTime.Now; } if (points.Count == 0) { RefillPoints(true); this.stuckDetector.SetTargetLocation(this.points.Peek()); } await Task.Delay(200); wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1"); if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather) { return; } if ((DateTime.Now - LastActive).TotalSeconds > 10) { var pointsRemoved = 0; this.stuckDetector.SetTargetLocation(this.points.Peek()); while (AdjustNextPointToClosest() && pointsRemoved < 5) { pointsRemoved++; } ; } await RandomJump(); if (this.classConfiguration.Mode != Mode.AttendedGather) { // press tab if (!this.playerReader.PlayerBitValues.PlayerInCombat && (DateTime.Now - lastTab).TotalMilliseconds > 1100) { //new PressKeyThread(this.wowProcess, ConsoleKey.Tab); if (await LookForTarget()) { if (this.playerReader.HasTarget) { logger.LogInformation("Has target!"); return; } } } } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, points.Peek()); var heading = DirectionCalculator.CalculateHeading(location, points.Peek()); if (this.classConfiguration.Mode == Mode.AttendedGather) { await AdjustHeading(heading); } if (lastDistance < distance) { await playerDirection.SetDirection(heading, points.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; if (distance < PointReachedDistance()) { logger.LogInformation($"Move to next point"); points.Pop(); lastDistance = 999; if (points.Count == 0) { RefillPoints(); } this.stuckDetector.SetTargetLocation(this.points.Peek()); heading = DirectionCalculator.CalculateHeading(location, points.Peek()); await playerDirection.SetDirection(heading, points.Peek(), "Move to next point"); if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40) { await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name); } } // should mount if (shouldMount && !this.playerReader.PlayerBitValues.IsMounted && !playerReader.PlayerBitValues.PlayerInCombat) { if (this.classConfiguration.Mode != Mode.AttendedGather) { shouldMount = false; if (await LookForTarget()) { return; } } logger.LogInformation("Mounting if level >=40 (druid 30) and no NPC in sight"); if (!this.npcNameFinder.MobsVisible) { if (this.playerReader.PlayerLevel >= 40 && this.playerReader.PlayerClass != PlayerClassEnum.Druid) { await wowProcess.TapStopKey(); await Task.Delay(500); await wowProcess.Mount(this.playerReader); } if (this.playerReader.PlayerLevel >= 30 && this.playerReader.PlayerClass == PlayerClassEnum.Druid) { this.classConfiguration.ShapeshiftForm .Where(s => s.ShapeShiftFormEnum == ShapeshiftForm.Druid_Travel) .ToList() .ForEach(async k => await this.wowProcess.KeyPress(k.ConsoleKey, 325)); } } else { logger.LogInformation("Not mounting as can see NPC."); } wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 3"); } LastActive = DateTime.Now; }
public override async Task PerformAction() { SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); await Task.Delay(200); if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather) { return; } if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0) { await FillRouteToDestination(); } else { wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "VendorGoal 1"); } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); var heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await AdjustHeading(heading); if (lastDistance < distance) { await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "VendorGoal 2"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } lastDistance = distance; if (distance < PointReachedDistance()) { logger.LogInformation($"Move to next point"); ReduceRoute(); lastDistance = 999; if (routeToWaypoint.Count == 0) { await this.stopMoving.Stop(); distance = WowPoint.DistanceTo(location, this.GetTargetLocation()); if (distance > 50) { await FillRouteToDestination(); } if (routeToWaypoint.Count == 0) { await MoveCloserToTarget(400); await MoveCloserToTarget(100); // we have reached the target location await InteractWithTarget(); } } if (routeToWaypoint.Count == 0) { return; } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point"); distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40 && distance > 200) { await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name); } } // should mount await MountIfRequired(); LastActive = DateTime.Now; }
public override async Task PerformAction() { SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); await SwitchGatherType(); //await Task.Delay(200); if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather) { return; } var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds; if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0 || timeSinceResetSeconds > 80) { logger.LogInformation("Trying to path a new route."); // recalculate next waypoint var pointsRemoved = 0; while (AdjustNextPointToClosest() && pointsRemoved < 5) { pointsRemoved++; } ; await RefillRouteToNextWaypoint(true); } else { wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1"); } await RandomJump(); if (await AquireTarget()) { return; } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); var heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await AdjustHeading(heading); if (lastDistance < distance) { AdjustNextPointToClosest(); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; if (distance < PointReachedDistance()) { logger.LogInformation($"Move to next point"); ReduceRoute(); lastDistance = 999; if (routeToWaypoint.Count == 0) { wayPoints.Pop(); await RefillRouteToNextWaypoint(false); } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point"); await BlinkIfMage(); } // should mount await MountIfRequired(); LastActive = DateTime.Now; }
public override async Task PerformAction() { lastPlayerLocation = playerReader.PlayerLocation; await wait.Update(1); if (!playerReader.Bits.PlayerInCombat) { playerWasInCombat = false; } else { // we are in combat if (!playerWasInCombat && HasPickedUpAnAdd) { logger.LogInformation("WARN Bodypull -- Looks like we have an add on approach"); logger.LogInformation($"Combat={playerReader.Bits.PlayerInCombat}, Is Target targetting me={playerReader.Bits.TargetOfTargetIsPlayer}"); await stopMoving.Stop(); await input.TapClearTarget(); await wait.Update(1); if (playerReader.PetHasTarget) { await input.TapTargetPet(); await input.TapTargetOfTarget(); await wait.Update(1); } } playerWasInCombat = true; } if (input.ClassConfig.Approach.GetCooldownRemaining() == 0) { await input.TapApproachKey(""); } lastPlayerDistance = WowPoint.DistanceTo(lastPlayerLocation, playerReader.PlayerLocation); if (lastPlayerDistance < 0.05 && playerReader.LastUIErrorMessage == UI_ERROR.ERR_AUTOFOLLOW_TOO_FAR) { playerReader.LastUIErrorMessage = UI_ERROR.NONE; input.SetKeyState(ConsoleKey.UpArrow, true, false, $"{GetType().Name}: Too far, start moving forward!"); await wait.Update(1); } if (SecondsSinceApproachStarted > 1 && lastPlayerDistance < 0.05 && !playerReader.Bits.PlayerInCombat) { await input.TapClearTarget(""); await wait.Update(1); await input.KeyPress(random.Next(2) == 0?ConsoleKey.LeftArrow : ConsoleKey.RightArrow, 1000, $"Seems stuck! Clear Target. Turn away. d: {lastPlayerDistance}"); approachStart = DateTime.Now; } if (SecondsSinceApproachStarted > 15 && !playerReader.Bits.PlayerInCombat) { await input.TapClearTarget(""); await wait.Update(1); await input.KeyPress(random.Next(2) == 0?ConsoleKey.LeftArrow : ConsoleKey.RightArrow, 1000, "Too long time. Clear Target. Turn away."); approachStart = DateTime.Now; } if (playerReader.TargetGuid == initialTargetGuid) { var initialTargetMinRange = playerReader.MinRange; if (!playerReader.Bits.PlayerInCombat) { await input.TapNearestTarget("Try to find closer target..."); await wait.Update(1); } if (playerReader.TargetGuid != initialTargetGuid) { if (playerReader.HasTarget) // blacklist { if (playerReader.MinRange < initialTargetMinRange) { Log($"Found a closer target! {playerReader.MinRange} < {initialTargetMinRange}"); initialMinRange = playerReader.MinRange; } else { initialTargetGuid = -1; await input.TapLastTargetKey($"Stick to initial target!"); await wait.Update(1); } } else { Log($"Lost the target due blacklist!"); } } } if (initialMinRange < playerReader.MinRange && !playerReader.Bits.PlayerInCombat) { Log($"We are going away from the target! {initialMinRange} < {playerReader.MinRange}"); await input.TapClearTarget(); await wait.Update(1); approachStart = DateTime.Now; } await RandomJump(); }
public override async Task PerformAction() { // is corpse visible if (this.playerReader.CorpseX < 1 && this.playerReader.CorpseX < 1) { await this.stopMoving.Stop(); logger.LogInformation($"Waiting for corpse location to update update before performing action. Corpse is @ {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(5000); NeedsToReset = true; return; } if (NeedsToReset) { await this.stopMoving.Stop(); while (this.playerReader.Bits.DeadStatus) { this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY, playerReader.ZCoord); if (this.corpseLocation.X >= 1 || this.corpseLocation.Y > 0) { break; } logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(1000); } logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}"); await Reset(); Deaths.Add(this.corpseLocation); } var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds; if (timeSinceResetSeconds > 80) { await this.stopMoving.Stop(); logger.LogInformation("We have been dead for over 1 minute, trying to path a new route."); await this.Reset(); } await Task.Delay(200); if (!this.playerReader.Bits.DeadStatus) { return; } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord, playerReader.ZCoord); double distance = 0; double heading = 0; if (points.Count == 0) { await Reset(); if (!points.Any()) { points.Push(this.playerReader.CorpseLocation); distance = DistanceTo(location, corpseLocation); heading = DirectionCalculator.CalculateHeading(location, corpseLocation); this.logger.LogInformation("no more points, heading to corpse"); await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse"); input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse"); this.stuckDetector.SetTargetLocation(points.Peek()); } } else { distance = DistanceTo(location, points.Peek()); heading = DirectionCalculator.CalculateHeading(location, points.Peek()); } if (lastDistance < distance) { await playerDirection.SetDirection(heading, points.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpseAction"); await Task.Delay(100); if (HasBeenActiveRecently()) { await stuckDetector.Unstick(); // give up if we have been dead for 10 minutes var timeDeadSeconds = (DateTime.Now - LastEventReceived).TotalSeconds; if (timeDeadSeconds > 600) { logger.LogInformation("We have been dead for 10 minutes and seem to be stuck."); SendActionEvent(new ActionEventArgs(GOAP.GoapKey.abort, true)); await Task.Delay(10000); return; } distance = DistanceTo(location, points.Peek()); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN; var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN; if (Math.Min(diff1, diff2) > 0.3) { await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction"); } } lastDistance = distance; if (distance < PointReachedDistance() && points.Any()) { if (points.Any()) { playerReader.ZCoord = points.Peek().Z; logger.LogInformation($"{GetType().Name}: PlayerLocation.Z = {playerReader.PlayerLocation.Z}"); } while (distance < PointReachedDistance() && points.Any()) { points.Pop(); if (points.Any()) { distance = WowPoint.DistanceTo(location, points.Peek()); } } lastDistance = 999; if (points.Count > 0) { heading = DirectionCalculator.CalculateHeading(location, points.Peek()); await playerDirection.SetDirection(heading, points.Peek(), "Move to next point"); this.stuckDetector.SetTargetLocation(points.Peek()); } } LastActive = DateTime.Now; }
public override async Task PerformAction() { // is corpse visible if (this.playerReader.CorpseX < 1 && this.playerReader.CorpseX < 1) { await this.stopMoving.Stop(); logger.LogInformation($"Waiting for corpse location to update update before performing action. Corpse is @ {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(5000); NeedsToReset = true; return; } if (NeedsToReset) { await this.stopMoving.Stop(); while (this.playerReader.PlayerBitValues.DeadStatus) { this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY); if (this.corpseLocation.X >= 1 || this.corpseLocation.Y > 0) { break; } logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(1000); } logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}"); await Reset(); Deaths.Add(this.corpseLocation); } await Task.Delay(200); if (!this.playerReader.PlayerBitValues.DeadStatus) { return; } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); double distance = 0; double heading = 0; if (points.Count == 0) { await Reset(); if (!points.Any()) { points.Push(this.playerReader.CorpseLocation); distance = DistanceTo(location, corpseLocation); heading = DirectionCalculator.CalculateHeading(location, corpseLocation); this.logger.LogInformation("no more points, heading to corpse"); await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse"); wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse"); this.stuckDetector.SetTargetLocation(points.Peek()); } } else { distance = DistanceTo(location, points.Peek()); heading = DirectionCalculator.CalculateHeading(location, points.Peek()); } if (lastDistance < distance) { await playerDirection.SetDirection(heading, points.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpseAction"); await Task.Delay(100); if (HasBeenActiveRecently()) { await stuckDetector.Unstick(); await this.stopMoving.Stop(); await this.Reset(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN; var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN; if (Math.Min(diff1, diff2) > 0.3) { await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction"); } } lastDistance = distance; if (distance < PointReachedDistance() && points.Any()) { while (distance < PointReachedDistance() && points.Any()) { points.Pop(); if (points.Any()) { distance = WowPoint.DistanceTo(location, points.Peek()); } } lastDistance = 999; if (points.Count > 0) { heading = DirectionCalculator.CalculateHeading(location, points.Peek()); await playerDirection.SetDirection(heading, points.Peek(), "Move to next point"); this.stuckDetector.SetTargetLocation(points.Peek()); } } LastActive = DateTime.Now; }
private bool IsPlayerMoving(WowPoint lastPos) { var distance = WowPoint.DistanceTo(lastPos, playerReader.PlayerLocation); return(distance > 0.5f); }
public override async Task PerformAction() { SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); if (await AquireTarget()) { await stopMoving.StopTurn(); if (playerReader.PlayerClass == PlayerClassEnum.Hunter) { if (playerReader.PlayerBitValues.TargetCanBeHostile) { await input.TapInteractKey("approach target as hunter"); } else { await input.TapClearTarget("not hostile"); } } return; } await SwitchGatherType(); await playerReader.WaitForNUpdate(1); if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather) { return; } var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds; if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0 || timeSinceResetSeconds > 80) { logger.LogInformation("Trying to path a new route."); // recalculate next waypoint var pointsRemoved = 0; while (AdjustNextPointToClosest() && pointsRemoved < 5) { pointsRemoved++; } ; await RefillRouteToNextWaypoint(true); if (routeToWaypoint.Count == 0) { logger.LogError("Didn't found path."); } } else { var playerLocation = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distanceToRoute = WowPoint.DistanceTo(playerLocation, routeToWaypoint.Peek()); if (routeToWaypoint.Count <= 1 && distanceToRoute > 200) { logger.LogError("wtf too far away kekw"); routeToWaypoint.Pop(); return; } //wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1"); input.SetKeyState(ConsoleKey.UpArrow, true, false); } await RandomJump(); var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); var heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await AdjustHeading(heading); if (lastDistance < distance) { AdjustNextPointToClosest(); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; //if (distance < PointReachedDistance((int)(avgDistance / 2))) //if (distance < PointReachedDistance(5)) if (distance < PointReachedDistance(10)) { Log($"Move to next point"); ReduceRouteByDistance(); lastDistance = 999; if (routeToWaypoint.Count == 0) { wayPoints.Pop(); await RefillRouteToNextWaypoint(false); } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point"); } // should mount await MountIfRequired(); LastActive = DateTime.Now; }
public override async Task PerformAction() { if (playerReader.HasTarget) { if (playerReader.Bits.TargetIsDead) { await input.TapClearTarget("Target is dead."); await wait.Update(1); return; } await stopMoving.StopTurn(); return; } if (playerReader.Bits.IsDrowning) { await StopDrowning(); } await SwitchGatherType(); if (this.playerReader.Bits.PlayerInCombat && classConfiguration.Mode != Mode.AttendedGather) { return; } var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds; if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0 || timeSinceResetSeconds > 80) { logger.LogInformation("Trying to path a new route."); // recalculate next waypoint var pointsRemoved = 0; while (AdjustNextPointToClosest() && pointsRemoved < 5) { pointsRemoved++; } ; await RefillRouteToNextWaypoint(true); if (routeToWaypoint.Count == 0) { logger.LogError("Didn't found path."); } } else { var playerLocation = new WowPoint(playerReader.XCoord, playerReader.YCoord, playerReader.ZCoord); if (routeToWaypoint.Count > 0) { var distanceToRoute = WowPoint.DistanceTo(playerLocation, routeToWaypoint.Peek()); if (routeToWaypoint.Count < 1 && distanceToRoute > 200) { logger.LogError($"No route To Waypoint or too far {distanceToRoute}>200"); routeToWaypoint.Pop(); return; } } input.SetKeyState(ConsoleKey.UpArrow, true, false); } await RandomJump(); var location = new WowPoint(playerReader.XCoord, playerReader.YCoord, playerReader.ZCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); var heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await AdjustHeading(heading); if (lastDistance < distance) { AdjustNextPointToClosest(); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2"); await wait.Update(1); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); } else { await wait.Update(1); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; if (distance < PointReachedDistance(MinDistance)) { Log($"Move to next point"); if (routeToWaypoint.Any()) { playerReader.ZCoord = routeToWaypoint.Peek().Z; Log($"PlayerLocation.Z = {playerReader.PlayerLocation.Z}"); } ReduceRouteByDistance(MinDistance); lastDistance = 999; if (routeToWaypoint.Count == 0) { wayPoints.Pop(); await RefillRouteToNextWaypoint(false); } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point"); } // should mount await MountIfRequired(); LastActive = DateTime.Now; await wait.Update(1); }
public override async Task PerformAction() { SendActionEvent(new ActionEventArgs(GoapKey.fighting, false)); if (this.classConfiguration.Mode == Mode.AttendedGather && this.lastGatherClick.AddSeconds(3) < DateTime.Now && this.classConfiguration.GatherFindKeyConfig.Count > 0) { lastGatherKey++; if (lastGatherKey >= this.classConfiguration.GatherFindKeyConfig.Count) { lastGatherKey = 0; } await wowProcess.KeyPress(classConfiguration.GatherFindKeyConfig[lastGatherKey].ConsoleKey, 200, "Gatherkey 1"); lastGatherClick = DateTime.Now; } await Task.Delay(200); if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather) { return; } if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0) { // recalculate next waypoint var pointsRemoved = 0; while (AdjustNextPointToClosest() && pointsRemoved < 5) { pointsRemoved++; } ; await RefillRouteToNextWaypoint(true); } else { wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1"); } await RandomJump(); if (this.classConfiguration.Mode != Mode.AttendedGather) { // press tab if (!this.playerReader.PlayerBitValues.PlayerInCombat && (DateTime.Now - lastTab).TotalMilliseconds > 1100) { //new PressKeyThread(this.wowProcess, ConsoleKey.Tab); if (await LookForTarget()) { if (this.playerReader.HasTarget) { logger.LogInformation("Has target!"); return; } } } } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); var heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); //if (this.classConfiguration.Mode == Mode.AttendedGather) //{ await AdjustHeading(heading); //} if (lastDistance < distance) { await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2"); await Task.Delay(100); if (HasBeenActiveRecently()) { await this.stuckDetector.Unstick(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; if (distance < PointReachedDistance()) { logger.LogInformation($"Move to next point"); ReduceRoute(); lastDistance = 999; if (routeToWaypoint.Count == 0) { wayPoints.Pop(); await RefillRouteToNextWaypoint(false); } this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek()); heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek()); await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point"); distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek()); if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40 && distance > 200 ) { await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name); } } // should mount await MountIfRequired(); LastActive = DateTime.Now; }