Skip to content

SpellManager ยป Cast Spell

Namespace: Mayo.Manager.Spells
Namespace: Mayo.Manager.Spells.Interface
Dependencies: ISpellManager
GameClient: GC.SM


You can find more info's about the Spell properties here:


The return value of the methods listed below indicates whether the spell was executed successfully or not.


Unlike Cast, TryCast checks additional parameters:

  • Spell cost
  • Cooldown
  • Conditions
  • Target (if specified)

bool CastAsync(int SpellID)
bool CastAsync(Spell Spell)
Example
var Spell = GC.SM.GetSpell("Arcane Intellect");
if (Spell != null)
{
    var Success = await GC.SM.CastAsync(Spell);

    if (Success)
        Log.Write($"{Spell.Name} was successfully executed.");
    else
        Log.Write($"{Spell.Name} could not be executed.");
}
bool TryCastAsync(Spell, List<Func<bool>>? Conditions)
Example
var Spell = GC.SM.GetSpell("Arcane Intellect");
if (Spell != null)
{
    await GC.SM.TryCastAsync(Spell, [
        () => !GC.OM.Me.HasAura("Arcane Intellect"),
    ]);
}
bool TryCastAsync(Spell, IUnit Target, List<Func<bool>>? Conditions)
bool TryCastAsync(Spell, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCastAsync(Spell, IModel Target, List<Func<bool>>? Conditions)
bool TryCastAsync(Spell, IGameObject Target, List<Func<bool>>? Conditions)

This casts Frostbolt on the target, provided the target does not have the slow effect of Frostbolt as an aura.

Example
var Target = GC.OM.Me.TargetUnit;
if (Target == null)
    return;

var Frostbolt = GC.SM.GetSpell("Frostbolt");
if (Frostbolt != null)
    await GC.SM.TryCastAsync(Frostbolt, Target, [
        () => !Target.HasAura(Frostbolt.ID),
    ]);

var Fireball = GC.SM.GetSpell("Fireball");
if (Fireball != null)
    await GC.SM.TryCastAsync(Fireball, Target);
bool TryCastAsync(int SpellID, List<Func<bool>>? Conditions)
Example
var ArcaneIntellectRank5 = 10157;

await GC.SM.TryCastAsync(ArcaneIntellectRank5, [
    () => !GC.OM.Me.HasAura(ArcaneIntellectRank5),
]);
bool TryCastAsync(int SpellID, IUnit Target, List<Func<bool>>? Conditions)
bool TryCastAsync(int SpellID, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCastAsync(int SpellID, IModel Target, List<Func<bool>>? Conditions)
bool TryCastAsync(int SpellID, IGameObject Target, List<Func<bool>>? Conditions)
Example
var FrostboltRank4 = 7322;
var FireballRank1 = 133;

var Target = GC.OM.Me.TargetUnit;
if (Target != null)
{
    await GC.SM.TryCastAsync(FrostboltRank4, Target, [
        () => !Target.HasAura(FrostboltRank4),
    ]);

    await GC.SM.TryCastAsync(FireballRank1, Target);
}
bool TryCastAsync(string SpellName, List<Func<bool>>? Conditions)
Example
await GC.SM.TryCastAsync("Arcane Intellect", [
    () => !GC.OM.Me.HasAura("Arcane Intellect"),
]);
bool TryCastAsync(string SpellName, IUnit Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, IModel Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, IGameObject Target, List<Func<bool>>? Conditions)
Example
var Target = GC.OM.Me.TargetUnit;
if (Target != null)
{
    await GC.SM.TryCastAsync("Frostbolt", Target, [
        () => !Target.HasAura("Frostbolt"),
    ]);

    await GC.SM.TryCastAsync("Fireball", Target);
}
bool TryCastAsync(string SpellName, int Rank, List<Func<bool>>? Conditions)
Example
await GC.SM.TryCastAsync("Arcane Intellect", 2);
bool TryCastAsync(string SpellName, int Rank, IUnit Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, int Rank, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, int Rank, IModel Target, List<Func<bool>>? Conditions)
bool TryCastAsync(string SpellName, int Rank, IGameObject Target, List<Func<bool>>? Conditions)
Example
var Target = GC.OM.Me.TargetUnit;
if (Target != null)
{
    await GC.SM.TryCastAsync("Frostbolt", 4, Target);
    await GC.SM.TryCastAsync("Fireball", 3, Target);
}

bool Cast(int SpellID)
bool Cast(Spell Spell)
bool TryCast(Spell, List<Func<bool>>? Conditions)
bool TryCast(Spell, IUnit Target, List<Func<bool>>? Conditions)
bool TryCast(Spell, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCast(Spell, IModel Target, List<Func<bool>>? Conditions)
bool TryCast(Spell, IGameObject Target, List<Func<bool>>? Conditions)
bool TryCast(int SpellID, List<Func<bool>>? Conditions)
bool TryCast(int SpellID, IUnit Target, List<Func<bool>>? Conditions)
bool TryCast(int SpellID, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCast(int SpellID, IModel Target, List<Func<bool>>? Conditions)
bool TryCast(int SpellID, IGameObject Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, IUnit Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, IModel Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, IGameObject Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, int Rank, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, int Rank, IUnit Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, int Rank, IPlayer Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, int Rank, IModel Target, List<Func<bool>>? Conditions)
bool TryCast(string SpellName, int Rank, IGameObject Target, List<Func<bool>>? Conditions)