Guest User

Untitled

a guest
Nov 17th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. //the CALL
  2.  
  3. Spell.CastSelfSpellByID(18540, ret => Me.CurrentTarget != null && Unit.IsTargetWorthy(Me.CurrentTarget), "Summon Terrorguard"))),
  4.  
  5. //The Method
  6.         public static Composite CastSpellByID(int spellid, CLU.UnitSelection onUnit, CanRunDecoratorDelegate cond, string label)
  7.         {
  8.             var spell = WoWSpell.FromId(spellid);
  9.             return new Decorator
  10.                 (context =>
  11.                 {
  12.                     if (!cond(context))
  13.                     {
  14.                         return false;
  15.                     }
  16.                     if (spell == null)
  17.                     {
  18.                         CLU.TroubleshootLog("SpellID not found: {0}", spellid);
  19.                         return false;
  20.                     }
  21.  
  22.                     var target = onUnit(context);
  23.  
  24.                     if (target == null)
  25.                     {
  26.                         CLU.TroubleshootLog("Target not found.");
  27.                         return false;
  28.                     }
  29.  
  30.                     var canCast = CanCast(spell, target);
  31.  
  32.                     if (!canCast)
  33.                     {
  34.                         return false;
  35.                     }
  36.  
  37.                     return true;
  38.                 },
  39.                  new Sequence
  40.                      (new Action(a => CLU.Log(" [Casting] {0} on {1}", label, CLU.SafeName(onUnit(a)))),
  41.                       new Action(a => SpellManager.Cast(spell, onUnit(a)))));
  42.         }
Add Comment
Please, Sign In to add comment