Exemplo n.º 1
0
        public static bool ShouldInterrupt(this WoWUnit unit, int minTime, int timeLeft)
        {
            if (Me.Specialization == WoWSpec.DemonHunterVengeance)
            {
                if ((unit.IsCasting || unit.IsCastingHealingSpell) && unit.CanInterruptCurrentSpellCast)
                {
                    // if casting, healing or channeling, and can interrupt
                    //L.debugLog("Unit: " + unit.SafeName + " is casting and can interrupt");

                    double castingForHowLong = new TimeSpan(DateTime.Now.Ticks - unit.CurrentCastStartTime.Ticks).TotalMilliseconds;
                    L.debugLog("Unit: " + unit.SafeName + " is casting and can interrupt. castingForHowLong: " + castingForHowLong + ", timeLeft: " + unit.CurrentCastTimeLeft.TotalMilliseconds);
                    if (minTime > 0 && timeLeft > 0)
                    {
                        if (castingForHowLong >= minTime && unit.CurrentCastTimeLeft.TotalMilliseconds < timeLeft)
                        {
                            L.debugLog("Should interrupt now");
                            return(true);
                        }
                    }
                    else
                    {
                        if ((minTime > 0 && castingForHowLong >= minTime) || (timeLeft > 0 && unit.CurrentCastTimeLeft.TotalMilliseconds < timeLeft))
                        {
                            L.debugLog("Should interrupt now");
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private static void WriteDebugLuaEvents(LuaEventArgs args)
        {
            int i = 0;

            foreach (var arg in args.Args)
            {
                L.debugLog("Arg[{0}]:{1}", i, arg);
                i += 1;
            }
        }
Exemplo n.º 3
0
 private bool GetNewTarget()
 {
     if (!Me.CurrentTarget.IsValidCombatUnit() && !HK.RotationOnlyOn)
     {
         var newUnits = U.activeEnemies(Me.Location, 50f).OrderBy(u => u.Distance).ThenBy(u => u.HealthPercent);
         L.debugLog("Number of new units: " + newUnits.Count());
         if (newUnits != null)
         {
             var newUnit = newUnits.FirstOrDefault();
             if (newUnit != null)
             {
                 L.pullMobLog(string.Format($"Switch target to {newUnit.SafeName} at {newUnit.Distance.ToString("F0")} yds @ {newUnit.HealthPercent.ToString("F0")}% HP"), Core.Helpers.Common.TargetColor);
                 newUnit.Target();
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public Vector3 FindLocation(Vector3 ptOrigin)
        {
            DateTime startFind              = DateTime.UtcNow;
            int      countPointsChecked     = 0;
            int      countFailDiff          = 0;
            int      countFailTrace         = 0;
            int      countFailToPointNav    = 0;
            int      countFailRange         = 0;
            int      countFailSafe          = 0;
            int      countFailToPointLoS    = 0;
            int      countFailToMobLoS      = 0;
            TimeSpan spanTrace              = TimeSpan.Zero;
            TimeSpan spanNav                = TimeSpan.Zero;
            double   furthestNearMobDistSqr = 0f;
            Vector3  ptFurthest             = Vector3.Zero;
            float    facingFurthest         = 0f;

            bool    reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget;
            Vector3 ptAdjOrigin = ptOrigin;
            // ptAdjOrigin.Z += 1f;   // comment out origin adjustment since using GetTraceLinePos()

            Vector3        ptDestination = new Vector3();
            List <Vector3> mobLocations  = new List <Vector3>();
            float          arcIncrement  = ((float)Math.PI * 2) / RaysToCheck;

            mobLocations = AllEnemyMobLocationsToCheck;
            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            float baseDestinationFacing;

            if (PreferredDirection == Direction.None && MobToRunFrom != null)
            {
                baseDestinationFacing = Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
            }
            else if (PreferredDirection == Direction.Frontwards)
            {
                baseDestinationFacing = Me.RenderFacing;
            }
            else // if (PreferredDirection == Disengage.Direction.Backwards)
            {
                baseDestinationFacing = Me.RenderFacing + (float)Math.PI;
            }

            L.debugLog("SafeArea: facing {0:F0} degrees, looking for safespot towards {1:F0} degrees", C.DefensiveColor,
                       WoWMathHelper.RadiansToDegrees(Me.RenderFacing),
                       WoWMathHelper.RadiansToDegrees(baseDestinationFacing)
                       );

            for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
            {
                // rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
                // .. so we favor a position furthest away from mob
                float checkFacing = baseDestinationFacing;
                if ((arcIndex & 1) == 0)
                {
                    checkFacing += arcIncrement * (arcIndex >> 1);
                }
                else
                {
                    checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);
                }

                checkFacing = WoWMathHelper.NormalizeRadian(checkFacing);
                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
                {
                    countPointsChecked++;

                    ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);

                    L.debugLog("SafeArea: checking {0:F1} degrees at {1:F1} yds", WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin);

                    DateTime start     = DateTime.UtcNow;
                    bool     failTrace = MeshTraceline(Me.Location, ptDestination);
                    spanTrace += DateTime.UtcNow - start;

                    bool failNav;
                    if (DirectPathOnly)
                    {
                        failNav = failTrace;
                        spanNav = spanTrace;
                    }
                    else
                    {
                        start   = DateTime.UtcNow;
                        failNav = false;
                        //failNav = !Navigator.CanNavigateFully(Me.Location, ptDestination);
                        spanNav += DateTime.UtcNow - start;
                    }

                    if (failTrace)
                    {
                        countFailTrace++;
                    }

                    if (failTrace != failNav)
                    {
                        countFailDiff++;
                    }

                    if (failNav)
                    {
                        // L.debugLog( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
                        countFailToPointNav++;
                        continue;
                    }

                    Vector3 ptNearest = NearestMobLoc(ptDestination, mobLocations);
                    if (ptNearest == Vector3.Zero)
                    {
                        if (furthestNearMobDistSqr < minSafeDistSqr)
                        {
                            furthestNearMobDistSqr = minSafeDistSqr;
                            ptFurthest             = ptDestination; // set best available if others fail
                            facingFurthest         = checkFacing;
                        }
                    }
                    else
                    {
                        double mobDistSqr = ptDestination.Distance2DSquared(ptNearest);
                        if (furthestNearMobDistSqr < mobDistSqr)
                        {
                            furthestNearMobDistSqr = mobDistSqr;
                            ptFurthest             = ptDestination; // set best available if others fail
                            facingFurthest         = checkFacing;
                        }
                        if (mobDistSqr <= minSafeDistSqr)
                        {
                            countFailSafe++;
                            continue;
                        }
                    }

                    if (reallyCheckRangeToLineOfSightMob && RangeToLineOfSightMob < ptDestination.Distance(LineOfSightMob.Location) - LineOfSightMob.MeleeDistance())
                    {
                        countFailRange++;
                        continue;
                    }

                    if (CheckLineOfSightToSafeLocation)
                    {
                        Vector3 ptAdjDest = ptDestination;
                        ptAdjDest.Z += 1f;
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptAdjOrigin, ptAdjDest))
                        {
                            // L.debugLog( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                            countFailToPointLoS++;
                            continue;
                        }
                    }

                    if (CheckSpellLineOfSightToMob && LineOfSightMob != null)
                    {
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(ptDestination, LineOfSightMob.GetTraceLinePos()))
                        {
                            if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptDestination, LineOfSightMob.GetTraceLinePos()))
                            {
                                // L.debugLog( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                                countFailToMobLoS++;
                                continue;
                            }
                        }
                    }

                    L.debugLog("SafeArea: Found mob-free location ({0:F1} yd radius) at degrees={1:F1} dist={2:F1} on point check# {3} at {4}, {5}, {6}", MinSafeDistance, WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin, countPointsChecked, ptDestination.X, ptDestination.Y, ptDestination.Z);
                    L.debugLog("SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
                    L.debugLog("SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
                    L.debugLog("SafeArea: stats for ({0:F1} yd radius) found within {1:F1} yds ({2} checked, {3} nav, {4} not safe, {5} range, {6} pt los, {7} mob los, {8} mesh trace)", MinSafeDistance, MaxScanDistance, countPointsChecked, countFailToPointNav, countFailSafe, countFailRange, countFailToPointLoS, countFailToMobLoS, countFailTrace);
                    return(ptDestination);
                }
            }

            L.debugLog("SafeArea: No mob-free location ({0:F1} yd radius) found within {1:F1} yds ({2} checked, {3} nav, {4} not safe, {5} range, {6} pt los, {7} mob los, {8} mesh trace)", MinSafeDistance, MaxScanDistance, countPointsChecked, countFailToPointNav, countFailSafe, countFailRange, countFailToPointLoS, countFailToMobLoS, countFailTrace);
            if (ChooseSafestAvailable && ptFurthest != Vector3.Zero)
            {
                L.debugLog("SafeArea: choosing best available spot in {0:F1} yd radius where closest mob is {1:F1} yds", MinSafeDistance, Math.Sqrt(furthestNearMobDistSqr));
                L.debugLog("SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
                L.debugLog("SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
                return(ChooseSafestAvailable ? ptFurthest : Vector3.Zero);
            }

            L.debugLog("SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
            L.debugLog("SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
            return(Vector3.Zero);
        }
Exemplo n.º 5
0
        public static async Task <bool> SingleTarget()
        {
            // we only want to use the single target rotation after the open rotation is finished.
            if (await S.CastGround(SB.MetamorphosisSpell, C.CombatColor, UseMetamorphosisCD(false)))
            {
                return(true);
            }

            if (await RushST())
            {
                return(true);
            }

            #region Single-Target Vengeful Retreat


            //use it if we have Prepared talent differently
            if (await S.GCD(SB.VengefulRetreat, C.CombatColor,
                            HS.HavocVengefulReatreatSingleTarget &&
                            C.MissingPower > 30 &&
                            (FelRushCheckCharge(true)) &&
                            T.HavocPrepared &&
                            Me.IsWithinMeleeRangeOf(CurrentTarget), "ST1", sleep: false))
            //{ felRushAfterVengefulRetreat.Restart(); C.fallingTimeout.Restart(); return true; }
            {
                return(true);
            }

            // use it if we DO NOT have Prepared talent without Fury check
            if (await S.GCD(SB.VengefulRetreat, C.CombatColor,
                            HS.HavocVengefulReatreatAoe &&
                            (FelRushCheckCharge(true)) &&
                            !T.HavocPrepared &&
                            Me.IsWithinMeleeRangeOf(CurrentTarget), "ST2", sleep: false))
            //{ felRushAfterVengefulRetreat.Restart(); C.fallingTimeout.Restart(); return true; }
            {
                return(true);
            }


            #endregion

            #region Single-Target Fel Rush
            // use this in combination with vengeful retreat
            //if (await S.Cast(SB.FelRush, C.CombatColor, HS.HavocFelRushSingleTarget && S.OnCooldown(SB.VengefulRetreat)
            //    //&& felRushAfterVengefulRetreat.ElapsedMilliseconds <= 2000
            //    && T.HavocFelMastery
            //    && Me.CurrentTarget.Distance <= 18
            //    && C.MissingPower <= 30,
            //"ST 1"))
            //{ felRushAfterVengefulRetreat.Reset(); return true; }
            //{ return true; }

            // use to engage
            if (await S.Cast(SB.FelRush, C.CombatColor, HS.HavocFelRushSingleTarget &&
                             !Me.IsWithinMeleeRangeOf(CurrentTarget) && CurrentTarget.Distance <= 18, "ST 2"))
            //{ felRushAfterVengefulRetreat.Reset(); return true; }
            {
                return(true);
            }
            #endregion

            // if we have used vengeful retreat, don't do anything else until we fel rush
            //if (felRushAfterVengefulRetreat.IsRunning && felRushAfterVengefulRetreat.ElapsedMilliseconds <= 2000) { return true; }

            // fel rush, almost max charges and needs momentum
            if (await S.Cast(SB.FelRush, C.CombatColor, HS.HavocFelRushSingleTarget && Me.IsWithinMeleeRangeOf(CurrentTarget) &&
                             FelRushAlmostMaxCharge() &&
                             NeedMomentum(true), "ST - Fel Rush for Momentum"))
            {
                return(true);
            }
            if (await S.Cast(SB.EyeBeam, C.CombatColor, T.HavocDemonic && CurrentTarget.Distance <= 10, "ST - Demonic talent"))
            {
                return(true);
            }
            if (await S.Cast(SB.FelEruption, C.CombatColor, T.HavocFelEruption && CurrentTarget.Distance <= 20, "ST"))
            {
                return(true);
            }
            L.debugLog(CanUseAbilityWithMomentum().ToString() + ", " + Me.IsWithinMeleeRangeOf(CurrentTarget).ToString() + ", " + UseFuryOfIllidariCD(false).ToString());
            if (await S.Cast(SB.FuryOfTheIllidari, C.CombatColor, CanUseAbilityWithMomentum() && Me.IsWithinMeleeRangeOf(CurrentTarget) &&
                             UseFuryOfIllidariCD(false), "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.BladeDance, C.CombatColor, CanUseAbilityWithMomentum() && T.HavocFirstBlood && Me.IsWithinMeleeRangeOf(CurrentTarget), "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.FelBlade, C.CombatColor, C.MissingPower <= 30 && CurrentTarget.Distance <= 15, "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.ThrowGlaive, C.CombatColor, CanUseAbilityWithMomentum() && T.HavocBloodlet && CurrentTarget.Distance <= 30, "ST"))
            {
                return(true);
            }
            //if (await S.Cast(SB.FelBarrage, C.CombatColor, NeedMomentum() && T.HavocFelBarrage && S.GetCharges(SB.FelBarrage) >= 5, "ST")) { return true; }
            if (await S.Cast(SB.ChaosStrike, C.CombatColor, C.MissingPower <= 30 && Me.HasAnyTempAura("Metamorphosis") && Me.IsWithinMeleeRangeOf(CurrentTarget), "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.EyeBeam, C.CombatColor, Me.HasAura(SB.AuraAnguishOfTheDeceiver) && CurrentTarget.Distance <= 10, "ST - Has Eye of the Deceiver Trait"))
            {
                return(true);
            }
            if (await S.Cast(SB.ChaosStrike, C.CombatColor, C.MissingPower <= 30 && Me.IsWithinMeleeRangeOf(CurrentTarget), "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.FelBarrage, C.CombatColor, CanUseAbilityWithMomentum() && T.HavocFelBarrage && S.GetCharges(SB.FelBarrage) >= 4 && CurrentTarget.Distance <= 30, "ST"))
            {
                return(true);
            }
            if (await S.Cast(SB.DemonsBite, C.CombatColor, !T.HavocDemonBlades && Me.IsWithinMeleeRangeOf(CurrentTarget) && !S.MaxChargesAvailable(SB.ThrowGlaive), "ST"))
            {
                return(true);
            }

            // melee range with Demon Blades
            if (await S.Cast(SB.ThrowGlaive, C.CombatColor,
                             Me.IsWithinMeleeRangeOf(CurrentTarget), "ST"))
            {
                return(true);
            }

            // nothing else to do so let's throw a glaive
            if (await S.Cast(SB.ThrowGlaive, C.CombatColor,
                             !Me.IsWithinMeleeRangeOf(CurrentTarget), "ST"))
            {
                return(true);
            }
            return(false);
        }