Esempio n. 1
0
        public bool CallPet()
        {
            /*
             *  Attempt to use "Call Pet" spells.
             */

            List <WoW.Classes.WowActionBarSlot> callPetSpells = WoW.Internals.ActionBar.GetFilledSlots().Where(x => x.IsSpell && Enum.IsDefined(typeof(CallPetSpells), x.ActionId)).ToList();

            if (callPetSpells.Count > 0)
            {
                WoW.Internals.ActionBar.PressSlot(callPetSpells.First().BarIndex, callPetSpells.First().SlotIndex);

                int startWaitPetTick = Environment.TickCount;

                while (!WoW.Internals.ObjectManager.Pet.IsValid ||
                       !WoW.Internals.ObjectManager.Pet.IsAlive)
                {
                    if (Environment.TickCount - startWaitPetTick > 3000)
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(100);
                }

                return(WoW.Internals.ObjectManager.Pet.IsValid && WoW.Internals.ObjectManager.Pet.IsAlive);
            }

            /*
             *  Attempt to use "Call Pet" flyout.
             */

            List <WoW.Classes.WowActionBarSlot> callPetFlyouts = WoW.Internals.ActionBar.GetFilledSlots().Where(x => x.IsFlyout && x.ActionId == 9).ToList();

            if (callPetFlyouts.Count > 0)
            {
                WoW.Classes.WowActionBarSlot actionSlot = callPetFlyouts.First();

                WoW.Internals.ActionBar.PressSlot(actionSlot.BarIndex, actionSlot.SlotIndex);

                System.Threading.Thread.Sleep(1000);

                WoW.Classes.Frames.WowFrame SpellFlyoutButton = WoW.Internals.UIFrame.GetFrameByName("SpellFlyoutButton1");

                if (SpellFlyoutButton.IsValid &&
                    SpellFlyoutButton.IsVisible)
                {
                    SpellFlyoutButton.LeftClick();

                    int startWaitPetTick = Environment.TickCount;

                    while (!WoW.Internals.ObjectManager.Pet.IsValid ||
                           !WoW.Internals.ObjectManager.Pet.IsAlive)
                    {
                        if (Environment.TickCount - startWaitPetTick > 3000)
                        {
                            break;
                        }

                        System.Threading.Thread.Sleep(100);
                    }
                }
            }

            return(WoW.Internals.ObjectManager.Pet.IsValid && WoW.Internals.ObjectManager.Pet.IsAlive);
        }