protected override float GetTimeTilAttack(Unit target) { var distance = target.Distance2D(ControlledUnit) - ControlledUnit.AttackRange - target.HullRadius - ControlledUnit.HullRadius; return((distance / ControlledUnit.MovementSpeed) + (float)ControlledUnit.AttackPoint() + (float)ControlledUnit.GetTurnTime(target) - Game.Ping / 1000.0f); }
protected override float GetTimeTilAttack(Unit target) { var distance = target.Distance2D(ControlledUnit) - target.HullRadius - ControlledUnit.HullRadius; var projectileTime = Math.Min(AttackRange, distance) / (float)ControlledUnit.ProjectileSpeed(); return((Math.Max(0, distance - AttackRange) / ControlledUnit.MovementSpeed) + (float)ControlledUnit.AttackPoint() + (float)ControlledUnit.GetTurnTime(target) + projectileTime - Game.Ping / 1000.0f); }
public override void AddRangeEffect() { if (RangeEffect != null || !FarmMenu.ShouldDrawLasthitRange) { return; } RangeEffect = ControlledUnit.AddParticleEffect("particles/ui_mouseactions/drag_selected_ring.vpcf"); RangeEffect.SetControlPoint(1, new Vector3(FarmMenu.RedColor, FarmMenu.GreenColor, FarmMenu.BlueColor)); // R G B RangeEffect.SetControlPoint(2, new Vector3(AttackRange + FarmMenu.RangedBonusRange, 255, 0)); }
protected async Task Auto() { if (ControlledUnit.AttackCapability == AttackCapability.None) { Log.Debug($"no attack"); await Follow(); return; } var hero = _myHero.Hero; var healthPerc = (float)ControlledUnit.Health / ControlledUnit.MaximumHealth; var time = Game.RawGameTime; if (_aura != null && !_isNecroUnit && (healthPerc <= 0.25f || !HasActiveSkill)) { await Follow(); return; } if ((hero.IsAttacking() || time - _lastAttackingTime <= hero.AttackBackswing() * 2) && _myHero.ComboTarget == null) { _lastAttackingTime = time; var target = ObjectManager.GetEntitiesParallel <Unit>() .FirstOrDefault( x => x.IsValid && x.IsAlive && x.Team != hero.Team && hero.IsAttacking(x)); if (target != null) { Log.Debug($"attack {target.Name}"); ControlledUnit.Attack(target); await Await.Delay(250); } else { Log.Debug($"is attacking but no target"); await Await.Delay(250); await Follow(); } } else { Log.Debug($"combo target"); await AttackComboTarget(); } }
protected async Task Follow() { var hero = _myHero.Hero; var distance = hero.Distance2D(ControlledUnit); var enemies = ObjectManager.GetEntitiesParallel <Hero>() .Where(x => x.IsValid && x.IsAlive && x.Team != hero.Team && x.Distance2D(hero) < 1000); if (!enemies.Any()) { ControlledUnit.Follow(hero); Log.Debug($"follow"); } else { var pos = Vector3.Zero; foreach (var enemy in enemies) { pos += enemy.NetworkPosition; } pos /= enemies.Count(); var dir = pos - hero.NetworkPosition; dir.Normalize(); if (_aura != null) { dir *= _auraRadius / 2; } else { dir *= 500; } pos = hero.NetworkPosition - dir; if (ControlledUnit.Distance2D(pos) < 75) { ControlledUnit.Hold(); } else { ControlledUnit.Move(pos); } Log.Debug($"follow away from enemy"); } await Await.Delay(100); }
public override bool LastHit() { if (LastTarget != null && !IsLastTargetValid) { if (FarmMenu.IsAutoStopEnabled) { ControlledUnit.Stop(); } LastTarget = null; } if (!Utils.SleepCheck($"lasthit_{ControlledUnit.Handle}")) { return(LastTarget != null); } if (FarmMenu.IsLasthittingActive) { var couldKill = InfoCentral.EnemyCreeps.Where(x => x.Distance2D(ControlledUnit) < (AttackRange + FarmMenu.RangedBonusRange)) .Where(x => GetPseudoHealth(x) <= (GetAttackDamage(x) * DamageMultiplier)) .OrderBy(x => x.Distance2D(ControlledUnit)) .FirstOrDefault(); if (couldKill != null) { LastTarget = couldKill; if (ControlledUnit.IsAttacking() && GetPseudoHealth(couldKill) > GetAttackDamage(couldKill)) { ControlledUnit.Stop(); Utils.Sleep((ControlledUnit.AttackPoint() * 250), $"lasthit_{ControlledUnit.Handle}"); return(false); } ControlledUnit.Attack(couldKill); Utils.Sleep((ControlledUnit.AttackPoint() * 250), $"lasthit_{ControlledUnit.Handle}"); return(true); } } if (!FarmMenu.IsDenyModeActive) { return(false); } var couldDeny = InfoCentral.AlliedCreeps.Where( x => x.Distance2D(ControlledUnit) < (AttackRange + FarmMenu.RangedBonusRange) && GetPseudoHealth(x) <= (GetAttackDamage(x) * DamageMultiplier)) .OrderBy(x => x.Distance2D(ControlledUnit)) .FirstOrDefault(); if (couldDeny != null) { LastTarget = couldDeny; if (ControlledUnit.IsAttacking() && GetPseudoHealth(couldDeny) > GetAttackDamage(couldDeny)) { ControlledUnit.Stop(); Utils.Sleep((ControlledUnit.AttackPoint() * 250), $"lasthit_{ControlledUnit.Handle}"); return(false); } ControlledUnit.Attack(couldDeny); Utils.Sleep((ControlledUnit.AttackPoint() * 250), $"lasthit_{ControlledUnit.Handle}"); return(true); } return(false); }
protected async Task AttackComboTarget() { var target = _myHero.ComboTarget; if (target == null) { Log.Debug($"no combo target"); await Follow(); return; } var hero = _myHero.Hero; foreach (var spell in ControlledUnit.Spellbook.Spells) { if (spell.IsHidden || !spell.IsActivated || !spell.CanBeCasted() || ControlledUnit.Mana < spell.ManaCost) { continue; } var usedSpell = false; if (spell.AbilityBehavior.HasFlag(AbilityBehavior.UnitTarget)) { if (spell.TargetTeamType.HasFlag(TargetTeamType.All) && spell.CanBeCasted(target) && spell.CanHit(target)) { Log.Debug($"use spell {spell.Name} with type {spell.TargetTeamType}"); spell.UseAbility(target); usedSpell = true; } else if (spell.TargetTeamType.HasFlag(TargetTeamType.Allied) && spell.CanHit(hero)) { Log.Debug($"use spell {spell.Name} with type {spell.TargetTeamType} on {hero.Name}"); spell.UseAbility(hero); } else if (spell.CanBeCasted(target) && spell.CanHit(target)) { Log.Debug( $"use spell {spell.Name} with type {spell.TargetTeamType} | {spell.CanBeCasted(hero)} | {spell.CanHit(hero)}"); spell.UseAbility(target); usedSpell = true; } } else if (spell.AbilityBehavior.HasFlag(AbilityBehavior.NoTarget) && spell.CanBeCasted(target) && spell.CanHit(target)) { spell.UseAbility(); usedSpell = true; } else if ((spell.AbilityBehavior.HasFlag(AbilityBehavior.AreaOfEffect) || spell.AbilityBehavior.HasFlag(AbilityBehavior.Point)) && spell.CanBeCasted(target) && spell.CanHit(target)) { spell.UseAbility(target.NetworkPosition); usedSpell = true; } if (usedSpell) { Log.Debug($"was using spell {spell.Name}"); await Await.Delay((int)(spell.FindCastPoint() * 1000 + Game.Ping + 125)); } } Log.Debug($"attack"); ControlledUnit.Attack(target); await Await.Delay(250); }