private static void Ground(IEnumerable <WoWGameObject> nodes, bool ignoreCanOpen = false) { try { nodes = nodes.OrderBy(x => x.GetDistance); foreach (WoWGameObject node in nodes) { WoWGameObject inode = node; if (_curNode != null && _curNode.IsValid && !nManagerSetting.IsBlackListed(_curNode.Guid)) { inode = _curNode; } if (!inode.IsValid) { MovementManager.StopMove(); nManagerSetting.AddBlackList(inode.Guid, 2 * 60 * 1000); Logging.Write("Current inode not valid, blacklist."); continue; } _curNode = inode; // we save a inode we potentially bypassed to make sure we run the list. if (!inode.CanOpen && !ignoreCanOpen) { nManagerSetting.AddBlackList(inode.Guid, 5000); return; } if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) > 5.0f) { if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) >= nManagerSetting.CurrentSetting.MinimumDistanceToUseMount || !nManagerSetting.CurrentSetting.UseGroundMount) { if (MountTask.GetMountCapacity() == MountCapacity.Fly || Usefuls.IsFlying) { if (!Usefuls.IsFlying) { if (!MountTask.OnFlyMount()) { MountTask.Mount(true, true); } else { MountTask.Takeoff(); } } Fly(nodes); return; } if (Usefuls.IsSwimming) { if (MountTask.GetMountCapacity() == MountCapacity.Swimm && !MountTask.OnAquaticMount()) { MountTask.Mount(); } Fly(nodes); return; } } // fallback to ground mount or feet if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) >= nManagerSetting.CurrentSetting.MinimumDistanceToUseMount && nManagerSetting.CurrentSetting.UseGroundMount) { if (MountTask.GetMountCapacity() == MountCapacity.Ground && !MountTask.OnGroundMount()) { MountTask.Mount(); } } if (MovementManager.FindTarget(inode, 5.5f, true, nManagerSetting.CurrentSetting.GatheringSearchRadius * 4.0f) == 0) { nManagerSetting.AddBlackList(inode.Guid, 1000 * 20); _curNode = null; return; } if (_lastnode != inode.Guid) { _lastnode = inode.Guid; Logging.Write("Ground Farm " + inode.Name + " (" + inode.Entry + ") > " + inode.Position); } if (inode.GetDistance < 5.5f) // max range is usually 5.8-9 yards { MovementManager.StopMove(); } if (MovementManager.InMovement) { return; } } MovementManager.StopMove(); while (ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(250); } Thread.Sleep(250 + Usefuls.Latency); if (ObjectManager.ObjectManager.Me.InCombat) { if (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId()))) { MountTask.DismountMount(); // If we don't have druid mount or Sky Golem, dismount and fight. return; } // We are druid or using sky golem, let's try to loot } _wasLooted = false; CountThisLoot = true; NodeOrUnit = true; Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 300); if (!ObjectManager.ObjectManager.Me.IsCast) { Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 250); } while (ObjectManager.ObjectManager.Me.IsCast) { Thread.Sleep(150); } if (ObjectManager.ObjectManager.Me.InCombat && (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId())))) { CountThisLoot = false; return; } Thread.Sleep(100 + Usefuls.Latency); if (ObjectManager.ObjectManager.Me.InCombat && (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId())))) { CountThisLoot = false; return; } if (CountThisLoot && !ObjectManager.ObjectManager.Me.InCombat) { nManagerSetting.AddBlackList(inode.Guid, 1000 * 20); } Thread.Sleep(1000); if (!_wasLooted) { Logging.Write("Farm failed #2"); if (ObjectManager.ObjectManager.Me.InCombat && (ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId()) || ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()))) { MountTask.DismountMount(); // we got cancelled during farm, let's fight this out for good.. } } return; } } catch (Exception ex) { Logging.WriteError("FarmingTask > Ground(IEnumerable<WoWGameObject> nodes): " + ex); } }
private static void Fly(IEnumerable <WoWGameObject> nodes, bool ignoreCanOpen = false) { try { nodes = nodes.OrderBy(x => x.GetDistance); foreach (WoWGameObject node in nodes.Where(node => node.IsValid)) { WoWGameObject inode = node; if (_curNode != null && _curNode.IsValid && !nManagerSetting.IsBlackListed(_curNode.Guid)) { inode = _curNode; } if (!inode.IsValid) { MovementManager.StopMove(); nManagerSetting.AddBlackList(inode.Guid, 2 * 60 * 1000); Logging.Write("Current inode not valid, blacklist."); continue; } _curNode = inode; // we save a inode we potentially bypassed to make sure we run the list. if (!inode.CanOpen && !ignoreCanOpen) { nManagerSetting.AddBlackList(inode.Guid, 5000); return; } float zT; if (ObjectManager.ObjectManager.Me.Position.Z < inode.Position.Z) { zT = inode.Position.Z + 5.5f; } else { zT = inode.Position.Z + 2.5f; } Point aboveNode = new Point(inode.Position); aboveNode.Z = aboveNode.Z + 2.5f; Point farAboveNode = new Point(aboveNode); farAboveNode.Z = farAboveNode.Z + 50; if (TraceLine.TraceLineGo(farAboveNode, aboveNode, CGWorldFrameHitFlags.HitTestAllButLiquid)) { MovementManager.StopMove(); if (TraceLine.TraceLineGo(ObjectManager.ObjectManager.Me.Position, aboveNode, CGWorldFrameHitFlags.HitTestAllButLiquid)) { Logging.Write("Node stuck"); nManagerSetting.AddBlackList(inode.Guid, 1000 * 60 * 2); return; } } else { MovementManager.StopMove(); } if (_lastnode != inode.Guid) { _lastnode = inode.Guid; Logging.Write("Farm " + inode.Name + " (" + inode.Entry + ") > " + inode.Position); } MovementManager.MoveTo(inode.Position.X, inode.Position.Y, zT, true); Helpful.Timer timer = new Helpful.Timer((int)(ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) / 3 * 1000) + 5000); bool toMine = false; bool landing = false; while (inode.IsValid && !Usefuls.BadBottingConditions && !Usefuls.ShouldFight && !timer.IsReady) { if (!landing) { bool noDirectPath = TraceLine.TraceLineGo(aboveNode, ObjectManager.ObjectManager.Me.Position, CGWorldFrameHitFlags.HitTestAllButLiquid); zT = noDirectPath ? ObjectManager.ObjectManager.Me.Position.Z : aboveNode.Z; if (ObjectManager.ObjectManager.Me.Position.Z < aboveNode.Z) { // elevate in a 45° angle instead of 90° Point direction = Math.GetPosition2DOfLineByDistance(ObjectManager.ObjectManager.Me.Position, inode.Position, (inode.Position.Z + 2.5f) - ObjectManager.ObjectManager.Me.Position.Z); // if there is an obstacle, then go mostly vertical but not 90° to prevent spinning around if (TraceLine.TraceLineGo(ObjectManager.ObjectManager.Me.Position, direction, CGWorldFrameHitFlags.HitTestAllButLiquid)) { direction = Math.GetPosition2DOfLineByDistance(ObjectManager.ObjectManager.Me.Position, inode.Position, 1.0f); } MovementManager.MoveTo(direction.X, direction.Y, inode.Position.Z + 5.0f); } else { MovementManager.MoveTo(inode.Position.X, inode.Position.Y, zT); } if (!ObjectManager.ObjectManager.Me.IsMounted) { return; } if (!noDirectPath) { landing = true; } } if (ObjectManager.ObjectManager.Me.Position.DistanceTo2D(inode.Position) < 4.0f && ObjectManager.ObjectManager.Me.Position.DistanceZ(inode.Position) >= 5.0f && !toMine) { toMine = true; if (!ObjectManager.ObjectManager.Me.IsMounted) { return; } zT = inode.Position.Z + 1.5f; MovementManager.MoveTo(inode.Position.X, inode.Position.Y, zT); if (inode.GetDistance > 3.0f && TraceLine.TraceLineGo(ObjectManager.ObjectManager.Me.Position, inode.Position, CGWorldFrameHitFlags.HitTestAllButLiquid)) { Logging.Write("Node outside view"); nManagerSetting.AddBlackList(inode.Guid, 1000 * 120); break; } } else if ((ObjectManager.ObjectManager.Me.Position.DistanceTo2D(inode.Position) < 1.1f || (!Usefuls.IsFlying && ObjectManager.ObjectManager.Me.Position.DistanceTo2D(inode.Position) < 3.0f)) && ObjectManager.ObjectManager.Me.Position.DistanceZ(inode.Position) < 6) { Thread.Sleep(150); MovementManager.StopMove(); if (Usefuls.IsFlying) { MountTask.Land(); } if (ObjectManager.ObjectManager.Me.GetMove) { MovementManager.StopMove(); } while (ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(50); } if (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId()))) { if (!(SpellManager.HasSpell(169606) && Usefuls.ContinentId == 1116 || Usefuls.ContinentId == 1464)) // Passive Silver Dollar Club given by Stables. { MountTask.DismountMount(); } } else if (inode.IsHerb && ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.DruidMountId())) { Logging.WriteDebug("Druid IsFlying ? " + Usefuls.IsFlying); if (Usefuls.IsFlying) { MountTask.Land(); MovementManager.StopMove(); if (Usefuls.IsFlying) { Logging.Write("You are still flying after two attemps of Landing."); Logging.Write("Make sure you have binded the action \"SitOrStand\" on a keyboard key and not any mouse button or special button."); Logging.Write("If you still have this message, please try a \"Reset Keybindings\" before posting on the forum."); Logging.Write("A work arround have been used, it may let you actually farm or not. Because it's random, please fix your keybinding issue."); MountTask.Land(true); } } } Thread.Sleep(Usefuls.Latency + 200); if (ObjectManager.ObjectManager.Me.InInevitableCombat) { MountTask.DismountMount(); return; } _wasLooted = false; CountThisLoot = true; NodeOrUnit = true; Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 500); if (!ObjectManager.ObjectManager.Me.IsCast) { Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 500); } while (ObjectManager.ObjectManager.Me.IsCast) { Thread.Sleep(100); } if (ObjectManager.ObjectManager.Me.InInevitableCombat) { MountTask.DismountMount(); CountThisLoot = false; return; } Thread.Sleep(Usefuls.Latency + 100); if (ObjectManager.ObjectManager.Me.InInevitableCombat) { MountTask.DismountMount(); CountThisLoot = false; return; } nManagerSetting.AddBlackList(inode.Guid, 1000 * 20); return; } else if (!ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(50); if (!ObjectManager.ObjectManager.Me.IsMounted) { return; } MovementManager.MoveTo(inode.Position.X, inode.Position.Y, zT); } if (States.Farming.PlayerNearest(inode)) { Logging.Write("Player near the inode, farm canceled"); nManagerSetting.AddBlackList(inode.Guid, 15 * 1000); return; } } if (timer.IsReady) { nManagerSetting.AddBlackList(inode.Guid, 60 * 1000); } MovementManager.StopMove(); if (!_wasLooted) { Logging.Write("Farm failed #1"); } } } catch (Exception ex) { Logging.WriteError("FarmingTask > Fly(IEnumerable<WoWGameObject> nodes): " + ex); } }
public static void Pulse(IEnumerable <WoWUnit> woWUnits) { try { woWUnits = woWUnits.OrderBy(x => x.GetDistance); foreach (WoWUnit wowUnit in woWUnits) { try { if (Products.Products.IsStarted) { if (nManagerSetting.IsBlackListed(wowUnit.Guid)) { continue; } MovementManager.StopMove(); MovementManager.StopMove(); Thread.Sleep(250 + Usefuls.Latency); while (ObjectManager.ObjectManager.Me.IsCast) { Thread.Sleep(200); } if (!wowUnit.IsValid) { continue; } bool looted = false; if (wowUnit.IsLootable) { Logging.Write("Loot " + wowUnit.Name); } else if (wowUnit.IsSkinnable && nManagerSetting.CurrentSetting.ActivateBeastSkinning) { Logging.Write("Skin " + wowUnit.Name); } else { continue; } FarmingTask.CurUnit = wowUnit; // We have no item to loot at range, then go to mob if (!CombatClass.InMeleeRange(wowUnit) && (!nManagerSetting.CurrentSetting.UseLootARange || LootARangeId == 0 || ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) > 40f || !ItemsManager.IsItemUsable(LootARangeId))) { bool success; List <Point> points = PathFinder.FindPath(wowUnit.Position, out success); if (points.Count <= 0) { points.Add(ObjectManager.ObjectManager.Me.Position); points.Add(wowUnit.Position); } if (!success) { if ((points.Count == 2 && wowUnit.GetDistance > 6) || points.Count != 2) { // we didn't find a valid path and the target is not that close, blacklisting. // Straightline wont help anyway. Logging.Write("No path to " + wowUnit.Name + ", blacklisting."); nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); } } MovementManager.Go(points); Timer timer = new Timer((int)(Math.DistanceListPoint(points) / 3 * 1000) + 3000); while (!ObjectManager.ObjectManager.Me.IsDeadMe && wowUnit.IsValid && Products.Products.IsStarted && ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0 && !(ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))) && !timer.IsReady) { if (ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) <= 4.0f) { MovementManager.StopMove(); MovementManager.StopMove(); MountTask.DismountMount(); Thread.Sleep(250); while (ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(50); } break; } } } // Now loot if (wowUnit.IsLootable) { // Code for 109167 Findle's Loot-A-Range and 60854 Loot-A-Rang if (nManagerSetting.CurrentSetting.UseLootARange && !CombatClass.InMeleeRange(wowUnit) && ObjectManager.ObjectManager.Me.Position.DistanceTo(wowUnit.Position) <= 40f && LootARangeId != 0 && ItemsManager.IsItemUsable(LootARangeId)) { // Since these items have a CD of only 3 sec, it's worth waiting for the CD to recover while (ItemsManager.IsItemOnCooldown(LootARangeId)) { Thread.Sleep(250); } FarmingTask.CountThisLoot = true; FarmingTask.NodeOrUnit = false; ItemsManager.UseToy(LootARangeId); Thread.Sleep(1000 + Usefuls.Latency); while (ObjectManager.ObjectManager.Me.IsCast) { if (ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))) { return; } Thread.Sleep(150); } } else { FarmingTask.CountThisLoot = true; FarmingTask.NodeOrUnit = false; Interact.InteractWith(wowUnit.GetBaseAddress); if ((ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying)))) { return; } Thread.Sleep(500 + Usefuls.Latency); } if (nManagerSetting.CurrentSetting.ActivateBeastSkinning && ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0) { return; } Statistics.Loots++; if (nManagerSetting.CurrentSetting.ActivateBeastSkinning) { Thread.Sleep(475 + Usefuls.Latency); // let the client react to unit flag change looted = true; } else { WoWUnit unit = wowUnit; // we blacklist all unit around for a short time to be sure we loot then foreach (WoWUnit u in woWUnits.Where(u => u != unit).Where(u => u.Position.DistanceTo2D(unit.Position) <= 25f)) { nManagerSetting.AddBlackList(u.Guid, 475 + Usefuls.Latency); } nManagerSetting.AddBlackList(wowUnit.Guid, 475 + Usefuls.Latency); return; } } if ((looted || !wowUnit.IsLootable) && !wowUnit.IsSkinnable) { continue; } // From here we are sure the unit is skinnable // if this is the unit we just looted, we need to redo check for extra loot // if this is NOT the unit we just looted, then the check is already done at list building time if (nManagerSetting.CurrentSetting.ActivateBeastSkinning && ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0) { if ((looted || !wowUnit.IsLootable)) { if (wowUnit.ExtraLootType.HasFlag(TypeFlag.HERB_LOOT) || wowUnit.Entry == 112052 || wowUnit.Entry == 113646) { int myHerbalismLevel = Skill.GetValue(SkillLine.Herbalism); if (myHerbalismLevel <= 0) { nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); continue; } } else if (wowUnit.ExtraLootType.HasFlag(TypeFlag.MINING_LOOT) || wowUnit.Entry == 104895 || wowUnit.Entry == 104877) { int myMiningLevel = Skill.GetValue(SkillLine.Mining); if (myMiningLevel <= 0) { nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); continue; } } else if (wowUnit.ExtraLootType.HasFlag(TypeFlag.ENGENEERING_LOOT)) { int myEngineeringLevel = Skill.GetValue(SkillLine.Engineering); if (myEngineeringLevel <= 0) { nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); continue; } } else { int mySkinningLevel = Skill.GetValue(SkillLine.Skinning); if (mySkinningLevel <= 0) { nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); continue; } } } // If we looted at range, we must go to creature to skin it if (!CombatClass.InMeleeRange(wowUnit)) { List <Point> points = PathFinder.FindPath(wowUnit.Position); if (points.Count <= 0) { points.Add(ObjectManager.ObjectManager.Me.Position); points.Add(wowUnit.Position); } MovementManager.Go(points); Timer timer = new Timer((int)(Math.DistanceListPoint(points) / 3 * 1000) + 3000); while (!ObjectManager.ObjectManager.Me.IsDeadMe && wowUnit.IsValid && Products.Products.IsStarted && ObjectManager.ObjectManager.GetNumberAttackPlayer() == 0 && !(ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))) && !timer.IsReady) { if (CombatClass.InMeleeRange(wowUnit)) { MovementManager.StopMove(); MovementManager.StopMove(); MountTask.DismountMount(); Thread.Sleep(250); while (ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(50); } break; } } } Logging.Write("Skin " + wowUnit.Name); Interact.InteractWith(wowUnit.GetBaseAddress); Thread.Sleep(200 + Usefuls.Latency); while (ObjectManager.ObjectManager.Me.IsCast) { Thread.Sleep(100); } if ((ObjectManager.ObjectManager.Me.InCombat && !(ObjectManager.ObjectManager.Me.IsMounted && (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying)))) { return; } Thread.Sleep(400 + Usefuls.Latency); if (nManagerSetting.CurrentSetting.ActivateBeastSkinning && ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0) { return; } Statistics.Farms++; nManagerSetting.AddBlackList(wowUnit.Guid, 1000 * 60 * 5); } } MovementManager.StopMove(); MovementManager.StopMove(); } catch { } } } catch (Exception ex) { Logging.WriteError("LootingTask > Pulse(IEnumerable<WoWUnit> woWUnits): " + ex); } }