Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1.         /// <summary>
  2.         ///     Casts the spell.
  3.         /// </summary>
  4.         /// <param name="spell">The spell.</param>
  5.         public void CastSpell(Spell spell)
  6.         {
  7.             if (!spell.CanUse())
  8.             {
  9.                 spell.InUse = false;
  10.                 return;
  11.             }
  12.  
  13.             if (spell.InUse)
  14.                 return;
  15.  
  16.             var info = Client.Aisling.ActiveSpellInfo;
  17.  
  18.             if (info != null)
  19.             {
  20.                 if (!string.IsNullOrEmpty(info.Data))
  21.                     spell.Script.Arguments = info.Data;
  22.  
  23.                 var target = GetObject(Map, i => i.Serial == info.Target, Get.Monsters | Get.Aislings | Get.Mundanes);
  24.                 spell.InUse = true;
  25.  
  26.  
  27.                 if (spell.Script != null)
  28.                 {
  29.                     if (target != null)
  30.                     {
  31.                         if (target is Aisling tobj)
  32.                         {
  33.                             spell.Script.OnUse(this, target as Aisling);
  34.                         }
  35.  
  36.                         if (target is Monster aobj)
  37.                         {
  38.                             spell.Script.OnUse(this, aobj);
  39.                         }
  40.  
  41.  
  42.                         if (target is Mundane)
  43.                             spell.Script.OnUse(this, target as Mundane);
  44.                     }
  45.                     else
  46.                     {
  47.                         spell.Script.OnUse(this, this);
  48.                     }
  49.                 }
  50.             }
  51.  
  52.             spell.NextAvailableUse = DateTime.UtcNow.AddSeconds(info.SpellLines > 0 ? 1 : 0.2);
  53.             spell.InUse = false;
  54.  
  55.             if (spell.Template.Cooldown > 0)
  56.             {
  57.                 Client.Send(new ServerFormat3F((byte)0,
  58.                     spell.Slot,
  59.                     spell.Template.Cooldown));
  60.             }
  61.  
  62.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement