public override void Run() { if (!Products.IsStarted || ObjectManager.Me.IsDeadMe || ObjectManager.Me.InCombatBlizzard) { return; } if (!FisherbotSetting.CurrentSetting.FishSchool) { if (_firstRun && FishingTask.IsLaunched) { _firstRun = false; } // If we have a saved position and we don't fish, then go to position if (FisherbotSetting.CurrentSetting.FisherbotPosition.IsValid && (!FishingTask.IsLaunched || _beenFighting) && !_firstRun) { _beenFighting = false; if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 5) { LongMove.LongMoveGo(FisherbotSetting.CurrentSetting.FisherbotPosition); } else if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 1.5f) { MovementManager.MoveTo(FisherbotSetting.CurrentSetting.FisherbotPosition); } MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation); } // If we don't fish or the timer is null, then start a new timer, save position and fish if (timer == null || !FishingTask.IsLaunched) { timer = new nManager.Helpful.Timer(10 * 60 * 1000 + 10 * 1000); FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position; FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation; Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName); FishingTask.LoopFish(0, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName, false, FisherbotSetting.AutomaticallyUseDraenorSecondaryBait); } // If the timer ended, stop fishing, equip weapon, null the timer else if (timer.IsReady) { FishingTask.StopLoopFish(); ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName); if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName)) { ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName); } timer = null; } // We are in timer, we fish, then save the position else { if (FishingTask._lastSuccessfullFishing > Environment.TickCount - 5000) { FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position; FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation; // We successfully fished in the last 5 seconds, let's record our position again. } if (FishingTask._lastSuccessfullFishing != 0 && FishingTask._lastSuccessfullFishing < Environment.TickCount - 25000) { // We did not catch a single thing in the last 25 seconds... FishingTask.StopLoopFish(); return; } // _lastSuccessfullFishing is fine or we never fished yet, let it load :) Thread.Sleep(500); } // No more while, we test what we need and return return; } // Nodes fishing code if (_node.IsValid) { FisherbotSetting.CurrentSetting.FisherbotPosition = Bot.Profile.Points[Math.NearestPointOfListPoints(Bot.Profile.Points, _node.Position)]; Logging.Write("Fish " + _node.Name + " > " + _node.Position); } if (FisherbotSetting.CurrentSetting.FishSchool) { Point whereToGo = Fishing.FindTheUltimatePoint(_node.Position); if (whereToGo.Type == "invalid") { Logging.Write("No valid point found"); nManagerSetting.AddBlackList(_node.Guid); return; } bool r; List <Point> points = PathFinder.FindPath(whereToGo, out r); if (points.Count <= 1 || points.Count >= 20) { points.Clear(); points.Add(ObjectManager.Me.Position); points.Add(whereToGo); } else { for (int i = 0; i < points.Count; i++) { if (points[i].Z < whereToGo.Z) { points[i].Z = whereToGo.Z; } } } Logging.Write("Going to point > " + whereToGo.X + " ; " + whereToGo.Y + " ; " + whereToGo.Z + " ; " + points[0].Type); MovementManager.Go(points); timer = new nManager.Helpful.Timer(((int)Math.DistanceListPoint(points) / 3 * 1000) + 4000); while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted && !ObjectManager.Me.IsDeadMe && !ObjectManager.Me.InInevitableCombat && !timer.IsReady && MovementManager.InMovement) { if (ObjectManager.Me.Position.DistanceTo2D(whereToGo) <= 0.2f) { MovementManager.StopMove(); break; } Thread.Sleep(50); } if (timer.IsReady && _node.GetDistance2D > DistanceMax) { Logging.Write("Fishing failed - No nearby point found (distance near position = " + ObjectManager.Me.Position.DistanceTo2D( FisherbotSetting.CurrentSetting.FisherbotPosition).ToString(CultureInfo.InvariantCulture) + ")"); MovementManager.StopMove(); nManagerSetting.AddBlackList(_node.Guid); return; } } // Stop move MovementManager.StopMove(); MountTask.DismountMount(); // Face if (_node.IsValid) { MovementManager.Face(_node); } else { MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation); } // Ce met a la bonne distance du banc de poisson if (_node.IsValid) { int nbIsSwimming = 0; timer = new nManager.Helpful.Timer(1000 * 8); while ((Usefuls.IsSwimming || _node.GetDistance > DistanceMax || _node.GetDistance < DistanceMin) && Products.IsStarted && !ObjectManager.Me.IsDeadMe && !ObjectManager.Me.InCombat && !timer.IsReady) { if (nbIsSwimming * 100 > TimeTryFindGoodPos) { FishingTask.StopLoopFish(); MovementsAction.MoveBackward(false); MovementsAction.MoveForward(false); Logging.Write("BlackList " + _node.Name); nManagerSetting.AddBlackList(_node.Guid); return; } FishingTask.StopLoopFish(); MovementManager.Face(_node); if (Usefuls.IsSwimming || _node.GetDistance < DistanceMin) { MovementsAction.MoveForward(false); MovementsAction.MoveBackward(true); } if (_node.GetDistance > DistanceMax) { MovementsAction.MoveBackward(false); MovementsAction.MoveForward(true); } nbIsSwimming++; Thread.Sleep(100); } MovementsAction.MoveBackward(false); MovementsAction.MoveForward(false); if (timer.IsReady) { Logging.Write("Fishing failed - Out of range" + timer.IsReady.ToString()); MovementManager.StopMove(); nManagerSetting.AddBlackList(_node.Guid); return; } } // Fish Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName); FishingTask.LoopFish(_node.Guid, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName, FisherbotSetting.CurrentSetting.PrecisionMode, FisherbotSetting.AutomaticallyUseDraenorSecondaryBait); timer = new nManager.Helpful.Timer(2 * 60 * 1000); while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted && !ObjectManager.Me.IsDeadMe && !ObjectManager.Me.InCombat && !timer.IsReady && FishingTask.IsLaunched) { if (ObjectManager.Me.Position.DistanceTo2D(FisherbotSetting.CurrentSetting.FisherbotPosition) > 3.5f && !FisherbotSetting.CurrentSetting.FishSchool) { break; } Thread.Sleep(300); } FishingTask.StopLoopFish(); ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName); if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName)) { ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName); } }
private static void LoopFishThread() { try { while (true) { try { while (_fishBotLaunched) { if (ObjectManager.ObjectManager.Me.InCombat) { StopLoopFish(); continue; } Fishing.EquipFishingPoles(_fishingPoleName); if (_useLure) { Fishing.UseLure(_lureName, _automaticallyUseDraenorSecondaryBait); } if (fishingSpell == null) { fishingSpell = new Spell("Fishing"); } fishingSpell.Launch(false, false, true); Thread.Sleep(4000); WoWGameObject objBobber = new WoWGameObject(Fishing.SearchBobber()); if (objBobber.IsValid) { WoWGameObject node = new WoWGameObject(ObjectManager.ObjectManager.GetObjectByGuid(_guidNode).GetBaseAddress); if (node.Position.DistanceTo2D(objBobber.Position) > distanceBobber && node.IsValid && _guidNode > 0 && _precision) { continue; } while (_fishBotLaunched && ObjectManager.ObjectManager.Me.IsCast && objBobber.IsValid && 1 != Memory.WowMemory.Memory.ReadShort(objBobber.GetBaseAddress + (uint)Patchables.Addresses.Fishing.BobberHasMoved)) { /* * BobberHasMoved FINDER * uint i = 148; * while (false) * { * short info = Memory.WowMemory.Memory.ReadShort(objBobber.GetBaseAddress + (uint) i); * if (info == 1) * { * Logging.Write("Info is " + info + " with i=" + i); * } * i += 4; * if (i > 350) * i = 148; * Thread.Sleep(30); * } */ Thread.Sleep(250); } if (_fishBotLaunched && ObjectManager.ObjectManager.Me.IsCast && objBobber.IsValid) { FarmingTask.CountThisLoot = true; FarmingTask.NodeOrUnit = true; Interact.InteractWith(objBobber.GetBaseAddress); _lastSuccessfullFishing = Environment.TickCount; Statistics.Farms++; Thread.Sleep(Usefuls.Latency + 400); // Arround 450 for (int i = 0; i < 10; i++) { if (!Others.IsFrameVisible("LootFrame")) { break; } Thread.Sleep(150); // usually stop at i = 2 for me // it's like the old 1sec sleep, but can be faster sometimes to recast. // and this will loot 100% of the time, while if you have high latency, 1sec wont loot everything. } /*if (Others.IsFrameVisible("LootFrame")) * { * Logging.WriteDebug("We did not loot all items within < 2 second + latency."); * // More of a debug code, no need. * }*/ } } } } catch { } Thread.Sleep(400); } } catch (Exception e) { Logging.WriteError("FishingTask > LoopFishThread(): " + e); } }