public AttackableUnit GetTarget() { AttackableUnit result = null; var r = float.MaxValue; if ((ActiveMode == OrbwalkingMode.Mixed || ActiveMode == OrbwalkingMode.LaneClear) && !_config.Item("PriorizeFarm").GetValue <bool>()) { var target = TargetSelector.GetTarget(-1, TargetSelector.DamageType.Physical); if (target != null) { return(target); } } /*Killable Minion*/ if (ActiveMode == OrbwalkingMode.LaneClear || ActiveMode == OrbwalkingMode.Mixed || ActiveMode == OrbwalkingMode.LastHit) { foreach (var minion in ObjectManager.Get <Obj_AI_Minion>() .Where( minion => minion.IsValidTarget() && InAutoAttackRange(minion) && minion.Health < 2 * (ObjectManager.Player.BaseAttackDamage + ObjectManager.Player.FlatPhysicalDamageMod)) ) { var t = (int)(Player.AttackCastDelay * 1000) - 100 + Game.Ping / 2 + 1000 * (int)Player.Distance(minion) / (int)GetMyProjectileSpeed(); var predHealth = HealthPrediction.GetHealthPrediction(minion, t, FarmDelay); if (minion.Team != GameObjectTeam.Neutral && MinionManager.IsMinion(minion, true)) { if (predHealth <= 0) { FireOnNonKillableMinion(minion); } if (predHealth > 0 && predHealth <= Player.GetAutoAttackDamage(minion, true)) { return(minion); } } } } //Forced target if (_forcedTarget.IsValidTarget() && InAutoAttackRange(_forcedTarget)) { return(_forcedTarget); } /* turrets / inhibitors / nexus */ if (ActiveMode == OrbwalkingMode.LaneClear) { /* turrets */ foreach (var turret in ObjectManager.Get <Obj_AI_Turret>().Where(t => t.IsValidTarget() && InAutoAttackRange(t))) { return(turret); } /* inhibitor */ foreach (var turret in ObjectManager.Get <Obj_BarracksDampener>() .Where(t => t.IsValidTarget() && InAutoAttackRange(t))) { return(turret); } /* nexus */ foreach (var nexus in ObjectManager.Get <Obj_HQ>() .Where(t => t.IsValidTarget() && InAutoAttackRange(t))) { return(nexus); } } /*Champions*/ if (ActiveMode != OrbwalkingMode.LastHit) { var target = TargetSelector.GetTarget(-1, TargetSelector.DamageType.Physical); if (target.IsValidTarget()) { return(target); } } /*Jungle minions*/ if (ActiveMode == OrbwalkingMode.LaneClear || ActiveMode == OrbwalkingMode.Mixed) { foreach (var mob in ObjectManager.Get <Obj_AI_Minion>() .Where( mob => mob.IsValidTarget() && InAutoAttackRange(mob) && mob.Team == GameObjectTeam.Neutral) .Where(mob => mob.MaxHealth >= r || Math.Abs(r - float.MaxValue) < float.Epsilon)) { result = mob; r = mob.MaxHealth; } } /*Lane Clear minions*/ r = float.MaxValue; if (ActiveMode == OrbwalkingMode.LaneClear) { if (!ShouldWait()) { if (_prevMinion.IsValidTarget() && InAutoAttackRange(_prevMinion)) { var predHealth = HealthPrediction.LaneClearHealthPrediction( _prevMinion, (int)((Player.AttackDelay * 1000) * LaneClearWaitTimeMod), FarmDelay); if (predHealth >= 2 * Player.GetAutoAttackDamage(_prevMinion, false) || Math.Abs(predHealth - _prevMinion.Health) < float.Epsilon) { return(_prevMinion); } } foreach (var minion in ObjectManager.Get <Obj_AI_Minion>() .Where(minion => minion.IsValidTarget() && InAutoAttackRange(minion))) { var predHealth = HealthPrediction.LaneClearHealthPrediction( minion, (int)((Player.AttackDelay * 1000) * LaneClearWaitTimeMod), FarmDelay); if (predHealth >= 2 * Player.GetAutoAttackDamage(minion) || Math.Abs(predHealth - minion.Health) < float.Epsilon) { if (minion.Health >= r || Math.Abs(r - float.MaxValue) < float.Epsilon) { result = minion; r = minion.Health; _prevMinion = minion; } } } } } return(result); }
/// <summary> /// Returns the unit health when the spell hits the unit. /// </summary> public float GetHealthPrediction(Obj_AI_Base unit) { var time = (int)(Delay * 1000 + From.Distance(unit.ServerPosition) / Speed - 100); return(HealthPrediction.GetHealthPrediction(unit, time)); }