Example #1
0
            private void SetCurrentPet()
            {
                var abilities = me.ExecLuaAndGetResult(
                    "abilities = ''; for i=1, NUM_PET_ACTION_SLOTS do abilities = abilities..GetPetActionInfo(i)..',' end",
                    "abilities");

                currentPet = new WarlockPet(me, abilities);
            }
            /// <summary>
            /// Summon the warlock pet, if we have no alive pet or if current pet is not the pet we want
            /// </summary>
            public bool SummonPet(WarlockPet pet)
            {
                if (pet == WarlockPet.ManualSelect)
                {
                    return(false);
                }

                bool hasBetterPets = HasSpell("Summon Fel Imp");

                // let rebot choose the best pet
                if (pet == WarlockPet.AutoSelect)
                {
                    if (HasSpell("Demonic Servitude"))
                    {
                        pet = WarlockPet.Infernal;
                    }
                    else if (HasSpell("Summon Felguard"))
                    {
                        pet = WarlockPet.Felguard;
                    }
                    else if (CurrentBotName == "PvP" && HasSpell("Summon Felhunter"))
                    {
                        pet = WarlockPet.Felhunter;
                    }
                    else if (HasSpell("Summon Voidwalker") && Group.GetNumGroupMembers() <= 1)
                    {
                        pet = WarlockPet.Voidwalker;
                    }
                    else if (hasBetterPets && HasSpell("Summon Felhunter"))
                    {
                        pet = WarlockPet.Felhunter;
                    }
                    else if (HasSpell("Summon Imp"))
                    {
                        pet = WarlockPet.SoulImp;
                    }
                    else
                    {
                        return(false); // we can not summon a pet
                    }
                }


                string spell     = null;
                int    displayId = 0;

                switch (pet)
                {
                case WarlockPet.Felhunter:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpFelhunter : (int)WlPetDisplayId.Felhunter;
                    spell     = "Summon Felhunter";
                    break;

                case WarlockPet.Voidwalker:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpVoidwalker : (int)WlPetDisplayId.Voidwalker;
                    spell     = "Summon Voidwalker";
                    break;

                case WarlockPet.Felguard:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpFelguard : (int)WlPetDisplayId.Felguard;
                    spell     = "Summon Felguard";
                    break;

                case WarlockPet.SoulImp:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpSoulImp : (int)WlPetDisplayId.SoulImp;
                    spell     = "Summon Imp";
                    break;

                case WarlockPet.Succubus:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpSuccubus : (int)WlPetDisplayId.Succubus;
                    spell     = "Summon Succubus";
                    break;

                case WarlockPet.Infernal:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpInfernal : (int)WlPetDisplayId.Infernal;
                    spell     = "Summon Infernal";
                    break;

                case WarlockPet.Doomguard:
                    displayId = hasBetterPets ? (int)WlPetDisplayId.ImpDoomguard : (int)WlPetDisplayId.Doomguard;
                    spell     = "Summon Doomguard";
                    break;
                }

                if (spell != null)
                {
                    return(CastSelfPreventDouble(
                               spell,
                               () => !Me.HasAlivePet || Me.Pet != null && Me.Pet.DisplayId != displayId,
                               5000 // 5 seconds to be sure it spawned on slow systems or serverlag
                               ));
                }

                return(false);
            }