public static bool LineIntersectLinearSpellEx(this Spell spell, Vector2 a, Vector2 b, out Vector2 intersection) //edited { var myBoundingRadius = ObjectManager.Player.BoundingRadius; var spellDir = spell.Direction; var pSpellDir = spell.Direction.Perpendicular(); var spellRadius = spell.Radius; var spellPos = spell.CurrentSpellPosition - spellDir * myBoundingRadius; //leave some space at back of spell var endPos = spell.GetSpellEndPosition() + spellDir * myBoundingRadius; //leave some space at the front of spell var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius); var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius); var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius); var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius); List <Geometry.IntersectionResult> intersects = new List <Geometry.IntersectionResult>(); Vector2 heroPos = ObjectManager.Player.ServerPosition.To2D(); intersects.Add(a.Intersection(b, startRightPos, startLeftPos)); intersects.Add(a.Intersection(b, endRightPos, endLeftPos)); intersects.Add(a.Intersection(b, startRightPos, endRightPos)); intersects.Add(a.Intersection(b, startLeftPos, endLeftPos)); var sortedIntersects = intersects.Where(i => i.Intersects).OrderBy(i => i.Point.Distance(heroPos)); //Get first intersection if (sortedIntersects.Count() > 0) { intersection = sortedIntersects.First().Point; return(true); } intersection = Vector2.Zero; return(false); }
public static bool LineIntersectLinearSpell(this Spell spell, Vector2 a, Vector2 b) { var myBoundingRadius = ObjectManager.Player.BoundingRadius; var spellDir = spell.Direction; var pSpellDir = spell.Direction.Perpendicular(); var spellRadius = spell.Radius; var spellPos = spell.CurrentSpellPosition; // -spellDir * myBoundingRadius; //leave some space at back of spell var endPos = spell.GetSpellEndPosition(); // +spellDir * myBoundingRadius; //leave some space at the front of spell var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius); var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius); var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius); var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius); bool int1 = MathUtils.CheckLineIntersection(a, b, startRightPos, startLeftPos); bool int2 = MathUtils.CheckLineIntersection(a, b, endRightPos, endLeftPos); bool int3 = MathUtils.CheckLineIntersection(a, b, startRightPos, endRightPos); bool int4 = MathUtils.CheckLineIntersection(a, b, startLeftPos, endLeftPos); if (int1 || int2 || int3 || int4) { return(true); } return(false); }
public static bool InSkillShot(this Vector2 position, Spell spell, float radius, bool predictCollision = true) { if (spell.SpellType == SpellType.Line) { Vector2 spellPos = spell.CurrentSpellPosition; Vector2 spellEndPos = predictCollision ? spell.GetSpellEndPosition() : spell.EndPos; //spellPos = spellPos - spell.direction * radius; //leave some space at back of spell //spellEndPos = spellEndPos + spell.direction * radius; //leave some space at the front of spell /*if (spell.info.projectileSpeed == float.MaxValue * && Evade.GetTickCount - spell.startTime > spell.info.spellDelay) * { * return false; * }*/ var projection = position.ProjectOn(spellPos, spellEndPos); /*if (projection.SegmentPoint.Distance(spellEndPos) < 100) //Check Skillshot endpoints * { * //unfinished * }*/ return(projection.IsOnSegment && projection.SegmentPoint.Distance(position) <= spell.Radius + radius); } else if (spell.SpellType == SpellType.Circular) { if (spell.Info.SpellName == "VeigarEventHorizon") { return(position.Distance(spell.EndPos) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius && position.Distance(spell.EndPos) >= spell.Radius + radius - GameData.HeroInfo.BoundingRadius - 125); } return(position.Distance(spell.EndPos) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius); } else if (spell.SpellType == SpellType.Arc) { if (position.IsLeftOfLineSegment(spell.StartPos, spell.EndPos)) { return(false); } var spellRange = spell.StartPos.Distance(spell.EndPos); var midPoint = spell.StartPos + spell.Direction * (spellRange / 2); return(position.Distance(midPoint) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius); } else if (spell.SpellType == SpellType.Cone) { } return(false); }
public static bool CanHeroWalkIntoSpell(Spell spell) { if (ConfigValue.AdvancedSpellDetection.GetBool()) { Vector2 heroPos = MyHero.Position.To2D(); var extraDist = MyHero.Distance(GameData.HeroInfo.ServerPos2D); if (spell.SpellType == SpellType.Line) { var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + spell.Info.Radius + extraDist + 10; var spellPos = spell.CurrentSpellPosition; var spellEndPos = spell.GetSpellEndPosition(); var projection = heroPos.ProjectOn(spellPos, spellEndPos); return(projection.SegmentPoint.Distance(heroPos) <= walkRadius); } else if (spell.SpellType == SpellType.Circular) { var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + spell.Info.Radius + extraDist + 10; if (heroPos.Distance(spell.EndPos) < walkRadius) { return(true); } } else if (spell.SpellType == SpellType.Arc) { var spellRange = spell.StartPos.Distance(spell.EndPos); var midPoint = spell.StartPos + spell.Direction * (spellRange / 2); var arcRadius = spell.Info.Radius * (1 + spellRange / 100); var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + arcRadius + extraDist + 10; if (heroPos.Distance(midPoint) < walkRadius) { return(true); } } return(false); } return(true); }
public static BoundingBox GetLinearSpellBoundingBox(this Spell spell) { var myBoundingRadius = GameData.HeroInfo.BoundingRadius; var spellDir = spell.Direction; var pSpellDir = spell.Direction.Perpendicular(); var spellRadius = spell.Radius; var spellPos = spell.CurrentSpellPosition - spellDir * myBoundingRadius; //leave some space at back of spell var endPos = spell.GetSpellEndPosition() + spellDir * myBoundingRadius; //leave some space at the front of spell var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius); var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius); return(new BoundingBox(new Vector3(endLeftPos.X, endLeftPos.Y, -1), new Vector3(startRightPos.X, startRightPos.Y, 1))); }
public static Vector2 GetSpellProjection(this Spell spell, Vector2 pos, bool predictPos = false) { if (spell.SpellType == SpellType.Line || spell.SpellType == SpellType.Arc) { if (predictPos) { var spellPos = spell.CurrentSpellPosition; var spellEndPos = spell.GetSpellEndPosition(); return(pos.ProjectOn(spellPos, spellEndPos).SegmentPoint); } return(pos.ProjectOn(spell.StartPos, spell.EndPos).SegmentPoint); } if (spell.SpellType == SpellType.Circular) { return(spell.EndPos); } return(Vector2.Zero); }
public static bool InSkillShot(this Vector2 position, Spell spell, float radius, bool predictCollision = true) { if (spell.SpellType == SpellType.Line) { Vector2 spellPos = spell.CurrentSpellPosition; Vector2 spellEndPos = predictCollision ? spell.GetSpellEndPosition() : spell.EndPos; //spellPos = spellPos - spell.direction * radius; //leave some space at back of spell //spellEndPos = spellEndPos + spell.direction * radius; //leave some space at the front of spell /*if (spell.info.projectileSpeed == float.MaxValue && Evade.GetTickCount - spell.startTime > spell.info.spellDelay) { return false; }*/ var projection = position.ProjectOn(spellPos, spellEndPos); /*if (projection.SegmentPoint.Distance(spellEndPos) < 100) //Check Skillshot endpoints { //unfinished }*/ return projection.IsOnSegment && projection.SegmentPoint.Distance(position) <= spell.Radius + radius; } else if (spell.SpellType == SpellType.Circular) { if (spell.Info.SpellName == "VeigarEventHorizon") { return position.Distance(spell.EndPos) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius && position.Distance(spell.EndPos) >= spell.Radius + radius - GameData.HeroInfo.BoundingRadius - 125; } return position.Distance(spell.EndPos) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius; } else if (spell.SpellType == SpellType.Arc) { if (position.IsLeftOfLineSegment(spell.StartPos, spell.EndPos)) { return false; } var spellRange = spell.StartPos.Distance(spell.EndPos); var midPoint = spell.StartPos + spell.Direction * (spellRange/2); return position.Distance(midPoint) <= spell.Radius + radius - GameData.HeroInfo.BoundingRadius; } else if (spell.SpellType == SpellType.Cone) { } return false; }
private void Drawing_OnDraw(EventArgs args) { if (ConfigValue.DrawEvadePosition.GetBool()) { //Render.Circle.DrawCircle(myHero.Position.ExtendDir(dir, 500), 65, Color.Red, 10); /*foreach (var point in myHero.Path) * { * Render.Circle.DrawCircle(point, 65, Color.Red, 10); * }*/ if (Evade.LastPosInfo != null) { var pos = Evade.LastPosInfo.Position; //Evade.lastEvadeCommand.targetPosition; Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, MyHero.Position.Z), 65, Color.Red, 10); } } //DrawPlayerPath(); DrawEvadeStatus(); if (!ConfigValue.DrawSkillShots.GetBool()) { return; } foreach (KeyValuePair <int, Spell> entry in SpellDetector.DrawSpells) { Spell spell = entry.Value; var width = 0; switch (spell.Dangerlevel) { case SpellDangerLevel.Low: width = ConfigValue.LowDangerDrawWidth.GetInt(); break; case SpellDangerLevel.Normal: width = ConfigValue.NormalDangerDrawWidth.GetInt(); break; case SpellDangerLevel.High: width = ConfigValue.HighDangerDrawWidth.GetInt(); break; case SpellDangerLevel.Extreme: width = ConfigValue.ExtremeDangerDrawWidth.GetInt(); break; } if (Config.Properties.GetSpell(spell.Info.SpellName).Draw) { if (spell.SpellType == SpellType.Line) { Vector2 spellPos = spell.CurrentSpellPosition; Vector2 spellEndPos = spell.GetSpellEndPosition(); DrawLineRectangle(spellPos, spellEndPos, (int)spell.Radius, width, GetSpellColor(spell.Dangerlevel)); /*foreach (var hero in ObjectManager.Get<AIHeroClient>()) * { * Render.Circle.DrawCircle(new Vector3(hero.ServerPosition.X, hero.ServerPosition.Y, myHero.Position.Z), (int)spell.radius, Color.Red, 5); * }*/ if (ConfigValue.DrawSpellPosition.GetBool() && spell.SpellObject != null) { //spellPos = SpellDetector.GetCurrentSpellPosition(spell, true, ObjectCache.gamePing); /*if (true) * { * var spellPos2 = spell.startPos + spell.direction * spell.info.projectileSpeed * (Evade.GetTickCount - spell.startTime - spell.info.spellDelay) / 1000 + spell.direction * spell.info.projectileSpeed * ((float)ObjectCache.gamePing / 1000); * Render.Circle.DrawCircle(new Vector3(spellPos2.X, spellPos2.Y, myHero.Position.Z), (int)spell.radius, Color.Red, 8); * }*/ /*if (spell.spellObject != null && spell.spellObject.IsValid && spell.spellObject.IsVisible && * spell.spellObject.Position.To2D().Distance(ObjectCache.myHeroCache.serverPos2D) < spell.info.range + 1000)*/ Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, MyHero.Position.Z), (int)spell.Radius, GetSpellColor(spell.Dangerlevel), width); } } else if (spell.SpellType == SpellType.Circular) { Render.Circle.DrawCircle(new Vector3(spell.EndPos.X, spell.EndPos.Y, spell.Height), (int)spell.Radius, GetSpellColor(spell.Dangerlevel), width); if (spell.Info.SpellName == "VeigarEventHorizon") { Render.Circle.DrawCircle(new Vector3(spell.EndPos.X, spell.EndPos.Y, spell.Height), (int)spell.Radius - 125, GetSpellColor(spell.Dangerlevel), width); } } else if (spell.SpellType == SpellType.Arc) { /*var spellRange = spell.startPos.Distance(spell.endPos); * var midPoint = spell.startPos + spell.direction * (spellRange / 2); * * Render.Circle.DrawCircle(new Vector3(midPoint.X, midPoint.Y, myHero.Position.Z), (int)spell.radius, spellDrawingConfig.Color, spellDrawingWidth); * * Drawing.DrawLine(Drawing.WorldToScreen(spell.startPos.To3D()), * Drawing.WorldToScreen(spell.endPos.To3D()), * spellDrawingWidth, spellDrawingConfig.Color);*/ } else if (spell.SpellType == SpellType.Cone) { } } } }
public static bool CanHeroWalkIntoSpell(Spell spell) { if (ConfigValue.AdvancedSpellDetection.GetBool()) { Vector2 heroPos = MyHero.Position.To2D(); var extraDist = MyHero.Distance(GameData.HeroInfo.ServerPos2D); if (spell.SpellType == SpellType.Line) { var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + spell.Info.Radius + extraDist + 10; var spellPos = spell.CurrentSpellPosition; var spellEndPos = spell.GetSpellEndPosition(); var projection = heroPos.ProjectOn(spellPos, spellEndPos); return projection.SegmentPoint.Distance(heroPos) <= walkRadius; } else if (spell.SpellType == SpellType.Circular) { var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + spell.Info.Radius + extraDist + 10; if (heroPos.Distance(spell.EndPos) < walkRadius) { return true; } } else if (spell.SpellType == SpellType.Arc) { var spellRange = spell.StartPos.Distance(spell.EndPos); var midPoint = spell.StartPos + spell.Direction * (spellRange / 2); var arcRadius = spell.Info.Radius * (1 + spellRange / 100); var walkRadius = GameData.HeroInfo.MoveSpeed * (spell.EndTime - EvadeUtils.TickCount) / 1000 + GameData.HeroInfo.BoundingRadius + arcRadius + extraDist + 10; if (heroPos.Distance(midPoint) < walkRadius) { return true; } } return false; } return true; }
public static float GetClosestDistanceApproach(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist) { var walkDir = (pos - heroPos).Normalized(); if (spell.SpellType == SpellType.Line && spell.Info.ProjectileSpeed != float.MaxValue) { var spellPos = spell.GetCurrentSpellPosition(true, delay); var spellStartPos = spell.CurrentSpellPosition; var spellEndPos = spell.GetSpellEndPosition(); var extendedPos = pos.ExtendDir(walkDir, GameData.HeroInfo.BoundingRadius + speed * delay / 1000); Vector2 cHeroPos; Vector2 cSpellPos; var cpa2 = MathUtils.GetCollisionDistanceEx( heroPos, walkDir * speed, GameData.HeroInfo.BoundingRadius, spellPos, spell.Direction * spell.Info.ProjectileSpeed, spell.Radius + extraDist, out cHeroPos, out cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); var cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment && cpa2 != float.MaxValue) { return 0; } var cpa = MathUtilsCpa.CPAPointsEx(heroPos, walkDir * speed, spellPos, spell.Direction * spell.Info.ProjectileSpeed, pos, spellEndPos, out cHeroPos, out cSpellPos); cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); var checkDist = GameData.HeroInfo.BoundingRadius + spell.Radius + extraDist; if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return Math.Max(0, cpa - checkDist); } else { return checkDist; } //return MathUtils.ClosestTimeOfApproach(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed); } else if (spell.SpellType == SpellType.Line && spell.Info.ProjectileSpeed == float.MaxValue) { var spellHitTime = Math.Max(0, spell.EndTime - EvadeUtils.TickCount - delay); //extraDelay var walkRange = heroPos.Distance(pos); var predictedRange = speed * (spellHitTime / 1000); var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos var projection = tHeroPos.ProjectOn(spell.StartPos, spell.EndPos); return Math.Max(0, tHeroPos.Distance(projection.SegmentPoint) - (spell.Radius + GameData.HeroInfo.BoundingRadius + extraDist)); //+ dodgeBuffer } else if (spell.SpellType == SpellType.Circular) { var spellHitTime = Math.Max(0, spell.EndTime - EvadeUtils.TickCount - delay); //extraDelay var walkRange = heroPos.Distance(pos); var predictedRange = speed * (spellHitTime / 1000); var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos if (spell.Info.SpellName == "VeigarEventHorizon") { var wallRadius = 65; var midRadius = spell.Radius - wallRadius; if (spellHitTime == 0) { return 0; } if (tHeroPos.Distance(spell.EndPos) >= spell.Radius) { return Math.Max(0, tHeroPos.Distance(spell.EndPos) - midRadius - wallRadius); } else { return Math.Max(0, midRadius - tHeroPos.Distance(spell.EndPos) - wallRadius); } } var closestDist = Math.Max(0, tHeroPos.Distance(spell.EndPos) - (spell.Radius + extraDist)); if (spell.Info.ExtraEndTime > 0 && closestDist != 0) { var remainingTime = Math.Max(0, spell.EndTime + spell.Info.ExtraEndTime - EvadeUtils.TickCount - delay); var predictedRange2 = speed * (remainingTime / 1000); var tHeroPos2 = heroPos + walkDir * Math.Min(predictedRange2, walkRange); if (CheckMoveToDirection(tHeroPos, tHeroPos2)) { return 0; } } else { return closestDist; } } else if (spell.SpellType == SpellType.Arc) { var spellPos = spell.GetCurrentSpellPosition(true, delay); var spellEndPos = spell.GetSpellEndPosition(); var pDir = spell.Direction.Perpendicular(); spellPos = spellPos - pDir * spell.Radius / 2; spellEndPos = spellEndPos - pDir * spell.Radius / 2; var extendedPos = pos.ExtendDir(walkDir, GameData.HeroInfo.BoundingRadius); Vector2 cHeroPos; Vector2 cSpellPos; var cpa = MathUtilsCpa.CPAPointsEx(heroPos, walkDir * speed, spellPos, spell.Direction * spell.Info.ProjectileSpeed, pos, spellEndPos, out cHeroPos, out cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); var cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); var checkDist = spell.Radius + extraDist; if (cHeroPos.InSkillShot(spell, GameData.HeroInfo.BoundingRadius)) { if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return Math.Max(0, cpa - checkDist); } else { return checkDist; } } } return 1; }