private async Task <bool> LookForTarget() { if (this.playerReader.HasTarget && !this.playerReader.PlayerBitValues.TargetIsDead && !blacklist.IsTargetBlacklisted()) { return(true); } else { await input.TapNearestTarget(); if (!playerReader.HasTarget) { npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Enemy); if (npcNameFinder.NpcCount > 0) { await this.npcNameFinder.FindAndClickNpc(0, true); } } } if (this.playerReader.HasTarget && !blacklist.IsTargetBlacklisted()) { if (playerReader.PlayerBitValues.IsMounted) { //await wowProcess.Dismount(); } await input.TapInteractKey("FollowRouteAction 4"); return(true); } return(false); }
private async Task <bool> LookForTarget(string source, CancellationToken cancellationToken) { if (playerReader.HasTarget && !playerReader.Bits.TargetIsDead && !blacklist.IsTargetBlacklisted()) { return(true); } else { if (!cancellationToken.IsCancellationRequested) { npcNameTargeting.ChangeNpcType(NpcNameToFind); await input.TapNearestTarget(source); } if (!classConfig.KeyboardOnly) { if (!playerReader.HasTarget && !cancellationToken.IsCancellationRequested) { npcNameTargeting.ChangeNpcType(NpcNameToFind); if (npcNameTargeting.NpcCount > 0 && !cancellationToken.IsCancellationRequested) { await npcNameTargeting.TargetingAndClickNpc(true, cancellationToken); if (!cancellationToken.IsCancellationRequested) { await wait.Update(1); } } } } } return(!cancellationToken.IsCancellationRequested && playerReader.HasTarget && !blacklist.IsTargetBlacklisted()); }
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); }
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.newtarget, 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.newtarget, true)); return; } } await input.TapClearTarget(); Log("No target found"); } }
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); } } } }
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); }
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 (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() { 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(); }