/// <summary>Casts a spell on the MostFocused Target (used for smite healing with disc priest mainly)</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The on Unit.</param> /// <param name="cond">The conditions that must be true</param> /// <param name="checkmovement">checks movement </param> /// <param name="label">A descriptive label for the clients GUI logging output</param> /// <param name="faceTarget">true if you want to auto face target</param> /// <returns>The cast spell at location.</returns> public static Composite CastSpellOnTargetFacing(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, bool checkmovement, string label, bool faceTarget) { return new Decorator( delegate(object a) { if (!cond(a)) return false; if (!Spell.CanCast(name, 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 Decorator(x => faceTarget && !StyxWoW.Me.IsSafelyFacing(onUnit(x), 45f), new Action(a => WoWMovement.Face(onUnit(a).Guid))), new Action(a => SpellManager.Cast(name, onUnit(a))))); }
// TODO: Check if we have an obstacle in our way and clear it ALSO need a mounted CHECK!!. private static Composite MovingFacingBehavior(CLU.UnitSelection onUnit) { var badStuff = ObjectManager.GetObjectsOfType<WoWUnit>(false, false).Where(q => q.CreatedByUnitGuid != Me.Guid && q.FactionId == 14 && !q.Attackable && q.Distance < 8).OrderBy(u => u.DistanceSqr).FirstOrDefault(); return new Sequence( // No Target? // Targeting Enabled? // Aquire Target new DecoratorContinue(ret => (onUnit == null || onUnit(ret) == null || onUnit(ret).IsDead || onUnit(ret).IsFriendly) && CLUSettings.Instance.EnableTargeting, new PrioritySelector( ctx => { // Clear our current target if its Dead or is Friendly. if (ctx != null && (onUnit(ctx).IsDead || onUnit(ctx).IsFriendly)) { CLULogger.TroubleshootLog(" Target Appears to be dead or a Friendly. Clearing Current Target [" + CLULogger.SafeName((WoWUnit)ctx) + "]"); StyxWoW.Me.ClearTarget(); } // Aquires a target. if (Unit.EnsureUnitTargeted != null) { // Clear our current target if its blacklisted. if (Blacklist.Contains(Unit.EnsureUnitTargeted.Guid) || Unit.EnsureUnitTargeted.IsDead) { CLULogger.TroubleshootLog(" EnsureUnitTargeted Appears to be dead or Blacklisted. Clearing Current Target [" + CLULogger.SafeName(Unit.EnsureUnitTargeted) + "]"); StyxWoW.Me.ClearTarget(); } return Unit.EnsureUnitTargeted; } return null ; }, new Decorator( ret => ret != null, //checks that the above ctx returned a valid target. new Sequence( //new Action(ret => SysLog.DiagnosticLog(" CLU targeting activated. Targeting " + SysLog.SafeName((WoWUnit)ret))), // pending spells like mage blizard cause targeting to fail. //new DecoratorContinue(ctx => StyxWoW.Me.CurrentPendingCursorSpell != null, // new Action(ctx => Lua.DoString("SpellStopTargeting()"))), new Action(ret => ((WoWUnit)ret).Target()), new WaitContinue(2, ret => onUnit(ret) != null && onUnit(ret) == (WoWUnit)ret, new ActionAlwaysSucceed()))))), // Are we Facing the target? // Is the Target in line of site? // Face Target new DecoratorContinue(ret => onUnit(ret) != null && !StyxWoW.Me.IsSafelyFacing(onUnit(ret), 45f) && onUnit(ret).InLineOfSight, new Sequence( new Action(ret => WoWMovement.Face(onUnit(ret).Guid)))), // Target in Line of site? // We are not casting? // We are not channeling? // Move to Location new DecoratorContinue(ret => onUnit(ret) != null && !onUnit(ret).InLineOfSight && !Me.IsCasting && !Spell.PlayerIsChanneling, new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Target not in LoS. Moving closer.")), new Action(ret => Navigator.MoveTo(onUnit(ret).Location)))), // Blacklist targets TODO: check this. new DecoratorContinue(ret => onUnit(ret) != null && !Me.IsInInstance && Navigator.GeneratePath(Me.Location, onUnit(ret).Location).Length <= 0, new Action(delegate { Blacklist.Add(Me.CurrentTargetGuid, TimeSpan.FromDays(365)); CLULogger.MovementLog("[CLU] " + CLU.Version + ": Failed to generate path to: {0} blacklisted!", Me.CurrentTarget.Name); return RunStatus.Success; })), // Move away from bad stuff new DecoratorContinue(ret => badStuff != null, new Sequence( new Action(ret => CLULogger.MovementLog("[CLU Movement] Movin out of bad Stuff.")), new Action(ret => { if (badStuff != null) { CLULogger.MovementLog("[CLU Movement] Movin out of {0}.", badStuff); Navigator.MoveTo(WoWMovement.CalculatePointFrom(badStuff.Location, 10)); } }))), // Move Behind Target enabled? // Target is Alive? // Target is not Moving? // Are we behind the target? // We are not casting? // We are not the tank? // We are not channeling? // Move Behind Target new DecoratorContinue(ret => CLUSettings.Instance.EnableMoveBehindTarget && onUnit(ret) != null && onUnit(ret) != StyxWoW.Me && // && !onUnit(ret).IsMoving onUnit(ret).InLineOfSight && onUnit(ret).IsAlive && !onUnit(ret).MeIsBehind && !Me.IsCasting && !Spell.PlayerIsChanneling && Unit.DistanceToTargetBoundingBox() >= 10,// && (Unit.Tanks != null && Unit.Tanks.Any(x => x.Guid != Me.Guid)) new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Not behind the target. Moving behind target.")), new Action(ret => Navigator.MoveTo(CalculatePointBehindTarget())))), // Target is greater than CombatMinDistance? // Target is Moving? // We are not moving Forward? // Move Forward to wards target new DecoratorContinue(ret => onUnit(ret) != null && Unit.DistanceToTargetBoundingBox() >= CLU.Instance.ActiveRotation.CombatMinDistance && onUnit(ret).IsMoving && !Me.MovementInfo.MovingForward && onUnit(ret).InLineOfSight && !IsFlyingUnit, new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Too far away from moving target (T[{0}] >= P[{1}]). Moving forward.", Unit.DistanceToTargetBoundingBox(), CLU.Instance.ActiveRotation.CombatMinDistance)), new Action(ret => WoWMovement.Move(WoWMovement.MovementDirection.Forward)))), // Target is less than CombatMinDistance? // Target is Moving? // We are moving Forward // Stop Moving Forward new DecoratorContinue(ret => onUnit(ret) != null && Unit.DistanceToTargetBoundingBox() < CLU.Instance.ActiveRotation.CombatMinDistance && onUnit(ret).IsMoving && Me.MovementInfo.MovingForward && onUnit(ret).InLineOfSight, new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Too close to target (T[{0}] < P[{1}]). Movement Stopped.", Unit.DistanceToTargetBoundingBox(), CLU.Instance.ActiveRotation.CombatMinDistance)), new Action(ret => WoWMovement.MoveStop()))), // Target is not Moving? // Target is greater than CombatMaxDistance? // We are not Moving? // Move Forward new DecoratorContinue(ret => onUnit(ret) != null && !onUnit(ret).IsMoving && Unit.DistanceToTargetBoundingBox() >= CLU.Instance.ActiveRotation.CombatMaxDistance && onUnit(ret).InLineOfSight, new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Too far away from non moving target (T[{0}] >= P[{1}]). Moving forward.", Unit.DistanceToTargetBoundingBox(), CLU.Instance.ActiveRotation.CombatMaxDistance)), new Action(ret => WoWMovement.Move(WoWMovement.MovementDirection.Forward, new TimeSpan(99, 99, 99))))), // Target is less than CombatMaxDistance? // We are Moving? // We are moving Forward? // Stop Moving new DecoratorContinue(ret => onUnit(ret) != null && Unit.DistanceToTargetBoundingBox() < CLU.Instance.ActiveRotation.CombatMaxDistance && Me.IsMoving && Me.MovementInfo.MovingForward && onUnit(ret).InLineOfSight, new Sequence( new Action(ret => CLULogger.MovementLog(" [CLU Movement] Too close to target (T[{0}] < P[{1}]). Movement Stopped", Unit.DistanceToTargetBoundingBox(), CLU.Instance.ActiveRotation.CombatMaxDistance)), new Action(ret => WoWMovement.MoveStop())))); }
/// <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))); }
/// <summary>Casts a spell on the MostFocused Target (used for smite healing with disc priest mainly)</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The on 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> /// <param name="faceTarget">true if you want to auto face target</param> /// <returns>The cast spell at location.</returns> public static Composite CastSpellOnMostFocusedTarget(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, bool checkmovement, string label, bool faceTarget) { return new Decorator( delegate(object a) { if (onUnit == null || onUnit(a) == null) return false; if (!cond(a)) return false; if (!Spell.CanCast(name, onUnit(a), true, checkmovement)) return false; //This is checking spell, unit, Range, Movement // if (Unit.TimeToDeath(onUnit(a).CurrentTarget) < 5) // return false; return (Unit.NearbyNonControlledUnits(onUnit(a).Location, 15, false).Any() || BossList.IgnoreRangeCheck.Contains(onUnit(a).CurrentTarget.Entry)); }, new Sequence( new Action(a => CLULogger.Log(" [Casting] {0} on {1}", label, CLULogger.SafeName(onUnit(a)))), new DecoratorContinue(x => faceTarget, new Action(a => WoWMovement.Face(onUnit(a).Guid))), new Action(a => SpellManager.Cast(name, onUnit(a))))); }
/// <summary>Casts a spell on a specified unit</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The Unit.</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 spell on the unit</returns> public static Composite CastSpell(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return CastSpell(name, onUnit, cond, true, label); }
/// <summary>Casts a spell on a specified unit</summary> /// <param name="spell">the name of the spell to cast</param> /// <param name="onUnit">The Unit.</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 spell on the unit</returns> public static Composite CastSpell(WoWSpell spell, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return CastSpell(spell, ret => Me.CurrentTarget, cond, true, label); }
/// <summary>Casts Sanctuary at the units location</summary> /// <param name="onUnit">The on Unit.</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>Sanctuary at location.</returns> public static Composite CastSanctuaryAtLocation(CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return new Decorator( delegate(object a) { if (!cond(a)) return false; return onUnit(a) != null && !WoWSpell.FromId(88685).Cooldown; }, new Sequence( new Action(a => CLULogger.Log(" [Casting at Location] {0} ", label)), Item.RunMacroText("/cast Holy Word: Sanctuary", cond, label), new Action(a => SpellManager.ClickRemoteLocation(onUnit(a).Location)))); }
public static Composite CastSpell(int spellid, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { var spell = WoWSpell.FromId(spellid); return new Decorator (context => { if (!cond(context)) { return false; } if (spell == null) { CLULogger.TroubleshootLog("SpellID not found: {0}", spellid); return false; } var target = onUnit(context); if (target == null) { CLULogger.TroubleshootLog("Target not found."); return false; } if (!Spell.CanCast(spell.ToString(), target, true)) return false; return true; }, new Sequence (new Action(a => CLULogger.Log(" [Casting] {0} on {1}", label, CLULogger.SafeName(onUnit(a)))), new Action(a => SpellManager.Cast(spell, onUnit(a))))); }
/// <summary>Casts the interupt by name on the provided target. Checks CanInterruptCurrentSpellCast.</summary> /// <param name="name">the name of the spell in english</param> /// <param name="onUnit">the unit to cas the interupt on. </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 interupt.</returns> public static Composite CastInterupt(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return new Decorator( delegate(object a) { if (!CLUSettings.Instance.EnableInterupts) return false; if (!cond(a)) return false; if (onUnit != null && onUnit(a) != null && !(onUnit(a).IsCasting && onUnit(a).CanInterruptCurrentSpellCast)) return false; if (onUnit != null && Spell.CanCast(name, onUnit(a), true, true)) return false; return true; }, new Sequence( new Action(a => CLULogger.Log(" [Interupt] {0} on {1}", label, CLULogger.SafeName(onUnit(a)))), new Action(a => SpellManager.Cast(name, onUnit(a))))); }
/// <summary>Casts a spell at the units location</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The on Unit.</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 spell at location.</returns> public static Composite CastOnUnitLocation(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return new Decorator( delegate(object a) { if (!CLUSettings.Instance.UseAoEAbilities) return false; if (!cond(a)) return false; return onUnit != null && Spell.CanCast(name, onUnit(a)); }, new Sequence( new Action(a => CLULogger.Log(" [Casting at Location] {0} ", label)), new Action(a => SpellManager.Cast(name)), //new WaitContinue( // 1, // ret => StyxWoW.Me.CurrentPendingCursorSpell != null && // StyxWoW.Me.CurrentPendingCursorSpell.Name == name, // new ActionAlwaysSucceed()), //new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()), new Action(ret => SpellManager.ClickRemoteLocation(onUnit(ret).Location)))); }
/// <summary>Casts a spell on a specified unit (used primarily for healing)</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The Unit.</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 spell on the unit</returns> public static Composite CastHeal(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return new Sequence( CastSpell(name, onUnit, cond, label), new WaitContinue( 1, ret => { WoWSpell spell; if (SpellManager.Spells.TryGetValue(name, out spell)) { if (spell.CastTime == 0) { return true; } return StyxWoW.Me.IsCasting; } return true; }, new ActionAlwaysSucceed()), new WaitContinue( 10, ret => { // Dont interupt chanelled spells if (StyxWoW.Me.ChanneledCastingSpellId != 0) { return false; } // Interrupted or finished casting. Continue if (!StyxWoW.Me.IsCasting) { return true; } // If conditions are no longer valid, stop casting and continue if (!cond(ret)) { SpellManager.StopCasting(); return true; } return false; }, new ActionAlwaysSucceed())); }
/// <summary> /// Sets a trap at the current targets location. /// </summary> /// <param name="trapName">the name of the trap to use</param> /// <param name="onUnit">the unit to place the trap on.</param> /// <param name="cond">check conditions supplied are true </param> /// <returns>nothing</returns> public static Composite HunterTrapBehavior(string trapName, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond) { return new PrioritySelector( new Decorator( delegate(object a) { if (!CLUSettings.Instance.Hunter.EnableHunterTraps) return false; if (!CLUSettings.Instance.UseAoEAbilities) return false; if (!cond(a)) return false; return onUnit != null && onUnit(a) != null && !onUnit(a).IsMoving && onUnit(a).DistanceSqr < 40 * 40 && SpellManager.HasSpell(trapName) && !SpellManager.Spells[trapName].Cooldown; }, new PrioritySelector( Buff.CastBuff("Trap Launcher", ret => true, "Trap Launcher"), new Decorator( ret => Me.HasAura("Trap Launcher"), new Sequence( //new Switch<string>(ctx => trapName, // new SwitchArgument<string>("Immolation Trap", // new Action(ret => SpellManager.CastSpellById(82945))), // new SwitchArgument<string>("Freezing Trap", // new Action(ret => SpellManager.CastSpellById(60192))), // new SwitchArgument<string>("Explosive Trap", // new Action(ret => SpellManager.CastSpellById(82939))), // new SwitchArgument<string>("Ice Trap", // new Action(ret => SpellManager.CastSpellById(82941))), // new SwitchArgument<string>("Snake Trap", // new Action(ret => SpellManager.CastSpellById(82948))) // ), //// new ActionSleep(200), //new Action(a => SpellManager.ClickRemoteLocation(onUnit(a).Location)))) new Action(ret => Lua.DoString(string.Format("CastSpellByName(\"{0}\")", trapName))), new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()), new Action(ret => SpellManager.ClickRemoteLocation(onUnit(ret).Location)) ))))); }
/// <summary>Casts a Pet spell at the units location</summary> /// <param name="name">the name of the spell to cast</param> /// <param name="onUnit">The on Unit.</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 spell at location.</returns> public static Composite CastPetSpellAtLocation(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { // CLU.DebugLog(" [CastSpellAtLocation] name = {0} location = {1} and can we cast it? {2}", name, SysLog.SafeName(unit), CanCast(name)); return new Decorator( delegate(object a) { if (!CLUSettings.Instance.UseAoEAbilities) return false; if (Me.CurrentTarget == null) return false; WoWPoint currTargetLocation = Me.CurrentTarget.Location; if (Unit.NearbyControlledUnits(currTargetLocation, 20, false).Any()) return false; if (!cond(a)) return false; if (!CanCastPetSpell(name)) return false; return onUnit != null; }, new Sequence( new Action(a => CLULogger.Log(" [Pet Casting at location] {0} ", label)), new Action(a => CastMyPetSpell(name)), // new WaitContinue( // 0, // ret => StyxWoW.Me.CurrentPendingCursorSpell != null && // StyxWoW.Me.CurrentPendingCursorSpell.Name == name, // new ActionAlwaysSucceed()), new Action(a => SpellManager.ClickRemoteLocation(onUnit(a).Location)))); }
/// <summary> /// Sets a trap at the specified targets location /// </summary> /// <param name="trapName">The name of the trap to use</param> /// <param name="onUnit">The unit to place the trap on</param> /// <param name="cond">Check conditions supplied are true</param> /// <returns></returns> public static Composite pvpTrapBehavior(string trapName, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond) { return ( new PrioritySelector( new Decorator(delegate(object a) { if (!cond(a)) return false; return onUnit != null && onUnit(a) != null && onUnit(a).DistanceSqr <= 20 * 20 && SpellManager.HasSpell(trapName) && !SpellManager.Spells[trapName].Cooldown; }, new PrioritySelector( Buff.CastBuff("Trap Launcher", ret => !Buff.PlayerHasBuff("Trap Launcher"), "Trap Launcher"), Spell.CastSpell("Scatter Shot", ret => true, "Scatter Shot"), new Decorator(ret => Buff.PlayerHasBuff("Trap Launcher"), new Sequence( new Action(ret => Lua.DoString(string.Format("CastSpellByName(\"{0}\")", trapName))), new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()), new Action(ret => SpellManager.ClickRemoteLocation(onUnit(ret).Location))))) ))); }
/// <summary>Casts a Buff on a specified unit</summary> /// <param name="name">the name of the Buff to cast</param> /// <param name="onUnit">The Unit.</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>Buff on the unit</returns> public static Composite CastBuffonUnit(string name, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label) { return new Decorator( delegate(object a) { if (TargetHasBuff(name)) return false; if (!cond(a)) return false; if (!SpellManager.CanBuff(name, Me)) return false; 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(name, onUnit(a))))); }