/// <summary> /// set evade /// </summary> /// <returns></returns> private void CheckEvade() { if (!EvadeEnabled || Player.Instance.IsDead || Player.Instance.IsDashing() || Player.Instance.IsInFountainRange()) { CurrentEvadeResult = null; return; } CacheSkillshots(); bool goodPath = IsPathSafeEx(CurrentEvadeResult?.WalkPoint.To2D() ?? LastIssueOrderPos); bool inside = IsHeroInDanger(); if ((inside || !goodPath) && CurrentEvadeResult == null) { bool oustside = !inside; var evade = CalculateEvade(LastIssueOrderPos, oustside); if (evade.IsValid) { evade.IsOutsideEvade = oustside; CurrentEvadeResult = evade; } } }
private void PlayerOnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args) { if (!sender.IsMe) { return; } if (args.Order == GameObjectOrder.AttackUnit) { LastIssueOrderPos = (Player.Instance.Distance(args.Target, true) > Player.Instance.GetAutoAttackRange(args.Target as AttackableUnit).Pow() ? args.Target.Position : Player.Instance.Position).To2D(); } else { LastIssueOrderPos = (args.Target?.Position ?? args.TargetPosition).To2D(); } if (IsPathSafeEx(args.TargetPosition.To2D()) && !IsHeroInDanger()) { //Chat.Print(Environment.TickCount); CurrentEvadeResult = null; } if (CurrentEvadeResult != null && CurrentEvadeResult.EnoughTime) { args.Process = false; } }
public void DoEvade(bool move = false) { if (IsChampionInDanger()) { if (_lastEvadeResult == null) { _lastEvadeResult = GetEvadeResult(_lastIssueOrderPos); if (!_lastEvadeResult.EnoughTime) { Chat.Print("[Evade+] Not enough time to walk."); } _lastEvadeResult.EvadePoint = _lastEvadeResult.EvadePoint.Extend(Player.Instance, -40); var path = GetPath(_lastEvadeResult.EvadePoint, _lastIssueOrderPos); AutoPathing.DoPath(path); //Player.IssueOrder(GameObjectOrder.MoveTo, _lastEvadeResult.EvadePoint.To3DWorld(), false); } } else { if (_lastEvadeResult == null && (move || !IsPathSafe(Player.Instance.GetPath(_lastIssueOrderPos.To3DWorld(), true).ToVector2()))) { var path = GetPath(Player.Instance.ServerPosition.To2D(), _lastIssueOrderPos); path = new[] {Player.Instance.ServerPosition.To2D()}.Concat(path).ToArray(); if (IsPathSafe(path)) AutoPathing.DoPath(path); } } }
public void AddEvadeResult(EvadeResult evadeResult) { if (!this.settings.DrawEvadeResult.IsEnabled) { return; } if (evadeResult == null || evadeResult.State == EvadeResult.EvadeState.TooEarly || evadeResult.State == EvadeResult.EvadeState.Ignore) { return; } if (this.evadeResults.Contains(evadeResult)) { return; } if (this.evadeResults.Count >= 7) { this.evadeResults.Remove(this.evadeResults.Last()); } this.evadeResults.Add(evadeResult); UpdateManager.BeginInvoke(() => this.evadeResults.Remove(evadeResult), 7500); }
public bool IsHeroPathSafe(EvadeResult evade, Vector3[] desiredPath, AIHeroClient hero = null) { return(false); //temporarily disabled hero = hero ?? Player.Instance; var path = (desiredPath ?? hero.RealPath()).ToVector2(); var polygons = ClippedPolygons; var points = new List <Vector2>(); for (var i = 0; i < path.Length - 1; i++) { var start = path[i]; var end = path[i + 1]; foreach (var pol in polygons) { var intersections = pol.GetIntersectionPointsWithLineSegment(start, end); if (intersections.Length > 0 && !pol.IsInside(hero)) { return(false); } points.AddRange(intersections); } } if (points.Count == 1) { var walkTime = hero.WalkingTime(points[0]); return(walkTime <= evade.TimeAvailable); } return(false); }
public EvadeResult CalculateEvade(Vector2 anchor, Vector2?awayFrom = null) { var playerPos = Player.Instance.ServerPosition.To2D(); var maxTime = GetTimeAvailable(); var time = Math.Max(0, maxTime - (Game.Ping + ServerTimeBuffer)); var points = GetEvadePoints(awayFrom ?? Player.Instance.Position.To2D()); if (!points.Any()) { Vector2 evadeSpellEvadePoint; //float needed = Player.Instance.Distance(GetClosestEvadePoint2()) / Player.Instance.MoveSpeed * 1000; //if (time < 30000) // Chat.Print("<b><font size='30' color='#FFFFFF'>dt: " + (needed - time) + " for " + Skillshots[0] + "</font></b>"); if (!EvadeSpellManager.TryEvadeSpell(time, this, out evadeSpellEvadePoint)) { return(new EvadeResult(this, GetClosestEvadePoint(playerPos), anchor, maxTime, time, ForceEvade) { IsForced = ForceEvade }); } //can use evade spell CurrentEvadeResult = new EvadeResult(this, evadeSpellEvadePoint, anchor, maxTime, time, true); } if (DoesComfortPointExist(points) && HasToAttendComfort()) { points.RemoveAll(p => !IsComfortPoint(p)); } var evadePoint = points.OrderBy(p => !p.IsUnderTurret()).ThenBy(p => p.Distance(Game.CursorPos)).FirstOrDefault(); return(new EvadeResult(this, evadePoint, anchor, maxTime, time, true)); }
private bool TryToSpendGold(Unit9 unit, IObstacle obstacle, EvadeResult evadeResult) { if (evadeResult?.State != EvadeResult.EvadeState.Failed) { return(false); } if (!this.menu.AbilitySettings.IsGoldSpenderEnabled()) { return(false); } if (!unit.IsMyHero || obstacle.IsModifierObstacle) { return(false); } var damage = obstacle.GetDamage(unit); if (damage < unit.Health) { return(false); } this.assemblyEventManager.InvokeEvaderPredictedDeath(); return(true); }
private void OnSkillshotDetected(EvadeSkillshot skillshot, bool isProcessSpell) { //TODO: update if (skillshot.ToPolygon().IsInside(Player.Instance)) { LastEvadeResult = null; } }
private void OnDash(Obj_AI_Base sender, Dash.DashEventArgs dashEventArgs) { if (!sender.IsMe || LastEvadeResult == null) { return; } LastEvadeResult = null; Player.IssueOrder(GameObjectOrder.MoveTo, LastIssueOrderPos.To3DWorld(), false); }
private void OnSkillshotDetected(EvadeSkillshot skillshot, bool isProcessSpell) { if (CurrentEvadeResult != null && CurrentEvadeResult.EnoughTime) { if (!skillshot.IsSafePath(Player.Instance.GetPath(CurrentEvadeResult.WalkPoint).ToVector2(), ServerTimeBuffer + Game.Ping)) { CurrentEvadeResult = null; } } }
private void OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (!sender.IsMe) { return; } if (args.SData.Name == "summonerflash") { LastEvadeResult = null; } }
public EvadeResult CalculateEvade(Vector2 anchor, Vector2?awayFrom = null) { var playerPos = Player.Instance.ServerPosition.To2D(); var maxTime = GetTimeAvailable(); var time = Math.Max(0, maxTime - (Game.Ping + ServerTimeBuffer)); var points = GetEvadePoints(awayFrom ?? Player.Instance.Position.To2D()); if (!points.Any()) { Vector2 evadeSpellEvadePoint; if (!EvadeSpellManager.TryEvadeSpell(time, this, out evadeSpellEvadePoint)) { var closest = GetClosestEvadePoint(playerPos); if (HasToAttendComfort() && !DoesComfortPointExist(new[] { closest }) && DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } return(new EvadeResult(this, closest, anchor, maxTime, time, ForceEvade) { IsForced = ForceEvade }); } if (HasToAttendComfort() && !DoesComfortPointExist(new [] { evadeSpellEvadePoint }) && DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } //can use evade spell CurrentEvadeResult = new EvadeResult(this, evadeSpellEvadePoint, anchor, maxTime, time, true); } if (HasToAttendComfort()) { if (DoesComfortPointExist(points)) { points.RemoveAll(p => !IsComfortPoint(p)); } else if (DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } } var evadePoint = points.OrderBy(p => !p.IsUnderTurret()).ThenBy(p => p.Distance(Game.CursorPos)).FirstOrDefault(); return(new EvadeResult(this, evadePoint, anchor, maxTime, time, true)); }
private void OnUpdate(EventArgs args) { if (Environment.TickCount - LastUpdateTick < 1) { return; } LastUpdateTick = Environment.TickCount; if (!EvadeEnabled || b_PassAA || Player.Instance.IsDead || Player.Instance.IsDashing() || Player.Instance.IsInFountainRange()) { CurrentEvadeResult = null; Orbwalker.DisableMovement = false; return; } CheckEvade(); if (CurrentEvadeResult != null && CurrentEvadeResult.EnoughTime) { if (CurrentEvadeResult.ShouldPreventStuttering) { var newPoints = GetEvadePoints(CurrentEvadeResult.WalkPoint.To2D()); var point = newPoints.FirstOrDefault(); if (point != default(Vector2)) { CurrentEvadeResult.EvadePoint = point; } } else if (AllowRecalculateEvade && Environment.TickCount - LastRecalcTick >= RecalculationDelay) { LastRecalcTick = Environment.TickCount; var newP = GetEvadePoints(Player.Instance.Position.To2D()).FirstOrDefault(); float angle = (newP.To3D() - Player.Instance.Position).To2D() .AngleBetween((CurrentEvadeResult.WalkPoint - Player.Instance.Position).To2D()); bool betterPos = newP.Distance(Game.CursorPos) < CurrentEvadeResult.EvadePoint.Distance(Game.CursorPos); if (angle >= MinRecalculationAngle && betterPos) { CurrentEvadeResult.EvadePoint = newP; } } MoveTo(CurrentEvadeResult.WalkPoint, false); } }
void PassAA() { int extraWindUpTime = Orbwalker.ExtraWindUpTime; switch (Player.Instance.Hero) { case Champion.Jinx: extraWindUpTime += 150; break; case Champion.Rengar: extraWindUpTime += 150; break; } float aaDelay = Orbwalker.AttackCastDelay * 1000.0f + extraWindUpTime + Game.Ping / 10.0f + 50; CurrentEvadeResult = null; b_PassAA = true; Core.DelayAction(() => b_PassAA = false, (int)Math.Ceiling(aaDelay)); }
/// <summary> /// set evade /// </summary> /// <returns></returns> private void CheckEvade() { bool isOrbwalking = Orbwalker.ActiveModesFlags != Orbwalker.ActiveModes.None; CacheSkillshots(); bool goodPath = IsPathSafeEx(isOrbwalking ? Game.CursorPos.To2D() : LastIssueOrderPos); if (!goodPath && CurrentEvadeResult == null) { var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { CurrentEvadeResult = evade; Orbwalker.DisableMovement = true; } } else if (goodPath) { CurrentEvadeResult = null; Orbwalker.DisableMovement = false; } }
private void OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (!sender.IsMe) { return; } if (args.SData.Name == "summonerflash") { LastEvadeResult = null; } }
private void OnSkillshotDetected(EvadeSkillshot skillshot, bool isProcessSpell) { //TODO: update if (skillshot.ToPolygon().IsInside(Player.Instance)) { LastEvadeResult = null; } }
public bool IsHeroPathSafe(EvadeResult evade, Vector3[] desiredPath, AIHeroClient hero = null) { hero = hero ?? Player.Instance; var path = (desiredPath ?? hero.RealPath()).ToVector2(); return IsPathSafeEx(path, hero); var polygons = ClippedPolygons; var points = new List<Vector2>(); for (var i = 0; i < path.Length - 1; i++) { var start = path[i]; var end = path[i + 1]; foreach (var pol in polygons) { var intersections = pol.GetIntersectionPointsWithLineSegment(start, end); if (intersections.Length > 0 && !pol.IsInside(hero)) { return false; } points.AddRange(intersections); } } if (points.Count == 1) { var walkTime = hero.WalkingTime(points[0]); return walkTime <= evade.TimeAvailable; } return false; }
private void OnDash(Obj_AI_Base sender, Dash.DashEventArgs dashEventArgs) { if (!sender.IsMe || LastEvadeResult == null) { return; } LastEvadeResult = null; Player.IssueOrder(GameObjectOrder.MoveTo, LastIssueOrderPos.To3DWorld(), false); }
private void OnSkillshotDetected(EvadeSkillshot skillshot, bool isProcessSpell) { _lastEvadeResult = null; DoEvade(); }
public bool DoEvade(Vector3[] desiredPath = null, PlayerIssueOrderEventArgs args = null) { if (!EvadeEnabled || Player.Instance.IsDead || Player.Instance.IsDashing()) { LastEvadeResult = null; AutoPathing.StopPath(); return false; } var hero = Player.Instance; if (args != null && args.Order == GameObjectOrder.AttackUnit) { if (!hero.IsInAutoAttackRange((AttackableUnit)args.Target)) { desiredPath = hero.GetPath(args.Target.Position, true); } } if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { // LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 500.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { return EvadeSpellManager.ProcessFlash(this); } } if (LastEvadeResult != null) //&& LastEvadeResult.EvadePoint.Distance(hero) > hero.HitBoxRadius() { var isPathSafe = IsHeroPathSafe(evade, desiredPath); if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || !isPathSafe) { AutoPathing.StopPath(); MoveTo(LastEvadeResult.WalkPoint, false); } return true; } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = PathFinding.GetPath(hero.Position.To2D(), LastIssueOrderPos); var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid) { path = new[] {evade.EvadePoint}.Concat(path).ToArray(); } if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return desiredPath != null; } else { AutoPathing.StopPath(); LastEvadeResult = null; } return false; }
public override EvadeResult Evade(Unit9 ally, IObstacle obstacle) { var result = new EvadeResult { Ally = ally.DisplayName, EnemyAbility = obstacle.EvadableAbility.Ability.DisplayName, IsModifier = obstacle.IsModifierObstacle, Mode = EvadeMode.Dodge, ObstacleId = obstacle.Id }; if (!obstacle.CanBeDodged || ally.IsCourier) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if (this.pathfinderMode == Pathfinder.EvadeMode.None) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if ((this.pathfinderMode == Pathfinder.EvadeMode.Disables || ally.IsCharging) && !obstacle.EvadableAbility.Ability.IsDisable()) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if (!ally.CanUseAbilities) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if (ally.IsInvulnerable || (!obstacle.EvadableAbility.Ability.CanHitSpellImmuneEnemy && ally.IsMagicImmune)) { result.State = EvadeResult.EvadeState.Successful; return(result); } if (!ally.CanMove(false)) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (!ally.IsControllable || this.ActionManager.IsInputBlocked(ally)) { result.State = EvadeResult.EvadeState.Failed; return(result); } var remainingTime = obstacle.GetEvadeTime(ally, true) - (Game.Ping / 2000f); if (remainingTime <= 0) { result.State = EvadeResult.EvadeState.Failed; return(result); } var movingIntoObstacle = !obstacle.IsIntersecting(ally, false); var path = movingIntoObstacle ? this.pathfinder.GetPathFromObstacle(ally, ally.Speed, ally.InFront(100), 69, out var success) : this.pathfinder.GetPathFromObstacle(ally, ally.Speed, ally.Position, 69, out success); if (!success) { result.State = EvadeResult.EvadeState.Failed; return(result); } var ignoreTime = obstacle.EvadableAbility.IgnoreRemainingTime(obstacle, null); var movePosition = path.Last(); var requiredTime = this.GetRequiredTime(ally, movePosition, remainingTime, out var speedBuffAbility) - 0.15f; if (obstacle is AreaOfEffectObstacle) { remainingTime -= 0.15f; } if (!ignoreTime) { if (requiredTime > remainingTime) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (requiredTime + 0.15 < remainingTime) { if (EvadeModeManager.MoveCamera && !Hud.IsPositionOnScreen(movePosition)) { Hud.CameraPosition = movePosition; } result.State = EvadeResult.EvadeState.TooEarly; return(result); } } if (ally.IsRuptured && ally.Distance(movePosition) > 300) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (!this.ChannelCanceled(ally, obstacle, remainingTime, null)) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (!this.PhaseCanceled(ally, obstacle, null)) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (speedBuffAbility != null) { speedBuffAbility.Use(ally, null, null); result.AllyAbility = speedBuffAbility.Ability.DisplayName; } if (EvadeModeManager.MoveCamera && !Hud.IsPositionOnScreen(movePosition)) { Hud.CameraPosition = movePosition; } ally.BaseUnit.Move(movePosition, false, true); this.ActionManager.BlockInput(ally, obstacle, requiredTime + 0.2f); this.ActionManager.IgnoreObstacle(ally, obstacle, requiredTime + 0.5f); result.State = EvadeResult.EvadeState.Successful; return(result); }
public override EvadeResult Evade(Unit9 ally, IObstacle obstacle) { var result = new EvadeResult { Ally = ally.DisplayName, EnemyAbility = obstacle.EvadableAbility.Ability.DisplayName, IsModifier = obstacle.IsModifierObstacle, Mode = EvadeMode.Counter, ObstacleId = obstacle.Id }; if (ally.IsInvulnerable || (!obstacle.EvadableAbility.Ability.CanHitSpellImmuneEnemy && ally.IsMagicImmune)) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if (!ally.IsImportant && !ally.IsCourier) { result.State = EvadeResult.EvadeState.Ignore; return(result); } //todo check linkens etc. var enemy = obstacle.Caster; foreach (var abilityId in obstacle.GetCounters(ally)) { foreach (var counterAbility in this.abilities) { if (counterAbility.Ability.Id != abilityId) { continue; } if (ally.IsCourier && !counterAbility.Owner.IsCourier) { continue; } if (!counterAbility.CanBeCasted(ally, enemy, obstacle)) { continue; } if (this.ActionManager.IsInputBlocked(counterAbility.Owner)) { continue; } var requiredTime = counterAbility.GetRequiredTime(ally, enemy, obstacle); var remainingTime = obstacle.GetEvadeTime(ally, false); if (remainingTime - requiredTime <= 0) { continue; } var ignoreTime = obstacle.EvadableAbility.IgnoreRemainingTime(obstacle, counterAbility); if (!ignoreTime && remainingTime - requiredTime > EvadeTiming) { result.State = EvadeResult.EvadeState.TooEarly; return(result); } if (!this.ChannelCanceled(ally, obstacle, remainingTime, counterAbility)) { continue; } if (!this.PhaseCanceled(ally, obstacle, counterAbility)) { continue; } if (!counterAbility.Use(ally, enemy, obstacle)) { continue; } if (counterAbility.BlockPlayersInput(obstacle)) { if (counterAbility.IsToggleable) { this.ActionManager.BlockInput(counterAbility.Ability, obstacle, remainingTime + 0.1f); } else { this.ActionManager.BlockInput(counterAbility.Owner, obstacle, requiredTime + 0.1f); } } this.ActionManager.IgnoreObstacle(ally, obstacle, remainingTime + 0.5f); result.AbilityOwner = counterAbility.Owner.DisplayName; result.AllyAbility = counterAbility.Ability.DisplayName; result.State = EvadeResult.EvadeState.Successful; return(result); } } result.State = EvadeResult.EvadeState.Failed; return(result); }
public bool DoEvade(Vector3[] desiredPath = null) { if (!EvadeEnabled || Player.Instance.IsDead) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || !IsPathSafe(hero.GetPath(LastEvadeResult.EvadePoint.To3DWorld(), true)) || LastEvadeResult.Expired())) { LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 300.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } if (IsHeroPathSafe(evade, desiredPath)) { LastEvadeResult = null; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { var result = EvadeSpellManager.ProcessFlash(this); if (!result && AlwaysEvade && evade.IsValid) { Player.IssueOrder(GameObjectOrder.MoveTo, evade.EvadePoint.To3DWorld(), false); } return(result); } } if (LastEvadeResult != null) { if (!hero.IsMovingTowards(LastEvadeResult.EvadePoint)) { AutoPathing.StopPath(); Player.IssueOrder(GameObjectOrder.MoveTo, LastEvadeResult.EvadePoint.To3DWorld(), false); } return(true); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = GetPath(hero.Position.To2D(), LastIssueOrderPos); if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return(true); } else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }
public bool DoEvade(Vector3[] desiredPath = null) { return false; if (!EvadeEnabled || Player.Instance.IsDead) { LastEvadeResult = null; AutoPathing.StopPath(); return false; } var hero = Player.Instance; if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 300.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { var result = EvadeSpellManager.ProcessFlash(this); if (!result && AlwaysEvade && evade.IsValid) { MoveTo(evade.WalkPoint); } return result; } } if (LastEvadeResult != null && !IsHeroPathSafe(evade, desiredPath)) { if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || EvadeIssurOrderTime + IssueOrderTickLimit <= Environment.TickCount) { AutoPathing.StopPath(); MoveTo(LastEvadeResult.WalkPoint, false); } } return true; } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { LastEvadeResult = null; return true; } else { AutoPathing.StopPath(); LastEvadeResult = null; } return false; }
public override EvadeResult Evade(Unit9 ally, IObstacle obstacle) { var result = new EvadeResult { Ally = ally.DisplayName, EnemyAbility = obstacle.EvadableAbility.Ability.DisplayName, IsModifier = obstacle.IsModifierObstacle, Mode = EvadeMode.Disable, ObstacleId = obstacle.Id }; var enemy = obstacle.Caster; if (enemy.IsInvulnerable) { result.State = EvadeResult.EvadeState.Failed; return(result); } if (!ally.IsImportant) { result.State = EvadeResult.EvadeState.Ignore; return(result); } foreach (var id in obstacle.GetDisables(ally)) { foreach (var disableAbility in this.abilities) { if (disableAbility.Ability.Id != id) { continue; } if (!disableAbility.CanBeCasted(ally, enemy, obstacle)) { continue; } if (this.ActionManager.IsInputBlocked(disableAbility.Owner)) { continue; } var requiredTime = disableAbility.GetRequiredTime(ally, enemy, obstacle); var remainingTime = obstacle.GetDisableTime(enemy); if (remainingTime - requiredTime <= 0) { continue; } var ignoreTime = obstacle.EvadableAbility.IgnoreRemainingTime(obstacle, disableAbility); if (!ignoreTime && remainingTime - requiredTime > EvadeTiming) { result.State = EvadeResult.EvadeState.TooEarly; return(result); } //todo remove/change this ? //if ((enemy.UnitState & disableAbility.AppliesUnitState) != 0) //{ // result.State = EvadeResult.EvadeState.Ignore; // return result; //} if (!this.ChannelCanceled(ally, obstacle, remainingTime, disableAbility)) { continue; } if (!this.PhaseCanceled(ally, obstacle, disableAbility)) { continue; } if (!disableAbility.Use(ally, enemy, obstacle)) { continue; } this.ActionManager.BlockInput(disableAbility.Owner, obstacle, requiredTime + 0.1f); this.ActionManager.IgnoreObstacle(obstacle, remainingTime + 0.5f); result.AbilityOwner = disableAbility.Owner.DisplayName; result.AllyAbility = disableAbility.Ability.DisplayName; result.Enemy = enemy.DisplayName; result.State = EvadeResult.EvadeState.Successful; return(result); } } result.State = EvadeResult.EvadeState.Failed; return(result); }
public bool DoEvade(Vector3[] desiredPath = null) { return(false); if (!EvadeEnabled || Player.Instance.IsDead) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 300.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { var result = EvadeSpellManager.ProcessFlash(this); if (!result && AlwaysEvade && evade.IsValid) { MoveTo(evade.WalkPoint); } return(result); } } if (LastEvadeResult != null && !IsHeroPathSafe(evade, desiredPath)) { if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || EvadeIssurOrderTime + IssueOrderTickLimit <= Environment.TickCount) { AutoPathing.StopPath(); MoveTo(LastEvadeResult.WalkPoint, false); } } return(true); } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { LastEvadeResult = null; return(true); } else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }
private void OnUpdate() { if (GameManager.IsPaused) { return; } try { var units = this.GetUnits(); foreach (var unit in units) { foreach (var obstacle in this.pathfinder.GetIntersectingObstacles(unit)) { if (!obstacle.EvadableAbility.Enabled) { continue; } if (this.actionManager.IsObstacleIgnored(unit, obstacle) || obstacle.EvadableAbility.IsObstacleIgnored(unit, obstacle)) { continue; } EvadeResult evadeResult = null; foreach (var mode in this.evadeModeManager.GetEvadeModes(obstacle)) { evadeResult = mode.Evade(unit, obstacle); if (evadeResult.State == EvadeResult.EvadeState.Successful || evadeResult.State == EvadeResult.EvadeState.TooEarly) { break; } } if (this.TryToBlock(unit, units, obstacle, evadeResult)) { // ReSharper disable once PossibleNullReferenceException evadeResult.Mode = EvadeMode.Dodge; evadeResult.State = EvadeResult.EvadeState.Successful; } if (this.TryToSpendGold(unit, obstacle, evadeResult)) { // ReSharper disable once PossibleNullReferenceException evadeResult.Mode = EvadeMode.GoldSpend; evadeResult.State = EvadeResult.EvadeState.Successful; } this.debugger.AddEvadeResult(evadeResult); } } } catch (Exception e) { Logger.Error(e); } }
public override EvadeResult Evade(Unit9 ally, IObstacle obstacle) { var result = new EvadeResult { Ally = ally.DisplayName, EnemyAbility = obstacle.EvadableAbility.Ability.DisplayName, IsModifier = obstacle.IsModifierObstacle, Mode = EvadeMode.Blink, ObstacleId = obstacle.Id }; if (ally.IsInvulnerable || (!obstacle.EvadableAbility.Ability.CanHitSpellImmuneEnemy && ally.IsMagicImmune)) { result.State = EvadeResult.EvadeState.Ignore; return(result); } if (!ally.IsImportant) { result.State = EvadeResult.EvadeState.Ignore; return(result); } var enemy = obstacle.Caster; foreach (var id in obstacle.GetBlinks(ally)) { foreach (var blinkAbility in this.abilities) { if (blinkAbility.Ability.Id != id || !blinkAbility.CanBeCasted(ally, enemy, obstacle)) { continue; } if (this.ActionManager.IsInputBlocked(blinkAbility.Owner)) { continue; } var requiredTime = blinkAbility.GetRequiredTime(ally, enemy, obstacle); var remainingTime = obstacle.GetEvadeTime(ally, true); if (remainingTime - requiredTime <= 0) { continue; } var ignoreTime = obstacle.EvadableAbility.IgnoreRemainingTime(obstacle, blinkAbility); if (!ignoreTime && remainingTime - requiredTime > EvadeTiming) { result.State = EvadeResult.EvadeState.TooEarly; return(result); } if (!this.ChannelCanceled(ally, obstacle, remainingTime, blinkAbility)) { continue; } if (!this.PhaseCanceled(ally, obstacle, blinkAbility)) { continue; } if (!blinkAbility.Use(ally, enemy, obstacle)) { continue; } this.ActionManager.BlockInput(blinkAbility.Owner, obstacle, requiredTime + 0.1f); this.ActionManager.IgnoreObstacle(ally, obstacle, remainingTime + 0.5f); result.AbilityOwner = blinkAbility.Owner.DisplayName; result.AllyAbility = blinkAbility.Ability.DisplayName; result.State = EvadeResult.EvadeState.Successful; return(result); } } result.State = EvadeResult.EvadeState.Failed; return(result); }
private void OnTick(EventArgs args) { if (_lastEvadeResult != null && !IsChampionInDanger()) { if(Player.Instance.IsMoving && !Player.Instance.Spellbook.IsAutoAttacking) AutoPathing.DoPath(GetPath(_lastEvadeResult.EvadePoint, _lastIssueOrderPos)); _lastEvadeResult = null; } }
private bool TryToBlock(Unit9 unit, IEnumerable <Unit9> units, IObstacle obstacle, EvadeResult evadeResult) { if (evadeResult?.State != EvadeResult.EvadeState.Failed) { return(false); } if (!(obstacle is LinearProjectileObstacle linearObstacle)) { return(false); } if ((obstacle.EvadableAbility.ActiveAbility.CollisionTypes & CollisionTypes.EnemyUnits) == 0) { return(false); } foreach (var otherUnit in units.Where(x => !x.Equals(unit) && x.IsUnit && !x.IsImportant && !x.IsInvulnerable && x.CanMove())) { if ((otherUnit.UnitState & UnitState.NoCollision) != 0) { continue; } var otherUnitPosition = otherUnit.Position.ToVector2(); var enemyPosition = linearObstacle.Position.Extend2D(unit.Position, 75).ToVector2(); var unitPosition = unit.Position.Extend2D(linearObstacle.Position, 75).ToVector2(); var projection = Vector2Extensions.ProjectOn(otherUnitPosition, enemyPosition, unitPosition); var movePosition = projection.IsOnSegment ? projection.LinePoint.ToVector3() .Extend2D(otherUnit.Position, obstacle.EvadableAbility.ActiveAbility.Radius * 0.75f) : projection.SegmentPoint.ToVector3(); var requiredTime = otherUnit.GetTurnTime(movePosition) + (otherUnit.Distance(movePosition) / otherUnit.Speed); if (linearObstacle.GetEvadeTime(movePosition) < requiredTime) { continue; } if (otherUnit.BaseUnit.Move(movePosition, false, true)) { this.actionManager.BlockInput(otherUnit, obstacle, requiredTime); this.actionManager.IgnoreObstacle(unit, obstacle, obstacle.GetEvadeTime(unit, false)); return(true); } } return(false); }
public bool DoEvade(AIHeroClient hero = null, Vector3[] desiredPath = null) { if (!EvadeEnabled || Player.Instance.IsDead) { LastEvadeResult = null; AutoPathing.StopPath(); return false; } hero = hero ?? Player.Instance; if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 300.Pow())) { LastEvadeResult = evade; } if (IsHeroPathSafe(evade, desiredPath)) { LastEvadeResult = null; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { return EvadeSpellManager.ProcessFlash(this); } } if (LastEvadeResult != null) { if (!hero.IsMovingTowards(LastEvadeResult.EvadePoint)) { AutoPathing.StopPath(); Player.IssueOrder(GameObjectOrder.MoveTo, LastEvadeResult.EvadePoint.To3DWorld(), false); } return true; } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = GetPath(hero.Position.To2D(), LastIssueOrderPos); if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return true; } else { AutoPathing.StopPath(); LastEvadeResult = null; } return false; }
public bool DoEvade(Vector3[] desiredPath = null, PlayerIssueOrderEventArgs args = null) { if (!EvadeEnabled || Player.Instance.IsDead || Player.Instance.IsDashing()) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (args != null && args.Order == GameObjectOrder.AttackUnit) { if (!hero.IsInAutoAttackRange((AttackableUnit)args.Target)) { desiredPath = hero.GetPath(args.Target.Position, true); } } if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { // LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 500.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { return(EvadeSpellManager.ProcessFlash(this)); } } if (LastEvadeResult != null) //&& LastEvadeResult.EvadePoint.Distance(hero) > hero.HitBoxRadius() { var isPathSafe = IsHeroPathSafe(evade, desiredPath); if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || !isPathSafe) { AutoPathing.StopPath(); MoveTo(LastEvadeResult.WalkPoint, false); } return(true); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = PathFinding.GetPath(hero.Position.To2D(), LastIssueOrderPos); var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid) { path = new[] { evade.EvadePoint }.Concat(path).ToArray(); } if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return(desiredPath != null); } else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }
public bool DoEvade(Vector3[] desiredPath = null, PlayerIssueOrderEventArgs args = null) { #region pre if (!EvadeEnabled || Player.Instance.IsDead || Player.Instance.IsDashing()) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (args != null && args.Order == GameObjectOrder.AttackUnit) { if (!hero.IsInAutoAttackRange((AttackableUnit)args.Target)) { desiredPath = hero.GetPath(args.Target.Position, true); } } #endregion pre #region execute evade point movement if (LastEvadeResult != null) { var isPathSafe = IsHeroPathSafe(desiredPath); if (!IsHeroInDanger(hero) && isPathSafe) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || !isPathSafe) { AutoPathing.StopPath(); MoveTo(GetExtendedEvade(LastEvadeResult.WalkPoint.To2D()), false); } return(true); } #endregion execute evade point movement #region check evade if (IsHeroInDanger(hero)) { var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 500.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else if (!evade.EnoughTime) { return(EvadeSpellManager.TryEvadeSpell(evade, this)); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var evade = CalculateEvade(LastIssueOrderPos, true); if (evade.IsValid) { LastEvadeResult = evade; return(true); } //LastEvadeResult = null; return(desiredPath != null); } #endregion check evade else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }