Example #1
0
        private void RepairSellMail(bool repair, bool vendor, bool mail)
        {
            uint     VendorEntry = 0;
            WoWPoint VendorLoc   = new WoWPoint();
            WoWPoint MailboxLoc  = new WoWPoint();

            if (Me.IsHorde)
            {
                VendorEntry = 3319;
                VendorLoc   = new WoWPoint(1584.327, -4318.02, 21.18613);
                MailboxLoc  = new WoWPoint(1551.957, -4359.154, 17.89191);
            }
            if (Me.IsAlliance)
            {
                VendorEntry = 54321;
                VendorLoc   = new WoWPoint(0, 0, 0);
                MailboxLoc  = new WoWPoint(0, 0, 0);
            }
            if (repair || vendor)
            {
                while (VendorLoc.Distance(Me.Location) > 1)
                {
                    if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                    {
                        Flightor.MountHelper.MountUp();
                        StyxWoW.SleepForLagDuration();
                        Thread.Sleep(500);
                        while (Me.IsCasting)
                        {
                            Thread.Sleep(100);
                        }
                    }
                    Log("Mounted and flying to Vendor!");
                    Flightor.MoveTo(VendorLoc);
                    Thread.Sleep(250);
                }

                Log("Dismounting.");
                //while (Me.IsFlying) { WoWMovement.Move(WoWMovement.MovementDirection.Descend, TimeSpan.FromSeconds(1)); }
                //Log("Landed.");
                Flightor.MountHelper.Dismount();
                StyxWoW.SleepForLagDuration();
                WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                Navigator.PlayerMover.MoveStop();

                Thread.Sleep(ranNum(500, 1500));
                foreach (WoWUnit unit in ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == VendorEntry))
                {
                    while (unit.Location.Distance(Me.Location) > unit.InteractRange)
                    {
                        Navigator.MoveTo(unit.Location);
                        Log(string.Format("Moving towards: {0}.", unit.Name));
                        unit.Target();
                        unit.Interact();
                        Thread.Sleep(500);
                        unit.Interact();
                        Thread.Sleep(ranNum(1000, 3000));
                        unit.Interact();
                    }
                    break;
                }
                StyxWoW.SleepForLagDuration();
            }
            if (Me.CurrentTarget != null)
            {
                if (repair && Me.CurrentTarget.Entry == VendorEntry && Me.CurrentTarget.IsRepairMerchant)
                {
                    Styx.Logic.Vendors.RepairAllItems(); Thread.Sleep(ranNum(500, 3000));
                }
                if (Me.Auras.ContainsKey("Herbouflage"))
                {
                    string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                }
                if (Me.ActiveAuras.ContainsKey("Herbouflage"))
                {
                    string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                }
                if (vendor && Me.CurrentTarget.Entry == VendorEntry && Me.CurrentTarget.IsVendor)
                {
                    Styx.Logic.Vendors.SellAllItems(); Thread.Sleep(ranNum(500, 3000));
                }
                if (Me.Auras.ContainsKey("Herbouflage"))
                {
                    string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                }
                if (Me.ActiveAuras.ContainsKey("Herbouflage"))
                {
                    string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                }
            }
            if (mail)
            {
                if (Styx.Logic.Inventory.InventoryManager.HaveItemsToMail)
                {
                    if (Styx.Helpers.CharacterSettings.Instance.MailRecipient != null && Styx.Helpers.CharacterSettings.Instance.MailRecipient != "")
                    {
                        bool Foundbox = false;
                        ObjectManager.Update();
                        Log("You have items to mail, and a Recipient set!");
                        var Mailboxes = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => Navigator.CanNavigateFully(Me.Location, o.Location) && o.SubType == WoWGameObjectType.Mailbox);
                        foreach (WoWGameObject Mailbox in ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => Navigator.CanNavigateFully(Me.Location, o.Location) && o.SubType == WoWGameObjectType.Mailbox))
                        {
                            Log("Found a Mailbox (Auto).  Moving to it.", null);
                            while (Mailbox.Location.Distance(Me.Location) > Mailbox.InteractRange)
                            {
                                Navigator.MoveTo(Mailbox.Location);
                            }
                            Thread.Sleep(500);
                            Navigator.PlayerMover.MoveStop();
                            WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                            Thread.Sleep(1000);
                            Mailbox.Interact();
                            Thread.Sleep(500);
                            Mailbox.Interact();
                            StyxWoW.SleepForLagDuration();
                            Log("Mailing Items!");
                            Thread.Sleep(ranNum(2000, 5000));
                            Styx.Logic.Vendors.MailAllItems();
                            if (Me.Auras.ContainsKey("Herbouflage"))
                            {
                                string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                            }
                            if (Me.ActiveAuras.ContainsKey("Herbouflage"))
                            {
                                string.Format("RunMacroText(\"{0}\")", "/cancelaura Herbouflage");
                            }
                            StyxWoW.SleepForLagDuration();
                            Foundbox = true;
                            break;
                        }
                        if (!Foundbox)
                        {
                            Log("Couldn't find a mailbox automatically.  Using back-up.");
                            while (MailboxLoc.Distance(Me.Location) > 5)
                            {
                                if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                                {
                                    Flightor.MountHelper.MountUp();
                                    StyxWoW.SleepForLagDuration();
                                    Thread.Sleep(500);
                                    while (Me.IsCasting)
                                    {
                                        Thread.Sleep(100);
                                    }
                                }
                                Log("Mounted and flying to Mailbox!");
                                Flightor.MoveTo(MailboxLoc);
                                Thread.Sleep(250);
                            }
                            Log("Dismounting.");
                            Flightor.MountHelper.Dismount();
                            StyxWoW.SleepForLagDuration();
                            WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                            Navigator.PlayerMover.MoveStop();

                            Thread.Sleep(ranNum(1500, 3000));
                            ObjectManager.Update();
                            Foundbox = true;
                        }
                        if (Foundbox)
                        {
                            while (VendorLoc.Distance(Me.Location) > 1)
                            {
                                Log("Walking back to Original Vendor Location.");
                                Thread.Sleep(250);
                                Navigator.MoveTo(VendorLoc);
                            }
                        }
                        if (!Foundbox)
                        {
                            Log("Didn't find a Mailbox to use.  Please head to TheBuddyForum and report this issue in the BuddyManager thread!!!");
                        }
                    }
                    else
                    {
                        Log("You don't have a mail recipient set!");
                    }
                }
                else
                {
                    Log("Found no items to mail.");
                }
            }

            while (VendorLoc.Distance(Me.Location) > 5)
            {
                Navigator.MoveTo(VendorLoc); Thread.Sleep(100);
            }

            NeedToRepairMailSell = false;
        }
private void PortalsRule()
{
    while (IsStarted && !StyxWoW.IsInWorld)
    {
        Thread.Sleep(1000);
    }
    //BotPoi.Current.Type == PoiType.Repair
    //Check for BG, Instance, Zone we can't get back to
    if (!IsStarted && (CurrentPOI.Type == PoiType.Mail || CurrentPOI.Type == PoiType.Repair || CurrentPOI.Type == PoiType.Sell) && !Styx.BotManager.Current.Name.ContainsAny(BadBotBases))
    {
        Log(CurrentPOI.Type.ToString(), "detected.  Using Portalling Option");
        IsStarted  = true;
        IsFinished = false;
        return;
    }
    while (!Me.IsActuallyInCombat && !MadeItToOrg && IsStarted)
    {
        OldLocation = Me.Location;
        OldMapId    = Me.MapId;
        Log("Old MapId is: ", Me.MapId.ToString());
        OldZoneName = Me.ZoneText;
        Log("Old ZoneName is: ", Me.ZoneText);
        if (ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.IsHostile && o.IsAlive && o.Distance < 5).Count() == 0)
        {
            SpellManager.StopCasting();
            Styx.Logic.Mount.Dismount();
            Navigator.PlayerMover.MoveStop();
            StyxWoW.SleepForLagDuration();
            if (SpellManager.CanCast(3567))
            {
                IsStarted = true;
                SpellManager.Cast(3567);
                Thread.Sleep(2500);
                while (Me.IsCasting || !StyxWoW.IsInWorld)
                {
                    Log("Sleeping while casting", null);
                    Thread.Sleep(5000);
                }
                Log("End of Sleep 1, Sleep additional 5 seconds.", null);
                Thread.Sleep(5000);
                if (/*Me.MapId == Org*/ true)
                {
                    MadeItToOrg = true;
                }
                return;
            }
            else
            {
                IsStarted = false;
            }
        }
    }


    //Move to Vendor (Sell & Repair), Move to Mailbox (Mail Items)
    while (MadeItToOrg && !DidRepair && IsStarted)
    {
        ObjectManager.Update();
        if (Me.Location.Distance(new WoWPoint(1776.5, -4338.8, -7.508744)) < 10)
        {
            Navigator.MoveTo(new WoWPoint(1823.608, -4304.775, -12.16005));
            foreach (WoWUnit Muragas in ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == 3330))
            {
                while (Muragas.Distance > Muragas.InteractRange)
                {
                    Navigator.MoveTo(Muragas.Location); Log("Moving to Repair.");
                }
                Navigator.PlayerMover.MoveStop();
                Muragas.Interact();
                StyxWoW.SleepForLagDuration();
                Styx.Logic.Vendors.RepairAllItems();
                StyxWoW.SleepForLagDuration();
                Styx.Logic.Vendors.SellAllItems();
                StyxWoW.SleepForLagDuration();
            }
        }
        DidRepair = true;
        return;
    }



    while (DidRepair && !CheckRunes && IsStarted)
    {
        //Check for Runes of Teleport, buy if I have less than 5
        uint NumberOfRunes = 0;
        ObjectManager.Update();
        foreach (WoWItem Runes in ObjectManager.GetObjectsOfType <WoWItem>().Where(o => o.Entry == 17031))
        {
            if (Runes.BagSlot != -1)
            {
                NumberOfRunes += Runes.StackCount;
            }
        }
        Log("Found # Runes:", NumberOfRunes.ToString());
        if (NumberOfRunes < 5)
        {
            while (new WoWPoint(1819.77, -4305.931, -12.17886).Distance(Me.Location) > 3)
            {
                Navigator.MoveTo(new WoWPoint(1819.77, -4305.931, -12.17886));
            }
            while (new WoWPoint(1812.137, -4318.922, -11.23538).Distance(Me.Location) > 3)
            {
                Navigator.MoveTo(new WoWPoint(1812.137, -4318.922, -11.23538));
            }
            while (new WoWPoint(1831.635, -4333.173, -15.48243).Distance(Me.Location) > 3)
            {
                Navigator.MoveTo(new WoWPoint(1831.635, -4333.173, -15.48243));
            }
            foreach (WoWUnit ReagentVendor in ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == 3335))
            {
                Log("Inside ReagVend Foreach.", null);
                while (ReagentVendor.Location.Distance(Me.Location) > ReagentVendor.InteractRange)
                {
                    Navigator.MoveTo(ReagentVendor.Location);
                }
                Navigator.PlayerMover.MoveStop();
                ReagentVendor.Interact();
                while (!MerchantFrame.Instance.IsVisible)
                {
                    Thread.Sleep(100);
                }
                MerchantFrame.Instance.BuyItem("Rune of Teleportation", 5);
                Log("Bought 5 'Rune of Teleportation'", null);
                StyxWoW.SleepForLagDuration();
            }
            NumberOfRunes = 0;
            while (new WoWPoint(1831.958, -4331.217, -15.48225).Distance(Me.Location) > 2)
            {
                Navigator.MoveTo(new WoWPoint(1831.958, -4331.217, -15.48225));
            }
        }
        CheckRunes = true;
        return;
    }


    while (CheckRunes && !MovedOutside && IsStarted)
    {
        while (new WoWPoint(1798.782, -4325.472, -11.27483).Distance(Me.Location) > 2)
        {
            Navigator.MoveTo(new WoWPoint(1798.782, -4325.472, -11.27483));
            Log("Moving Outside. Step 1.", null);
        }
        while (new WoWPoint(1778.542, -4295.233, 6.407692).Distance(Me.Location) > 2)
        {
            Navigator.MoveTo(new WoWPoint(1778.542, -4295.233, 6.407692));
            Log("Moving Outside. Step 2", null);
        }
        while (new WoWPoint(1756.049, -4306.153, 6.61089).Distance(Me.Location) > 3)
        {
            Navigator.MoveTo(new WoWPoint(1756.049, -4306.153, 6.61089));
            Log("Moving Outside. Step 3", null);
        }
        while (new WoWPoint(1786.761, -4239.646, 40.70471).Distance(Me.Location) > 4)
        {
            Navigator.MoveTo(new WoWPoint(1786.761, -4239.646, 40.70471));
            Log("Moving Outside. Step 4", null);
        }
        MovedOutside = true;
        return;
    }


    while (MovedOutside && !DidMail && IsStarted)
    {
        if (Styx.Logic.Inventory.InventoryManager.HaveItemsToMail && Styx.Helpers.CharacterSettings.Instance.MailRecipient != null)
        {
            ObjectManager.Update();
            Log("Mailing Items");
            foreach (WoWGameObject Mailbox in ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.Entry == 206732 && o.SubType == WoWGameObjectType.Mailbox))
            {
                Log("Inside Mailbox Foreach", null);
                while (Mailbox.Location.Distance(Me.Location) > Mailbox.InteractRange)
                {
                    Navigator.MoveTo(Mailbox.Location);
                }
                Navigator.PlayerMover.MoveStop();
                Thread.Sleep(1000);
                Mailbox.Interact();
                StyxWoW.SleepForLagDuration();
                Styx.Logic.Vendors.MailAllItems();
                StyxWoW.SleepForLagDuration();
            }
        }
        else
        {
            Log("No Items to Mail.  Continue!");
            DidMail = true;
            return;
        }
    }


    while (DidMail && !MovedToPortals && IsStarted)
    {
        //Move to Portal Area
        Thread.Sleep(1000);
        if (!Me.Mounted)
        {
            Flightor.MountHelper.MountUp();
        }
        Thread.Sleep(1000);
        while (Me.IsCasting)
        {
            Thread.Sleep(100);
        }
        Log("Flightor moving to Portals");
        while (new WoWPoint(2048.148, -4376.259, 98.84513).Distance(Me.Location) > 4)
        {
            Flightor.MoveTo(new WoWPoint(2048.148, -4376.259, 98.84513));
            Thread.Sleep(100);
        }
        Log("Made it to Portals");
        Thread.Sleep(500);
        Flightor.MountHelper.Dismount();
        MovedToPortals = true;
        return;
    }


    while (MovedToPortals && !UsedPortal && IsStarted)
    {
        while (Me.IsCasting)
        {
            Thread.Sleep(50);
        }
        Thread.Sleep(500);
        if (Me.Mounted)
        {
            Flightor.MountHelper.Dismount();
        }
        Thread.Sleep(500);
        ObjectManager.Update();
        foreach (WoWGameObject Portal in ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.Entry == 206595))
        {
            while (Portal.Location.Distance(Me.Location) > Portal.InteractRange)
            {
                Navigator.MoveTo(Portal.Location);
                Log("Moving towards ", Portal.Name);
                Thread.Sleep(100);
            }
            Navigator.PlayerMover.MoveStop();
            Thread.Sleep(500);
            Portal.Interact();
            Thread.Sleep(5000);
        }
        //Insert Logic to use correct portal, or just f**k off!
        if (OldMapId == 599999)
        {
            //I don't f*****g know
        }

        if (OldZoneName == "ShitYea")
        {
            //F**k off
        }
        UsedPortal = true;
        return;
    }


    while (MadeItToOrg && DidRepair && CheckRunes && DidMail && MovedToPortals && UsedPortal && !ReturnedToXYZ && IsStarted)
    {
        Thread.Sleep(10000);
        if (Me.MapId == OldMapId)
        {
            if (BotManager.Current.Name == "Grind Bot")
            {
                Log("Using 'Grind Bot'.");

                /*if(Styx.Logic.Profiles.Quest.ProfileHelperFunctionsBase.CanFly())
                 * {
                 *  Log("Flying back to Original XYZ.");
                 *  Flightor.MountHelper.MountUp();
                 *  Thread.Sleep(1000);
                 *  while (Me.IsCasting) { Thread.Sleep(100); }
                 *  while (OldLocation.Distance(Me.Location) > 5)
                 *  {
                 *      Flightor.MoveTo(OldLocation);
                 *      Thread.Sleep(100);
                 *  }
                 * }*/
                //Doesn't fackin work!
                Thread.Sleep(5000);
                Log("Returning to Orig XYZ");
                while (OldLocation.Distance(Me.Location) > 5)
                {
                    Navigator.MoveTo(OldLocation);
                    Thread.Sleep(100);
                }
                Log("At Original XYZ.");
                IsFinished = true;
            }

            /*
             * if (BotManager.Current.Name == "Gatherbuddy2")
             * {
             *  Flightor.MountHelper.MountUp();
             *  IsFinished = true;
             * }
             * if (BotManager.Current.Name == "Questing")
             * {
             *  Flightor.MountHelper.MountUp();
             *  Thread.Sleep(500);
             *  while (Me.IsCasting) { Thread.Sleep(100); }
             *  StyxWoW.SleepForLagDuration();
             *  Flightor.MoveTo(OldLocation);
             *  IsFinished = true;
             * }
             * if (BotManager.Current.Name == "ArchaeologyBuddy")
             * {
             *  Flightor.MountHelper.MountUp();
             *  IsFinished = true;
             * }*/
        }
        IsFinished    = true;
        ReturnedToXYZ = true;
        return;
    }

    if (IsStarted && IsFinished)
    {
        Log("Successful internention of Sell/Mail/Repair");
        Log("Now waiting for another opportunity...");
        MadeItToOrg    = false;
        DidRepair      = false;
        CheckRunes     = false;
        DidMail        = false;
        MovedOutside   = false;
        MovedToPortals = false;
        UsedPortal     = false;
        ReturnedToXYZ  = false;
        IsStarted      = false;
        IsFinished     = false;
    }
    if (IsStarted && !IsFinished)
    {
        Log("Well I messed up somewhere.", null);
        Log("You're character is now stuck, and I don't have the logic to get it back to where it was apparently, so please attach this log in the MageHelper thread and explain where you were farming.", null);
        IsStarted  = true;
        IsFinished = true;
    }

    /* ZONE ID LIST
     * 0 = Kalimdor
     * 1 = Eastern Kingdoms
     * 8 = Outlands
     * 10 = Northrend
     * 11 = Maelstrom
     * 5042 = Deepholm
     * 5389 = Tol Barad Peninsula
     *
     */
}        //End of PortalsRule()