private void Check(DetectedSkillshotData skillshot) { if (skillshot == null) { return; } var coll = skillshot.Data.Collisions; var targets = new List <Vector2>(); if (coll.Contains(Collision.Caster) && skillshot.IsInside(skillshot.Caster) && skillshot.GetHealthPrediction(skillshot.Caster) > 0) { targets.Add(skillshot.Caster.ServerPosition.To2D().Extend(skillshot.Start, skillshot.Caster.BoundingRadius - 35)); } if (coll.Contains(Collision.Heros)) { targets.AddRange(EntityManager.Heroes.AllHeroes.FindAll(h => !h.IsMe && h.IsValidTarget() && h.Team != skillshot.Caster.Team && skillshot.IsInside(h) && skillshot.GetHealthPrediction(h) > 0) .Select(h => h.ServerPosition.To2D().Extend(skillshot.Start, h.BoundingRadius - 35))); } if (coll.Contains(Collision.Minions)) { targets.AddRange(EntityManager.MinionsAndMonsters.Combined.Where(h => !h.IsMe && h.IsValidTarget() && h.Team != skillshot.Caster.Team && skillshot.IsInside(h) && skillshot.GetHealthPrediction(h) > 1). Select(h => h.ServerPosition.To2D().Extend(skillshot.Start, h.BoundingRadius - 35))); } if (coll.Contains(Collision.YasuoWall)) { var collidePoint = skillshot.CurrentPosition.GetYasuoWallCollision(skillshot.EndPosition, false, true); if (collidePoint.IsValid()) { targets.Add(collidePoint.To2D()); } } if (coll.Contains(Collision.Walls)) { targets.AddRange(this.CellsAnalyze(skillshot.CurrentPosition, skillshot.generatePolygon2()).Select(c => c.WorldPosition.To2D())); } if (!targets.Any()) { return; } var orderPoints = targets.OrderBy(t => t.Distance(skillshot.Start)).ToArray(); var multiCollide = skillshot.Data.CollideCount > 0; Vector2 collisionPoint = orderPoints[multiCollide && targets.Count > skillshot.Data.CollideCount + 1 ? skillshot.Data.CollideCount : 0]; Vector2 extendToCollidePoint = skillshot.Start.Extend(skillshot.EndPosition, skillshot.Start.Distance(collisionPoint)); this.CorrectCollidePoint = collisionPoint; this.CollidePoint = extendToCollidePoint; }
internal static void Add(DetectedSkillshotData data) { if (data == null) { Console.WriteLine("Invalid DetectedSkillshot"); return; } if (data.Data.IsTrap && SkillshotsDetected.Any(x => x.Trap != null && data.Trap.Equals(x.Trap))) { return; } if (data.Missile == null && data.Data.DetectByMissile) { return; } if (data.Data.type == Type.Cone) { if (SkillshotsDetected.Any(s => s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data))) { return; } } if (!data.Data.AllowDuplicates) { if (SkillshotsDetected.Any(s => s.Missile != null && data.Missile == null && s.Caster != null && data.Caster != null && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data))) { // Already Detected by Missile return; } var replaceByMissile = SkillshotsDetected.FirstOrDefault(s => s.Missile == null && data.Missile != null && s.Caster != null && data.Caster != null && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data)); if (replaceByMissile != null && data.Missile != null && !(data.Data.StaticStart && data.Data.StaticEnd)) { // Add the Missile replaceByMissile.Missile = data.Missile; replaceByMissile.End = data.Missile.EndPosition.To2D(); replaceByMissile.Start = data.Missile.StartPosition.To2D(); return; } if (SkillshotsDetected.Any(s => s.Caster != null && !s.DetectedByMissile && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data))) { return; } } if (data.Data.StaticStart && data.Data.StaticEnd && data.Missile == null) { var start = data.Start; var end = data.End; data.Start = end - (end - start).Normalized().Perpendicular() * (data.Range / 2); data.End = end + (end - start).Normalized().Perpendicular() * (data.Range / 2); } if (data.Data.IsSpellName("YorickE")) { var start = data.End.Extend(data.Start, 200); var end = data.End.Extend(data.Start, -450); data.Start = start; data.End = end; } if (data.Data.CasterNames.Length == 3 && data.Data.type == Type.CircleMissile) { var obj = ObjectManager.Get <Obj_AI_Base>().FirstOrDefault(o => o.IsValid && !o.IsDead && o.Team == data.Caster.Team && data.Data.CasterNames[1].Equals(o.BaseSkinName) && data.Data.CasterNames[2].Equals(o.Model)); if (obj != null) { data.Start = obj.ServerPosition.To2D(); data.End = obj.ServerPosition.To2D(); } } if (data.Data.IsSpellName("JarvanIVDragonStrike")) { var jarvanFlag = ObjectManager.Get <Obj_AI_Base>().OrderBy(o => o.Distance(data.EndPosition)).FirstOrDefault(o => o.BaseSkinName.Equals("JarvanIVStandard") && o.Team == data.Caster.Team && o.IsValid && data.IsInside(o)); if (jarvanFlag != null) { var jarvanEQData = SkillshotDatabase.Current.FirstOrDefault(s => s.IsSpellName("JarvanIVEQ")); if (jarvanEQData != null) { var jarvanEQ = new DetectedSkillshotData { Data = jarvanEQData, Start = data.Start, End = jarvanFlag.ServerPosition.To2D(), Caster = data.Caster, StartTick = Core.GameTickCount, }; Add(jarvanEQ); return; } } } if (data.Data.DecaySpeedWithLessRange) { data.Speed = data.Data.Speed * (data.Start.Distance(data.EndPosition) / data.Data.Range); } data.DetectedByMissile = data.Missile != null; data.FromFOW = !data.Caster.IsHPBarRendered; data.Update(); SkillshotsDetected.Add(data); OnSkillShotDetected.Invoke(data); if (data.Data.IsSpellName("SyndraE")) { var qeData = SkillshotDatabase.Current.FirstOrDefault(s => s.IsSpellName("SyndraEQ")); if (qeData != null) { var syndraBalls = ObjectManager.Get <Obj_AI_Base>().Where(o => o.BaseSkinName.Equals("SyndraSphere") && o.Team == data.Caster.Team && data.IsInside(o) && o.IsValid && o.Mana > 17.5); foreach (var ball in syndraBalls) { var newDetect = new DetectedSkillshotData { Caster = data.Caster, Start = ball.ServerPosition.To2D(), End = data.Start.Extend(ball.ServerPosition.To2D(), qeData.Range), Data = qeData, StartTick = Core.GameTickCount, extraDelay = data.TravelTime(ball) }; newDetect.Update(); SkillshotsDetected.Add(newDetect); OnSkillShotDetected.Invoke(newDetect); } } } }