Example #1
0
        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);
            }
        }