public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force)
    {
        // targetfinder function already checks that they are in LoS
        if (unit == null || !spell.IsKnown() || !spell.CanCast() || !unit.IsValid || unit.IsDead)
        {
            return(false);
        }

        if (wManager.wManagerSetting.CurrentSetting.IgnoreFightGoundMount && ObjectManager.Me.IsMounted)
        {
            return(false);
        }

        MountTask.DismountMount();

        if (ObjectManager.Me.IsCasting() && !force)
        {
            return(false);
        }

        if (ObjectManager.Me.GetMove && spell.Spell.CastTime > 0)
        {
            //MovementManager.StopMove();
            MovementManager.StopMoveTo(false, Usefuls.Latency + 500);
        }

        if (force)
        {
            Lua.LuaDoString("SpellStopCasting();");
        }

        if (AreaSpells.Contains(spell.Spell.Name))
        {
            /*spell.Launch(true, true, false);
             *  Thread.Sleep(Usefuls.Latency + 50);
             *  ClickOnTerrain.Pulse(unit.Position);*/

            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            //SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position);
            ClickOnTerrain.Pulse(unit.Position);
        }
        else
        {
            if (unit.Guid != ObjectManager.Me.Guid)
            {
                //FaceUnit(unit);
                MovementManager.Face(unit);
            }

            _disableTargeting = true;
            WoWUnit temp = ObjectManager.Target;
            TargetUnit(unit);
            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            TargetUnit(temp);
            //SpellManager.CastSpellByNameOn(spell.FullName(), GetLuaId(unit));
            //Interact.InteractObject also works and can be used to target another unit
            _disableTargeting = false;
        }
        return(true);
    }
 private void UpdateRanks()
 {
     if (IceArmor.IsKnown())
     {
         Armor = IceArmor;
     }
 }
    public static void CastBuff(RotationSpell buff, WoWUnit target)
    {
        switch (buff.Spell.Name)
        {
        case "Power Word: Fortitude" when target.HaveBuff("Prayer of Fortitude"):
            return;

        case "Divine Spirit" when target.HaveBuff("Prayer of Spirit"):
            return;

        case "Blessing of Kings" when target.HaveBuff("Greater Blessing of Kings"):
            return;
        }

        if (!target.HaveBuff(buff.Spell.Name))
        {
            CastSpell(buff, target);
        }
    }
Exemplo n.º 4
0
    public override bool Equals(object obj)
    {
        RotationSpell otherObj = (RotationSpell)obj;

        return(_name.Equals(otherObj._name) && _rank == otherObj._rank);
    }
 public static bool CastSpell(RotationSpell spell, WoWUnit unit)
 {
     return(CastSpell(spell, unit, false));
 }
    public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force)
    {
        //silly vanilla logic
        if (unit != null && unit.IsValid && unit.IsAlive && spell.IsKnown() && spell.GetCooldown() == 0 && !spell.IsUsable() && !spell.NotEnoughMana())
        {
            if (ObjectManager.Me.HaveBuff("Bear Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Bear Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Dire Bear Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Dire Bear Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Cat Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Cat Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Ghost Wolf"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Ghost Wolf"", true)");
            }
        }

        // targetfinder function already checks that they are in LoS
        if (unit == null || !spell.IsKnown() || !spell.CanCast() || !unit.IsValid || unit.IsDead)
        {
            return(false);
        }

        if (wManager.wManagerSetting.CurrentSetting.IgnoreFightGoundMount && ObjectManager.Me.IsMounted)
        {
            return(false);
        }

        MountTask.DismountMount();

        //already wanding, don't turn it on again!
        if (spell.Spell.Name == "Shoot" && IsAutoRepeating("Shoot"))
        {
            return(true);
        }

        if (ObjectManager.Me.IsCasting() && !force)
        {
            return(false);
        }

        if (ObjectManager.Me.GetMove && spell.Spell.CastTime > 0)
        {
            //MovementManager.StopMove();
            MovementManager.StopMoveTo(false, Usefuls.Latency + 500);
        }

        if (force)
        {
            Lua.LuaDoString("SpellStopCasting();");
        }

        if (AreaSpells.Contains(spell.Spell.Name))
        {
            /*spell.Launch(true, true, false);
             *  Thread.Sleep(Usefuls.Latency + 50);
             *  ClickOnTerrain.Pulse(unit.Position);*/

            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            //SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position);
            ClickOnTerrain.Pulse(unit.Position);
        }
        else
        {
            //don't switch target if targeting enemy - rely on auto selfcast
            WoWUnit temp   = ObjectManager.Target;
            bool    onSelf = unit.Guid == ObjectManager.Me.Guid;

            if (!onSelf)
            {
                //FaceUnit(unit);
                MovementManager.Face(unit);
                _disableTargeting = true;
                TargetUnit(unit);
            }


            Lua.LuaDoString($"CastSpellByName('{spell.FullName()}', {onSelf.ToString().ToLower()})");

            if (!onSelf)
            {
                if (temp.Guid == 0 || !temp.IsValid)
                {
                    Lua.LuaDoString("ClearTarget();");
                }
                else
                {
                    TargetUnit(temp);
                }

                //SpellManager.CastSpellByNameOn(spell.FullName(), GetLuaId(unit));
                //Interact.InteractObject also works and can be used to target another unit
                _disableTargeting = false;
            }
        }
        return(true);
    }
 public static void CastBuff(RotationSpell buff)
 {
     CastBuff(buff, ObjectManager.Me);
 }