Пример #1
0
    //public static bool GroupHealSpell1(Spell spell, WoWUnit target, int buffTimeLeft = 0, int stacks = 0, Spell debuff = null, bool owner = true)
    //{
    //    bool hasDebuff;
    //    if (debuff != null)
    //    {
    //        hasDebuff = Extension.HasBuff(debuff, target, buffTimeLeft, stacks, owner);
    //    }
    //    else
    //    {
    //        hasDebuff = Extension.HasBuff(spell, target, buffTimeLeft, stacks, owner);
    //    }

    //    // Validate spell
    //    if (!ObjectManager.Me.IsStunned && !ObjectManager.Me.IsDead && !ObjectManager.Me.IsCast && !target.IsDead && spell.KnownSpell && spell.IsSpellUsable && spell.IsDistanceGood && !hasDebuff)
    //    {
    //        if (target.Guid == ObjectManager.Me.Guid)
    //        {
    //            // Cast on self
    //            Lua.LuaDoString($"CastSpellByID({spell.Id}, \"player\")");
    //            Usefuls.WaitIsCasting();
    //        }
    //        else
    //        {
    //            // Cast on target
    //            Lua.LuaDoString($"CastSpellByID({spell.Id}, \"{target.Name}\")");
    //            Usefuls.WaitIsCasting();
    //        }

    //        // Log
    //        Logging.WriteDebug($"Cast: {spell.NameInGame}");

    //        // Return
    //        return true;
    //    }

    //    // Return
    //    return false;
    //}

    public static bool HasBuff(Spell spell, WoWUnit target, double buffTimeLeft = 0, int stacks = 0, bool owner = true)
    {
        // Get target auras
        List <Aura> auraList = target.GetAllBuff();

        // Get aura
        Aura aura = null;

        if (owner)
        {
            // Set
            aura = auraList.Where(s => s.ToString().Contains(spell.Name) && s.Owner == ObjectManager.Me.Guid).FirstOrDefault();
        }
        else
        {
            // Set
            aura = auraList.FirstOrDefault(s => s.ToString().Contains(spell.Name));
        }

        // Any found?
        if (aura != null)
        {
            // Validate
            if (aura.TimeLeftSeconde > buffTimeLeft && aura.Stack >= stacks)
            {
                // Return
                return(true);
            }
        }

        // Return
        return(false);
    }
 public static bool HasAnyBuff(this WoWUnit unit, params string[] names)
 {
     return(unit.GetAllBuff().Any(b => names.Contains(b.GetSpell.Name)));
 }
 public static bool HaveAllDebuffs(this WoWUnit unit, params string[] names)
 {
     return(unit.GetAllBuff().Select(b => b.GetSpell.Name).All(names.Contains));
 }
 //this does a multi-language check because it gets the spellname in English (not nameInGame)
 public static bool HasBuff(this WoWUnit unit, string name)
 {
     return(unit.GetAllBuff().Any(b => name == b.GetSpell.Name));
 }