public override async Task ExecuteAsync(CancellationToken token) { try { _target = _targetSelector.Active.GetTargets().FirstOrDefault(); var unitMaxHp = EntityManager <Unit> .Entities.Where(x => x.IsValid && x.IsVisible && x.IsAlive && x.IsSpawned && x.Distance2D(Owner) < 400 && (x.NetworkName == "CDOTA_BaseNPC_Creep_Neutral" || x.NetworkName == "CDOTA_BaseNPC_Creep" || x.NetworkName == "CDOTA_BaseNPC_Creep_Lane" || x.NetworkName == "CDOTA_BaseNPC_Creep_Siege")).OrderBy(x => x.MaximumHealth).LastOrDefault(); if (_target == null || _target.IsAttackImmune() || _target.IsInvulnerable()) { Orbwalker.OrbwalkTo(null); return; } if (_configuration.AbilityManager.Value.IsEnabled(DeathPact.Ability.Name) && DeathPact.CanBeCasted && !_target.IsEthereal() && unitMaxHp != null) { DeathPact.UseAbility(unitMaxHp); await Await.Delay(DeathPact.GetCastDelay(unitMaxHp), token); } if (_configuration.AbilityManager.Value.IsEnabled(Strafe.Ability.Name) && Strafe.CanBeCasted && !_target.IsEthereal() && Owner.IsInAttackRange(_target)) { Strafe.UseAbility(); await Await.Delay(Strafe.GetCastDelay(), token); } if (_configuration.AbilityManager.Value.IsEnabled(Arrows.Ability.Name) && Arrows.CanBeCasted && !_target.IsEthereal() && !Arrows.Ability.IsAutoCastEnabled && Owner.IsInAttackRange(_target)) { Arrows.Ability.ToggleAutocastAbility(); } if (SolarCrest != null && SolarCrest.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() && _configuration.ItemManager.Value.IsEnabled(SolarCrest.Ability.Name) && !_target.IsMagicImmune() && Owner.IsInAttackRange(_target)) { SolarCrest.UseAbility(_target); await Await.Delay(SolarCrest.GetCastDelay(_target), token); } if (Meddallion != null && Meddallion.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() && _configuration.ItemManager.Value.IsEnabled(Meddallion.Ability.Name) && !_target.IsMagicImmune() && Owner.IsInAttackRange(_target)) { Meddallion.UseAbility(_target); await Await.Delay(Meddallion.GetCastDelay(_target), token); } if (DiffusalBlade != null && DiffusalBlade.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() && _configuration.ItemManager.Value.IsEnabled(DiffusalBlade.Ability.Name) && !_target.IsMagicImmune() && Owner.IsInAttackRange(_target)) { DiffusalBlade.Ability.UseAbility(_target); await Await.Delay(DiffusalBlade.GetCastDelay(_target), token); } if (Mjollnir != null && Mjollnir.CanBeCasted && !Owner.IsAttacking() && Owner.IsInAttackRange(_target) && _configuration.ItemManager.Value.IsEnabled(Mjollnir.Ability.Name)) { Mjollnir.UseAbility(Owner); await Await.Delay(Mjollnir.GetCastDelay(Owner), token); } if (Bloodthorn != null && Bloodthorn.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManager.Value.IsEnabled(Bloodthorn.ToString()) && Owner.IsInAttackRange(_target)) { Bloodthorn.UseAbility(_target); await Await.Delay(Bloodthorn.GetCastDelay(_target), token); } if (SheepStick != null && SheepStick.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManager.Value.IsEnabled(SheepStick.Ability.Name) && Owner.IsInAttackRange(_target)) { SheepStick.UseAbility(_target); await Await.Delay(SheepStick.GetCastDelay(_target), token); } if (Orchid != null && Orchid.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManager.Value.IsEnabled(Orchid.Ability.Name) && Owner.IsInAttackRange(_target)) { Orchid.UseAbility(_target); await Await.Delay(Orchid.GetCastDelay(_target), token); } if (_target != null && (_target.IsInvulnerable() || _target.IsAttackImmune())) { Orbwalker.Move(Game.MousePosition); } else if (_target != null) { Orbwalker.OrbwalkTo(_target); } else { Orbwalker.Move(Game.MousePosition); } } catch (Exception e) { Log.Error(e); } }
public override async Task ExecuteAsync(CancellationToken token) { try { _target = _targetSelector.Active.GetTargets().FirstOrDefault(); var blinkPdValue = _configuration.UseBlink.Item.GetValue <Slider>().Value; if (_target == null || _target.IsAttackImmune() || _target.IsInvulnerable()) { Orbwalker.OrbwalkTo(null); return; } if (_configuration.AbilityManager.Value.IsEnabled(Warcry.Ability.Name) && Warcry.CanBeCasted && Owner.IsInRange(_target, 1500)) { Warcry.UseAbility(); await Await.Delay(Warcry.GetCastDelay(Owner), token); } if (_configuration.AbilityManager.Value.IsEnabled(GodsStrength.Ability.Name) && GodsStrength.CanBeCasted && Owner.IsInRange(_target, 1500)) { GodsStrength.UseAbility(); await Await.Delay(GodsStrength.GetCastDelay(Owner), token); } if (Mjollnir != null && Mjollnir.CanBeCasted && !Owner.IsAttacking() && Owner.IsInRange(_target, 1500) && _configuration.ItemManager.Value.IsEnabled(Mjollnir.Ability.Name)) { Mjollnir.UseAbility(Owner); await Await.Delay(Mjollnir.GetCastDelay(Owner), token); } if (Blink != null && Blink.Item.IsValid && Blink.CanBeCasted && _target != null && Owner.Distance2D(_target) <= 1200 + blinkPdValue && !(Owner.Distance2D(_target) <= 150) && _configuration.ItemManager.Value.IsEnabled(Blink.Ability.Name)) { var l = (Owner.Distance2D(_target) - blinkPdValue) / blinkPdValue; var posA = Owner.Position; var posB = _target.Position; var x = (posA.X + (l * posB.X)) / (1 + l); var y = (posA.Y + (l * posB.Y)) / (1 + l); var position = new Vector3((int)x, (int)y, posA.Z); Blink.UseAbility(position); await Await.Delay(Blink.GetCastDelay(position), token); } if (_configuration.AbilityManager.Value.IsEnabled(Bolt.Ability.Name) && Bolt.CanBeCasted && Owner.IsInRange(_target, 600) && !(_target.IsStunned() || _target.IsHexed())) { Bolt.UseAbility(_target); await Await.Delay(Bolt.GetCastDelay(Owner), token); } if (DiffusalBlade != null && DiffusalBlade.CanBeCasted && !Owner.IsAttacking() && !_target.IsEthereal() && _configuration.ItemManager.Value.IsEnabled(DiffusalBlade.Ability.Name) && !_target.IsMagicImmune() && Owner.IsInRange(_target, 600)) { DiffusalBlade.Ability.UseAbility(_target); await Await.Delay(DiffusalBlade.GetCastDelay(_target), token); } if (Bloodthorn != null && Bloodthorn.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManager.Value.IsEnabled(Bloodthorn.Ability.Name) && Owner.IsInRange(_target, 600) && !_target.IsSilenced()) { Bloodthorn.UseAbility(_target); await Await.Delay(Bloodthorn.GetCastDelay(_target), token); } if (Orchid != null && Orchid.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManager.Value.IsEnabled(Orchid.Ability.Name) && Owner.IsInRange(_target, 600) && !_target.IsSilenced()) { Orchid.UseAbility(_target); await Await.Delay(Orchid.GetCastDelay(_target), token); } if (SheepStick != null && SheepStick.CanBeCasted && !Owner.IsAttacking() && !_target.IsMagicImmune() && _configuration.ItemManagerTwo.Value.IsEnabled(SheepStick.Ability.Name) && !(_target.IsStunned() || _target.IsHexed()) && Owner.IsInRange(_target, 600)) { SheepStick.UseAbility(_target); await Await.Delay(SheepStick.GetCastDelay(_target), token); } if (Mjollnir != null && Mjollnir.CanBeCasted && !Owner.IsAttacking() && _target.IsAttacking() && Owner.IsInRange(_target, 600) && _configuration.ItemManagerTwo.Value.IsEnabled(Mjollnir.Ability.Name)) { Mjollnir.UseAbility(Owner); await Await.Delay(Mjollnir.GetCastDelay(Owner), token); } if (Halberd != null && Halberd.CanBeCasted && !Owner.IsAttacking() && _target.IsAttacking() && Owner.IsInRange(_target, 600) && _configuration.ItemManagerTwo.Value.IsEnabled(Halberd.Ability.Name)) { Halberd.UseAbility(_target); await Await.Delay(Halberd.GetCastDelay(_target), token); } if (Abyssal != null && Abyssal.CanBeCasted && !Owner.IsAttacking() && !(_target.IsStunned() || _target.IsHexed()) && Owner.IsInRange(_target, 600) && _configuration.ItemManagerTwo.Value.IsEnabled(Abyssal.Ability.Name)) { Abyssal.Ability.CastStun(_target); await Await.Delay(Abyssal.GetCastDelay(_target), token); } if (Mask != null && Mask.CanBeCasted && !Owner.IsAttacking() && Owner.IsInRange(_target, 600) && _configuration.ItemManager.Value.IsEnabled(Mask.Ability.Name) && !Bolt.CanBeCasted && !Warcry.CanBeCasted && !GodsStrength.CanBeCasted) { Mask.UseAbility(); await Await.Delay(Mask.GetCastDelay(Owner), token); } if (_target != null && (_target.IsInvulnerable() || _target.IsAttackImmune())) { Orbwalker.Move(Game.MousePosition); } else if (_target != null) { Orbwalker.OrbwalkTo(_target); } else { Orbwalker.Move(Game.MousePosition); } } catch (Exception e) { Log.Error(e); } }