/// <summary>Returns a summoned pet</summary> /// <param name="nameID">the id of the spell</param> /// <param name="cond">The conditions that must be true</param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <returns>The cast pet summon spell.</returns> public static Composite CastPetSummonSpell(int nameID, CanRunDecoratorDelegate cond, string label) { WoWSpell summonPet = WoWSpell.FromId(nameID); if (summonPet.CastTime > 0) { Spell.KnownChanneledSpells.Add(summonPet.Name); } return(new Decorator( delegate(object a) { if (!cond(a)) { return false; } if (!Spell.CanCast(summonPet.ToString())) { return false; } return true; }, new Decorator(ret => !Me.GotAlivePet && PetTimer.IsFinished, new Sequence( new Action(a => CLULogger.Log(" {0}", label)), new Action(a => SpellManager.Cast(summonPet)), Spell.CreateWaitForLagDuration(), new Wait(5, a => Me.GotAlivePet || !Me.IsCasting, new PrioritySelector( new Decorator(a => StyxWoW.Me.IsCasting, new Action(ret => SpellManager.StopCasting())), new ActionAlwaysSucceed())))))); }
/// <summary>Casts a spell on a specified unit</summary> /// <param name="spell">the WoWSpell to be casted</param> /// <param name="onUnit">The Unit.</param> /// <param name="cond">The conditions that must be true</param> /// <param name="checkmovement"> check movement </param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <returns>The cast spell on the unit</returns> public static Composite CastSpell(WoWSpell spell, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, bool checkmovement, string label) { return new Decorator( delegate(object a) { if (!cond(a)) return false; if (!Spell.CanCast(spell.ToString(), onUnit(a), true, checkmovement)) return false; //This is checking spell, unit, Range, Movement return onUnit(a) != null; }, new Sequence( new Action(a => CLULogger.Log(" [Casting] {0} on {1}", label, CLULogger.SafeName(onUnit(a)))), new Action(a => SpellManager.Cast(spell, onUnit(a))), new Action(a => LastspellCast = spell.Name))); }