public static ProjectionInfo ProjectOn(this Vector2 point, Vector2 segmentStart, Vector2 segmentEnd) { var cx = point.X; var cy = point.Y; var ax = segmentStart.X; var ay = segmentStart.Y; var bx = segmentEnd.X; var by = segmentEnd.Y; var rL = ((cx - ax) * (bx - ax) + (cy - ay) * (by - ay)) / ((bx - ax) * (bx - ax) + (by - ay) * (by - ay)); var pointLine = new Vector2(ax + rL * (bx - ax), ay + rL * (by - ay)); float rS; if (rL < 0) { rS = 0; } else if (rL > 1) { rS = 1; } else { rS = rL; } var isOnSegment = rS.CompareTo(rL) == 0; var pointSegment = isOnSegment ? pointLine : new Vector2(ax + rS * (bx - ax), ay + rS * (by - ay)); return(new ProjectionInfo(isOnSegment, pointSegment, pointLine)); }
public void Update() { var pos = LocalPlayer.Instance.Pos(); ClosestPoint = GeometryLib.NearestPointOnFiniteLine(DashObject.StartPosition, DashObject.TargetPosition, pos); if (Data.StartDelay > 0) { var age = DashObject.GameObject.Get <AgeObject>().Age; if (age > Data.StartDelay) { EstimatedImpact = Time.time + (pos.Distance(DashObject.GameObject.Get <BaseGameObject>().Owner as Character) - LocalPlayer.Instance.MapCollision.MapCollisionRadius) / Data.Speed; } else { EstimatedImpact = Time.time + Data.StartDelay - age + (pos.Distance(DashObject.GameObject.Get <BaseGameObject>().Owner as Character) - LocalPlayer.Instance.MapCollision.MapCollisionRadius) / Data.Speed; } } else { EstimatedImpact = Time.time + (pos.Distance(DashObject.GameObject.Get <BaseGameObject>().Owner as Character) - LocalPlayer.Instance.MapCollision.MapCollisionRadius) / Data.Speed; } IsDangerous = GetIsDangerous(pos); }
private bool CheckForCollision(Vector2 pos) { var targetCollision = CollisionSolver.CheckThickLineCollision(ClosestPoint, DashObject.StartPosition, LocalPlayer.Instance.MapCollision.MapCollisionRadius); return(targetCollision != null && targetCollision.IsColliding && targetCollision.CollisionFlags.HasFlag(CollisionFlags.LowBlock | CollisionFlags.HighBlock)); }
public void Update() { var pos = LocalPlayer.Instance.Pos(); ClosestOutsidePoint = LocalPlayer.Instance.GetClosestExitPointFromCircle(TravelObject.TargetPosition, Data.Radius); EstimatedImpact = Data.FixedDelay - TravelObject.GameObject.Get <AgeObject>().Age + Time.time; IsDangerous = GetIsDangerous(pos); }
private bool GetIsDangerous(Vector2 pos) { if (Projectile.Reversed) { return(false); } return(Math.Abs(Projectile.CurveWidth) > 0.1 ? GeometryLib.CheckForOverLaps(Path.ToClipperPath(), LocalPlayer.Instance.MapCollision.ToClipperPath()) : IsInsideHitbox(pos)); }
public void Update() { var pos = LocalPlayer.Instance.Pos(); ClosestPoint = GeometryLib.NearestPointOnFiniteLine(StartPosition, EndPosition, pos); EstimatedImpact = Time.time + (pos.Distance(Projectile.GameObject.Get <BaseGameObject>().Owner as Character) - LocalPlayer.Instance.MapCollision.MapCollisionRadius) / Data.Speed; IsDangerous = GetIsDangerous(pos); }
public void Update() { var pos = LocalPlayer.Instance.Pos(); ClosestPoint = GeometryLib.NearestPointOnFiniteLine(Projectile.StartPosition, Projectile.CalculatedEndPosition, pos); EstimatedImpact = Time.time + (pos.Distance(Projectile.LastPosition) - LocalPlayer.Instance.MapCollision.MapCollisionRadius) / Data.Speed; IsDangerous = GetIsDangerous(pos); }
public static Vector2 NearestPointOnFiniteLine(Vector2 start, Vector2 end, Vector2 pnt) { var line = (end - start); var len = Mathf.Sqrt(line.X * line.X + line.Y * line.Y); line = line.Normalized; var v = pnt - start; var d = Vector2.Dot(v, line); d = Mathf.Clamp(d, 0f, len); return(start + line * d); }
public static Vector2 GetClosestOutsidePoint(this Vector2 from, List <Vector2> points) { var result = new List <Vector2>(); for (var i = 0; i <= points.Count - 1; i++) { var sideStart = points[i]; var sideEnd = points[i == points.Count - 1 ? 0 : i + 1]; result.Add(from.ProjectOn(sideStart, sideEnd).SegmentPoint); } return(result.OrderBy(vector2 => vector2.Distance(from)).FirstOrDefault()); }
private static void Combo() { var enemyTarget = TargetSelectorHelper.GetTarget(TargetingMode.NearLocalPlayer, 9f); var enemyProjectiles = GetEnemyProjectiles(10f); if (enemyTarget == null) { return; } var enemyDistance = player.Distance(enemyTarget.WorldPosition); var intersectingWithProjectile = Helper.IsProjectileColliding(player, enemyProjectiles); Vector2 intersectPoint = Geometry.GetClosestPointOnLineSegment(enemyProjectiles.StartPosition, enemyProjectiles.CalculatedEndPosition, player.WorldPosition, out enemyDistance); if (useQ && LocalPlayer.GetAbilityHudData(AbilitySlot.Ability4).CooldownTime < 0.1f && intersectingWithProjectile) { //if (player.Distance(enemyProjectiles.WorldPosition) <= player.MapCollisionRadius*2.4) // LocalPlayer.CastAbility(AbilitySlot.Ability4); } var hasBuff = Helper.HasBuff(enemyTarget, "RecastBuff"); eSkill = new SkillBase(AbilitySlot.Ability5, SkillType.Circle, 10f, 4.4f, 2f); var lmbSkill = new SkillBase(AbilitySlot.Ability1, SkillType.Line, 8f, 8f, 0.6f); var predictLMB = player.GetPrediction(enemyTarget, lmbSkill.Speed, lmbSkill.Range, lmbSkill.SpellCollisionRadius, lmbSkill.SkillType); if (!enemyTarget.IsDead && !enemyTarget.HasConsumeBuff && !enemyTarget.IsCountering && !enemyTarget.IsImmaterial && !Helper.HasBuff(enemyTarget, "GustBuff") && !Helper.HasBuff(enemyTarget, "BulwarkBuff") && !Helper.HasBuff(enemyTarget, "Incapacitate") && !Helper.HasBuff(enemyTarget, "PetrifyStone") && !Helper.IsColliding(player, enemyTarget)) { if (LocalPlayer.GetAbilityHudData(eSkill.Slot).CooldownTime < 0.1f) // TODO incorporate RecastBuff with E { LocalPlayer.UpdateCursorPosition(intersectPoint, true); // TODO needs more work LocalPlayer.CastAbility(eSkill.Slot); } if (predictLMB.HitChancePercent >= 35f) { LocalPlayer.UpdateCursorPosition(predictLMB.MoveMousePosition); LocalPlayer.CastAbility(AbilitySlot.Ability1); } } }
private bool IsInsideHitbox(Vector2 pos) { var num = Vector2.DistanceSquared(ClosestPoint, pos); var num2 = LocalPlayer.Instance.MapCollision.MapCollisionRadius + Data.Radius; if (num <= num2 * num2) { var normalized = (DashObject.TargetPosition - DashObject.StartPosition).Normalized; var value = pos + normalized * Data.Radius; if (Vector2.Dot(normalized, value - DashObject.StartPosition) > 0f) { return(true); } } return(false); }
private static void DrawRectangle(Vector2 start, Vector2 end, float radius, Color color) { var w = end.X - start.X; var h = end.Y - start.Y; var l = Math.Sqrt(w * w + h * h); var xS = (radius * h / l); var yS = (radius * w / l); var rightStartPos = new Vector2((float)(start.X - xS), (float)(start.Y + yS)); var leftStartPos = new Vector2((float)(start.X + xS), (float)(start.Y - yS)); var rightEndPos = new Vector2((float)(end.X - xS), (float)(end.Y + yS)); var leftEndPos = new Vector2((float)(end.X + xS), (float)(end.Y - yS)); Drawing.DrawLine(rightStartPos, rightEndPos, color); Drawing.DrawLine(leftStartPos, leftEndPos, color); Drawing.DrawLine(rightStartPos, leftStartPos, color); Drawing.DrawLine(leftEndPos, rightEndPos, color); }
public TrackedCurveProjectile(CurveProjectileObject curveProjectile, AbilityInfo data) { StartPosition = curveProjectile.Position; EndPosition = curveProjectile.TargetPosition; Projectile = curveProjectile; Data = data; Path = new List <Vector2>(); if (Math.Abs(Projectile.CurveWidth) > 0.1) { var middleLength = StartPosition.Distance(EndPosition) / 2; var middleOfLine = StartPosition.Extend(EndPosition, middleLength); var perpendicular = (EndPosition - StartPosition).Normalized.Perpendicular(); var offset = -perpendicular *Math.Sign(Projectile.CurveWidth) * data.Radius; var middleOfArc = middleOfLine + -perpendicular * Projectile.CurveWidth; Path.AddRange(GeometryLib.MakeSmoothCurve(new[] { StartPosition, middleOfArc + offset, EndPosition }, 3)); Path.AddRange(GeometryLib.MakeSmoothCurve(new[] { EndPosition + offset, middleOfArc + offset * 2, StartPosition + offset }, 3)); Path.Add(StartPosition); } Update(); }
public static bool IsInsidePolygon(this Vector2 point, List <Vector2> points) { return(Clipper.PointInPolygon(new IntPoint(point.X, point.Y), points.ToClipperPath()) == 1); }
public ProjectionInfo(bool isOnSegment, Vector2 segmentPoint, Vector2 linePoint) { IsOnSegment = isOnSegment; SegmentPoint = segmentPoint; LinePoint = linePoint; }
private static void DodgeWithWalk(Vector2 towards) { LocalPlayer.BlockAllInput = true; LocalPlayer.Move(towards.Normalized); }
private bool GetIsDangerous(Vector2 pos) { return(IsInsideHitbox(pos)); }
private bool IsInsideHitbox(Vector2 pos) { return(pos.Distance(TravelObject.TargetPosition) < Data.Radius + LocalPlayer.Instance.MapCollision.MapCollisionRadius); }
public static Vector2 Perpendicular(this Vector2 v) { return(new Vector2(-v.Y, v.X)); }
private void UpdateEndPos() { EndPos = Caster.Pos().Extend(InputManager.MousePosition, Data.Range); }
private bool GetIsDangerous(Vector2 pos) { return(IsInsideHitbox(pos) && !CheckForCollision(pos)); }
public static UnityEngine.Vector2 ConvertToUnity2D(this Vector2 source) { return(new UnityEngine.Vector2(source.X, Screen.height - source.Y)); }