No tested, but use code like:
public static bool CastSpell(Spell spell, WoWUnit unit, bool force)
{
// Handle bullshit units
if (unit == null || !unit.IsValid || unit.IsDead || !spell.KnownSpell || !spell.IsSpellUsable)
{
return false;
}
// Check If Toon is Wanding
if (spell.Name == "Shoot" && IsAutoRepeating("Shoot"))
{
return true;
}
// Fuck off if toon is already casting and (force == false)
if (ObjectManager.Me.IsCast && !force)
return false;
// Stop moving if spell needs to be cast
if (spell.CastTime > 0)
MovementManager.StopMoveTo(false, Usefuls.Latency + 500);
// Force cast spell if (force == true)
if (force)
Lua.LuaDoString("SpellStopCasting();");
// Cast AoE spells by location
if (AreaSpells.Contains(spell.Name))
{
Lua.LuaDoString("CastSpellByName(\"" + spell.NameInGame + "\")");
ClickOnTerrain.Pulse(unit.Position);
}
else
{
// Face unit to cast
if (!unit.IsLocalPlayer)
MovementManager.Face(unit);
if (unit.IsLocalPlayer || unit.Type == WoWObjectType.Player)
SpellManager.CastSpellByNameOn(spell.NameInGame, unit.Name);
if (unit.IsMyTarget)
SpellManager.CastSpellByNameOn(spell.NameInGame, "target");
else
{
var old = ObjectManager.Me.MouseOverGuid;
ObjectManager.Me.MouseOverGuid = unit.Guid;
SpellManager.CastSpellByNameOn(spell.NameInGame, "mouseover");
ObjectManager.Me.MouseOverGuid = old;
}
}
return true;
}