Example #1
0
 private static void Swap(Obj_AI_Hero target)
 {
     var eCanKill = E.CanCast(target) && target.Health + target.PhysicalShield <= E.GetDamage(target);
     if (MainMenu["Combo"]["SwapIfKill"])
     {
         if (IsKillByMark(target) || eCanKill)
         {
             SwapCountEnemy();
         }
     }
     if (Player.HealthPercent < MainMenu["Combo"]["SwapIfHpU"])
     {
         if (IsKillByMark(target) || !eCanKill || Player.HealthPercent < target.HealthPercent)
         {
             SwapCountEnemy();
         }
     }
     else if (MainMenu["Combo"]["SwapGap"].GetValue<MenuList>().Index > 0 && !E.IsInRange(target)
              && !IsKillByMark(target))
     {
         var playerDist = target.DistanceToPlayer();
         var wDist = WState == 1 && wShadow.IsValid() ? wShadow.Distance(target) : float.MaxValue;
         var rDist = RState == 1 && rShadow.IsValid() ? rShadow.Distance(target) : float.MaxValue;
         var minDist = Math.Min(Math.Min(wDist, rDist), playerDist);
         if (minDist < playerDist)
         {
             switch (MainMenu["Combo"]["SwapGap"].GetValue<MenuList>().Index)
             {
                 case 1:
                     if (Math.Abs(minDist - wDist) < float.Epsilon)
                     {
                         var comboW = GetCombo(
                             target,
                             Q.IsReady() && minDist < Q.Range,
                             false,
                             E.IsReady() && minDist < E.Range,
                             MainMenu["Combo"]["R"] && MainMenu["Combo"]["RCast" + target.ChampionName]
                             && RState == 0 && minDist < R.Range);
                         if (minDist > target.GetRealAutoAttackRange())
                         {
                             comboW[0] -= Player.GetAutoAttackDamage(target);
                         }
                         if (target.Health + target.PhysicalShield <= comboW[0] && Player.Mana >= comboW[1]
                             && W.Cast())
                         {
                             return;
                         }
                         if (MainMenu["Combo"]["R"] && MainMenu["Combo"]["RCast" + target.ChampionName]
                             && RState == 0 && !R.IsInRange(target) && minDist < R.Range
                             && (MainMenu["Combo"]["RMode"].GetValue<MenuList>().Index == 0 || CanR)
                             && W.Cast())
                         {
                             return;
                         }
                     }
                     else if (Math.Abs(minDist - rDist) < float.Epsilon)
                     {
                         var comboR = GetCombo(
                             target,
                             Q.IsReady() && minDist < Q.Range,
                             false,
                             E.IsReady() && minDist < E.Range,
                             false);
                         if (minDist > target.GetRealAutoAttackRange())
                         {
                             comboR[0] -= Player.GetAutoAttackDamage(target);
                         }
                         if (target.Health + target.PhysicalShield <= comboR[0] && Player.Mana >= comboR[1]
                             && R.Cast())
                         {
                             return;
                         }
                     }
                     if (minDist < E.Range && target.HealthPercent <= 20
                         && target.HealthPercent < Player.HealthPercent && (Q.IsReady() || E.IsReady()))
                     {
                         if (Math.Abs(minDist - wDist) < float.Epsilon)
                         {
                             W.Cast();
                         }
                         else if (Math.Abs(minDist - rDist) < float.Epsilon)
                         {
                             R.Cast();
                         }
                     }
                     break;
                 case 2:
                     if (minDist <= 500)
                     {
                         if (Math.Abs(minDist - wDist) < float.Epsilon)
                         {
                             W.Cast();
                         }
                         else if (Math.Abs(minDist - rDist) < float.Epsilon)
                         {
                             R.Cast();
                         }
                     }
                     break;
             }
         }
     }
 }
 /// <summary>
 ///     Determines whether [is valid target] [the specified hero].
 /// </summary>
 /// <param name="hero">
 ///     The hero.
 /// </param>
 /// <param name="range">
 ///     The range.
 /// </param>
 /// <param name="damageType">
 ///     Type of the damage.
 /// </param>
 /// <param name="ignoreShields">
 ///     Indicates whether to ignore shields.
 /// </param>
 /// <param name="from">The from location.</param>
 /// <returns>
 ///     The <see cref="bool" />.
 /// </returns>
 private static bool IsValidTarget(
     Obj_AI_Hero hero,
     float range,
     DamageType damageType,
     bool ignoreShields = true,
     Vector3 from = default(Vector3))
 {
     return hero.IsValidTarget()
            && hero.DistanceSquared(@from.Equals(default(Vector3)) ? GameObjects.Player.ServerPosition : @from)
            < Math.Pow(range <= 0 ? hero.GetRealAutoAttackRange() : range, 2)
            && !Invulnerable.Check(hero, damageType, ignoreShields);
 }