public static void DrawRectangle(int length, int width, Vector3 position, int xoffset = 0, int yoffset = 0) { Vector3 SW = Vector3.Zero, SE = Vector3.Zero, NW = Vector3.Zero, NE = Vector3.Zero; SW = new Vector3(position.X - (length / 2) + xoffset, position.Y - (width / 2) + yoffset, 0f); SE = new Vector3(position.X + (length / 2) + xoffset, position.Y - (width / 2) + yoffset, 0f); NW = new Vector3(position.X - (length / 2) + xoffset, position.Y + (width / 2) + yoffset, 0f); NE = new Vector3(position.X + (length / 2) + xoffset, position.Y + (width / 2) + yoffset, 0f); Drawing.DrawLine(SW.WorldToScreen(), SE.WorldToScreen(), 3, drawColor); Drawing.DrawLine(SW.WorldToScreen(), NW.WorldToScreen(), 3, drawColor); Drawing.DrawLine(NW.WorldToScreen(), NE.WorldToScreen(), 3, drawColor); Drawing.DrawLine(NE.WorldToScreen(), SE.WorldToScreen(), 3, drawColor); }
//if onSpellCast was used then the spells end position is the direction the caster is facing extended to max range. IE: xerath q, velkoz r public static void DrawLinearSkillshot(Vector3 startPosition, Vector3 endPosition, float width, float missileSpeed, float range, float collisionCount) { if (collisionCount != 0 && collisionCount != int.MaxValue) { List<Obj_AI_Base> enemiesThatWillBeHit = new List<Obj_AI_Base>(); //get if unit(s) will be hit by spell if so get the info.CollisionCount's units position and set it as the end position foreach(Obj_AI_Base enemy in EntityManager.Enemies.Where(a=>!a.IsDead &&a.Distance(startPosition) <= range)) if (Prediction.Position.Collision.LinearMissileCollision(enemy, startPosition.To2D(), endPosition.To2D(), missileSpeed, (int)width, 0)) enemiesThatWillBeHit.Add(enemy); enemiesThatWillBeHit.OrderByDescending(a => a.Distance(startPosition)); if(enemiesThatWillBeHit.Count() >= collisionCount) endPosition = enemiesThatWillBeHit[(int)collisionCount - 1].Position; } Vector3 northernMostPoint = (startPosition.Y >= endPosition.Y) ? startPosition : endPosition; Vector3 southernMostPoint = (startPosition.Y >= endPosition.Y) ? endPosition : startPosition; Vector3 betweenVector = new Vector3(northernMostPoint.X - southernMostPoint.X, northernMostPoint.Y - southernMostPoint.Y, 0f); Vector2 betweenVector2 = new Vector2(betweenVector.Y, -betweenVector.X); double Length = Math.Sqrt(betweenVector2.X * betweenVector2.X + betweenVector2.Y * betweenVector2.Y); //Thats length of perpendicular Vector2 NewVector = new Vector2((float)(betweenVector2.X / Length), (float)(betweenVector2.Y / Length)); //Now N is normalized perpendicular Vector3 NEPoint = new Vector3(southernMostPoint.X + NewVector.X * (width / 2), southernMostPoint.Y + NewVector.Y * (width / 2), startPosition.Z); Vector3 NWPoint = new Vector3(southernMostPoint.X - NewVector.X * (width / 2), southernMostPoint.Y - NewVector.Y * (width / 2), startPosition.Z); Vector3 SEPoint = new Vector3(northernMostPoint.X + NewVector.X * (width / 2), northernMostPoint.Y + NewVector.Y * (width / 2), startPosition.Z); Vector3 SWPoint = new Vector3(northernMostPoint.X - NewVector.X * (width / 2), northernMostPoint.Y - NewVector.Y * (width / 2), startPosition.Z); //top Drawing.DrawLine(NEPoint.WorldToScreen(), NWPoint.WorldToScreen(), 3, drawColor); //bottom Drawing.DrawLine(SEPoint.WorldToScreen(), SWPoint.WorldToScreen(), 3, drawColor); //right Drawing.DrawLine(NEPoint.WorldToScreen(), SEPoint.WorldToScreen(), 3, drawColor); //left Drawing.DrawLine(NWPoint.WorldToScreen(), SWPoint.WorldToScreen(), 3, drawColor); }
private static void DrawRangeLines() { if (!Spells.Any(s => s.IsLearned)) return; uint[] maxrange = { Spells.Where(s => s.IsLearned).Max(s => s.Range) }; if (maxrange[0] == 0) try { foreach (var ss in Spells.Where(s => s.IsLearned).Cast<Spell.Skillshot>().Where(ss => ss.Width > maxrange[0])) { maxrange[0] = (uint)ss.Width; } } catch (Exception) { // ignored } foreach ( var hero in EntityManager.Heroes.Enemies.Where( e => e.Distance(Player) < maxrange[0] && !e.IsDead && e.IsValid && e.IsVisible && e.IsValidTarget(maxrange[0]))) { var spellranges = new Dictionary<uint, List<SpellSlot>>(); var s = from spell in Spells where spell.IsLearned select spell.Range; var spells = s.ToList(); spells.Sort(); foreach (var spell in spells) { var range = (uint)0; if (spell > 0) range = spell; else { try { var ss = (Spell.Skillshot)Spells.Find(sp => sp.Range == spell); range = (uint)ss.Width; } catch (Exception) { // ignored } } if (range < 50) continue; if (range > hero.Distance(Player)) if (spellranges.ContainsKey((uint)hero.Distance(Player))) spellranges[(uint)hero.Distance(Player)].Add( Spells.Find(sp => sp.Range == spell).Slot); else spellranges.Add((uint)hero.Distance(Player), new List<SpellSlot> { Spells.Find(sp => sp.Range == spell).Slot }); else if (spellranges.ContainsKey(range)) spellranges[range].Add(Spells.Find(sp => sp.Range == spell).Slot); else spellranges.Add(range, new List<SpellSlot> { Spells.Find(sp => sp.Range == spell).Slot }); } var i = 0; var lastloc = new Vector3(0, 0, 0); foreach (var range in spellranges) { var angle = Math.Atan2(hero.Position.Y - Player.Position.Y, hero.Position.X - Player.Position.X); var sin = (Math.Sin(angle) * (range.Key - 20)) + Player.Position.Y; var cosin = (Math.Cos(angle) * (range.Key - 20)) + Player.Position.X; var location = new Vector3((float)cosin, (float)sin, Player.Position.Z); if (i == 0) { Drawing.DrawLine(Player.Position.WorldToScreen(), location.WorldToScreen(), 2, Color.Red); sin = (Math.Sin(angle) * (range.Key)) + Player.Position.Y; cosin = (Math.Cos(angle) * (range.Key)) + Player.Position.X; location = new Vector3((float)cosin, (float)sin, Player.Position.Z); if (Spells.Find(sp => range.Value.Contains(sp.Slot)).IsReady()) new Circle { Color = Color.Chartreuse, Radius = 20, BorderWidth = 1f }.Draw(location); else new Circle { Color = Color.Firebrick, Radius = 20, BorderWidth = 1f }.Draw(location); string text = ""; text = range.Value.Aggregate(text, (current, spell) => current + spell); Drawing.DrawText(location.WorldToScreen().X, location.WorldToScreen().Y - (float)7.5, Color.White, text, 15); i++; sin = (Math.Sin(angle) * (range.Key + 20)) + Player.Position.Y; cosin = (Math.Cos(angle) * (range.Key + 20)) + Player.Position.X; lastloc = new Vector3((float)cosin, (float)sin, Player.Position.Z); } else { Drawing.DrawLine(lastloc.WorldToScreen(), location.WorldToScreen(), 2, Color.Red); sin = (Math.Sin(angle) * (range.Key)) + Player.Position.Y; cosin = (Math.Cos(angle) * (range.Key)) + Player.Position.X; location = new Vector3((float)cosin, (float)sin, Player.Position.Z); if (Spells.Find(sp => range.Value.Contains(sp.Slot)).IsReady()) new Circle() { Color = Color.Chartreuse, Radius = 20, BorderWidth = 2f }.Draw(location); else new Circle() { Color = Color.Firebrick, Radius = 20, BorderWidth = 2f }.Draw(location); string text = ""; text = range.Value.Aggregate(text, (current, spell) => current + spell); Drawing.DrawText(location.WorldToScreen().X, location.WorldToScreen().Y - (float)7.5, Color.White, text, 15); i++; sin = (Math.Sin(angle) * (range.Key + 20)) + Player.Position.Y; cosin = (Math.Cos(angle) * (range.Key + 20)) + Player.Position.X; lastloc = new Vector3((float)cosin, (float)sin, Player.Position.Z); } } } }
private static void DrawLineIfWallBetween(Vector3 startPos, Obj_AI_Base target) { Vector3 endPos = YasuoCalcs.GetDashingEnd(target); List<Vector3> inbetweenPoints = new List<Vector3>(); Vector2 wallStartPosition = Vector2.Zero; Vector2 wallEndPosition = Vector2.Zero; //get every point between yasuo's position and the end position of the dash extended to a range of 1000. //1 point is every 1/100 of total length for (int i = 0; i <= 100; i++) inbetweenPoints.Add(startPos.Extend(startPos.Extend(endPos, 1000), i* (startPos.Distance(startPos.Extend(endPos, 1000)) / 100)).To3D()); //for every point in the list of points, find the beginning and the end of the wal foreach (Vector2 vec in inbetweenPoints) { if (vec.IsWall()) { if (wallStartPosition == Vector2.Zero) wallStartPosition = vec; } else if (wallEndPosition == Vector2.Zero && wallStartPosition != Vector2.Zero) wallEndPosition = vec; } //draw the wall in the color blue if (wallStartPosition != Vector2.Zero && wallEndPosition != Vector2.Zero) { double wallWidth = Math.Round(wallStartPosition.Distance(wallEndPosition)), distanceToWall = Math.Round(startPos.Distance(wallStartPosition)), totalDistance = Math.Round(wallStartPosition.Distance(wallEndPosition) + startPos.Distance(wallStartPosition)), monsterDist = Math.Round(target.Position.Distance(wallStartPosition)); Drawing.DrawLine(wallStartPosition.To3D().WorldToScreen(), wallEndPosition.To3D().WorldToScreen(), 10, System.Drawing.Color.Black); //if the end point of yasuos dash brings him at least halfway between the two points (closer to the wall end than to the walls beginning) //and the wall has to be thinner than yasuo's total dash range. TESTED THIS TO CONFIRM IT WORKS //if (endPos.Distance(wallEndPosition) < endPos.Distance(wallStartPosition) && wallStartPosition.Distance(wallEndPosition) <= Program.E.Range) if (totalDistance <= 630) Drawing.DrawLine(startPos.WorldToScreen(), startPos.Extend(endPos, 1000).To3D().WorldToScreen(), 3, System.Drawing.Color.Green); else Drawing.DrawLine(startPos.WorldToScreen(), startPos.Extend(endPos, 1000).To3D().WorldToScreen(), 3, System.Drawing.Color.Red); Drawing.DrawText(wallStartPosition.To3D().WorldToScreen(), System.Drawing.Color.Purple, wallStartPosition.Distance(wallEndPosition).ToString(), 15); Drawing.DrawText(startPos.Extend(endPos, 1000).To3D().WorldToScreen(), System.Drawing.Color.Purple, (wallStartPosition.Distance(wallEndPosition) + startPos.Distance(wallStartPosition)).ToString(), 15); Drawing.DrawCircle(endPos, 50, System.Drawing.Color.White); } }
public static void DrawTargetedSpell(Vector3 startPosition, GameObject target) { Drawing.DrawLine(startPosition.WorldToScreen(), target.Position.WorldToScreen(), 10, drawColor); }
public static void DrawTargetedSpell(Vector3 startPosition, Vector3 endPosition) { Drawing.DrawLine(startPosition.WorldToScreen(), endPosition.WorldToScreen(), 10, drawColor); }