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);
    }
Esempio n. 2
0
    private bool doKicks()
    {
        Vector3 lastPos = ObjectManager.Me.Position;

        if (OutlawSettings.CurrentSetting.EnableInterrupt)
        {
            WoWUnit toInterrupt = MyHelpers.InterruptableUnits();
            if (toInterrupt != null)
            {
                ObjectManager.Me.FocusGuid = toInterrupt.Guid;
                if (Kick.IsSpellUsable && Kick.KnownSpell && MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange())
                {
                    MovementManager.Face(toInterrupt.Position);
                    Kick.Launch(false, false, false, "focus");
                    MovementManager.Face(ObjectManager.Target.Position);
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Kick " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return(true);
                }

                if (Blind.IsSpellUsable && Blind.KnownSpell && MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange())
                {
                    MovementManager.Face(toInterrupt.Position);
                    Blind.Launch(false, false, false, "focus");
                    MovementManager.Face(ObjectManager.Target.Position);
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Blind " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 3
0
    public void strafe(MoveAction direction, int timeStrafe)
    {
        int portionSleep = timeStrafe / 20;

        switch (direction)
        {
        case MoveAction.Left:
            Move.StrafeLeft(Move.MoveAction.DownKey);
            for (int i = 0; i < timeStrafe; i += portionSleep)
            {
                Thread.Sleep(portionSleep);
                MovementManager.Face(ObjectManager.Target.Position);
            }
            Move.StrafeLeft(Move.MoveAction.UpKey);
            break;

        case MoveAction.Right:

            Move.StrafeRight(Move.MoveAction.DownKey);
            for (int i = 0; i < timeStrafe; i += portionSleep)
            {
                Thread.Sleep(portionSleep);
                MovementManager.Face(ObjectManager.Target.Position);
            }
            Move.StrafeRight(Move.MoveAction.UpKey);

            break;
        }
    }
Esempio n. 4
0
    public static void searchAttackers()
    {
        List <WoWUnit> list = ObjectManager.GetWoWUnitAttackables(9.0f);

        if (list.Count > 0)
        {
            ObjectManager.Me.Target = list[0].Guid;
            MovementManager.Face(ObjectManager.Target.Position);
        }
    }
Esempio n. 5
0
    private bool FacingBehavior(WoWPlayer unit)
    {
        if (!MeHumanSettings.CurrentSetting.FacingBehavior || unit == null)
        {
            return(false);
        }

        MovementManager.Face(unit.Position);
        Thread.Sleep(500);
        return(true);
    }
Esempio n. 6
0
    private void EmoteBehavior(WoWPlayer unit, string emote)
    {
        MovementManager.Face(unit.Position);
        Thread.Sleep(500);

        Lua.RunMacroText(@"/" + emote);
        Thread.Sleep(550);
        Lua.LuaDoString("ClearTarget();");
        Thread.Sleep(550);

        EmotedPeoples.Add(unit.Name);
    }
Esempio n. 7
0
        protected override void PullNextMob()
        {
            var closestHostile = ObjectManager.GetWoWUnitHostile()
                                 .Where(x => !x.IsDead &&
                                        !TraceLine.TraceLineGo(ObjectManager.Me.Position, x.Position, CGWorldFrameHitFlags.HitTestSpellLoS))
                                 .OrderBy(x => x.GetDistance2D)
                                 .FirstOrDefault();

            if (closestHostile == null)
            {
                return;
            }

            closestHostile.TargetEnemy();
            MovementManager.Face(closestHostile);
            MovementManager.StopMove();
            SpellManager.CastSpellByNameLUA("Shoot Crossbow");
        }
Esempio n. 8
0
    public void doPath(List <Vector3> path)
    {
        MountUp();


        foreach (Vector3 next in path)
        {
            if (!ObjectManager.Me.IsMounted)
            {
                if (ObjectManager.Me.InCombat)
                {
                    MovementManager.StopMoveTo();
                    MovementManager.Face(ObjectManager.Target.Position);
                    Thread.Sleep(100);
                }
            }
            MovementManager.MoveTo(next);
            Thread.Sleep(100);
            while (ObjectManager.Me.SpeedMoving > 0)
            {
                if (!ObjectManager.Me.IsMounted)
                {
                    if (ObjectManager.Me.InCombat)
                    {
                        MovementManager.StopMoveTo();
                        MovementManager.Face(ObjectManager.Target.Position);
                        Thread.Sleep(5000);
                    }
                }
            }
            MovementManager.MoveTo(next);
        }

        Thread.Sleep(2000);
        wManager.Wow.Bot.Tasks.MountTask.DismountMount();
        while (ObjectManager.Me.InCombat)
        {
            MovementManager.StopMoveTo();
            MovementManager.Face(ObjectManager.Target.Position);
            Thread.Sleep(100);
        }
        Thread.Sleep(1000);
        MountUp();
    }
Esempio n. 9
0
        protected override void GatherLooseMobs()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            var closestLooseMob = LooseMobs
                                  .OrderBy(x => x.GetDistance)
                                  .FirstOrDefault();

            if (closestLooseMob != null)
            {
                while (stopwatch.Elapsed < TimeSpan.FromSeconds(5))
                {
                    closestLooseMob.TargetEnemy();
                    MovementManager.Face(closestLooseMob);
                    MovementManager.MoveTo(closestLooseMob);
                    if (_taunt.CooldownEnabled)
                    {
                        break;
                    }
                    _taunt.Cast();
                }
            }
        }
Esempio n. 10
0
        public static UInt128 StartFightDamageDealer(UInt128 guid = default(UInt128))
        {
            WoWUnit targetNpc = null;

            try
            {
                if (ObjectManager.ObjectManager.Me.IsMounted)
                {
                    return(0);
                }
                if (guid == 0)
                {
                    targetNpc = new WoWUnit(ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                }
                else
                {
                    targetNpc = new WoWUnit(ObjectManager.ObjectManager.GetObjectByGuid(guid).GetBaseAddress);
                }

                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                    return(0);
                }

                InFight = true;

                if (!ObjectManager.ObjectManager.Me.IsCast)
                {
                    if (CombatClass.InRange(targetNpc) && CombatClass.GetRange <= 5) // Initiate auto attack on melees + target.
                    {
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }
                    ObjectManager.ObjectManager.Me.Target = targetNpc.Guid;
                }
                Thread.Sleep(100);
                Point positionStartTarget = targetNpc.Position;
figthStart:
                // If pos start is far, we will Loop to it anyway.
                if (targetNpc.Position.DistanceTo(positionStartTarget) > CombatClass.GetRange + 5f)
                {
                    return(0);
                }
                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                    return(0);
                }
                if (Usefuls.IsInBattleground && !Battleground.IsFinishBattleground())
                {
                    List <WoWUnit> tLUnit = ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer();
                    if (tLUnit.Count > 0)
                    {
                        if (ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).GetDistance < targetNpc.GetDistance && ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).SummonedBy == 0)
                        {
                            return(0);
                        }
                    }
                }
                Thread.Sleep(200);
                if (CombatClass.InRange(targetNpc) && CombatClass.GetRange > 5 && ObjectManager.ObjectManager.Me.GetMove && !ObjectManager.ObjectManager.Me.IsCast)
                {
                    Logging.Write("Your class recquires you to stop moving in order to cast spell, as this product is passive, we wont try to force stop.");
                }
                if ((ObjectManager.ObjectManager.Me.Target != targetNpc.Guid) && !targetNpc.IsDead && !ObjectManager.ObjectManager.Me.IsCast)
                {
                    ObjectManager.ObjectManager.Me.Target = targetNpc.Guid;
                    if (CombatClass.GetRange <= 5) // Initiate auto attack on melees + target.
                    {
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }
                }

                // If target died after only 0.2sec of fight, let's find a new target.
                if (targetNpc.IsDead || !targetNpc.IsValid)
                {
                    targetNpc = new WoWUnit(ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                    if (!ObjectManager.ObjectManager.Me.IsCast && ObjectManager.ObjectManager.Me.Target != targetNpc.Guid)
                    {
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }
                    if (nManagerSetting.CurrentSetting.ActivateAutoFacingDamageDealer)
                    {
                        MovementManager.Face(targetNpc, false);
                    }
                }

                while (!ObjectManager.ObjectManager.Me.IsDeadMe && !targetNpc.IsDead && targetNpc.IsValid && InFight && targetNpc.Attackable)
                {
                    // check for IsTransport if we are specifically inside a taxi, but allow fighting in ships etc.
                    // I guess transport Id become the creature Id in that case ? So check if transport id is actually a unit and not a gameobject or a continentid ?

                    // Target Pos Verif
                    if (!targetNpc.Position.IsValid)
                    {
                        return(targetNpc.Guid);
                    }

                    // Target mob if not target
                    if (ObjectManager.ObjectManager.Me.Target != targetNpc.Guid && !targetNpc.IsDead && !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        // Player has switched the target.
                        if (ObjectManager.ObjectManager.Me.Target == 0)
                        {
                            return(0);                 // if player have no target anymore, don't do anything.
                        }
                        if (CombatClass.GetRange <= 5) // Initiate auto attack on melees.
                        {
                            Interact.InteractWith(ObjectManager.ObjectManager.Target.GetBaseAddress);
                        }

                        // Switch Target
                        targetNpc = new WoWUnit(ObjectManager.ObjectManager.Target.GetBaseAddress);
                        goto figthStart;
                    }

                    if (nManagerSetting.CurrentSetting.ActivateAutoFacingDamageDealer)
                    {
                        MovementManager.Face(targetNpc, false);
                    }
                    // If we are not facing anymore, it's because of player moves in 99% of the case, so wait for the next player move to apply the facing.
                    Thread.Sleep(50);
                }
            }
            catch (Exception exception)
            {
                Logging.WriteError("StartFightDamageDealer(UInt128 guid = 0, bool inBg = false): " + exception);
            }
            if (targetNpc != null)
            {
                return(targetNpc.Guid);
            }
            return(0);
        }
Esempio n. 11
0
        public static UInt128 StartFight(UInt128 guid = default(UInt128))
        {
            MovementManager.StopMove();
            WoWUnit targetNpc = null;

            try
            {
                if (guid == 0)
                {
                    targetNpc =
                        new WoWUnit(
                            ObjectManager.ObjectManager.GetNearestWoWUnit(
                                ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                }
                else
                {
                    targetNpc =
                        new WoWUnit(ObjectManager.ObjectManager.GetObjectByGuid(guid).GetBaseAddress);
                }

                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                }

                if (ObjectManager.ObjectManager.Me.IsMounted &&
                    (CombatClass.InAggroRange(targetNpc) || CombatClass.InRange(targetNpc)))
                {
                    MountTask.DismountMount();
                }

                InFight = true;

                if (!ObjectManager.ObjectManager.Me.IsCast)
                {
                    Interact.InteractWith(targetNpc.GetBaseAddress);
                }
                Thread.Sleep(100);
                if (ObjectManager.ObjectManager.Me.GetMove && !ObjectManager.ObjectManager.Me.IsCast)
                {
                    MovementManager.StopMoveTo();
                }

                Point positionStartTarget = targetNpc.Position;

                int timer = 0;
figthStart:
                // If pos start is very different
                if (targetNpc.Position.DistanceTo(positionStartTarget) > 50)
                {
                    return(0);
                }
                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                    // Some become unattackable instead of being dead.
                    // Some will evade.
                }
                if (Usefuls.IsInBattleground && !Battleground.IsFinishBattleground())
                {
                    List <WoWUnit> tLUnit = ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer();
                    if (tLUnit.Count > 0)
                    {
                        if (ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).GetDistance < targetNpc.GetDistance &&
                            ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).SummonedBy == 0)
                        {
                            return(0);
                        }
                    }
                }
                if ((ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InRange(targetNpc)) || TraceLine.TraceLineGo(targetNpc.Position)) // If obstacle or not in range
                {
                    bool         resultSucces;
                    List <Point> points = PathFinder.FindPath(targetNpc.Position, out resultSucces);
                    if (!resultSucces && !Usefuls.IsFlying && MountTask.GetMountCapacity() >= MountCapacity.Fly)
                    {
                        MountTask.Mount(true, true);
                    }

                    // TODO: Code a FindTarget that includes CombatClass.GetRange here or we will often do wierd thing with casters.
                    MovementManager.Go(points);
                    timer = Others.Times + (int)(Math.DistanceListPoint(points) / 3 * 1000) + 15000;

                    while (!ObjectManager.ObjectManager.Me.IsDeadMe && !targetNpc.IsDead && targetNpc.Attackable && !targetNpc.IsLootable &&
                           targetNpc.Health > 0 && targetNpc.IsValid &&
                           MovementManager.InMovement && InFight && Usefuls.InGame &&
                           (TraceLine.TraceLineGo(targetNpc.Position) || !CombatClass.InAggroRange(targetNpc))
                           )
                    {
                        // Mob already in fight
                        if (targetNpc.Type != Enums.WoWObjectType.Player && !(targetNpc.IsTargetingMe || targetNpc.Target == 0 || ((WoWUnit)ObjectManager.ObjectManager.GetObjectByGuid(targetNpc.Target)).
                                                                              SummonedBy == ObjectManager.ObjectManager.Me.Guid || targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid))
                        {
                            return(targetNpc.Guid);
                        }

                        // Timer
                        if (Others.Times > timer && TraceLine.TraceLineGo(targetNpc.Position))
                        {
                            return(targetNpc.Guid);
                        }

                        // Target Pos Verif
                        if (!targetNpc.Position.IsValid)
                        {
                            return(targetNpc.Guid);
                        }

                        // If pos start is very different
                        if (targetNpc.Position.DistanceTo(positionStartTarget) > 50)
                        {
                            return(0);
                        }

                        // Return if player/pet is attacked by another unit
                        if (ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0 && !targetNpc.IsTargetingMe && !(targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid && targetNpc.Target > 0))
                        {
                            return(0);
                        }
                        Thread.Sleep(50);
                    }
                }
                timer = Others.Times + (int)(ObjectManager.ObjectManager.Me.Position.DistanceTo(targetNpc.Position) / 3 * 1000) + 5000;
                if (MovementManager.InMovement)
                {
                    MovementManager.StopMove();
                }

                if (!ObjectManager.ObjectManager.Me.IsCast && ObjectManager.ObjectManager.Me.Target != targetNpc.Guid)
                {
                    Interact.InteractWith(targetNpc.GetBaseAddress);
                }

                InFight = true;
                Thread.Sleep(200);
                if (CombatClass.InAggroRange(targetNpc))
                {
                    if (ObjectManager.ObjectManager.Me.GetMove && !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        MovementManager.StopMoveTo();
                    }
                    if (!ObjectManager.ObjectManager.Me.GetMove && ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        MountTask.DismountMount();
                    }
                }

                // If target died after only 0.2sec of fight, let's find a new target.
                if (targetNpc.IsDead || !targetNpc.IsValid || targetNpc.Attackable)
                {
                    WoWUnit newTargetNpc = new WoWUnit(ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                    if (newTargetNpc.IsValid && !ObjectManager.ObjectManager.Me.IsCast && ObjectManager.ObjectManager.Me.Target != newTargetNpc.Guid)
                    {
                        targetNpc = newTargetNpc;
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                        // Face the new target
                        MovementManager.Face(targetNpc);
                    }
                }

                while (!ObjectManager.ObjectManager.Me.IsDeadMe && !targetNpc.IsDead && targetNpc.Attackable && targetNpc.IsValid && InFight &&
                       targetNpc.IsValid && !ObjectManager.ObjectManager.Me.InTransport)
                {
                    // Return if player attacked and this target not attack player
                    if (targetNpc.Type != Enums.WoWObjectType.Player && !targetNpc.IsTargetingMe && !(targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid && targetNpc.Target > 0) &&
                        ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0)
                    {
                        return(0);
                    }

                    // Cancel fight if the mob was tapped by another player
                    if (targetNpc.IsTapped)
                    {
                        return(0);
                    }

                    // Target Pos Verif
                    if (!targetNpc.Position.IsValid)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }

                    // Target mob if not target
                    if (ObjectManager.ObjectManager.Me.Target != targetNpc.Guid && !targetNpc.IsDead && !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }

                    // Move to target if out of range
                    if (!ObjectManager.ObjectManager.Me.IsCast &&
                        ((!ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InAggroRange(targetNpc)) ||
                         ((ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InRange(targetNpc)))))
                    {
                        int rJump = Others.Random(1, 20);
                        MovementManager.MoveTo(targetNpc);
                        if (rJump == 5)
                        {
                            MovementsAction.Jump();
                        }
                    }
                    // Create path if the mob is out of sight or out of range
                    if ((!CombatClass.InRange(targetNpc) && !ObjectManager.ObjectManager.Me.IsCast) ||
                        TraceLine.TraceLineGo(targetNpc.Position))
                    {
                        goto figthStart;
                    }
                    // Stop move if in range
                    if (CombatClass.InRange(targetNpc) && ObjectManager.ObjectManager.Me.GetMove &&
                        !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        MovementManager.StopMoveTo();
                    }
                    if (ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        MountTask.DismountMount();
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }

                    // Face player to mob
                    MovementManager.Face(targetNpc);

                    // If obstacle between us and the target after this timer expires then stop the fight and blacklist
                    if (Others.Times > timer && TraceLine.TraceLineGo(targetNpc.Position) &&
                        targetNpc.HealthPercent > 90)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }

                    Thread.Sleep(75 + Usefuls.Latency);

                    // If timer expires and still not in fight, then stop the fight and blacklist
                    if (Others.Times > timer && !ObjectManager.ObjectManager.Me.InCombat && !targetNpc.IsDead)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }
                }

                MovementManager.StopMoveTo();
                InFight = false;
            }
            catch (Exception exception)
            {
                Logging.WriteError("StartFight(UInt128 guid = 0, bool inBg = false): " + exception);
                InFight = false;
            }
            try
            {
                if (targetNpc != null)
                {
                    return(targetNpc.Guid);
                }
            }
            catch
            {
                return(0);
            }
            return(0);
        }
    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);
    }
Esempio n. 13
0
        public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force = false)
        {
            // still waiting to make sure last spell was casted successfully, this can be interrupted
            // by interrupting the current cast to cast something else (which will clear the verification)
            if (RotationSpellVerifier.IsWaitingForVerification() && !force)
            {
                return(false);
            }

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

            // targetfinder function already checks that they are in LoS and RotationStep takes care of the range check
            if (unit != null && spell.IsKnown() && spell.CanCast())
            {
                Lua.LuaDoString("if IsMounted() then Dismount() end");

                if (spell.Spell.CastTime > 0)
                {
                    if (spell.Verification != RotationSpell.VerificationType.NONE)
                    {
                        //setting this for delegates, so we don't miss events
                        //SetFocusGuid(unit.Guid);
                        RotationSpellVerifier.QueueVerification(spell.Spell.Name, unit, spell.Verification);
                    }

                    //force iscast so we don't have to wait for client updates
                    RotationFramework.IsCast = true;
                    //ObjectManager.Me.ForceIsCast = true;
                }

                if (AreaSpells.Contains(spell.Spell.Name))
                {
                    SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position);
                }
                else
                {
                    if (unit.Guid != RotationFramework.Me.Guid && unit.Guid != RotationFramework.Target.Guid)
                    {
                        MovementManager.Face(unit);
                    }

                    ExecuteActionOnUnit <object>(unit, (luaUnitId =>
                    {
                        RotationLogger.Fight($"Casting {spell.FullName()} ({spell.Spell.Name} on {luaUnitId} with guid {unit.Guid}");
                        //MovementManager.StopMoveTo(false, (int) spell.CastTime());
                        Lua.LuaDoString($@"
						if {force.ToString().ToLower()} then SpellStopCasting() end
                        CastSpellByName(""{spell.FullName()}"", ""{luaUnitId}"");
						--CombatTextSetActiveUnit(""{luaUnitId}"");
						FocusUnit(""{luaUnitId}"");
						"                        );
                        return(null);
                    }));
                }

                return(true);
            }

            return(false);
        }
Esempio n. 14
0
    /*
     * CombatRotation()
     */
    public void CombatRotation()
    {
        if (OutlawSettings.CurrentSetting.EnableInterrupt)
        {
            WoWUnit toInterrupt = MyHelpers.InterruptableUnits();
            if (toInterrupt != null)
            {
                ObjectManager.Me.FocusGuid = toInterrupt.Guid;

                if (Kick.IsSpellUsable && Kick.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Kick.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Kick " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Gouge.IsSpellUsable && Gouge.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Gouge.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Gouge " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Blind.IsSpellUsable && Blind.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Blind.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Blind " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.7)
        {
            if (CrimsonVial.KnownSpell && CrimsonVial.IsSpellUsable)
            {
                CrimsonVial.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Crimson Vial"")");
                return;
            }


            if (Feint.KnownSpell && Feint.IsSpellUsable)
            {
                Feint.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Feint"")");
                return;
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.3)
        {
            if (SmokeBomb.KnownSpell && SmokeBomb.IsSpellUsable)
            {
                SmokeBomb.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Smoke Bomb"")");
                return;
            }

            if (Riposte.KnownSpell && Riposte.IsSpellUsable)
            {
                Riposte.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Riposte"")");
                return;
            }
        }

        if (ObjectManager.Me.IsStunned || ObjectManager.Me.Rooted || ObjectManager.Me.Confused)
        {
            if (GladiatorsMedallion.KnownSpell && GladiatorsMedallion.IsSpellUsable)
            {
                GladiatorsMedallion.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Gladiators Medallion"")");
                return;
            }
        }

        if (ObjectManager.Me.SpeedMoving < 8.05 && ObjectManager.Me.SpeedMoving > 0)
        {
            if (OutlawSettings.CurrentSetting.EnableCloakOfShadows &&
                CloakOfShadows.KnownSpell && CloakOfShadows.IsSpellUsable)
            {
                CloakOfShadows.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Cloak Of Shadows"")");
                return;
            }
        }
        if (OutlawSettings.CurrentSetting.EnableRazorCoral &&
            EquippedItems.GetEquippedItems().Find(x => x.GetItemInfo.ItemName == ItemsManager.GetNameById(169311)) != null &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            Lua.LuaDoString("result = \"\";  local cooldown = GetItemCooldown(169311) if (cooldown == 0 ) then     result = true else     result = false end ", "result") == "true" &&
            (!ObjectManager.Target.BuffCastedByAll("Razor Coral").Contains(ObjectManager.Me.Guid) || ObjectManager.Target.BuffStack("Razor Coral") >= 10))
        {
            ItemsManager.UseItem(169311);
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Razor Coral"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableBladeFlurry &&
            BladeFlurry.KnownSpell && !MyHelpers.haveBuff("Blade Flurry") && BladeFlurry.IsSpellUsable && (MyHelpers.getAttackers(10) > 1))
        {
            BladeFlurry.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Blade Flurry"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableBloodoftheEnemy &&
            BloodoftheEnemy.KnownSpell &&
            BloodoftheEnemy.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            !MyHelpers.rtbReroll() &&
            BetweenTheEyes.IsSpellUsable &&
            (ObjectManager.Target.IsLocalPlayer || ObjectManager.Target.Type == WoWObjectType.Player)

            )
        {
            BloodoftheEnemy.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Bloodof the Enemy"")");
            return;
        }



        if (OutlawSettings.CurrentSetting.EnableGrapplingHook &&
            !ObjectManager.Me.IsMounted &&
            GrapplingHook.KnownSpell &&
            GrapplingHook.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= 20.0f &&
            MyHelpers.getTargetDistance() > MyHelpers.getMeleeRange()
            )
        {
            ClickOnTerrain.Spell(195457, ObjectManager.Target.Position);
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Grappling Hook"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableSprint &&
            !ObjectManager.Me.IsMounted &&
            Sprint.KnownSpell &&
            Sprint.IsSpellUsable &&
            MyHelpers.getTargetDistance() > 20.0f
            )
        {
            Sprint.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Sprint"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableRolltheBones &&
            RolltheBones.KnownSpell &&
            RolltheBones.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            MyHelpers.getComboPoint() >= 4 &&
            MyHelpers.rtbReroll()
            )
        {
            RolltheBones.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Roll the Bones"")");
            return;
        }
        if (OutlawSettings.CurrentSetting.EnableAdrenalineRush &&
            AdrenalineRush.KnownSpell &&
            AdrenalineRush.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            (ObjectManager.Target.IsBoss ||
             ObjectManager.Target.IsElite ||
             ObjectManager.Target.IsLocalPlayer ||
             ObjectManager.Target.Type == WoWObjectType.Player ||
             MyHelpers.getAttackers(10) > 3))
        {
            AdrenalineRush.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Adrenaline Rush"")");
            return;
        }

        if (BladeRush.KnownSpell &&
            BladeRush.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= 20.0f &&
            MyHelpers.getTargetDistance() > MyHelpers.getMeleeRange() &&
            !ObjectManager.Me.IsMounted
            )
        {
            BladeRush.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Blade Rush"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnablePistolShot &&
            PistolShot.KnownSpell &&
            PistolShot.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= 20.0f &&
            ((MyHelpers.haveBuff("Opportunity") && MyHelpers.getComboPoint() <= 4) ||
             (MyHelpers.getTargetDistance() > MyHelpers.getMeleeRange() && !(BetweenTheEyes.IsSpellUsable && MyHelpers.getComboPoint() == 6)) ||
             (MyHelpers.haveBuff("Deadshot") && MyHelpers.haveBuff("Seething Rage") && !BetweenTheEyes.IsSpellUsable)
            ))
        {
            PistolShot.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Pistol Shot"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableSinisterStrike &&
            SinisterStrike.KnownSpell &&
            SinisterStrike.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            MyHelpers.getComboPoint() <= 5)
        {
            SinisterStrike.Launch();
            Lua.LuaDoString("dRotationFrame.text:SetText(\"Sinister Strike " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
            return;
        }



        if (OutlawSettings.CurrentSetting.EnableBetweenTheEyes &&
            BetweenTheEyes.KnownSpell &&
            BetweenTheEyes.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= 20.0f &&
            MyHelpers.getComboPoint() == 6)
        {
            BetweenTheEyes.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Between the Eyes"")");

            return;
        }

        if (OutlawSettings.CurrentSetting.EnableDispatch &&
            Dispatch.KnownSpell &&
            Dispatch.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            MyHelpers.getComboPoint() == 6)
        {
            Dispatch.Launch();
            Lua.LuaDoString("dRotationFrame.text:SetText(\"Dispatch " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
            return;
        }
    }
Esempio n. 15
0
    /*
     * CombatRotation()
     */
    public void CombatRotation()
    {
        if (lastTarget != ObjectManager.Target)
        {
            lastTarget = ObjectManager.Target;
            isCheap    = true;
        }

        if (OutlawSettings.CurrentSetting.EnableInterrupt)
        {
            WoWUnit toInterrupt = MyHelpers.InterruptableUnits();
            if (toInterrupt != null)
            {
                ObjectManager.Me.FocusGuid = toInterrupt.Guid;

                if (Kick.IsSpellUsable && Kick.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Kick.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Kick " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Gouge.IsSpellUsable && Gouge.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Gouge.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Gouge " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Blind.IsSpellUsable && Blind.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Blind.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Blind " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.7)
        {
            if (CrimsonVial.KnownSpell && CrimsonVial.IsSpellUsable)
            {
                CrimsonVial.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Crimson Vial"")");
                return;
            }
            if (Feint.KnownSpell && Feint.IsSpellUsable)
            {
                Feint.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Feint"")");
                return;
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.3)
        {
            if (Evasion.KnownSpell && Evasion.IsSpellUsable)
            {
                Evasion.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Evasion"")");
                return;
            }

            if (EquippedItems.GetEquippedItems().Find(x => x.GetItemInfo.ItemName == ItemsManager.GetNameById(167378)) != null &&
                MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
                Lua.LuaDoString("result = \"\";  local cooldown = GetItemCooldown(167378) if (cooldown == 0 ) then     result = true else     result = false end ", "result") == "true")
            {
                ItemsManager.UseItem(167378);
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Emblem"")");
                return;
            }
        }

        if (ObjectManager.Me.IsStunned || ObjectManager.Me.Rooted || ObjectManager.Me.Confused)
        {
            if (GladiatorsMedallion.KnownSpell && GladiatorsMedallion.IsSpellUsable)
            {
                GladiatorsMedallion.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Gladiators Medallion"")");
                return;
            }
        }


        if (MyHelpers.sealthed() &&
            ColdBlood.KnownSpell &&
            ColdBlood.IsSpellUsable &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            ColdBlood.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ColdBlood"")");
            return;
        }

        if (Sealth.KnownSpell &&
            Sealth.IsSpellUsable
            )
        {
            Sealth.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Sealth"")");
            return;
        }

        if (MyHelpers.sealthed() &&
            ShadowBlades.KnownSpell &&
            ShadowBlades.IsSpellUsable &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            ShadowBlades.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ShadowBlades"")");
            return;
        }
        if (SymbolsofDeath.KnownSpell &&
            SymbolsofDeath.IsSpellUsable &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            SymbolsofDeath.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""SymbolsofDeath"")");
            return;
        }
        if (MyHelpers.sealthed() &&
            isCheap &&
            CheapShot.KnownSpell &&
            CheapShot.IsSpellUsable &&
            !ObjectManager.Target.HaveBuff("Cheap Shot") &&
            !ObjectManager.Target.HaveBuff("Kidney Shot") &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            CheapShot.Launch();
            Thread newThread = new Thread(runCheap);
            newThread.Start();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""CheapShot"")");
            return;
        }
        if (EquippedItems.GetEquippedItems().Find(x => x.GetItemInfo.ItemName == ItemsManager.GetNameById(167383)) != null &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            Lua.LuaDoString("result = \"\";  local cooldown = GetItemCooldown(167383) if (cooldown == 0 ) then     result = true else     result = false end ", "result") == "true"
            )
        {
            ItemsManager.UseItem(167383);
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""maledict"")");
            return;
        }
        if (MarkedforDeath.KnownSpell &&
            MarkedforDeath.IsSpellUsable &&
            MyHelpers.getComboPoint() == 0 &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            MarkedforDeath.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""MarkedforDeath"")");
            return;
        }
        if (MyHelpers.sealthed() &&
            Nightblade.KnownSpell &&
            Nightblade.IsSpellUsable &&
            MyHelpers.getComboPoint() >= 4 &&
            !ObjectManager.Target.HaveBuff("Nightblade") &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            Nightblade.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Nightblade"")");
            return;
        }

        if (MyHelpers.sealthed() &&
            Shadowstrike.KnownSpell &&
            Shadowstrike.IsSpellUsable &&
            MyHelpers.getComboPoint() < 4 &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            Shadowstrike.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Shadowstrike"")");
            return;
        }
        if (ShadowStep.KnownSpell &&
            ShadowStep.IsSpellUsable &&
            MyHelpers.getTargetDistance() > MyHelpers.getMeleeRange() &&
            MyHelpers.getTargetDistance() < 25.0f
            )
        {
            ShadowStep.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ShadowStep"")");
            return;
        }
        if (!MyHelpers.sealthed() &&
            ShadowDance.KnownSpell &&
            ShadowDance.IsSpellUsable &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            ShadowDance.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ShadowDance"")");
            return;
        }
        if (!MyHelpers.sealthed() &&
            KidneyShot.KnownSpell &&
            KidneyShot.IsSpellUsable &&
            MyHelpers.getComboPoint() >= 4 &&
            !ObjectManager.Target.HaveBuff("Cheap Shot") &&
            !ObjectManager.Target.HaveBuff("Kidney Shot") &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            KidneyShot.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ShadowDance"")");
            return;
        }

        if (Eviscerate.KnownSpell &&
            Eviscerate.IsSpellUsable &&
            MyHelpers.getComboPoint() >= 4 &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            Eviscerate.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Eviscerate"")");
            return;
        }
        if (ConcentratedFlame.KnownSpell &&
            ConcentratedFlame.IsSpellUsable
            )
        {
            ConcentratedFlame.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Concentrated Flame"")");
            return;
        }
        if (!MyHelpers.sealthed() &&
            Backstab.KnownSpell &&
            Backstab.IsSpellUsable &&
            MyHelpers.getComboPoint() < 4 &&
            MyHelpers.getTargetDistance() < MyHelpers.getMeleeRange()
            )
        {
            Backstab.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""ShadowDance"")");
            return;
        }
    }
Esempio n. 16
0
        public override void Run()
        {
            if (!Products.IsStarted || ObjectManager.Me.IsDeadMe || ObjectManager.Me.InCombatBlizzard)
            {
                return;
            }
            if (!FisherbotSetting.CurrentSetting.FishSchool)
            {
                if (_firstRun && FishingTask.IsLaunched)
                {
                    _firstRun = false;
                }
                // If we have a saved position and we don't fish, then go to position
                if (FisherbotSetting.CurrentSetting.FisherbotPosition.IsValid && (!FishingTask.IsLaunched || _beenFighting) && !_firstRun)
                {
                    _beenFighting = false;
                    if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 5)
                    {
                        LongMove.LongMoveGo(FisherbotSetting.CurrentSetting.FisherbotPosition);
                    }
                    else if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 1.5f)
                    {
                        MovementManager.MoveTo(FisherbotSetting.CurrentSetting.FisherbotPosition);
                    }
                    MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation);
                }
                // If we don't fish or the timer is null, then start a new timer, save position and fish
                if (timer == null || !FishingTask.IsLaunched)
                {
                    timer = new nManager.Helpful.Timer(10 * 60 * 1000 + 10 * 1000);
                    FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position;
                    FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation;
                    Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName);
                    FishingTask.LoopFish(0, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName, false,
                                         FisherbotSetting.AutomaticallyUseDraenorSecondaryBait);
                }
                // If the timer ended, stop fishing, equip weapon, null the timer
                else if (timer.IsReady)
                {
                    FishingTask.StopLoopFish();
                    ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName);
                    if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName))
                    {
                        ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName);
                    }

                    timer = null;
                }
                // We are in timer, we fish, then save the position
                else
                {
                    if (FishingTask._lastSuccessfullFishing > Environment.TickCount - 5000)
                    {
                        FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position;
                        FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation;
                        // We successfully fished in the last 5 seconds, let's record our position again.
                    }
                    if (FishingTask._lastSuccessfullFishing != 0 && FishingTask._lastSuccessfullFishing < Environment.TickCount - 25000)
                    {
                        // We did not catch a single thing in the last 25 seconds...
                        FishingTask.StopLoopFish();
                        return;
                    }
                    // _lastSuccessfullFishing is fine or we never fished yet, let it load :)
                    Thread.Sleep(500);
                }
                // No more while, we test what we need and return
                return;
            }

            // Nodes fishing code
            if (_node.IsValid)
            {
                FisherbotSetting.CurrentSetting.FisherbotPosition =
                    Bot.Profile.Points[Math.NearestPointOfListPoints(Bot.Profile.Points, _node.Position)];
                Logging.Write("Fish " + _node.Name + " > " + _node.Position);
            }

            if (FisherbotSetting.CurrentSetting.FishSchool)
            {
                Point whereToGo = Fishing.FindTheUltimatePoint(_node.Position);
                if (whereToGo.Type == "invalid")
                {
                    Logging.Write("No valid point found");
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
                bool         r;
                List <Point> points = PathFinder.FindPath(whereToGo, out r);
                if (points.Count <= 1 || points.Count >= 20)
                {
                    points.Clear();
                    points.Add(ObjectManager.Me.Position);
                    points.Add(whereToGo);
                }
                else
                {
                    for (int i = 0; i < points.Count; i++)
                    {
                        if (points[i].Z < whereToGo.Z)
                        {
                            points[i].Z = whereToGo.Z;
                        }
                    }
                }
                Logging.Write("Going to point > " + whereToGo.X + " ; " + whereToGo.Y + " ; " + whereToGo.Z + " ; " +
                              points[0].Type);
                MovementManager.Go(points);

                timer = new nManager.Helpful.Timer(((int)Math.DistanceListPoint(points) / 3 * 1000) + 4000);
                while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted &&
                       !ObjectManager.Me.IsDeadMe &&
                       !ObjectManager.Me.InInevitableCombat &&
                       !timer.IsReady && MovementManager.InMovement)
                {
                    if (ObjectManager.Me.Position.DistanceTo2D(whereToGo) <= 0.2f)
                    {
                        MovementManager.StopMove();
                        break;
                    }
                    Thread.Sleep(50);
                }

                if (timer.IsReady && _node.GetDistance2D > DistanceMax)
                {
                    Logging.Write("Fishing failed - No nearby point found (distance near position = " +
                                  ObjectManager.Me.Position.DistanceTo2D(
                                      FisherbotSetting.CurrentSetting.FisherbotPosition).ToString(CultureInfo.InvariantCulture) + ")");
                    MovementManager.StopMove();
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
            }

            // Stop move
            MovementManager.StopMove();
            MountTask.DismountMount();

            // Face
            if (_node.IsValid)
            {
                MovementManager.Face(_node);
            }
            else
            {
                MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation);
            }

            // Ce met a la bonne distance du banc de poisson
            if (_node.IsValid)
            {
                int nbIsSwimming = 0;
                timer = new nManager.Helpful.Timer(1000 * 8);
                while ((Usefuls.IsSwimming || _node.GetDistance > DistanceMax || _node.GetDistance < DistanceMin) &&
                       Products.IsStarted && !ObjectManager.Me.IsDeadMe && !ObjectManager.Me.InCombat && !timer.IsReady)
                {
                    if (nbIsSwimming * 100 > TimeTryFindGoodPos)
                    {
                        FishingTask.StopLoopFish();
                        MovementsAction.MoveBackward(false);
                        MovementsAction.MoveForward(false);
                        Logging.Write("BlackList " + _node.Name);
                        nManagerSetting.AddBlackList(_node.Guid);
                        return;
                    }
                    FishingTask.StopLoopFish();
                    MovementManager.Face(_node);

                    if (Usefuls.IsSwimming || _node.GetDistance < DistanceMin)
                    {
                        MovementsAction.MoveForward(false);
                        MovementsAction.MoveBackward(true);
                    }
                    if (_node.GetDistance > DistanceMax)
                    {
                        MovementsAction.MoveBackward(false);
                        MovementsAction.MoveForward(true);
                    }

                    nbIsSwimming++;
                    Thread.Sleep(100);
                }
                MovementsAction.MoveBackward(false);
                MovementsAction.MoveForward(false);
                if (timer.IsReady)
                {
                    Logging.Write("Fishing failed - Out of range" + timer.IsReady.ToString());
                    MovementManager.StopMove();
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
            }

            // Fish
            Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName);
            FishingTask.LoopFish(_node.Guid, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName,
                                 FisherbotSetting.CurrentSetting.PrecisionMode, FisherbotSetting.AutomaticallyUseDraenorSecondaryBait);

            timer = new nManager.Helpful.Timer(2 * 60 * 1000);
            while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted &&
                   !ObjectManager.Me.IsDeadMe &&
                   !ObjectManager.Me.InCombat && !timer.IsReady &&
                   FishingTask.IsLaunched)
            {
                if (ObjectManager.Me.Position.DistanceTo2D(FisherbotSetting.CurrentSetting.FisherbotPosition) > 3.5f &&
                    !FisherbotSetting.CurrentSetting.FishSchool)
                {
                    break;
                }
                Thread.Sleep(300);
            }
            FishingTask.StopLoopFish();
            ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName);
            if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName))
            {
                ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName);
            }
        }
Esempio n. 17
0
    /*
     * CombatRotation()
     */
    public void CombatRotation()
    {
        if (OutlawSettings.CurrentSetting.EnableInterrupt)
        {
            WoWUnit toInterrupt = MyHelpers.InterruptableUnits();
            if (toInterrupt != null)
            {
                ObjectManager.Me.FocusGuid = toInterrupt.Guid;

                if (Kick.IsSpellUsable && Kick.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Kick.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Kick " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Gouge.IsSpellUsable && Gouge.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Gouge.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Gouge " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
                if (Blind.IsSpellUsable && Blind.KnownSpell)
                {
                    MovementManager.Face(toInterrupt.Position);
                    Blind.Launch(false, false, false, "focus");
                    Lua.LuaDoString("dRotationFrame.text:SetText(\"Blind " + MyHelpers.getTargetDistance() + " / " + MyHelpers.GetMeleeRangeWithTarget() + "\")");
                    return;
                }
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.6)
        {
            if (CrimsonVial.KnownSpell && CrimsonVial.IsSpellUsable)
            {
                CrimsonVial.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Crimson Vial"")");
                return;
            }


            if (Feint.KnownSpell && Feint.IsSpellUsable)
            {
                Feint.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Feint"")");
                return;
            }
        }

        if (ObjectManager.Me.Health < ObjectManager.Me.MaxHealth * 0.3)
        {
            if (SmokeBomb.KnownSpell && SmokeBomb.IsSpellUsable)
            {
                SmokeBomb.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Smoke Bomb"")");
                return;
            }

            if (Riposte.KnownSpell && Riposte.IsSpellUsable)
            {
                Riposte.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Riposte"")");
                return;
            }
        }

        if (ObjectManager.Me.IsStunned || ObjectManager.Me.Rooted || ObjectManager.Me.Confused)
        {
            if (GladiatorsMedallion.KnownSpell && GladiatorsMedallion.IsSpellUsable)
            {
                GladiatorsMedallion.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Gladiators Medallion"")");
                return;
            }
        }

        if (ObjectManager.Me.SpeedMoving < 8.05 && ObjectManager.Me.SpeedMoving > 0)
        {
            if (OutlawSettings.CurrentSetting.EnableCloakOfShadows &&
                CloakOfShadows.KnownSpell && CloakOfShadows.IsSpellUsable)
            {
                CloakOfShadows.Launch();
                Lua.LuaDoString(@"dRotationFrame.text:SetText(""Cloak Of Shadows"")");
                return;
            }
        }
        if (OutlawSettings.CurrentSetting.EnableRazorCoral &&
            EquippedItems.GetEquippedItems().Find(x => x.GetItemInfo.ItemName == ItemsManager.GetNameById(169311)) != null &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            Lua.LuaDoString("result = \"\";  local cooldown = GetItemCooldown(169311) if (cooldown == 0 ) then     result = true else     result = false end ", "result") == "true" &&
            (!ObjectManager.Target.BuffCastedByAll("Razor Coral").Contains(ObjectManager.Me.Guid) || ObjectManager.Target.BuffStack("Razor Coral") >= 10))
        {
            ItemsManager.UseItem(169311);
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Razor Coral"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableSprint &&
            !ObjectManager.Me.IsMounted &&
            Sprint.KnownSpell &&
            Sprint.IsSpellUsable &&
            MyHelpers.getTargetDistance() > 20.0f
            )
        {
            Sprint.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Sprint"")");
            return;
        }

        if (OutlawSettings.CurrentSetting.EnableAdrenalineRush &&
            AdrenalineRush.KnownSpell &&
            AdrenalineRush.IsSpellUsable &&
            MyHelpers.getTargetDistance() <= MyHelpers.getMeleeRange() &&
            (ObjectManager.Target.IsBoss ||
             ObjectManager.Target.IsElite ||
             ObjectManager.Target.IsLocalPlayer ||
             ObjectManager.Target.Type == WoWObjectType.Player ||
             MyHelpers.getAttackers(10) > 3))
        {
            AdrenalineRush.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Adrenaline Rush"")");
            return;
        }



        if (Garrote.KnownSpell && Garrote.IsSpellUsable &&
            !ObjectManager.Target.HaveBuff("Garrote"))
        {
            Garrote.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Garrote"")");
            return;
        }

        if (Rupture.KnownSpell && Rupture.IsSpellUsable &&
            MyHelpers.getComboPoint() >= 4 &&
            !ObjectManager.Target.HaveBuff("Rupture"))
        {
            Rupture.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Rupture"")");
            return;
        }
        if (ToxicBlade.KnownSpell && ToxicBlade.IsSpellUsable &&
            ObjectManager.Target.HaveBuff("Rupture"))
        {
            ToxicBlade.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Toxic Blade"")");
            return;
        }
        if (Vendetta.KnownSpell && Vendetta.IsSpellUsable &&
            ObjectManager.Target.HaveBuff("Rupture"))
        {
            Vendetta.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Vendetta"")");
            return;
        }
        if (Envenom.KnownSpell && Envenom.IsSpellUsable &&
            MyHelpers.getComboPoint() >= 4 &&
            ObjectManager.Target.HaveBuff("Rupture"))
        {
            Envenom.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Envenom"")");
            return;
        }
        if (Mutilate.KnownSpell && Mutilate.IsSpellUsable &&
            MyHelpers.getComboPoint() < 4)
        {
            Mutilate.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Mutilate"")");
            return;
        }
    }