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);
    }
Beispiel #2
0
    public void Damage()
    {
        if (Meteor.IsSpellUsable &&
            MyHelpers.haveBuff(RuneofPower.Name) &&
            (MyHelpers.haveBuffStack("Blaster Master") == 3 || (!MyHelpers.haveBuff(Combustion.Name) || MyHelpers.spellCharges(FireBlast.Name) == 0)) &&
            MyHelpers.getTargetDistance() <= 40.0f
            )
        {
            MyHelpers.castSpell(Meteor.Name);
            ClickOnTerrain.Pulse(ObjectManager.Target.Position);

            return;
        }
        if (MyHelpers.haveBuff("Hot Streak!") && !buffTime)
        {
            while (MyHelpers.haveBuff(Combustion.Name))
            {
                if (MyHelpers.haveBuff("Hot Streak!"))
                {
                    Pyroblast.Launch();
                    Thread.Sleep(200);
                    if (MyHelpers.spellCharges(FireBlast.Name) == 0)
                    {
                        Thread.Sleep(200);
                    }

                    canBlast = true;
                    continue;
                }
                if (!ObjectManager.Me.IsCast && MyHelpers.spellCharges(FireBlast.Name) > 0 && MyHelpers.haveBuff("Heating Up"))
                {
                    canBlast = false;
                    MyHelpers.castSpell(FireBlast.Name);
                    continue;
                }
                if (MyHelpers.itemIsUsable("Hyperthread Wristwraps") && MyHelpers.spellCharges(FireBlast.Name) == 0 && !ObjectManager.Me.IsCast)
                {
                    ItemsManager.UseItem(ItemsManager.GetIdByName("Hyperthread Wristwraps"));
                    continue;
                }
                if (MyHelpers.spellCharges(FireBlast.Name) == 0 &&
                    !MyHelpers.haveBuff("Hot Streak!") && !ObjectManager.Me.IsCast)
                {
                    Thread.Sleep(400);

                    if (MyHelpers.spellCharges(FireBlast.Name) == 0 &&
                        !MyHelpers.haveBuff("Hot Streak!") && !ObjectManager.Me.IsCast)
                    {
                        MyHelpers.castSpell(Scorch.Name);
                        while (ObjectManager.Me.IsCast)
                        {
                            Thread.Sleep(50);
                        }

                        continue;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (MyHelpers.haveBuff("Hot Streak!"))
            {
                MyHelpers.castSpell(Pyroblast.Name);
            }
            return;
        }
        if (MyHelpers.spellCharges(FireBlast.Name) > 0 && !buffTime && MyHelpers.haveBuff("Heating Up") && !MyHelpers.haveBuff(Combustion.Name))
        {
            MyHelpers.castSpell(FireBlast.Name);
            return;
        }
        if (BlazingBarrier.IsSpellUsable)
        {
            MyHelpers.castSpell(BlazingBarrier.Name);
        }

        if (!MyHelpers.haveBuff("Hot Streak!") &&
            Scorch.IsSpellUsable &&
            !buffTime &&
            (ObjectManager.Me.SpeedMoving > 0 || ObjectManager.Target.HealthPercent < 30))


        {
            Thread.Sleep(100);
            if (!MyHelpers.haveBuff("Hot Streak!") &&
                Scorch.IsSpellUsable &&
                !buffTime &&
                (ObjectManager.Me.SpeedMoving > 0 || ObjectManager.Target.HealthPercent < 30))
            {
                MyHelpers.castSpell(Scorch.Name);
            }

            return;
        }


        if (!MyHelpers.haveBuff("Hot Streak!") && !buffTime && !MyHelpers.haveBuff(Combustion.Name) && !(ObjectManager.Me.SpeedMoving > 0 || ObjectManager.Target.HealthPercent < 30))
        {
            MyHelpers.castSpell(Fireball.Name);
            return;
        }
    }
Beispiel #3
0
    public void burstPrepare()
    {
        buffTime = true;
        doBurst  = false;

        while (!MyHelpers.itemIsUsable("Azshara's Font of Power") || ObjectManager.Me.IsCast)
        {
            Thread.Sleep(100);
        }
        while (MyHelpers.itemIsUsable("Azshara's Font of Power"))
        {
            ItemsManager.UseItem(ItemsManager.GetIdByName("Azshara's Font of Power"));
        }

        Thread.Sleep(4020);

        if (!MyHelpers.inCombat())
        {
            if (MyHelpers.itemIsEquiped("Notorious Gladiator's Badge"))
            {
                Thread.Sleep(13000);
            }

            if (!MyHelpers.haveBuff("Hot Streak!") && !MyHelpers.haveBuff("Heating Up"))
            {
                MyHelpers.castSpell(Fireball.Name);
                Thread.Sleep(2300);
            }
        }
        if (MyHelpers.itemIsEquiped("Notorious Gladiator's Badge"))
        {
            while (!MyHelpers.itemIsUsable("Notorious Gladiator's Badge"))
            {
                if (MyHelpers.inCombat())
                {
                    if (ObjectManager.Target.HealthPercent < 30 || ObjectManager.Me.SpeedMoving > 0)
                    {
                        if (!MyHelpers.haveBuff("Hot Streak!") &&
                            Scorch.IsSpellUsable &&
                            (ObjectManager.Me.SpeedMoving > 0 || ObjectManager.Target.HealthPercent < 30))


                        {
                            Thread.Sleep(100);
                            if (!MyHelpers.haveBuff("Hot Streak!") &&
                                Scorch.IsSpellUsable &&
                                (ObjectManager.Me.SpeedMoving > 0 || ObjectManager.Target.HealthPercent < 30))
                            {
                                MyHelpers.castSpell(Scorch.Name);
                            }

                            continue;
                        }
                        if (ObjectManager.Target.HealthPercent < 30 && MyHelpers.haveBuff("Hot Streak!"))
                        {
                            MyHelpers.castSpell(Pyroblast.Name);
                            continue;
                        }
                    }
                    else
                    {
                        if (MyHelpers.haveBuff("Hot Streak!") && MyHelpers.BuffTimeLeft("Hot Streak!") < 10)
                        {
                            MyHelpers.castSpell(Pyroblast.Name);
                            continue;
                        }
                        else if (MyHelpers.spellCharges(FireBlast.Name) > 0 && MyHelpers.haveBuff("Heating Up"))
                        {
                            MyHelpers.castSpell(FireBlast.Name);
                            continue;
                        }
                        else
                        {
                            MyHelpers.castSpell(Fireball.Name);
                            continue;
                        }
                    }
                }
            }
            ;

            while (!MyHelpers.itemIsUsable("Notorious Gladiator's Badge") || ObjectManager.Me.IsCast)
            {
                Thread.Sleep(10);
            }
            while (MyHelpers.itemIsUsable("Notorious Gladiator's Badge"))
            {
                ItemsManager.UseItem(ItemsManager.GetIdByName("Notorious Gladiator's Badge"));
            }
        }

        if (!MyHelpers.haveBuff("Hot Streak!") && !MyHelpers.haveBuff("Heating Up"))
        {
            needBlast = true;
        }

        while (!MemoryofLucidDreams.IsSpellUsable || ObjectManager.Me.IsCast)
        {
            Thread.Sleep(10);
        }
        while (!MyHelpers.haveBuff(MemoryofLucidDreams.Name))
        {
            MyHelpers.castSpell(MemoryofLucidDreams.Name);
        }

        Thread.Sleep(100);

        if (!MyHelpers.haveBuff("Hot Streak!"))
        {
            MyHelpers.castSpell(FireBlast.Name);
        }


        while (Berserking.IsSpellUsable)
        {
            MyHelpers.castSpell(Berserking.Name);
        }



        while (!RuneofPower.IsSpellUsable)
        {
            Thread.Sleep(10);
        }
        while (!MyHelpers.haveBuff(RuneofPower.Name))
        {
            MyHelpers.castSpell(RuneofPower.Name);
        }



        while (!Meteor.IsSpellUsable || ObjectManager.Me.IsCast)
        {
            Thread.Sleep(10);
        }
        while (Meteor.IsSpellUsable)
        {
            MyHelpers.castSpell(Meteor.Name);
            ClickOnTerrain.Pulse(ObjectManager.Target.Position);
        }


        while (!Combustion.IsSpellUsable || ObjectManager.Me.IsCast)
        {
            Thread.Sleep(10);
        }
        while (!MyHelpers.haveBuff(Combustion.Name))
        {
            MyHelpers.castSpell(Combustion.Name);
        }

        if (needBlast && !MyHelpers.haveBuff("Hot Streak!"))
        {
            MyHelpers.castSpell(FireBlast.Name);
        }
        needBlast = false;
        buffTime  = false;
        return;
    }
        public bool AdvancedCast(AIOSpell spell, bool stopWandAndCast = true, bool onSelf = false, WoWUnit onUnitFocus = null, Vector3 location = null)
        {
            WoWUnit Me     = ObjectManager.Me;
            float   buffer = 600;

            if (IsApproachingTarget)
            {
                return(true);
            }

            CurrentSpell         = spell;
            CurrentSpellLocation = location;

            CombatDebug("*----------- INTO PRE CAST FOR " + CurrentSpell.Name);

            if (!CurrentSpell.KnownSpell ||
                IsBackingUp ||
                Me.CastingTimeLeft > buffer ||
                !CurrentSpell.IsForcedCooldownReady ||
                Me.IsStunned)
            {
                return(false);
            }

            // Define target
            if (onUnitFocus != null)
            {
                CurrentSpellTarget = onUnitFocus;
            }
            else if (CurrentSpellLocation != null)
            {
                CurrentSpellTarget = null;
            }
            else if (onSelf)
            {
                CurrentSpellTarget = ObjectManager.Me;
            }
            else
            {
                if (CurrentSpell.MaxRange <= 0 && ObjectManager.Target.GetDistance > RangeManager.GetMeleeRangeWithTarget())
                {
                    return(false);
                }
                CurrentSpellTarget = ObjectManager.Target;
            }

            // Now that we know the target
            if (CurrentSpellLocation == null)
            {
                if (CurrentSpellTarget == null ||
                    CurrentSpellTarget.GetDistance > 100 ||
                    (CurrentSpellTarget.IsDead && !CurrentSpell.OnDeadTarget) ||
                    (CurrentSpell.MinRange > 0 && CurrentSpellTarget.GetDistance <= CurrentSpell.MinRange) ||
                    UnitImmunities.Contains(CurrentSpellTarget, CurrentSpell.Name) ||
                    (!CurrentSpellTarget.IsValid && !CurrentSpell.OnDeadTarget))    // double check this
                {
                    return(false);
                }
            }

            CombatDebug("*----------- INTO CAST FOR " + CurrentSpell.Name);

            // CHECK COST
            if (CurrentSpell.PowerType == -2 && Me.Health < CurrentSpell.Cost)
            {
                CombatDebug($"{CurrentSpell.Name}: Not enough health {CurrentSpell.Cost}/{Me.Health}, SKIPPING");
                return(false);
            }
            else if (CurrentSpell.PowerType == 0 && Me.Mana < CurrentSpell.Cost)
            {
                CombatDebug($"{CurrentSpell.Name}: Not enough mana {CurrentSpell.Cost}/{Me.Mana}, SKIPPING");
                return(false);
            }
            else if (CurrentSpell.PowerType == 1 && Me.Rage < CurrentSpell.Cost)
            {
                CombatDebug($"{CurrentSpell.Name}: Not enough rage {CurrentSpell.Cost}/{Me.Rage}, SKIPPING");
                return(false);
            }
            else if (CurrentSpell.PowerType == 2 && ObjectManager.Pet.Focus < CurrentSpell.Cost)
            {
                CombatDebug($"{CurrentSpell.Name}: Not enough pet focus {CurrentSpell.Cost}/{ObjectManager.Pet.Focus}, SKIPPING");
                return(false);
            }
            else if (CurrentSpell.PowerType == 3 && Me.Energy < CurrentSpell.Cost)
            {
                CombatDebug($"{CurrentSpell.Name}: Not enough energy {CurrentSpell.Cost}/{Me.Energy}, SKIPPING");
                return(false);
            }

            // DON'T CAST BECAUSE WANDING
            if (WandSpell != null &&
                ToolBox.UsingWand() &&
                !stopWandAndCast)
            {
                CombatDebug("Didn't cast because we were wanding");
                return(false);
            }

            // COOLDOWN CHECKS
            float _spellCD = CurrentSpell.GetCurrentCooldown;

            CombatDebug($"Cooldown is {_spellCD}");

            if (_spellCD >= 500)
            {
                CombatDebug("Didn't cast because cd is too long");
                return(false);
            }

            // STOP WAND FOR CAST
            if (WandSpell != null &&
                ToolBox.UsingWand() &&
                stopWandAndCast)
            {
                StopWandWaitGCD(WandSpell);
            }


            // Wait for remaining Cooldown
            if (_spellCD > 0f && _spellCD < buffer)
            {
                CombatDebug($"{CurrentSpell.Name} is almost ready, waiting");
                while (CurrentSpell.GetCurrentCooldown > 0 && CurrentSpell.GetCurrentCooldown < 500)
                {
                    Thread.Sleep(50);
                }
                Thread.Sleep(50); // safety
            }

            if (!CurrentSpell.IsSpellUsable)
            {
                CombatDebug("Didn't cast because spell somehow not usable");
                return(false);
            }

            bool stopMove = CurrentSpell.CastTime > 0 || CurrentSpell.IsChannel;

            if (CurrentSpellLocation != null || CurrentSpellTarget.Guid != Me.Guid)
            {
                Vector3 spellPosition = CurrentSpellLocation != null ? CurrentSpellLocation : CurrentSpellTarget.Position;
                if (CurrentSpell.MaxRange > 0 && spellPosition.DistanceTo(Me.Position) > CurrentSpell.MaxRange || TraceLine.TraceLineGo(spellPosition))
                {
                    if (Me.HaveBuff("Spirit of Redemption"))
                    {
                        return(false);
                    }

                    Logger.LogFight($"Target not in range/sight, recycling {CurrentSpell.Name}");

                    if (Fight.InFight)
                    {
                        IsApproachingTarget = true;
                    }
                    else
                    {
                        ApproachSpellTarget();
                    }

                    return(true);
                }
            }

            if (onUnitFocus != null)
            {
                ObjectManager.Me.FocusGuid = CurrentSpellTarget.Guid;
            }

            string unit = onUnitFocus != null ? "focus" : "target";

            unit = onSelf || CurrentSpellLocation != null ? "player" : unit;

            // Wait for remaining cast in case of buffer
            while (Me.CastingTimeLeft > 0)
            {
                Thread.Sleep(25);
            }

            if (stopMove)
            {
                MovementManager.StopMoveNewThread();
            }

            if (CombatLogON)
            {
                string rankString = CurrentSpell.Rank > 0 ? $"(Rank {CurrentSpell.Rank})" : "";
                string target     = CurrentSpellLocation != null?CurrentSpellLocation.ToString() : CurrentSpellTarget.Name;

                Logger.Log($"[Spell] Casting {CurrentSpell.Name.Replace("()", "")} {rankString} on {target}");
            }

            CurrentSpell.Launch(stopMove, false, true, unit);

            if (CurrentSpell.IsClickOnTerrain)
            {
                ClickOnTerrain.Pulse(CurrentSpellLocation);
            }

            Thread.Sleep(50);

            ToolBox.ClearCursor();

            // Wait for channel to end
            if (CurrentSpell.IsChannel)
            {
                CombatDebug($"{CurrentSpell.Name} is channel, wait cast");
                while (ToolBox.GetChannelTimeLeft("player") < 0)
                {
                    Thread.Sleep(50);
                }

                CurrentSpell.StartForcedCooldown();
                return(true);
            }

            // Wait for instant cast GCD
            if (CurrentSpell.CastTime <= 0)
            {
                CurrentSpell.StartForcedCooldown();
                Timer gcdLimit = new Timer(1500);
                CombatDebug($"{CurrentSpell.Name} is instant, wait GCD");
                while (DefaultBaseSpell.GetCurrentCooldown > buffer && !gcdLimit.IsReady)
                {
                    Thread.Sleep(50);
                }

                if (gcdLimit.IsReady)
                {
                    Logger.LogError("We had to resort to timer wait (GCD)");
                }

                return(true);
            }

            if (CurrentSpell.CastTime > 0)
            {
                // Wait for cast to end
                buffer = CurrentSpell.PreventDoubleCast ? 0 : buffer;
                CombatDebug($"{CurrentSpell.Name} is normal, wait until {buffer} left");
                while (Me.CastingTimeLeft > buffer)
                {
                    if (CurrentSpell.IsResurrectionSpell && CurrentSpellTarget.IsAlive)
                    {
                        Lua.RunMacroText("/stopcasting");
                    }

                    Thread.Sleep(50);
                }
                CurrentSpell.StartForcedCooldown();
            }

            return(true);
        }
    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);
    }