/// <summary> /// checks for chained cascade targets. this is expensive as the theoretical linked distance is 200 yds /// if all 4 hops occur and mobs are in straight line. regardless, this ability can easily aggro the /// entire countryside while questing, so we will be conservative in our assessment of whether it can /// be used or not while still maximizing the number of mobs hit based upon the initial targets proximity /// to linked mobs /// </summary> /// <returns></returns> public static WoWUnit GetBestCascadeTarget() { if (!Spell.CanCastHack("Cascade", Me, skipWowCheck: true)) { Logger.WriteDebug("GetBestCascadeTarget: CanCastHack says NO to Cascade"); return(null); } // search players we are facing in range for the number of hops they represent var targetInfo = Unit.UnfriendlyUnits() .Where(u => u.SpellDistance() < 40 && Me.IsSafelyFacing(u) && u.InLineOfSpellSight) .Select(p => new { Unit = p, Count = Clusters.GetChainedClusterCount(p, Unit.UnfriendlyUnits(), 40f, AvoidAttackingTarget) }) .OrderByDescending(v => v.Count) // maximize count .OrderByDescending(v => (int)v.Unit.DistanceSqr) // maximize initial distance .DefaultIfEmpty(null) .FirstOrDefault(); if (targetInfo == null) { Logger.WriteDiagnostic("GetBestCascadeTarget: 0 mobs without unwanted aggro / cc break"); return(null); } Logger.WriteDiagnostic( "GetBestCascadeTarget: {0} will hit {1} mobs without unwanted aggro / cc break", targetInfo.Unit.SafeName(), targetInfo.Count ); return(targetInfo.Unit); }