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); }
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 (ezEvade.LastPosInfo != null) { var pos = ezEvade.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) { } } } }