public void Calculate_Ydirection_for_smaller_150_equal_down() { var ret = DirectionCalculator.CalculateDirectionY(ValueYDown, DefaultCoeficient); Assert.AreEqual(HandMoveDirection.Down, ret); }
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 void Calculate_Ydirection_for_bigger_250_equal_up() { var ret = DirectionCalculator.CalculateDirectionY(ValueYUp, DefaultCoeficient); Assert.AreEqual(HandMoveDirection.Up, ret); }
public void Calculate_Ydirection_for_150_equal_center() { var ret = DirectionCalculator.CalculateDirectionY(ValueYMinCenter, DefaultCoeficient); Assert.AreEqual(HandMoveDirection.Center, ret); }
/// <summary> /// Gets the direction at this position. /// </summary> public static DirectionEnum Direction(this RoutePosition position) { return(DirectionCalculator.Calculate(position.Location(), position.NextLocation())); }
public void Calculate_Xdirection_for_smaller_minus50_equal_left() { var ret = DirectionCalculator.CalculateDirectionX(ValueXLeft, DefaultCoeficient); Assert.AreEqual(HandMoveDirection.Left, ret); }
public void ReturnEastWhenReversedFromWest() { Assert.Equal(DirectionCalculator.West, DirectionCalculator.Reverse(DirectionCalculator.East)); }
public async Task Reset() { LastReset = DateTime.Now; await this.stopMoving.Stop(); points.Clear(); logger.LogInformation("Sleeping 5 seconds"); await Task.Delay(5000); while (new List <double> { playerReader.XCoord, playerReader.YCoord, corpseLocation.X, corpseLocation.Y }.Max() > 100) { logger.LogInformation($"Waiting... odd coords read. Player {playerReader.XCoord},{playerReader.YCoord} corpse { corpseLocation.X}{corpseLocation.Y}"); await Task.Delay(5000); } logger.LogInformation($"player location {playerReader.XCoord},{playerReader.YCoord}. Corpse {corpseLocation.X},{corpseLocation.Y}."); var path = await pather.FindRouteTo(this.playerReader, corpseLocation); if (path.Any()) { path.Reverse(); path.ForEach(p => points.Push(p)); } else { var closestRouteAndSpiritPathPoints = routePoints.SelectMany(s => spiritWalkerPath.Select(swp => (pathPoint: s, spiritPathPoint: swp, distance: DistanceTo(s, swp)))) .OrderBy(s => s.distance) .First(); // spirit walker path leg var spiritWalkerLeg = new List <WowPoint>(); for (int i = 0; i < spiritWalkerPath.Count; i++) { spiritWalkerLeg.Add(spiritWalkerPath[i]); if (spiritWalkerPath[i] == closestRouteAndSpiritPathPoints.spiritPathPoint) { break; } } var closestRoutePointToCorpse = routePoints.Select(s => (pathPoint: s, distance: DistanceTo(s, corpseLocation))) .OrderBy(s => s.distance) .First() .pathPoint; //from closestRouteAndSpiritPathPoints to closestRoutePointToCorpse var pathStartPoint = closestRouteAndSpiritPathPoints.pathPoint; // see if we can walk forward through the points var legFromSpiritEndToCorpse = FillPathToCorpse(closestRoutePointToCorpse, pathStartPoint, routePoints); if (legFromSpiritEndToCorpse.Count == 0) { var reversePath = routePoints.Select(s => s).ToList(); reversePath.Reverse(); legFromSpiritEndToCorpse = FillPathToCorpse(closestRoutePointToCorpse, pathStartPoint, reversePath); } var routeToCorpse = spiritWalkerLeg.Select(s => s).ToList(); routeToCorpse.AddRange(legFromSpiritEndToCorpse); var myLocation = new WowPoint(playerReader.XCoord, playerReader.YCoord); var truncatedRoute = WowPoint.ShortenRouteFromLocation(myLocation, routeToCorpse); for (int i = truncatedRoute.Count - 1; i > -1; i--) { points.Push(truncatedRoute[i]); } var cp = new CorpsePath { MyLocation = myLocation, CorpseLocation = corpseLocation }; cp.RouteToCorpse.Clear(); cp.RouteToCorpse.AddRange(routeToCorpse); cp.TruncatedRoute.Clear(); cp.TruncatedRoute.AddRange(truncatedRoute); #if DEBUG //File.WriteAllText($"CorpsePath_{DateTime.Now.ToString("yyyyMMddHHmmss")}.json", JsonConvert.SerializeObject(cp)); #endif } if (points.Any()) { lastDistance = 999; NeedsToReset = false; this.stuckDetector.SetTargetLocation(points.Peek()); var heading = DirectionCalculator.CalculateHeading(this.playerReader.PlayerLocation, points.Peek()); await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse"); input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse"); this.stuckDetector.SetTargetLocation(points.Peek()); this.LastActive = DateTime.Now; } }
public void ReturnSouthWhenReversedFromNorth() { Assert.Equal(DirectionCalculator.South, DirectionCalculator.Reverse(DirectionCalculator.North)); }
public void ReturnWestWhenTurnedLeftFromNorth() { Assert.Equal(DirectionCalculator.West, DirectionCalculator.TurnLeft(DirectionCalculator.North)); }
public void ReturnNorthWhenTurnedRightFromWest() { Assert.Equal(DirectionCalculator.North, DirectionCalculator.TurnRight(DirectionCalculator.West)); }
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() { if (!await IsDead()) { return; } if (NeedsToReset) { Reset(); this.stuckDetector.SetTargetLocation(points.Peek()); } await Task.Delay(200); var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); double distance = 0; double heading = 0; if (points.Count == 0) { logger.LogInformation("No points left"); return; } 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(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { await AdjustHeading(heading); } lastDistance = distance; if (distance < 30 && points.Any()) { logger.LogInformation($"Move to next point"); points.Pop(); 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() { 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 (NeedsToReset) { while (true && this.playerReader.PlayerBitValues.DeadStatus) { this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY); if (this.corpseLocation.X > 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(); this.stuckDetector.SetTargetLocation(points.Peek()); 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) { 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(); } 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 < 40 && points.Any()) { logger.LogInformation($"Move to next point"); points.Pop(); 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() { 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 void Calculate_Xdirection_for_bigger_50_equal_right() { var ret = DirectionCalculator.CalculateDirectionX(ValueXRight, DefaultCoeficient); Assert.AreEqual(HandMoveDirection.Right, ret); }
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); } 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.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"); 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()) { 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() { 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; }