public static PositionInfo CanHeroWalkToPos(Vector2 pos, float speed, float delay, float extraDist, bool useServerPosition = true) { int posDangerLevel = 0; int posDangerCount = 0; float closestDistance = float.MaxValue; List<int> dodgeableSpells = new List<int>(); List<int> undodgeableSpells = new List<int>(); Vector2 heroPos = ObjectCache.myHeroCache.serverPos2D; var minComfortDistance = ObjectCache.menuCache.cache["MinComfortZone"].Cast<Slider>().CurrentValue; if (useServerPosition == false) { heroPos = myHero.Position.LSTo2D(); } foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells) { Spell spell = entry.Value; var moveBuff = EvadeSpell.evadeSpells.OrderBy(s => s.dangerlevel).FirstOrDefault(s => s.evadeType == EvadeType.MovementSpeedBuff); if (moveBuff != null && EvadeSpell.ShouldUseMovementBuff(spell)) { speed += speed * moveBuff.speedArray[myHero.GetSpell(moveBuff.spellKey).Level - 1] / 100; } closestDistance = Math.Min(closestDistance, GetClosestDistanceApproach(spell, pos, speed, delay, heroPos, extraDist)); if (pos.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius - 6) || PredictSpellCollision(spell, pos, speed, delay, heroPos, extraDist, useServerPosition) || (spell.info.spellType != SpellType.Line && pos.isNearEnemy(minComfortDistance))) { posDangerLevel = Math.Max(posDangerLevel, spell.dangerlevel); posDangerCount += spell.dangerlevel; undodgeableSpells.Add(spell.spellID); } else { dodgeableSpells.Add(spell.spellID); } } return new PositionInfo( pos, posDangerLevel, posDangerCount, posDangerCount > 0, closestDistance, dodgeableSpells, undodgeableSpells); }
public static PositionInfo CanHeroWalkToPos(Vector2 pos, float speed, float delay, float extraDist, bool useServerPosition = true) { int posDangerLevel = 0; int posDangerCount = 0; float closestDistance = float.MaxValue; List<int> dodgeableSpells = new List<int>(); List<int> undodgeableSpells = new List<int>(); Vector2 heroPos = ObjectCache.myHeroCache.serverPos2D; var minComfortDistance = ObjectCache.menuCache.cache["MinComfortZone"].GetValue<Slider>().Value; if (useServerPosition == false) { heroPos = myHero.Position.To2D(); } foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells) { Spell spell = entry.Value; closestDistance = Math.Min(closestDistance, GetClosestDistanceApproach(spell, pos, speed, delay, heroPos, extraDist)); //GetIntersectTime(spell, ObjectCache.myHeroCache.serverPos2D, pos); //Math.Min(closestDistance, GetClosestDistanceApproach(spell, pos, ObjectCache.myHeroCache.moveSpeed, delay, ObjectCache.myHeroCache.serverPos2D)); if (pos.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius + 6) || PredictSpellCollision(spell, pos, speed, delay, heroPos, extraDist) || pos.IsUnderTurret() || (spell.info.spellType != SpellType.Line && pos.isNearEnemy(minComfortDistance))) { posDangerLevel = Math.Max(posDangerLevel, spell.dangerlevel); posDangerCount += spell.dangerlevel; undodgeableSpells.Add(spell.spellID); } else { dodgeableSpells.Add(spell.spellID); } } return new PositionInfo( pos, posDangerLevel, posDangerCount, posDangerCount > 0, closestDistance, dodgeableSpells, undodgeableSpells); }
public static PositionInfo CanHeroWalkToPos(Vector2 pos, float speed, float delay, float extraDist, bool useServerPosition = true) { int posDangerLevel = 0; int posDangerCount = 0; float closestDistance = float.MaxValue; List<int> dodgeableSpells = new List<int>(); List<int> undodgeableSpells = new List<int>(); Vector2 heroPos = GameData.HeroInfo.ServerPos2D; if (useServerPosition == false) { heroPos = MyHero.Position.To2D(); } foreach (KeyValuePair<int, Spell> entry in SpellDetector.Spells) { Spell spell = entry.Value; closestDistance = Math.Min(closestDistance, GetClosestDistanceApproach(spell, pos, speed, delay, heroPos, extraDist)); //GetIntersectTime(spell, GameData.HeroInfo.serverPos2D, pos); //Math.Min(closestDistance, GetClosestDistanceApproach(spell, pos, GameData.HeroInfo.moveSpeed, delay, GameData.HeroInfo.serverPos2D)); if (pos.InSkillShot(spell, GameData.HeroInfo.BoundingRadius + 6) || PredictSpellCollision(spell, pos, speed, delay, heroPos, extraDist, useServerPosition) || (spell.Info.SpellType != SpellType.Line && pos.IsNearEnemy(ConfigValue.MinimumComfortZone.GetInt()))) { posDangerLevel = Math.Max(posDangerLevel, (int)spell.Dangerlevel); posDangerCount += (int)spell.Dangerlevel; undodgeableSpells.Add(spell.SpellId); } else { dodgeableSpells.Add(spell.SpellId); } } return new PositionInfo( pos, posDangerLevel, posDangerCount, posDangerCount > 0, closestDistance, dodgeableSpells, undodgeableSpells); }
public static bool CheckMoveToDirection(Vector2 from, Vector2 movePos, float extraDelay = 0) { var dir = (movePos - from).Normalized(); //movePos = movePos.ExtendDir(dir, ObjectCache.myHeroCache.boundingRadius); foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells) { Spell spell = entry.Value; if (!from.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius)) { Vector2 spellPos = spell.currentSpellPosition; if (spell.spellType == SpellType.Line) { if (spell.LineIntersectLinearSpell(from, movePos)) return true; } else if (spell.spellType == SpellType.Circular) { if (spell.info.spellName == "VeigarEventHorizon") { var cpa2 = MathUtilsCPA.CPAPointsEx(from, dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, new Vector2(0, 0), movePos, spell.endPos); if (from.Distance(spell.endPos) < spell.radius && !(from.Distance(spell.endPos) < spell.radius - 135 && movePos.Distance(spell.endPos) < spell.radius - 135)) { return true; } else if (from.Distance(spell.endPos) > spell.radius && cpa2 < spell.radius + 10) { return true; } } else { Vector2 cHeroPos; Vector2 cSpellPos; var cpa2 = MathUtils.GetCollisionDistanceEx( from, dir * ObjectCache.myHeroCache.moveSpeed, 1, spell.endPos, new Vector2(0, 0), spell.radius, out cHeroPos, out cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(from, movePos); if (cHeroPosProjection.IsOnSegment && cpa2 != float.MaxValue) { return true; } /*var cpa = MathUtilsCPA.CPAPointsEx(from, dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, new Vector2(0, 0), movePos, spell.endPos); if (cpa < spell.radius + 10) { return true; }*/ } } else if (spell.spellType == SpellType.Arc) { if (from.isLeftOfLineSegment(spell.startPos, spell.endPos)) { return MathUtils.CheckLineIntersection(from, movePos, spell.startPos, spell.endPos); } var spellRange = spell.startPos.Distance(spell.endPos); var midPoint = spell.startPos + spell.direction * (spellRange / 2); var cpa = MathUtilsCPA.CPAPointsEx(from, dir * ObjectCache.myHeroCache.moveSpeed, midPoint, new Vector2(0, 0), movePos, midPoint); if (cpa < spell.radius + 10) { return true; } } else if (spell.spellType == SpellType.Cone) { } } } return false; }
public static float GetIntersectDistance(Spell spell, Vector2 start, Vector2 end) { if (spell == null) return float.MaxValue; Vector3 start3D = new Vector3(start.X, start.Y, 0); Vector2 walkDir = (end - start); Vector3 walkDir3D = new Vector3(walkDir.X, walkDir.Y, 0); Ray heroPath = new Ray(start3D, walkDir3D); if (spell.spellType == SpellType.Line) { Vector2 intersection; bool hasIntersection = spell.LineIntersectLinearSpellEx(start, end, out intersection); if (hasIntersection) { return start.Distance(intersection); } } else if (spell.spellType == SpellType.Circular) { if (end.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius) == false) { Vector2 intersection1, intersection2; MathUtils.FindLineCircleIntersections(spell.endPos, spell.radius, start, end, out intersection1, out intersection2); if (intersection1.X != float.NaN && MathUtils.isPointOnLineSegment(intersection1, start, end)) { return start.Distance(intersection1); } else if (intersection2.X != float.NaN && MathUtils.isPointOnLineSegment(intersection2, start, end)) { return start.Distance(intersection2); } } } return float.MaxValue; }
public static bool CheckMoveToDirection(Vector2 from, Vector2 movePos, float extraDelay = 0) { var dir = (movePos - from).Normalized(); //movePos = movePos.ExtendDir(dir, ObjectCache.myHeroCache.boundingRadius); foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells) { Spell spell = entry.Value; if (!from.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius)) { Vector2 spellPos = spell.currentSpellPosition; /*if (ObjectCache.menuCache.cache["AllowCrossing"].GetValue<bool>()) { var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"].GetValue<Slider>().Value + 65; var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"].GetValue<Slider>().Value + 10; if (PredictSpellCollision(spell, movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer, from, extraDist) == false) { return false; Console.WriteLine("cross"); } //continue; }*/ if (spell.info.spellType == SpellType.Line) { if (spell.LineIntersectLinearSpell(from, movePos)) return true; } else if (spell.info.spellType == SpellType.Circular) { if (spell.info.spellName == "VeigarEventHorizon") { Vector2 out1, out2; Vector2 perDir = dir.Perpendicular(); Vector2 from1 = from + perDir * ObjectCache.myHeroCache.boundingRadius; Vector2 from2 = from - perDir * ObjectCache.myHeroCache.boundingRadius; Vector2 to1 = movePos + perDir * ObjectCache.myHeroCache.boundingRadius; Vector2 to2 = movePos - perDir * ObjectCache.myHeroCache.boundingRadius; var intersections1 = MathUtils.FindLineCircleIntersections(spell.endPos, spell.radius, from1, to1, out out1, out out2); var intersections2 = MathUtils.FindLineCircleIntersections(spell.endPos, spell.radius - 135, from1, to1, out out1, out out2); var intersections3 = MathUtils.FindLineCircleIntersections(spell.endPos, spell.radius, from2, to2, out out1, out out2); var intersections4 = MathUtils.FindLineCircleIntersections(spell.endPos, spell.radius - 135, from2, to2, out out1, out out2); return !(intersections1 == 0 && intersections2 == 0 && intersections3 == 0 && intersections4 == 0); } var cpa = MathUtilsCPA.CPAPointsEx(from, dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, new Vector2(0, 0), movePos, spell.endPos); if (cpa < spell.radius + 10) { return true; } } else if (spell.info.spellType == SpellType.Cone) { } } } return false; }
public static bool CheckMoveToDirection(Vector2 from, Vector2 movePos, float extraDelay = 0) { var dir = (movePos - from).Normalized(); foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells) { Spell spell = entry.Value; if (!from.InSkillShot(spell, ObjectCache.myHeroCache.boundingRadius)) { Vector2 spellPos = spell.currentSpellPosition; /*if (ObjectCache.menuCache.cache["AllowCrossing"].GetValue<bool>()) { var extraDelayBuffer = Evade.menu.Item("ExtraPingBuffer").GetValue<Slider>().Value; var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"].GetValue<Slider>().Value; if (PredictSpellCollision(spell, movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer, from, extraDist)) { return true; } Console.WriteLine("cross"); continue; }*/ if (spell.info.spellType == SpellType.Line) { if (spell.LineIntersectLinearSpell(from, movePos)) return true; } else if (spell.info.spellType == SpellType.Circular) { var cpa = MathUtilsCPA.CPAPointsEx(from, dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, new Vector2(0, 0), movePos, spell.endPos); if (cpa < spell.radius + 10) { return true; } } else if (spell.info.spellType == SpellType.Cone) { } } } return false; }