async Task GoalExit() { SendActionEvent(new ActionEventArgs(GoapKey.shouldskin, false)); npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Enemy); await input.TapClearTarget(); }
public async Task <GoapGoal?> GetAction() { if (playerReader.HealthPercent > 1 && blacklist.IsTargetBlacklisted()) { logger.LogWarning("Target is blacklisted"); await input.TapClearTarget(); UpdateWorldState(); } var goal = new HashSet <KeyValuePair <GoapKey, GoapPreCondition> >(); //Plan Queue <GoapGoal> plan = planner.Plan(AvailableGoals, WorldState, goal); if (plan != null && plan.Count > 0) { CurrentGoal = plan.Peek(); } else { logger.LogInformation($"Target Health: {playerReader.TargetHealth}, max {playerReader.TargetMaxHealth}, dead {playerReader.PlayerBitValues.TargetIsDead}"); if (this.classConfiguration.Mode != Mode.AttendedGrind) { await input.TapNearestTarget(); } } return(CurrentGoal); }
public async Task <bool> Search(string source, CancellationToken cancellationToken) { if (!cancellationToken.IsCancellationRequested && !playerReader.Bits.PlayerInCombat && classConfig.TargetNearestTarget.MillisecondsSinceLastClick > random.Next(1000, 1500)) { if (await LookForTarget(source, cancellationToken)) { if (playerReader.HasTarget && !playerReader.Bits.TargetIsDead) { logger.LogInformation($"{source}: Has target!"); return(true); } else { if (!cancellationToken.IsCancellationRequested) { await input.TapClearTarget($"{source}: Target is dead!"); } if (!cancellationToken.IsCancellationRequested) { await wait.Update(1); } } } } return(false); }
private async Task CreatureTargetMeOrMyPet() { await wait.Update(1); if (playerReader.PetHasTarget && addonReader.CreatureHistory.CombatDeadGuid.Value != playerReader.PetTargetGuid) { logger.LogWarning("---- My pet has a target!"); ResetCooldowns(); await input.TapTargetPet(); await input.TapTargetOfTarget(); await wait.Update(1); return; } if (addonReader.CombatCreatureCount > 1) { await input.TapNearestTarget($"{GetType().Name}: Checking target in front of me"); await wait.Update(1); if (playerReader.HasTarget) { if (playerReader.Bits.TargetInCombat && playerReader.Bits.TargetOfTargetIsPlayer) { ResetCooldowns(); logger.LogWarning("---- Somebody is attacking me!"); await input.TapInteractKey("Found new target to attack"); await stopMoving.Stop(); await wait.Update(1); return; } await input.TapClearTarget(); await wait.Update(1); } else { // threat must be behind me var anyDamageTakens = addonReader.CreatureHistory.DamageTaken.Where(x => (DateTime.Now - x.LastEvent).TotalSeconds < 10 && x.HealthPercent > 0); if (anyDamageTakens.Any()) { logger.LogWarning($"---- Possible threats found behind {anyDamageTakens.Count()}. Waiting for my target to change!"); await wait.Interrupt(2000, () => playerReader.HasTarget); } } } }
public override async Task PerformAction() { await input.TapTargetPet(); await input.TapTargetOfTarget(); if (playerReader.HasTarget && playerReader.Bits.TargetIsDead) { await input.TapClearTarget(); } }
public override async Task PerformAction() { lastLoot = playerReader.LastLootTime; await stopMoving.Stop(); combatUtil.Update(); await input.TapLastTargetKey($"{GetType().Name}: No corpse name found - check last dead target exists"); await wait.Update(1); if (playerReader.HasTarget) { if (playerReader.Bits.TargetIsDead) { await input.TapInteractKey($"{GetType().Name}: Found last dead target"); await wait.Update(1); (bool foundTarget, bool moved) = await combatUtil.FoundTargetWhileMoved(); if (foundTarget) { Log("Goal interrupted!"); return; } if (moved) { await input.TapInteractKey($"{GetType().Name}: Last dead target double"); } } else { await input.TapClearTarget($"{GetType().Name}: Don't attack the target!"); } } await GoalExit(); }
private async Task AquireTarget() { if (this.playerReader.PlayerBitValues.PlayerInCombat && this.playerReader.PetHasTarget) { await input.TapTargetPet(); Log($"Pets target {this.playerReader.TargetTarget}"); if (this.playerReader.TargetTarget == TargetTargetEnum.PetHasATarget) { Log("Found target by pet"); await input.TapTargetOfTarget(); SendActionEvent(new ActionEventArgs(GoapKey.shouldloot, false)); SendActionEvent(new ActionEventArgs(GoapKey.newtarget, true)); SendActionEvent(new ActionEventArgs(GoapKey.hastarget, true)); return; } await input.TapNearestTarget(); await playerReader.WaitForNUpdate(1); if (this.playerReader.HasTarget && playerReader.PlayerBitValues.TargetInCombat) { if (playerReader.PlayerBitValues.TargetOfTargetIsPlayer) { Log("Found from nearest target"); SendActionEvent(new ActionEventArgs(GoapKey.shouldloot, false)); SendActionEvent(new ActionEventArgs(GoapKey.newtarget, true)); SendActionEvent(new ActionEventArgs(GoapKey.hastarget, true)); return; } } await input.TapClearTarget(); Log("No target found"); } }
public async Task <GoapGoal?> GetAction() { if (playerReader.HealthPercent > 1 && blacklist.IsTargetBlacklisted()) { logger.LogWarning($"{GetType().Name}: Target is blacklisted - StopAttack & ClearTarget"); await input.TapStopAttack(""); await input.TapClearTarget(""); UpdateWorldState(); } var goal = new HashSet <KeyValuePair <GoapKey, GoapPreCondition> >(); //Plan Queue <GoapGoal> plan = planner.Plan(AvailableGoals, WorldState, goal); if (plan != null && plan.Count > 0) { if (CurrentGoal == plan.Peek() && !CurrentGoal.Repeatable) { logger.LogInformation($"Plan= {CurrentGoal.GetType().Name} is not Repeatable!"); CurrentGoal = null; } else { CurrentGoal = plan.Peek(); } } else { if (CurrentGoal != null && !CurrentGoal.Repeatable) { logger.LogInformation($"Plan= {CurrentGoal.GetType().Name} is not Repeatable!"); CurrentGoal = null; await stopMoving.Stop(); } } return(CurrentGoal); }
private async Task <bool> CreatureTargetMeOrMyPet() { if (playerReader.PetHasTarget && playerReader.LastKilledGuid != playerReader.PetTargetGuid) { logger.LogWarning("---- My pet has a target!"); ResetCooldowns(); await input.TapTargetPet(); await input.TapTargetOfTarget(); return(playerReader.HasTarget); } // check for targets attacking me await input.TapNearestTarget(); await playerReader.WaitForNUpdate(1); if (this.playerReader.HasTarget && playerReader.PlayerBitValues.TargetInCombat) { if (this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer) { ResetCooldowns(); logger.LogWarning("---- Somebody is attacking me or my pet!"); await input.TapInteractKey("Found new target to attack"); return(true); } } await input.TapClearTarget(); logger.LogWarning("---- No Threat has been found!"); return(false); }
private async Task GoalExit() { if (!await wait.Interrupt(1000, () => lastLoot != playerReader.LastLootTime)) { Log($"Skin-Loot Successfull"); } else { Log($"Skin-Loot Failed"); } lastLoot = playerReader.LastLootTime; SendActionEvent(new ActionEventArgs(GoapKey.shouldskin, false)); if (playerReader.HasTarget && playerReader.Bits.TargetIsDead) { await input.TapClearTarget(); await wait.Update(1); } }
public override async Task PerformAction() { long lastHealth = playerReader.HealthCurrent; WowPoint lastPosition = playerReader.PlayerLocation; SendActionEvent(new ActionEventArgs(GoapKey.shouldskin, !playerReader.Unskinnable)); await input.TapInteractKey("interact target"); while (IsPlayerMoving(lastPosition)) { logger.LogInformation("wait till the player become stil!"); lastPosition = playerReader.PlayerLocation; if (!await Wait(100, () => playerReader.HealthCurrent < lastHealth)) { return; } } if (!await Wait(100, () => playerReader.HealthCurrent < lastHealth)) { return; } await input.TapInteractKey("Looting..."); // wait grabbing the loot if (!await Wait(200, () => playerReader.HealthCurrent < lastHealth)) { return; } logger.LogDebug("Loot was Successfull"); SendActionEvent(new ActionEventArgs(GoapKey.shouldloot, false)); //clear target //await wowProcess.KeyPress(ConsoleKey.F3, 50); await input.TapClearTarget(); }
private async Task <bool> AquireTarget() { if (this.classConfiguration.Mode != Mode.AttendedGather) { if (!this.playerReader.PlayerBitValues.PlayerInCombat && classConfiguration.TargetNearestTarget.MillisecondsSinceLastClick > 1000) { if (await LookForTarget()) { if (this.playerReader.HasTarget && !playerReader.PlayerBitValues.TargetIsDead) { logger.LogInformation("Has target!"); return(true); } else { await input.TapClearTarget("Target is dead!"); } } } } return(false); }
public override async Task PerformAction() { await input.TapStopAttack(); this.playerReader.LastUIErrorMessage = UI_ERROR.NONE; if ((DateTime.Now - LastActive).TotalSeconds > 5) { PullStartTime = DateTime.Now; } LastActive = DateTime.Now; /* * if ((DateTime.Now - PullStartTime).TotalSeconds > 30) * { * //await wowProcess.KeyPress(ConsoleKey.F3, 50); // clear target * await wowProcess.TapClearTarget(); * await this.wowProcess.KeyPress(ConsoleKey.RightArrow, 1000, "Turn after pull timeout"); * return; * } */ SendActionEvent(new ActionEventArgs(GoapKey.fighting, true)); if (playerReader.PlayerBitValues.IsMounted) { logger.LogInformation($"Dismount"); await input.Dismount(); } if (ShouldStopBeforePull) { logger.LogInformation($"Stop approach"); await this.stopMoving.Stop(); await input.TapStopAttack(); await input.TapStopKey(); } bool pulled = await Pull(); if (!pulled) { if (HasPickedUpAnAdd) { logger.LogInformation($"Combat={this.playerReader.PlayerBitValues.PlayerInCombat}, Is Target targetting me={this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer}"); logger.LogInformation($"Add on approach"); await this.stopMoving.Stop(); await input.TapStopKey(); //await wowProcess.KeyPress(ConsoleKey.F3, 50); // clear target //await wowProcess.TapClearTarget(); await input.TapNearestTarget(); if (this.playerReader.HasTarget && playerReader.PlayerBitValues.TargetInCombat) { if (this.playerReader.TargetTarget == TargetTargetEnum.TargetIsTargettingMe) { return; } } await input.TapClearTarget(); return; } if (!this.stuckDetector.IsMoving()) { await this.stuckDetector.Unstick(); } await Interact(); await this.playerReader.WaitForNUpdate(1); } else { this.SendActionEvent(new ActionEventArgs(GoapKey.pulled, true)); this.playerReader.LastUIErrorMessage = UI_ERROR.NONE; } }
public override async Task PerformAction() { if (playerReader.PlayerBitValues.IsMounted) { await input.Dismount(); } if (NeedsToReset) { this.stuckDetector.ResetStuckParameters(); } var location = playerReader.PlayerLocation; if (!playerReader.PlayerBitValues.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={this.playerReader.PlayerBitValues.PlayerInCombat}, Is Target targetting me={this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer}"); await this.stopMoving.Stop(); await input.TapClearTarget(); await input.TapStopKey(); if (playerReader.PetHasTarget) { await this.input.TapTargetPet(); await this.input.TapTargetOfTarget(); } } playerWasInCombat = true; } await this.TapInteractKey("ApproachTargetAction 1"); await this.playerReader.WaitForNUpdate(1); var newLocation = playerReader.PlayerLocation; if ((location.X == newLocation.X && location.Y == newLocation.Y && SecondsSinceLastFighting > 5) || this.playerReader.LastUIErrorMessage == UI_ERROR.ERR_AUTOFOLLOW_TOO_FAR) { input.SetKeyState(ConsoleKey.UpArrow, true, false, "ApproachTargetAction"); await Wait(100, () => false); await input.TapJump(); this.playerReader.LastUIErrorMessage = UI_ERROR.NONE; } await RandomJump(); // int approachSeconds = (int)(this.stuckDetector.actionDurationSeconds); if (approachSeconds > 20) { await this.stuckDetector.Unstick(); await this.TapInteractKey("ApproachTargetAction unstick"); await Task.Delay(250); } if (playerReader.WithInCombatRange && ( playerReader.PlayerClass == PlayerClassEnum.Rogue || playerReader.PlayerClass == PlayerClassEnum.Warrior || playerReader.PlayerClass == PlayerClassEnum.Paladin)) { Log("WithInCombatRange -- Strictly melee -- Wait a moment"); await stopMoving.Stop(); await this.TapInteractKey("ApproachTargetAction engage"); await Task.Delay(200); } }
public override async Task PerformAction() { if (SecondsSincePullStarted > 7) { await input.TapClearTarget(); await input.KeyPress(random.Next(2) == 0?ConsoleKey.LeftArrow : ConsoleKey.RightArrow, 1000, "Too much time to pull!"); pullStart = DateTime.Now; return; } SendActionEvent(new ActionEventArgs(GoapKey.fighting, true)); if (!await Pull()) { if (HasPickedUpAnAdd) { Log($"Combat={this.playerReader.Bits.PlayerInCombat}, Is Target targetting me={this.playerReader.Bits.TargetOfTargetIsPlayer}"); Log($"Add on approach"); await stopMoving.Stop(); await input.TapNearestTarget(); await wait.Update(1); if (this.playerReader.HasTarget && playerReader.Bits.TargetInCombat) { if (this.playerReader.TargetTarget == TargetTargetEnum.TargetIsTargettingMe) { return; } } await input.TapClearTarget(); await wait.Update(1); pullStart = DateTime.Now; return; } if (!stuckDetector.IsMoving()) { await stuckDetector.Unstick(); } if (classConfiguration.Approach.GetCooldownRemaining() == 0) { await input.TapApproachKey($"{GetType().Name}"); await wait.Update(1); } } else { SendActionEvent(new ActionEventArgs(GoapKey.pulled, true)); } }
public override async Task PerformAction() { lastLoot = playerReader.LastLootTime; await stopMoving.Stop(); combatUtil.Update(); await npcNameTargeting.WaitForNUpdate(2); bool foundCursor = await npcNameTargeting.FindBy(CursorType.Loot); if (foundCursor) { Log("Found corpse - clicked"); (bool notFoundTarget, double elapsedMs) = await wait.InterruptTask(200, () => playerReader.TargetId != 0); if (!notFoundTarget) { Log($"Found target after {elapsedMs}ms"); } CheckForSkinning(); (bool foundTarget, bool moved) = await combatUtil.FoundTargetWhileMoved(); if (foundTarget) { Log("Interrupted!"); return; } if (moved) { await input.TapInteractKey($"{GetType().Name}: Had to move so interact again"); await wait.Update(1); } } else { await input.TapLastTargetKey($"{GetType().Name}: No corpse name found - check last dead target exists"); await wait.Update(1); if (playerReader.HasTarget) { if (playerReader.Bits.TargetIsDead) { CheckForSkinning(); await input.TapInteractKey($"{GetType().Name}: Found last dead target"); await wait.Update(1); (bool foundTarget, bool moved) = await combatUtil.FoundTargetWhileMoved(); if (foundTarget) { Log("Goal interrupted!"); return; } if (moved) { await input.TapInteractKey($"{GetType().Name}: Last dead target double"); } } else { await input.TapClearTarget($"{GetType().Name}: Don't attack the target!"); } } } await GoalExit(); }
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() { 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() { 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() { WowPoint lastPosition = playerReader.PlayerLocation; Log("Search for corpse"); npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Corpse); await stopMoving.Stop(); await npcNameFinder.WaitForNUpdate(1); bool lootSuccess = await npcNameFinder.FindByCursorType(Cursor.CursorClassification.Loot); if (lootSuccess) { Log("Found corpse - interact with it"); await playerReader.WaitForNUpdate(1); if (classConfiguration.Skin) { var targetSkinnable = !playerReader.Unskinnable; AddEffect(GoapKey.shouldskin, targetSkinnable); Log($"Should skin ? {targetSkinnable}"); SendActionEvent(new ActionEventArgs(GoapKey.shouldskin, targetSkinnable)); } bool hadToMove = false; if (IsPlayerMoving(lastPosition)) { hadToMove = true; Log("Goto corpse - Wait till player become stil!"); } while (IsPlayerMoving(lastPosition)) { lastPosition = playerReader.PlayerLocation; if (!await Wait(100, DiDEnteredCombat())) { await AquireTarget(); return; } } // TODO: damn spell batching // arriving to the corpse min distance to interact location // and says you are too far away // so have to wait and retry the action // at this point the player have a target // might be a good idea to check the last error message :shrug: if (hadToMove) { if (!await Wait(200, DiDEnteredCombat())) { await AquireTarget(); return; } } await input.TapInteractKey("Approach corpse"); // TODO: find a better way to get notified about the successful loot // challlange: // - the mob might have no loot at all so cant check inventory change // - loot window could be checked /* * if (!await Wait(400, DiDEnteredCombat())) * { * await AquireTarget(); * return; * } */ Log("Loot Successfull"); await GoalExit(); } else { Log($"No corpse found - Npc Count: {npcNameFinder.NpcCount}"); await input.TapLastTargetKey("loot second attempt by last target"); await playerReader.WaitForNUpdate(1); if (playerReader.HasTarget) { if (playerReader.PlayerBitValues.TargetIsDead) { await input.TapInteractKey("loot dead corpse by last target"); } else { await input.TapClearTarget("dont attack"); } } if (!await Wait(100, DiDEnteredCombat())) { await AquireTarget(); } else { await GoalExit(); } } }