public bool CancelChanneling(TargetManager targetManager) { if (!this.Ability.IsChanneling || !this.Ability.BaseAbility.IsChanneling) { return(false); } var target = targetManager.Target; if (target.IsStunned || target.IsRooted) { return(false); } var polygon = new Polygon.Rectangle( this.Owner.Position, this.Owner.Position.Extend2D(this.castPosition, this.Ability.Range), this.Ability.Radius - 75); var input = this.Ability.GetPredictionInput(target); input.Delay = this.powershot.ChannelTime - this.Ability.BaseAbility.ChannelTime; var output = this.Ability.GetPredictionOutput(input); if (!polygon.IsInside(output.TargetPosition) || this.powershot.GetCurrentDamage(target) > target.Health) { return(this.Owner.BaseUnit.Stop()); } return(false); }
public override bool UseAbility(TargetManager targetManager, Sleeper comboSleeper, Vector3 toPosition) { if (this.Owner.Distance(toPosition) < 200) { return(false); } var position = this.Owner.Position.Extend2D(toPosition, Math.Min(this.Ability.CastRange - 25, this.Owner.Distance(toPosition))); var rec = new Polygon.Rectangle(this.Owner.Position, position, this.Ability.Radius); if (EntityManager9.Units.Any(x => x.IsHero && x.IsEnemy(this.Owner) && x.IsAlive && rec.IsInside(x.Position))) { return(false); } if (!this.Ability.UseAbility(position)) { return(false); } var delay = this.Ability.GetCastDelay(position); comboSleeper.Sleep(delay); this.Sleeper.Sleep(delay + 0.5f); this.OrbwalkSleeper.Sleep(delay); return(true); }
private Vector3 GetClosestTree(Vector3 preferedPosition) { var ownerPosition = this.Owner.Position; var maxPosition = ownerPosition.Extend2D(preferedPosition, this.Ability.CastRange); var availableTress = EntityManager9.Trees.Where(x => x.Distance2D(ownerPosition) < this.Ability.CastRange) .OrderBy(x => x.Distance2D(preferedPosition)) .ToArray(); foreach (var tree in availableTress) { var treePosition = tree.Position; if (ownerPosition.Distance2D(treePosition) < 500) { continue; } var angle = (tree.Position - ownerPosition).AngleBetween(maxPosition - tree.Position); if (angle > 60) { continue; } var polygon = new Polygon.Rectangle(ownerPosition, tree.Position, this.timberChain.ChainRadius); if (availableTress.Any(x => x != tree && polygon.IsInside(x.Position))) { continue; } return(tree.Position); } return(Vector3.Zero); }
public override bool UseAbility(List <Unit9> heroes) { if (!this.settings.UseWhenMagicImmune && this.Owner.IsMagicImmune) { return(false); } if (this.Owner.HealthPercentage > this.settings.HpThreshold) { return(false); } var enemies = heroes.Where(x => x.IsEnemy(this.Owner)).ToList(); var closeEnemies = enemies.Count(x => x.Distance(this.Owner) < this.settings.Distance); foreach (var enemy in enemies) { if (!this.settings.IsHeroEnabled(enemy.Name)) { continue; } if (this.Owner.Distance(enemy) > this.settings.Distance) { continue; } if (closeEnemies < this.settings.EnemiesCount) { continue; } var blinkLocation = this.Owner.Position.Extend2D(this.Fountain, this.Ability.CastRange); var castRange = this.Ability.CastRange; foreach (var tree in EntityManager9.Trees .Where( x => x.Distance2D(blinkLocation) < castRange && x.Distance2D(this.Owner.Position) < castRange && x.Distance2D(this.Owner.Position) > 500) .OrderBy(x => x.Distance2D(this.Fountain))) { var rec = new Polygon.Rectangle(this.Owner.Position, tree.Position, this.timberChain.ChainRadius); if (EntityManager9.Trees.Any(x => rec.IsInside(x.Position))) { continue; } return(this.Ability.UseAbility(tree.Position)); } } return(false); }
// Token: 0x06000169 RID: 361 RVA: 0x0000C8E0 File Offset: 0x0000AAE0 public bool CancelChanneling(TargetManager targetManager) { if (!base.Ability.IsChanneling || !base.Ability.BaseAbility.IsChanneling) { return(false); } Unit9 target = targetManager.Target; if (target.IsStunned || target.IsRooted) { return(false); } Polygon polygon = new Polygon.Rectangle(base.Owner.Position, Vector3Extensions.Extend2D(base.Owner.Position, this.castPosition, base.Ability.Range), base.Ability.Radius - 75f); PredictionInput9 predictionInput = base.Ability.GetPredictionInput(target, null); predictionInput.Delay = this.powershot.ChannelTime - base.Ability.BaseAbility.ChannelTime; PredictionOutput9 predictionOutput = base.Ability.GetPredictionOutput(predictionInput); return((!polygon.IsInside(predictionOutput.TargetPosition) || (float)this.powershot.GetCurrentDamage(target) > target.Health) && base.Owner.BaseUnit.Stop()); }
public override void Update() { if (this.NavMeshId == null /*&& !this.Caster.IsRotating*/) { var chain = new Polygon.Rectangle(this.Position, this.Caster.InFront(this.Range), this.timberChain.ChainRadius); var tree = EntityManager9.Trees.Where(x => x.Distance2D(this.Position) < this.Range && chain.IsInside(x.Position)) .OrderBy(x => x.Distance2D(this.Position)) .FirstOrDefault(); if (tree == null) { this.EndObstacleTime = 0; this.IsUpdated = true; return; } this.EndPosition = tree.Position; this.ActivationDelay = this.Position.Distance2D(this.EndPosition) / this.Speed; this.EndObstacleTime += this.ActivationDelay * 2; this.Polygon = new Polygon.Rectangle(this.Position, this.EndPosition, this.Radius); this.NavMeshObstacles = this.Pathfinder.AddNavMeshObstacle(this.Position, this.EndPosition, this.Radius); this.NavMeshId = 1; //hack } else if (this.NavMeshId != null) { ////todo check activation delay of all obstacles var time = GameManager.RawGameTime - this.EndCastTime - this.ActivationDelay /*- 0.35f*/; if (time < 0) { return; } var currentPosition = this.Position.Extend2D(this.EndPosition, time * this.Speed); //this.Pathfinder.NavMesh.UpdateObstacle(this.NavMeshId.Value, currentPosition, this.Radius); var rectangle = (Polygon.Rectangle) this.Polygon; rectangle.Start = currentPosition.ToVector2(); rectangle.UpdatePolygon(); } }
public override bool ForceUseAbility(TargetManager targetManager, Sleeper comboSleeper) { var target = targetManager.Target; var input = this.GetPredictionInput(target); var output = this.Ability.GetPredictionOutput(input); if (output.HitChance < HitChance.Low) { return(false); } foreach (var unit in EntityManager9.Units.Where( x => x.IsUnit && (!x.IsHero || x.IsIllusion) && x.Distance(this.Owner) < this.Ability.CastRange && x.IsAlive)) { var rec = new Polygon.Rectangle( this.Owner.Position.Extend2D(unit.Position, -100), this.Owner.Position.Extend2D(unit.Position, this.Ability.Range), this.Ability.Radius); if (!rec.IsInside(output.TargetPosition)) { continue; } if (!this.Ability.UseAbility(unit)) { continue; } var delay = this.Ability.GetCastDelay(targetManager.Target); comboSleeper.Sleep(delay); this.Sleeper.Sleep(delay + 0.5f); this.OrbwalkSleeper.Sleep(delay); return(true); } return(false); }
public override bool UseAbility(TargetManager targetManager, Sleeper comboSleeper, bool aoe) { var target = targetManager.Target; var input = this.GetPredictionInput(target); var output = this.Ability.GetPredictionOutput(input); if (output.HitChance < HitChance.Low) { return(false); } foreach (var stone in EntityManager9.Units.Where( x => x.Name == "npc_dota_earth_spirit_stone" && x.Distance(this.Owner) < this.Ability.CastRange && x.IsAlive)) { var rec = new Polygon.Rectangle( this.Owner.Position.Extend2D(output.TargetPosition, -100), this.Owner.Position.Extend2D(output.TargetPosition, this.Ability.Range), this.Ability.Radius); if (!rec.IsInside(stone.Position)) { continue; } if (!this.Ability.UseAbility(output.CastPosition)) { continue; } var delay = this.Ability.GetCastDelay(targetManager.Target); comboSleeper.Sleep(delay); this.Sleeper.Sleep(delay + 0.5f); this.OrbwalkSleeper.Sleep(delay); return(true); } return(false); }
// Token: 0x0600082C RID: 2092 RVA: 0x00025794 File Offset: 0x00023994 public override bool UseAbility(TargetManager targetManager, Sleeper comboSleeper, Vector3 toPosition) { if (base.Owner.Distance(toPosition) < 200f) { return(false); } Vector3 vector = Vector3Extensions.Extend2D(base.Owner.Position, toPosition, Math.Min(base.Ability.CastRange - 25f, base.Owner.Distance(toPosition))); Polygon.Rectangle rec = new Polygon.Rectangle(base.Owner.Position, vector, base.Ability.Radius); if (EntityManager9.Units.Any((Unit9 x) => x.IsHero && x.IsEnemy(this.Owner) && x.IsAlive && rec.IsInside(x.Position))) { return(false); } if (!base.Ability.UseAbility(vector, false, false)) { return(false); } float castDelay = base.Ability.GetCastDelay(vector); comboSleeper.Sleep(castDelay); base.Sleeper.Sleep(castDelay + 0.5f); base.OrbwalkSleeper.Sleep(castDelay); return(true); }
// Token: 0x06000298 RID: 664 RVA: 0x00010B14 File Offset: 0x0000ED14 public override bool CanHit(TargetManager targetManager, IComboModeMenu comboMenu) { Unit9 target = targetManager.Target; PredictionInput9 predictionInput = base.Ability.GetPredictionInput(target, null); predictionInput.Delay += base.Owner.Distance(target) / base.Ability.Speed; PredictionOutput9 predictionOutput = base.Ability.GetPredictionOutput(predictionInput); Vector3 ownerPosition = base.Owner.Position; this.castPosition = predictionOutput.CastPosition; Polygon.Rectangle polygon = new Polygon.Rectangle(ownerPosition, this.castPosition, this.timberChain.ChainRadius); Tree[] array = (from x in this.trees where x.IsValid && x.IsAlive && x.Distance2D(ownerPosition) < this.Ability.CastRange select x).ToArray <Tree>(); foreach (Tree tree3 in array) { if (polygon.IsInside(tree3.Position)) { return(false); } } Vector3 end = Vector3Extensions.Extend2D(ownerPosition, this.castPosition, base.Ability.CastRange); polygon = new Polygon.Rectangle(this.castPosition, end, this.timberChain.Radius); foreach (Tree tree2 in array) { if (polygon.IsInside(tree2.Position)) { this.castPosition = tree2.Position; return(true); } } if (base.Ability.Level < 4u || ownerPosition.Distance2D(this.castPosition, false) < 400f) { return(false); } IEnumerable <Tree> source = array; Func <Tree, float> < > 9__1; Func <Tree, float> keySelector; if ((keySelector = < > 9__1) == null) { keySelector = (< > 9__1 = ((Tree x) => x.Distance2D(this.castPosition))); } using (IEnumerator <Tree> enumerator = source.OrderBy(keySelector).GetEnumerator()) { while (enumerator.MoveNext()) { Tree tree = enumerator.Current; Vector3 position = tree.Position; if ((position.Distance2D(this.castPosition, false) <= 500f || target.GetAngle(position, false) <= 0.75f) && ownerPosition.Distance2D(this.castPosition, false) >= position.Distance2D(this.castPosition, false)) { polygon = new Polygon.Rectangle(ownerPosition, position, this.timberChain.ChainRadius); if (!array.Any((Tree x) => !x.Equals(tree) && polygon.IsInside(x.Position))) { this.castPosition = position; return(true); } } } } return(false); }
private void OnUpdate() { try { if (this.Sleeper.IsSleeping) { return; } var target = this.TargetManager.TargetLocked ? this.TargetManager.Target : this.killSteal.Target; if (target?.IsValid != true || !target.IsVisible) { return; } foreach (var abilityTiming in this.abilityTimings.ToList()) { var ability = abilityTiming.Key; if (!ability.IsValid || !ability.BaseAbility.IsInAbilityPhase) { continue; } var owner = ability.Owner; var phaseEnd = abilityTiming.Value; var input = ability.GetPredictionInput(target); input.Delay = Math.Max(phaseEnd - GameManager.RawGameTime, 0) + ability.ActivationDelay; var output = ability.GetPredictionOutput(input); if (!(ability is IHasRadius)) { continue; } if (!this.abilityPositions.TryGetValue(ability.Handle, out var castPosition)) { continue; } Polygon polygon = null; switch (ability) { case AreaOfEffectAbility aoe: { polygon = new Polygon.Circle(castPosition, aoe.Radius + 50); break; } case CircleAbility circle: { polygon = new Polygon.Circle(castPosition, circle.Radius + 50); break; } case ConeAbility cone: { polygon = new Polygon.Trapezoid( owner.Position.Extend2D(castPosition, -cone.Radius / 2), owner.Position.Extend2D(castPosition, cone.Range), cone.Radius + 50, cone.EndRadius + 100); break; } case LineAbility line: { polygon = new Polygon.Rectangle( owner.Position, owner.Position.Extend2D(castPosition, line.Range), line.Radius + 50); break; } } if (polygon == null) { continue; } if (!target.IsAlive || output.HitChance == HitChance.Impossible || !polygon.IsInside(output.TargetPosition)) { this.Sleeper.Sleep(0.15f); this.abilityTimings.Remove(ability); this.abilityPositions.Remove(ability.Handle); this.OrbwalkSleeper.Reset(ability.Owner.Handle); this.AbilitySleeper.Reset(ability.Handle); // this.TargetSleeper.Reset(target.Handle); this.killSteal.KillStealSleeper.Reset(); target.RefreshUnitState(); ability.Owner.BaseUnit.Stop(); var unit = this.BaseHero.UnitManager.AllControllableUnits.FirstOrDefault(x => x.Handle == ability.Owner.Handle); unit?.ComboSleeper.Reset(); } } } catch (Exception e) { Logger.Error(e); } }
public override bool CanHit(TargetManager targetManager, IComboModeMenu comboMenu) { var target = targetManager.Target; if (target.IsMagicImmune && !this.Ability.CanHitSpellImmuneEnemy) { return(false); } if (this.Owner.Distance(target) > this.Ability.CastRange) { return(false); } // ult if (target.HasModifier("modifier_mars_arena_of_blood_leash")) { return(true); } var mainInput = this.Ability.GetPredictionInput(target); mainInput.Range = this.Ability.CastRange; var mainOutput = this.Ability.PredictionManager.GetSimplePrediction(mainInput); var targetPredictedPosition = mainOutput.TargetPosition; var range = this.Ability.Range - 200; var width = this.Ability.Radius; //todo predict collision positions ? var collisionRec = new Polygon.Rectangle(this.Owner.Position, targetPredictedPosition, width); if (targetManager.AllEnemyHeroes.Any(x => x != target && collisionRec.IsInside(x.Position))) { return(false); } // tree foreach (var tree in EntityManager9.Trees) { var rec = new Polygon.Rectangle( targetPredictedPosition, this.Owner.Position.Extend2D(targetPredictedPosition, range), width - 50); if (rec.IsInside(tree.Position)) { this.castPosition = mainOutput.CastPosition; return(true); } } // building foreach (var building in EntityManager9.Units.Where(x => x.IsBuilding && x.IsAlive)) { var rec = new Polygon.Rectangle( targetPredictedPosition, this.Owner.Position.Extend2D(targetPredictedPosition, range), width); if (rec.IsInside(building.Position)) { this.castPosition = mainOutput.CastPosition; return(true); } } // wall const int CellCount = 30; for (var i = 0; i < CellCount; ++i) { for (var j = 0; j < CellCount; ++j) { var p = new Vector2( (this.navMesh.CellSize * (i - (CellCount / 2))) + targetPredictedPosition.X, (this.navMesh.CellSize * (j - (CellCount / 2))) + targetPredictedPosition.Y); if ((this.navMesh.GetCellFlags(p) & NavMeshCellFlags.InteractionBlocker) != 0) { var rec = new Polygon.Rectangle( targetPredictedPosition, this.Owner.Position.Extend2D(targetPredictedPosition, range), width - 100); if (rec.IsInside(p)) { this.castPosition = mainOutput.CastPosition; return(true); } } } } return(false); }
// Token: 0x0600053A RID: 1338 RVA: 0x0001ADB0 File Offset: 0x00018FB0 public override bool CanHit(TargetManager targetManager, IComboModeMenu comboMenu) { if (!comboMenu.GetAbilitySettingsMenu <SpearOfMarsMenu>(this).StunOnly) { return(base.CanHit(targetManager, comboMenu)); } Unit9 target = targetManager.Target; if (target.IsMagicImmune && !base.Ability.CanHitSpellImmuneEnemy) { return(false); } if (base.Owner.Distance(target) > base.Ability.CastRange) { return(false); } if (target.HasModifier("modifier_mars_arena_of_blood_leash")) { return(true); } PredictionInput9 predictionInput = base.Ability.GetPredictionInput(target, null); predictionInput.Range = base.Ability.CastRange; PredictionOutput9 simplePrediction = base.Ability.PredictionManager.GetSimplePrediction(predictionInput); Vector3 targetPosition = simplePrediction.TargetPosition; float num = base.Ability.Range - 200f; float radius = base.Ability.Radius; Polygon.Rectangle collisionRec = new Polygon.Rectangle(base.Owner.Position, targetPosition, radius); if (targetManager.AllEnemyHeroes.Any((Unit9 x) => x != target && collisionRec.IsInside(x.Position))) { return(false); } foreach (Tree tree in from x in this.trees where x.IsValid && x.IsAlive select x) { if (new Polygon.Rectangle(targetPosition, Vector3Extensions.Extend2D(base.Owner.Position, targetPosition, num), radius - 50f).IsInside(tree.Position)) { this.castPosition = simplePrediction.CastPosition; return(true); } } foreach (Building building in from x in this.buildings where x.IsValid && x.IsAlive select x) { if (new Polygon.Rectangle(targetPosition, Vector3Extensions.Extend2D(base.Owner.Position, targetPosition, num), radius).IsInside(building.Position)) { this.castPosition = simplePrediction.CastPosition; return(true); } } for (int i = 0; i < 30; i++) { for (int j = 0; j < 30; j++) { Vector2 vector; vector..ctor(this.navMesh.CellSize * (float)(i - 15) + targetPosition.X, this.navMesh.CellSize * (float)(j - 15) + targetPosition.Y); if ((this.navMesh.GetCellFlags(vector) & NavMeshCellFlags.InteractionBlocker) != NavMeshCellFlags.None && new Polygon.Rectangle(targetPosition, Vector3Extensions.Extend2D(base.Owner.Position, targetPosition, num), radius - 100f).IsInside(vector)) { this.castPosition = simplePrediction.CastPosition; return(true); } } } return(false); }
// Token: 0x060009F9 RID: 2553 RVA: 0x0002B730 File Offset: 0x00029930 private void OnUpdate() { try { if (!this.Sleeper.IsSleeping) { Unit9 unit = base.TargetManager.TargetLocked ? base.TargetManager.Target : this.killSteal.Target; if (unit != null && unit.IsValid && unit.IsVisible) { foreach (KeyValuePair <ActiveAbility, float> keyValuePair in this.abilityTimings.ToList <KeyValuePair <ActiveAbility, float> >()) { ActiveAbility ability = keyValuePair.Key; if (ability.IsValid && ability.BaseAbility.IsInAbilityPhase) { Unit9 owner = ability.Owner; float value = keyValuePair.Value; PredictionInput9 predictionInput = ability.GetPredictionInput(unit, null); predictionInput.Delay = Math.Max(value - Game.RawGameTime, 0f) + ability.ActivationDelay; PredictionOutput9 predictionOutput = ability.GetPredictionOutput(predictionInput); Vector3 vector; if (ability is IHasRadius && this.abilityPositions.TryGetValue(ability.Handle, out vector)) { Polygon polygon = null; ActiveAbility ability2 = ability; if (ability2 != null) { AreaOfEffectAbility areaOfEffectAbility; if ((areaOfEffectAbility = (ability2 as AreaOfEffectAbility)) == null) { CircleAbility circleAbility; if ((circleAbility = (ability2 as CircleAbility)) == null) { ConeAbility coneAbility; if ((coneAbility = (ability2 as ConeAbility)) == null) { LineAbility lineAbility; if ((lineAbility = (ability2 as LineAbility)) != null) { LineAbility lineAbility2 = lineAbility; polygon = new Polygon.Rectangle(owner.Position, Vector3Extensions.Extend2D(owner.Position, vector, lineAbility2.Range), lineAbility2.Radius + 50f); } } else { ConeAbility coneAbility2 = coneAbility; polygon = new Polygon.Trapezoid(Vector3Extensions.Extend2D(owner.Position, vector, -coneAbility2.Radius / 2f), Vector3Extensions.Extend2D(owner.Position, vector, coneAbility2.Range), coneAbility2.Radius + 50f, coneAbility2.EndRadius + 100f); } } else { CircleAbility circleAbility2 = circleAbility; polygon = new Polygon.Circle(vector, circleAbility2.Radius + 50f, 20); } } else { AreaOfEffectAbility areaOfEffectAbility2 = areaOfEffectAbility; polygon = new Polygon.Circle(vector, areaOfEffectAbility2.Radius + 50f, 20); } } if (polygon != null && (!unit.IsAlive || predictionOutput.HitChance == null || !polygon.IsInside(predictionOutput.TargetPosition))) { this.Sleeper.Sleep(0.15f); this.abilityTimings.Remove(ability); this.abilityPositions.Remove(ability.Handle); this.OrbwalkSleeper.Reset(ability.Owner.Handle); this.AbilitySleeper.Reset(ability.Handle); this.killSteal.KillStealSleeper.Reset(); unit.RefreshUnitState(); ability.Owner.BaseUnit.Stop(); ControllableUnit controllableUnit = base.BaseHero.UnitManager.AllControllableUnits.FirstOrDefault((ControllableUnit x) => x.Handle == ability.Owner.Handle); if (controllableUnit != null) { controllableUnit.ComboSleeper.Reset(); } } } } } } } } catch (Exception ex) { Logger.Error(ex, null); } }
private void GetAreaOfEffectPrediction(PredictionInput9 input, PredictionOutput9 output) { var targets = new List <PredictionOutput9>(); foreach (var target in input.AreaOfEffectTargets.Where(x => !x.Equals(output.Target))) { var aoeTargetInput = new PredictionInput9 { Target = target, Caster = input.Caster, Delay = input.Delay, Speed = input.Speed, CastRange = input.CastRange, Radius = input.Radius, RequiresToTurn = input.RequiresToTurn }; var aoeTargetOutput = this.GetSimplePrediction(aoeTargetInput); var range = input.SkillShotType == SkillShotType.Line ? input.Range + input.CastRange : input.Range; if (input.Caster.Distance(aoeTargetOutput.CastPosition) < range) { targets.Add(aoeTargetOutput); } } switch (input.SkillShotType) { case SkillShotType.RangedAreaOfEffect: { targets.Insert(0, output); output.CastPosition = input.Target.Position; output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)).ToList(); if (!output.AoeTargetsHit.Contains(output)) { output.AoeTargetsHit.Add(output); } break; } case SkillShotType.AreaOfEffect: { targets.Insert(0, output); output.CastPosition = input.CastRange > 0 ? input.Caster.InFront(input.CastRange) : input.Caster.Position; output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)).ToList(); break; } case SkillShotType.Circle: { targets.Insert(0, output); if (targets.Count == 1) { output.AoeTargetsHit.Add(output); } else { while (targets.Count > 1) { var mecResult = MEC.GetMec(targets.Select(x => x.TargetPosition.ToVector2()).ToList()); if (mecResult.Radius > 0 && mecResult.Radius < input.Radius && input.Caster.Distance(mecResult.Center.ToVector3()) < input.Range) { output.CastPosition = new Vector3( targets.Count <= 2 ? (targets[0].TargetPosition.ToVector2() + targets[1].TargetPosition.ToVector2()) / 2 : mecResult.Center, output.CastPosition.Z); output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)) .ToList(); break; } var itemToRemove = targets.MaxOrDefault(x => targets[0].TargetPosition.DistanceSquared(x.TargetPosition)); targets.Remove(itemToRemove); output.AoeTargetsHit.Add(output); } } break; } case SkillShotType.Cone: { targets.Insert(0, output); if (targets.Count > 1) { // yolo var polygons = new Dictionary <Polygon.Trapezoid, List <PredictionOutput9> >(); if (input.UseBlink) { var targetPosition = output.TargetPosition; var otherTargets = targets.Skip(1).ToList(); foreach (var predictionOutput9 in otherTargets) { var aoeTargetPosition = predictionOutput9.TargetPosition; var averagePosition = (targetPosition + aoeTargetPosition) / 2; var start = targetPosition.Extend2D(aoeTargetPosition, -100); var end = start.Extend2D(aoeTargetPosition, input.Range); var rec = new Polygon.Trapezoid(start, end, input.Radius, input.EndRadius); foreach (var output9 in otherTargets) { if (output9.Target == predictionOutput9.Target) { continue; } var averagePosition2 = (averagePosition + output9.TargetPosition) / 2; var start2 = targetPosition.Extend2D(averagePosition2, -100); var end2 = start2.Extend2D(averagePosition2, input.Range); var rec2 = new Polygon.Trapezoid(start2, end2, input.Radius + 50, input.EndRadius + 50); if (!rec2.IsInside(aoeTargetPosition) || !rec2.IsInside(output9.TargetPosition)) { continue; } rec = rec2; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } else { var startPosition = input.Caster.Position; foreach (var predictionOutput in targets) { var endPosition = startPosition.Extend2D(predictionOutput.TargetPosition, input.Range); var rec = new Polygon.Trapezoid(startPosition, endPosition, input.Radius * 1.4f, input.EndRadius * 1.8f); if (rec.IsOutside(output.TargetPosition.To2D())) { continue; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } var polygon = polygons.MaxOrDefault(x => x.Value.Count); if (polygon.Key != null) { var positions = polygon.Value.ToList(); var center = positions.Aggregate(new Vector3(), (sum, pos) => sum + pos.TargetPosition) / positions.Count; if (positions.Count == 0) { output.HitChance = HitChance.Impossible; return; } var max = positions.Max( x => input.UseBlink ? output.TargetPosition.Distance(x.TargetPosition) : input.Caster.Distance(x.TargetPosition)); var range = Math.Min(input.UseBlink ? input.Range : input.CastRange, max); output.CastPosition = input.UseBlink ? output.TargetPosition.Extend2D(center, range) : input.Caster.Position.Extend2D(center, range); output.AoeTargetsHit = polygon.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = input.Caster.Distance(output.TargetPosition) > input.CastRange ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; } case SkillShotType.Line: { targets.Insert(0, output); if (targets.Count > 1) { // yolo var polygons = new Dictionary <Polygon.Rectangle, List <PredictionOutput9> >(); if (input.UseBlink) { var targetPosition = output.TargetPosition; var otherTargets = targets.Skip(1).ToList(); foreach (var predictionOutput9 in otherTargets) { var aoeTargetPosition = predictionOutput9.TargetPosition; var averagePosition = (targetPosition + aoeTargetPosition) / 2; var start = targetPosition.Extend2D(aoeTargetPosition, -100); var end = start.Extend2D(aoeTargetPosition, input.Range); var rec = new Polygon.Rectangle(start, end, input.Radius); foreach (var output9 in otherTargets) { if (output9.Target == predictionOutput9.Target) { continue; } var averagePosition2 = (averagePosition + output9.TargetPosition) / 2; var start2 = targetPosition.Extend2D(averagePosition2, -100); var end2 = start2.Extend2D(averagePosition2, input.Range); var rec2 = new Polygon.Rectangle(start2, end2, input.Radius + 50); if (!rec2.IsInside(aoeTargetPosition) || !rec2.IsInside(output9.TargetPosition)) { continue; } rec = rec2; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } else { var startPosition = input.Caster.Position; foreach (var predictionOutput in targets) { var endPosition = startPosition.Extend2D(predictionOutput.TargetPosition, input.Range); var rec = new Polygon.Rectangle(startPosition, endPosition, input.Radius * 1.3f); if (rec.IsOutside(output.TargetPosition.To2D())) { continue; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } var polygon = polygons.MaxOrDefault(x => x.Value.Count); if (polygon.Key != null) { var positions = polygon.Value.ToList(); var center = positions.Aggregate(new Vector3(), (sum, pos) => sum + pos.TargetPosition) / positions.Count; if (positions.Count == 0) { output.HitChance = HitChance.Impossible; return; } var max = positions.Max( x => input.UseBlink ? output.TargetPosition.Distance(x.TargetPosition) : input.Caster.Distance(x.TargetPosition)); var range = Math.Min(input.UseBlink ? input.Range : input.CastRange, max); output.CastPosition = input.UseBlink ? output.TargetPosition.Extend2D(center, range) : input.Caster.Position.Extend2D(center, range); output.AoeTargetsHit = polygon.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = input.Caster.Distance(output.TargetPosition) > input.CastRange ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; } } }
public override bool CanHit(TargetManager targetManager, IComboModeMenu comboMenu) { var target = targetManager.Target; var input = this.Ability.GetPredictionInput(target); input.Delay += this.Owner.Distance(target) / this.Ability.Speed; var output = this.Ability.GetPredictionOutput(input); var ownerPosition = this.Owner.Position; this.castPosition = output.CastPosition; var polygon = new Polygon.Rectangle(ownerPosition, this.castPosition, this.timberChain.ChainRadius); var availableTrees = EntityManager9.Trees.Where(x => x.Distance2D(ownerPosition) < this.Ability.CastRange).ToArray(); foreach (var tree in availableTrees) { if (polygon.IsInside(tree.Position)) { return(false); } } var chainEndPosition = ownerPosition.Extend2D(this.castPosition, this.Ability.CastRange); polygon = new Polygon.Rectangle(this.castPosition, chainEndPosition, this.timberChain.Radius); foreach (var tree in availableTrees) { if (polygon.IsInside(tree.Position)) { this.castPosition = tree.Position; return(true); } } if (this.Ability.Level < 4 || ownerPosition.Distance2D(this.castPosition) < 400) { return(false); } foreach (var tree in availableTrees.OrderBy(x => x.Distance2D(this.castPosition))) { var treePosition = tree.Position; if (treePosition.Distance2D(this.castPosition) > 500 && target.GetAngle(treePosition) > 0.75f) { continue; } if (ownerPosition.Distance2D(this.castPosition) < treePosition.Distance2D(this.castPosition)) { continue; } polygon = new Polygon.Rectangle(ownerPosition, treePosition, this.timberChain.ChainRadius); if (availableTrees.Any(x => !x.Equals(tree) && polygon.IsInside(x.Position))) { continue; } this.castPosition = treePosition; return(true); } return(false); }
// Token: 0x0600004A RID: 74 RVA: 0x0000FBAC File Offset: 0x0000DDAC private void GetAreaOfEffectPrediction(PredictionInput9 input, PredictionOutput9 output) { List <PredictionOutput9> targets = new List <PredictionOutput9>(); IEnumerable <Unit9> areaOfEffectTargets = input.AreaOfEffectTargets; Func <Unit9, bool> < > 9__2; Func <Unit9, bool> predicate; if ((predicate = < > 9__2) == null) { predicate = (< > 9__2 = ((Unit9 x) => !x.Equals(output.Target))); } foreach (Unit9 target in areaOfEffectTargets.Where(predicate)) { PredictionInput9 input2 = new PredictionInput9 { Target = target, Caster = input.Caster, Delay = input.Delay, Speed = input.Speed, CastRange = input.CastRange, Radius = input.Radius, RequiresToTurn = input.RequiresToTurn }; PredictionOutput9 simplePrediction = this.GetSimplePrediction(input2); float num = (input.SkillShotType == SkillShotType.Line) ? (input.Range + input.CastRange) : input.Range; if (input.Caster.Distance(simplePrediction.CastPosition) < num) { targets.Add(simplePrediction); } } switch (input.SkillShotType) { case SkillShotType.AreaOfEffect: targets.Insert(0, output); output.CastPosition = ((input.CastRange > 0f) ? input.Caster.InFront(input.CastRange, 0f, true) : input.Caster.Position); output.AoeTargetsHit = (from x in targets where output.CastPosition.IsInRange(x.TargetPosition, input.Radius) select x).ToList <PredictionOutput9>(); return; case SkillShotType.RangedAreaOfEffect: targets.Insert(0, output); output.CastPosition = input.Target.Position; output.AoeTargetsHit = (from x in targets where output.CastPosition.IsInRange(x.TargetPosition, input.Radius) select x).ToList <PredictionOutput9>(); if (!output.AoeTargetsHit.Contains(output)) { output.AoeTargetsHit.Add(output); return; } break; case SkillShotType.Line: targets.Insert(0, output); if (targets.Count > 1) { Dictionary <Polygon.Rectangle, List <PredictionOutput9> > dictionary = new Dictionary <Polygon.Rectangle, List <PredictionOutput9> >(); if (input.UseBlink) { Vector3 targetPosition = output.TargetPosition; List <PredictionOutput9> list = targets.Skip(1).ToList <PredictionOutput9>(); using (List <PredictionOutput9> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { PredictionOutput9 predictionOutput = enumerator2.Current; Vector3 targetPosition2 = predictionOutput.TargetPosition; Vector3 vector = (targetPosition + targetPosition2) / 2f; Vector3 vector2 = targetPosition.Extend2D(targetPosition2, -100f); Vector3 end = vector2.Extend2D(targetPosition2, input.Range); Polygon.Rectangle rec = new Polygon.Rectangle(vector2, end, input.Radius); foreach (PredictionOutput9 predictionOutput2 in list) { if (!(predictionOutput2.Target == predictionOutput.Target)) { Vector3 to = (vector + predictionOutput2.TargetPosition) / 2f; Vector3 vector3 = targetPosition.Extend2D(to, -100f); Vector3 end2 = vector3.Extend2D(to, input.Range); Polygon.Rectangle rectangle = new Polygon.Rectangle(vector3, end2, input.Radius + 50f); if (rectangle.IsInside(targetPosition2) && rectangle.IsInside(predictionOutput2.TargetPosition)) { rec = rectangle; } } } dictionary[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } goto IL_C36; } } Vector3 position = input.Caster.Position; foreach (PredictionOutput9 predictionOutput3 in targets) { Vector3 end3 = position.Extend2D(predictionOutput3.TargetPosition, input.Range); Polygon.Rectangle rec = new Polygon.Rectangle(position, end3, input.Radius * 1.3f); if (!rec.IsOutside(output.TargetPosition.To2D())) { dictionary[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } } IL_C36: KeyValuePair <Polygon.Rectangle, List <PredictionOutput9> > keyValuePair = dictionary.MaxOrDefault((KeyValuePair <Polygon.Rectangle, List <PredictionOutput9> > x) => x.Value.Count); if (keyValuePair.Key != null) { List <PredictionOutput9> list2 = keyValuePair.Value.ToList <PredictionOutput9>(); Vector3 to2 = list2.Aggregate(default(Vector3), (Vector3 sum, PredictionOutput9 pos) => sum + pos.TargetPosition) / (float)list2.Count; if (list2.Count == 0) { output.HitChance = HitChance.Impossible; return; } float val = list2.Max(delegate(PredictionOutput9 x) { if (!input.UseBlink) { return(input.Caster.Distance(x.TargetPosition)); } return(output.TargetPosition.Distance(x.TargetPosition)); }); float distance = Math.Min(input.UseBlink ? input.Range : input.CastRange, val); output.CastPosition = (input.UseBlink ? output.TargetPosition.Extend2D(to2, distance) : input.Caster.Position.Extend2D(to2, distance)); output.AoeTargetsHit = keyValuePair.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = ((input.Caster.Distance(output.TargetPosition) > input.CastRange) ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100f)); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; case SkillShotType.Circle: { targets.Insert(0, output); if (targets.Count == 1) { output.AoeTargetsHit.Add(output); return; } Func <PredictionOutput9, bool> < > 9__4; Func <PredictionOutput9, float> < > 9__5; while (targets.Count > 1) { MEC.MecCircle mec = MEC.GetMec((from x in targets select x.TargetPosition.ToVector2()).ToList <Vector2>()); if (mec.Radius > 0f && mec.Radius < input.Radius && input.Caster.Distance(mec.Center.ToVector3(0f)) < input.Range) { output.CastPosition = new Vector3((targets.Count <= 2) ? ((targets[0].TargetPosition.ToVector2() + targets[1].TargetPosition.ToVector2()) / 2f) : mec.Center, output.CastPosition.Z); PredictionOutput9 output2 = output; IEnumerable <PredictionOutput9> targets3 = targets; Func <PredictionOutput9, bool> predicate2; if ((predicate2 = < > 9__4) == null) { predicate2 = (< > 9__4 = ((PredictionOutput9 x) => output.CastPosition.IsInRange(x.TargetPosition, input.Radius))); } output2.AoeTargetsHit = targets3.Where(predicate2).ToList <PredictionOutput9>(); return; } IEnumerable <PredictionOutput9> targets2 = targets; Func <PredictionOutput9, float> comparer; if ((comparer = < > 9__5) == null) { comparer = (< > 9__5 = ((PredictionOutput9 x) => targets[0].TargetPosition.DistanceSquared(x.TargetPosition))); } PredictionOutput9 item = targets2.MaxOrDefault(comparer); targets.Remove(item); output.AoeTargetsHit.Add(output); } return; } case SkillShotType.Cone: targets.Insert(0, output); if (targets.Count > 1) { Dictionary <Polygon.Trapezoid, List <PredictionOutput9> > dictionary2 = new Dictionary <Polygon.Trapezoid, List <PredictionOutput9> >(); if (input.UseBlink) { Vector3 targetPosition3 = output.TargetPosition; List <PredictionOutput9> list3 = targets.Skip(1).ToList <PredictionOutput9>(); using (List <PredictionOutput9> .Enumerator enumerator2 = list3.GetEnumerator()) { while (enumerator2.MoveNext()) { PredictionOutput9 predictionOutput4 = enumerator2.Current; Vector3 targetPosition4 = predictionOutput4.TargetPosition; Vector3 vector4 = (targetPosition3 + targetPosition4) / 2f; Vector3 vector5 = targetPosition3.Extend2D(targetPosition4, -100f); Vector3 end4 = vector5.Extend2D(targetPosition4, input.Range); Polygon.Trapezoid rec = new Polygon.Trapezoid(vector5, end4, input.Radius, input.EndRadius); foreach (PredictionOutput9 predictionOutput5 in list3) { if (!(predictionOutput5.Target == predictionOutput4.Target)) { Vector3 to3 = (vector4 + predictionOutput5.TargetPosition) / 2f; Vector3 vector6 = targetPosition3.Extend2D(to3, -100f); Vector3 end5 = vector6.Extend2D(to3, input.Range); Polygon.Trapezoid trapezoid = new Polygon.Trapezoid(vector6, end5, input.Radius + 50f, input.EndRadius + 50f); if (trapezoid.IsInside(targetPosition4) && trapezoid.IsInside(predictionOutput5.TargetPosition)) { rec = trapezoid; } } } dictionary2[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } goto IL_751; } } Vector3 position2 = input.Caster.Position; foreach (PredictionOutput9 predictionOutput6 in targets) { Vector3 end6 = position2.Extend2D(predictionOutput6.TargetPosition, input.Range); Polygon.Trapezoid rec = new Polygon.Trapezoid(position2, end6, input.Radius * 1.4f, input.EndRadius * 1.8f); if (!rec.IsOutside(output.TargetPosition.To2D())) { dictionary2[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } } IL_751: KeyValuePair <Polygon.Trapezoid, List <PredictionOutput9> > keyValuePair2 = dictionary2.MaxOrDefault((KeyValuePair <Polygon.Trapezoid, List <PredictionOutput9> > x) => x.Value.Count); if (keyValuePair2.Key != null) { List <PredictionOutput9> list4 = keyValuePair2.Value.ToList <PredictionOutput9>(); Vector3 to4 = list4.Aggregate(default(Vector3), (Vector3 sum, PredictionOutput9 pos) => sum + pos.TargetPosition) / (float)list4.Count; if (list4.Count == 0) { output.HitChance = HitChance.Impossible; return; } float val2 = list4.Max(delegate(PredictionOutput9 x) { if (!input.UseBlink) { return(input.Caster.Distance(x.TargetPosition)); } return(output.TargetPosition.Distance(x.TargetPosition)); }); float distance2 = Math.Min(input.UseBlink ? input.Range : input.CastRange, val2); output.CastPosition = (input.UseBlink ? output.TargetPosition.Extend2D(to4, distance2) : input.Caster.Position.Extend2D(to4, distance2)); output.AoeTargetsHit = keyValuePair2.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = ((input.Caster.Distance(output.TargetPosition) > input.CastRange) ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100f)); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; return; } } break; default: return; } }