private static void Obj_AI_Base_OnDelete(GameObject sender, EventArgs args) { if (sender.Name.ToLower().Contains("olaf_axe_totem_team_id_green.troy") && lastQpos.LSDistance(sender.Position) < 150) { lastQpos = Vector3.Zero; } }
/// <summary> /// Credit /// https://github.com/LXMedia1/UltimateCarry2/blob/master/LexxersAIOCarry/Thresh.cs /// </summary> private void SafeFriendLatern() { if (!W.IsReady()) { return; } var bestcastposition = new Vector3(0f, 0f, 0f); foreach (var friend in ObjectManager.Get <AIHeroClient>() .Where( hero => hero.IsAlly && !hero.IsMe && hero.LSDistance(ObjectManager.Player) <= W.Range + 300 && hero.LSDistance(ObjectManager.Player) <= W.Range - 200 && hero.Health / hero.MaxHealth * 100 >= 20 && !hero.IsDead)) { foreach (var enemy in ObjectManager.Get <AIHeroClient>().Where(h => h.IsEnemy)) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (friend == null || !(friend.LSDistance(enemy) <= 300)) { continue; } var center = ObjectManager.Player.Position; const int points = 36; var radius = W.Range; const double slice = 2 * Math.PI / points; for (var i = 0; i < points; i++) { var angle = slice * i; var newX = (int)(center.X + radius * Math.Cos(angle)); var newY = (int)(center.Y + radius * Math.Sin(angle)); var p = new Vector3(newX, newY, 0); if (p.LSDistance(friend.Position) <= bestcastposition.LSDistance(friend.Position)) { bestcastposition = p; } } if (friend.LSDistance(ObjectManager.Player) <= W.Range) { W.Cast(bestcastposition, true); return; } } if (bestcastposition.LSDistance(new Vector3(0f, 0f, 0f)) >= 100) { W.Cast(bestcastposition, true); } } }
public static List <AIHeroClient> GetAlliesInRange(this Vector3 point, float range, Obj_AI_Base originalunit = null) { if (originalunit != null) { return (HeroManager.Allies .FindAll( x => x.NetworkId != originalunit.NetworkId && point.LSDistance(x.ServerPosition, true) <= range * range)); } return (HeroManager.Allies .FindAll(x => point.LSDistance(x.ServerPosition, true) <= range * range)); }
private static List <AIHeroClient> GetRTarget(Vector3 pos) { return (HeroManager.Enemies.Where( i => i.IsValidTarget() && pos.LSDistance(Prediction.GetPrediction(i, 0.25f).UnitPosition) < RWidth) .ToList()); }
internal static float GetHealth(bool ally, Vector3 pos) { return (HeroManager.AllHeroes.Where( h => !h.IsDead && h.IsAlly == ally && pos.LSDistance(h.Position) < GameInfo.ChampionRange) .Sum(h => h.Health)); }
private static List <Vector3> AimQ(Vector3 finalPos) { var CircleLineSegmentN = 36; var radius = 500; var position = Player.Position; var points = new List <Vector3>(); for (var i = 1; i <= CircleLineSegmentN; i++) { var angle = i * 2 * Math.PI / CircleLineSegmentN; var point = new Vector3(position.X + radius * (float)Math.Cos(angle), position.Y + radius * (float)Math.Sin(angle), position.Z); if (point.LSDistance(Player.Position.LSExtend(finalPos, radius)) < 430) { points.Add(point); //Utility.DrawCircle(point, 20, System.Drawing.Color.Aqua, 1, 1); } } var point2 = points.OrderBy(x => x.LSDistance(finalPos)); points = point2.ToList(); points.RemoveAt(0); points.RemoveAt(1); return(points); }
public static Vector3 GetBestPosition(AIHeroClient target, Vector3 firstPosition, Vector3 secondPosition) { if (firstPosition.IsWall() && !secondPosition.IsWall() && secondPosition.LSDistance(target.ServerPosition) < firstPosition.LSDistance(target.ServerPosition)) // if firstposition is a wall and second position isn't { return secondPosition; //return second position } if (secondPosition.IsWall() && !firstPosition.IsWall() && firstPosition.LSDistance(target.ServerPosition) < secondPosition.LSDistance(target.ServerPosition)) // if secondPosition is a wall and first position isn't { return firstPosition; // return first position } return firstPosition; }
/// <summary> /// Credit /// https://github.com/LXMedia1/UltimateCarry2/blob/master/LexxersAIOCarry/Thresh.cs /// </summary> private void EngageFriendLatern() { if (!W.IsReady()) { return; } var bestcastposition = new Vector3(0f, 0f, 0f); foreach (var friend in ObjectManager.Get <AIHeroClient>() .Where( hero => hero.IsAlly && !hero.IsMe && hero.LSDistance(Player) <= W.Range + 300 && hero.LSDistance(Player) <= W.Range - 300 && hero.Health / hero.MaxHealth * 100 >= 20 && Player.LSCountEnemiesInRange(150) >= 1)) { var center = Player.Position; const int points = 36; var radius = W.Range; const double slice = 2 * Math.PI / points; for (var i = 0; i < points; i++) { var angle = slice * i; var newX = (int)(center.X + radius * Math.Cos(angle)); var newY = (int)(center.Y + radius * Math.Sin(angle)); var p = new Vector3(newX, newY, 0); if (p.LSDistance(friend.Position) <= bestcastposition.LSDistance(friend.Position)) { bestcastposition = p; } } if (friend.LSDistance(ObjectManager.Player) <= W.Range) { W.Cast(bestcastposition, true); return; } } if (bestcastposition.LSDistance(new Vector3(0f, 0f, 0f)) >= 100) { W.Cast(bestcastposition, true); } }
public static Vector3 GetBestPosition(AIHeroClient target, Vector3 firstPosition, Vector3 secondPosition) { if (firstPosition.IsWall() && !secondPosition.IsWall() && secondPosition.LSDistance(target.ServerPosition) < firstPosition.LSDistance(target.ServerPosition)) // if firstposition is a wall and second position isn't { return(secondPosition); //return second position } if (secondPosition.IsWall() && !firstPosition.IsWall() && firstPosition.LSDistance(target.ServerPosition) < secondPosition.LSDistance(target.ServerPosition)) // if secondPosition is a wall and first position isn't { return(firstPosition); // return first position } return(firstPosition); }
private WardStruct GetWardStructForInvisible(Vector3 start, Vector3 end) { return (HeroManager.Enemies.Where(hero => this._heroNoWards.All(h => h.Hero.NetworkId != hero.NetworkId)) .Any(hero => hero.LSDistance(start.LSExtend(end, start.LSDistance(end) / 2f)) <= 1500f) && HeroManager.Enemies.Any(e => e.Level > 3) ? this._wardStructs[3] : this._wardStructs[0]); }
public static List <T> GetObjects <T>(string objectName, float range, Vector3 rangeCheckFrom = new Vector3()) where T : GameObject, new() { if (rangeCheckFrom.Equals(Vector3.Zero)) { rangeCheckFrom = HeroManager.Player.ServerPosition; } return(ObjectManager.Get <T>().Where(x => rangeCheckFrom.LSDistance(x.Position, true) < range * range).ToList()); }
private void CastE(Vector3 target) { if (target.LSDistance(player.Position) > eRanges[E.Level - 1]) { return; } if (E.IsCharging) { if (target.LSDistance(player.Position) < E.Range) { E.Cast(target, getCheckBoxItem(config, "packets")); } } else if (target.LSDistance(player.Position) < eRanges[E.Level - 1]) { E.SetCharged("ZacE", "ZacE", 295, eRanges[E.Level - 1], eChannelTimes[E.Level - 1]); E.StartCharging(target); } }
public bool InAARange(Vector3 point) { if (!getCheckBoxItem("AAcheck")) { return(true); } if (Orbwalker.LastTarget != null && Orbwalker.LastTarget.Type == GameObjectType.AIHeroClient) { return(point.LSDistance(Orbwalker.LastTarget.Position) < Player.AttackRange); } return(point.CountEnemiesInRange(Player.AttackRange) > 0); }
public static bool CheckWalls(Vector3 player, Vector3 enemy) { var distance = player.LSDistance(enemy); for (var i = 1; i < 6; i++) { if (player.Extend(enemy, distance + 55 * i).IsWall()) { return(true); } } return(false); }
public static Obj_AI_Base GetNearest(Vector3 pos, float dist = 700f) { var minions = ObjectManager.Get <Obj_AI_Minion>() .Where( minion => minion.LSIsValidTarget() && minion.IsEnemy && !minion.IsDead && !minion.Name.Contains("Mini") && Camps.BigMobs.Any( name => minion.Name.StartsWith(name) && pos.LSDistance(minion.Position) <= dist)) .OrderByDescending(m => m.MaxHealth); return(minions.FirstOrDefault()); }
public static Vector3 ClosestWall(Vector3 StartPos, Vector3 EndPos) { var distance = StartPos.LSDistance(EndPos); for (int i = 1; i < 8; i++) { if (StartPos.LSExtend(EndPos, distance + 55 * i).LSIsWall()) { return(StartPos.LSExtend(EndPos, distance + 55 * i)); } } return(EndPos); }
public static bool CheckWalls(Vector3 from, Vector3 to) { var steps = 6f; var stepLength = from.LSDistance(to) / steps; for (var i = 1; i < steps + 1; i++) { if (from.Extend(to, stepLength * i).IsWall()) { return(true); } } return(false); }
public static bool IsWallBetween(Vector3 start, Vector3 end, int step = 3) { if (start.IsValid() && end.IsValid() && step > 0) { var distance = start.LSDistance(end); for (var i = 0; i < distance; i = i + step) { if (NavMesh.GetCollisionFlags(start.LSExtend(end, i)) == CollisionFlags.Wall) { return(true); } } } return(false); }
public static Vector3?GetFirstWallPoint(this Vector3 from, Vector3 to, float step = 25) { var direction = (to - from).Normalized(); for (float d = 0; d < from.LSDistance(to); d = d + step) { var testPoint = from + d * direction; if (NavMesh.GetCollisionFlags(testPoint.X, testPoint.Y).HasFlag(CollisionFlags.Wall) || NavMesh.GetCollisionFlags(testPoint.X, testPoint.Y).HasFlag(CollisionFlags.Building)) { return(from + d * direction); } } return(null); }
public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, int step = 1) { if (start.IsValid() && end.IsValid()) { var distance = start.LSDistance(end); for (var i = 0; i < distance; i = i + step) { var newPoint = start.LSExtend(end, i); if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.LSIsWall()) { return(newPoint); } } } return(Vector3.Zero); }
public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, int step = 1) { if (start.IsValid() && end.IsValid()) { var distance = start.LSDistance(end); for (var i = 0; i < distance; i = i + step) { var newPoint = start.LSExtend(end, i); if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.LSIsWall()) { return newPoint; } } } return Vector3.Zero; }
static bool IsTurretPosition(Vector3 pos) { float mindistance = 2000; foreach (int NetID in AllEnemyTurret) { Obj_AI_Turret turret = ObjectManager.GetUnitByNetworkId <Obj_AI_Turret>((uint)NetID); if (turret != null && !turret.IsDead && !TurretHasAggro[NetID]) { float distance = pos.LSDistance(turret.Position); if (mindistance >= distance) { mindistance = distance; } } } return(mindistance <= 950); }
/// <summary> /// Collideses the with wall. /// </summary> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <returns></returns> internal static bool CollidesWithWall(Vector3 start, Vector3 end) { if (Environment.TickCount - _wallCastT > 4000) { return(false); } GameObject wall = null; foreach (var gameObject in ObjectManager.Get <GameObject>() .Where( gameObject => gameObject.IsValid && Regex.IsMatch( gameObject.Name, "_w_windwall_enemy_0.\\.troy", RegexOptions.IgnoreCase)) ) { wall = gameObject; } if (wall == null) { return(false); } var level = wall.Name.Substring(wall.Name.Length - 6, 1); var wallWidth = 300 + 50 * Convert.ToInt32(level); var wallDirection = (wall.Position.To2D() - _yasuoWallCastedPos).Normalized().Perpendicular(); var wallStart = wall.Position.To2D() + wallWidth / 2f * wallDirection; var wallEnd = wallStart - wallWidth * wallDirection; for (var i = 0; i < start.LSDistance(end); i += 30) { var currentPosition = start.LSExtend(end, i); if (wallStart.Intersection(wallEnd, currentPosition.LSTo2D(), start.To2D()).Intersects) { return(true); } } return(false); }
private static void JumpUnderTurret(float extrarange, Vector3 objectPosition) { float mindistance = 100000; //Getting next Turret Obj_AI_Turret turretToJump = null; foreach (int NetID in AllAllyTurret) { Obj_AI_Turret turret = ObjectManager.GetUnitByNetworkId <Obj_AI_Turret>((uint)NetID); if (turret != null && !turret.IsDead) { float distance = Player.Position.LSDistance(turret.Position); if (mindistance >= distance) { mindistance = distance; turretToJump = turret; } } } if (turretToJump != null && !TurretHasAggro[turretToJump.NetworkId] && Player.Position.LSDistance(turretToJump.Position) < 1500) { int i = 0; do { Vector3 extPos = Player.Position.LSExtend(turretToJump.Position, 685 - i); float dist = objectPosition.LSDistance(extPos + extrarange); Vector3 predictedPosition = objectPosition.LSExtend(extPos, dist); if (predictedPosition.LSDistance(turretToJump.Position) <= 890 && !predictedPosition.LSIsWall()) { WardJump(Player.Position.LSExtend(turretToJump.Position, 650 - i), false); JumpPosition = Player.Position.LSExtend(turretToJump.Position, 650 - i); ShallJumpNow = true; break; } i += 50; } while (i <= 300 || !Player.Position.LSExtend(turretToJump.Position, 650 - i).LSIsWall()); } }
private Vector3 GuessPosition(Vector3 start, Vector3 end) { try { var grass = new List <Vector3>(); var distance = start.LSDistance(end); for (var i = 0; i < distance; i++) { var pos = start.LSExtend(end, i); if (NavMesh.IsWallOfGrass(pos, 1)) { grass.Add(pos); } } return(grass.Count > 0 ? grass[(int)(grass.Count / 2d + 0.5d * Math.Sign(grass.Count / 2d))] : end); } catch (Exception e) { Console.WriteLine(e); } return(end); }
private void kill(Positions positions, Vector3 pos) { if (R.IsReady() && pos.LSDistance(positions.Player.Position) < 1200 && ObjectManager.Get <AIHeroClient>() .Count(o => o.IsAlly && o.LSDistance(pos) < config["Alliesrange"].Cast <Slider>().CurrentValue) < 1) { if (checkdmg(positions.Player, pos) && UltTime(pos) < positions.RecallData.GetRecallTime() && !isColliding(pos)) { if (player.ChampionName == "Xerath") { xerathUlt(positions, pos); } R.Cast(pos); if (player.ChampionName == "Draven" && config["CallBack"].Cast <CheckBox>().CurrentValue) { LeagueSharp.Common.Utility.DelayAction.Add((int)(UltTime(pos) - 300), () => R.Cast()); } } } }
public static Geometry.Polygon GetPolyFromVector(Vector3 from, Vector3 to, float width) { var POS = to.Extend(from, from.LSDistance(to)); var direction = (POS - to.To2D()).Normalized(); var pos1 = (to.To2D() - direction.Perpendicular() * width / 2f).To3D(); var pos2 = (POS + (POS - to.To2D()).Normalized() + direction.Perpendicular() * width / 2f).To3D(); var pos3 = (to.To2D() + direction.Perpendicular() * width / 2f).To3D(); var pos4 = (POS + (POS - to.To2D()).Normalized() - direction.Perpendicular() * width / 2f).To3D(); var poly = new Geometry.Polygon(); poly.Add(pos1); poly.Add(pos3); poly.Add(pos2); poly.Add(pos4); return(poly); }
private void Game_ProcessSpell(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (sender.IsMe) { if (args.Slot == SpellSlot.Q || args.Slot == SpellSlot.R) { bladeOnCast = args.End; } if (args.SData.Name == "ShenW") { justW = true; Utility.DelayAction.Add(1750, () => { justW = false; }); } if (args.SData.Name == "ShenE" && Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Combo)) { if (Q.IsReady() && CheckQDef() && blade.LSDistance(args.End) > bladeRadius / 2f) { Q.Cast(); } } } }
public static bool goesThroughWall(Vector3 vec1, Vector3 vec2) { if (wall.endtime < Game.Time || wall.pointL == null || wall.pointL == null) { return(false); } Vector2 inter = YasMath.LineIntersectionPoint(vec1.LSTo2D(), vec2.LSTo2D(), wall.pointL.Position.LSTo2D(), wall.pointR.Position.LSTo2D()); float wallW = (300 + 50 * W.Level); if (wall.pointL.Position.LSTo2D().LSDistance(inter) > wallW || wall.pointR.Position.LSTo2D().LSDistance(inter) > wallW) { return(false); } var dist = vec1.LSDistance(vec2); if (vec1.LSTo2D().LSDistance(inter) + vec2.LSTo2D().LSDistance(inter) - 30 > dist) { return(false); } return(true); }
public static float DistanceToPlayer(this Vector3 position) { return(position.LSDistance(Player.ServerPosition)); }
private void Game_OnIssueOrder(Obj_AI_Base hero, PlayerIssueOrderEventArgs args) { if (!hero.IsMe) { return; } if (!Situation.ShouldDodge()) { return; } if (args.Order == GameObjectOrder.MoveTo) { if (isDodging && SpellDetector.spells.Any()) { CheckHeroInDanger(); lastBlockedUserMoveTo = new EvadeCommand { order = EvadeOrderCommand.MoveTo, targetPosition = args.TargetPosition.LSTo2D(), timestamp = EvadeUtils.TickCount, isProcessed = false, }; args.Process = false; } else { var movePos = args.TargetPosition.LSTo2D(); var extraDelay = ObjectCache.menuCache.cache["ExtraPingBuffer"].Cast <Slider>().CurrentValue; if (EvadeHelper.CheckMovePath(movePos, ObjectCache.gamePing + extraDelay)) { /*if (ObjectCache.menuCache.cache["AllowCrossing"].Cast<CheckBox>().CurrentValue) * { * var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"] * .GetValue<Slider>().Value + 30; * var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"] * .GetValue<Slider>().Value + 10; * * var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer + ObjectCache.gamePing, extraDist); * * if (tPosInfo.posDangerLevel == 0) * { * lastPosInfo = tPosInfo; * return; * } * }*/ lastBlockedUserMoveTo = new EvadeCommand { order = EvadeOrderCommand.MoveTo, targetPosition = args.TargetPosition.LSTo2D(), timestamp = EvadeUtils.TickCount, isProcessed = false, }; args.Process = false; //Block the command if (EvadeUtils.TickCount - lastMovementBlockTime < 500 && lastMovementBlockPos.LSDistance(args.TargetPosition) < 100) { return; } lastMovementBlockPos = args.TargetPosition; lastMovementBlockTime = EvadeUtils.TickCount; var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos); if (posInfo != null) { EvadeCommand.MoveTo(posInfo.position); } return; } else { lastBlockedUserMoveTo.isProcessed = true; } } } else //need more logic { if (isDodging) { args.Process = false; //Block the command } else { if (args.Order == GameObjectOrder.AttackUnit) { var target = args.Target; if (target != null && target.IsValid <Obj_AI_Base>()) { var baseTarget = target as Obj_AI_Base; if (ObjectCache.myHeroCache.serverPos2D.LSDistance(baseTarget.ServerPosition.LSTo2D()) > myHero.AttackRange + ObjectCache.myHeroCache.boundingRadius + baseTarget.BoundingRadius) { var movePos = args.TargetPosition.LSTo2D(); var extraDelay = ObjectCache.menuCache.cache["ExtraPingBuffer"].Cast <Slider>().CurrentValue; if (EvadeHelper.CheckMovePath(movePos, ObjectCache.gamePing + extraDelay)) { args.Process = false; //Block the command return; } } } } } } if (args.Process == true) { lastIssueOrderGameTime = Game.Time * 1000; lastIssueOrderTime = EvadeUtils.TickCount; lastIssueOrderArgs = args; if (args.Order == GameObjectOrder.MoveTo) { lastMoveToPosition = args.TargetPosition.LSTo2D(); lastMoveToServerPos = myHero.ServerPosition.LSTo2D(); } if (args.Order == GameObjectOrder.Stop) { lastStopPosition = myHero.ServerPosition.LSTo2D(); } } }
public bool InAARange(Vector3 point) { if (!getCheckBoxItem("AAcheck")) return true; if (Orbwalker.LastTarget != null && Orbwalker.LastTarget.Type == GameObjectType.AIHeroClient) { return point.LSDistance(Orbwalker.LastTarget.Position) < Player.AttackRange; } return point.CountEnemiesInRange(Player.AttackRange) > 0; }
private static Obj_AI_Base GetClosestDirectEnemyUnitToPos(Vector3 pos) { List <Obj_AI_Base> possibleHeroes = HeroManager.Enemies.Where(x => x.IsValidTarget() && pos.LSDistance(x.ServerPosition) < distLeeToWardjump && x.Health > spellQ.GetDamage(x)).ToList().ConvertAll(x => (Obj_AI_Base)x); List <Obj_AI_Base> possibleMinions = MinionManager.GetMinions(pos, distLeeToWardjump).Where(x => x.Health > spellQ.GetDamage(x)).ToList(); List <Obj_AI_Base> allPossible = possibleHeroes.Concat(possibleMinions).ToList(); allPossible = allPossible.OrderBy(unit => unit.LSDistance(pos)).ToList(); Obj_AI_Base bestUnit = null; foreach (var candidate in allPossible) { var sCol = SPrediction.Collision.GetCollisions( leeHero.ServerPosition.To2D(), candidate.ServerPosition.To2D(), ChampInfo.Q.Range, ChampInfo.Q.Width, ChampInfo.Q.Delay, ChampInfo.Q.Speed); var sColUnits = sCol.Units; var realUnits = new List <Obj_AI_Base>(); if (sColUnits.Any()) { realUnits.AddRange(sColUnits.Where(unit => unit.NetworkId != leeHero.NetworkId && unit.NetworkId != candidate.NetworkId)); } if (realUnits.Any()) { continue; } bestUnit = candidate; break; } return(bestUnit); }