public static Spells.HitChances GetHiChance(Vector3 From, Obj_AI_Base target, Spells spell) { if (target == null) { return(Spells.HitChances.Notarget); } else { //Game.PrintChat("1"); if (target.HasBuffOfType(BuffType.Knockup) || target.HasBuffOfType(BuffType.Snare) || target.HasBuffOfType(BuffType.Stun)) { //Game.PrintChat("2"); float time = GetImmobileTime(target) - Utils.TickCount; if (time / 1000 + (spell.radius + target.BoundingRadius - 20) / target.MoveSpeed >= spell.delay + Game.Ping / 2 / 1000 + From.Distance(target.Position) / spell.speed) { return(Spells.HitChances.Immobile); } else { return(Spells.HitChances.VeryLow); } } else { //Game.PrintChat("3"); var predict = Prediction.GetPrediction(target, 100).CastPosition; float y = target.MoveSpeed * 100 / 1000; bool moving = !(target.Distance(predict) < y); var chuot = moving == false ? target.Position : target.Position.Extend(predict, y); if (chuot == target.Position) { return(Spells.HitChances.VeryLow); } else { //Game.PrintChat("4"); var cosB = math.CosB(From, target.Position, chuot); var gocB = Math.Acos(cosB) * (180 / Math.PI); if (gocB <= 40) { return(Spells.HitChances.VeryHigh); } else if (gocB <= 90) { return(Spells.HitChances.High); } else if (gocB <= 165) { return(Spells.HitChances.Medium); } else { return(Spells.HitChances.Low); } } } } }
public static bool IsReady(this Spells spell, int delay = 0) { return(spell.spellslot.IsReady(delay)); }
public static List <Obj_AI_Base> GetCollision(Vector3 from, Vector3 to, Spells spell) { var result = new List <Obj_AI_Base>(); var list = new List <CollisionableObjects>(); list.Add(CollisionableObjects.Minions); list.Add(CollisionableObjects.YasuoWall); float time = spell.delay + Game.Ping / 2 / 1000 + from.Distance(to) / spell.speed; foreach (var objectType in list) { switch (objectType) { case CollisionableObjects.Minions: foreach (var minion in ObjectManager.Get <Obj_AI_Minion>() .Where( minion => minion.IsValidTarget( Math.Min(spell.range + spell.radius + 100, 2000), true, from))) { //var chuot = Prediction.GetPrediction(minion, 100).CastPosition; //float y = minion.MoveSpeed * 100 / 1000; //bool moving = !(minion.Distance(chuot) < y); //var minionPrediction = moving == false ? minion.Position : minion.Position.Extend(chuot, time * minion.MoveSpeed); var minionPrediction = Prediction.GetPrediction(minion, time * 1000).UnitPosition; if ( minionPrediction.To2D() .Distance(from.To2D(), to.To2D(), true, true) <= Math.Pow((spell.radius * 2 + 15 + minion.BoundingRadius), 2) || minion.Position.To2D().Distance(from.To2D(), to.To2D(), true, true) <= Math.Pow((spell.radius * 2 + 15 + minion.BoundingRadius), 2)) { result.Add(minion); } } break; //case CollisionableObjects.Heroes: // foreach (var hero in // HeroManager.Enemies.FindAll( // hero => // hero.IsValidTarget( // Math.Min(input.Range + input.Radius + 100, 2000), true, input.RangeCheckFrom)) // ) // { // input.Unit = hero; // var prediction = Prediction.GetPrediction(input, false, false); // if ( // prediction.UnitPosition.To2D() // .Distance(input.From.To2D(), position.To2D(), true, true) <= // Math.Pow((input.Radius + 50 + hero.BoundingRadius), 2)) // { // result.Add(hero); // } // } // break; //case CollisionableObjects.Walls: // var step = position.Distance(input.From) / 20; // for (var i = 0; i < 20; i++) // { // var p = input.From.To2D().Extend(position.To2D(), step * i); // if (NavMesh.GetCollisionFlags(p.X, p.Y).HasFlag(CollisionFlags.Wall)) // { // result.Add(ObjectManager.Player); // } // } // break; case CollisionableObjects.YasuoWall: if (Utils.TickCount - _wallCastT > 4000) { break; } 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) { break; } 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; if (wallStart.Intersection(wallEnd, to.To2D(), from.To2D()).Intersects) { var t = Utils.TickCount + (wallStart.Intersection(wallEnd, to.To2D(), from.To2D()) .Point.Distance(from) / spell.speed + spell.delay) * 1000; if (t < _wallCastT + 4000) { result.Add(ObjectManager.Player); } } break; } } return(result.Distinct().ToList()); }
public static bool Cast(this Spells spell, Obj_AI_Base ToTarget, Spells.HitChances minhitchance = Spells.HitChances.VeryLow) { return(Cast(spell, Player.Position, ToTarget, minhitchance)); }
public static List <Obj_AI_Base> GetCollisions(Vector3 from, Vector3 to, Spells spell) { var result = new List <Obj_AI_Base>(); float t = spell.delay + Game.Ping / 2 / 1000 + from.Distance(to) / spell.speed; foreach (var obj in ObjectManager.Get <Obj_AI_Base>().Where(obj => obj.Type != GameObjectType.obj_AI_Turret && obj.Type != GameObjectType.obj_Building && obj.IsEnemy || obj.Team == GameObjectTeam.Neutral)) { if (obj.IsMoving) { var chuot = Prediction.GetPrediction(obj, 100).CastPosition; Vector3 obj2 = obj.Position.Extend(chuot, t * obj.MoveSpeed); var x = Geometry.Intersection(from.To2D(), to.To2D(), obj.Position.To2D(), obj2.To2D()); if (x.Intersects == true) { result.Add(obj); } else { Vector2 y; double d; math.FindDistanceToSegment(obj2.To2D(), from.To2D(), to.To2D(), out y, out d); if (from.To2D().Distance(y) <= from.To2D().Distance(to.To2D()) && to.To2D().Distance(y) <= from.To2D().Distance(to.To2D())) { if (d <= obj.BoundingRadius + spell.radius) { result.Add(obj); } } } } else { Vector2 y; double d; math.FindDistanceToSegment(obj.Position.To2D(), from.To2D(), to.To2D(), out y, out d); if (from.To2D().Distance(y) <= from.To2D().Distance(to.To2D()) && to.To2D().Distance(y) <= from.To2D().Distance(to.To2D())) { if (d <= obj.BoundingRadius + spell.radius) { result.Add(obj); } } } } 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))) { if (Utils.TickCount - _wallCastT > 4000) { break; } wall = gameObject; if (wall == null) { break; } 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; var x = Geometry.Intersection(wallStart, wallEnd, from.To2D(), to.To2D()); if (x.Intersects == true) { result.Add(ObjectManager.Player); } else { Vector2 y; double d; math.FindDistanceToSegment(wallStart, from.To2D(), to.To2D(), out y, out d); Vector2 y1; double d1; math.FindDistanceToSegment(wallEnd, from.To2D(), to.To2D(), out y1, out d1); if (from.To2D().Distance(y) <= from.To2D().Distance(to.To2D()) && to.To2D().Distance(y) <= from.To2D().Distance(to.To2D())) { if (d <= spell.radius) { result.Add(ObjectManager.Player); } } if (from.To2D().Distance(y1) <= from.To2D().Distance(to.To2D()) && to.To2D().Distance(y1) <= from.To2D().Distance(to.To2D())) { if (d1 <= spell.radius) { result.Add(ObjectManager.Player); } } } } return(result.Distinct().ToList()); }