private static void AntiTristana(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (args.Slot.Equals(SpellSlot.W) && args.End.Distance(Player.Position) <= SpellManager.Q.Range) { Vector3 TristPosition = new Vector3(); if (args.End.Distance(args.Start) >= 825) TristPosition = sender.Position.Extend(args.End, 825); if (args.Start.Distance(args.End) < 825) TristPosition = args.End; if (MenuConfig.AntiTristana && SpellManager.Q.IsReady()) { if (TristPosition.Distance(Player.Position) <= SpellManager.Q.Range) { Utility.DelayAction.Add((int)(500 + Player.Distance(TristPosition) / args.SData.MissileSpeed - (Player.Distance(TristPosition) / SpellManager.Q.Speed) - 250), () => { if (TristPosition.Distance(Player.Position) < SpellManager.Q.Range) { SpellManager.Q.Cast(TristPosition); } }); } } } }
public static bool CheckPositionForSkipping(Vector3 Position) { foreach (var v in UsedSkipAheadAreaCache) { if (Position.Distance(v.Position) <= v.Radius) return true; } bool valid = false; if (SkipAheadAreaCache.Count > 0) { int validIndex = -1; for (int i = 0; i < SkipAheadAreaCache.Count - 1; i++) { SkipAheadNavigation v = SkipAheadAreaCache[i]; if (Position.Distance(v.Position) <= v.Radius) { validIndex = i; valid = true; break; } } if (valid && validIndex > 0) { UsedSkipAheadAreaCache.Add(SkipAheadAreaCache[validIndex].Clone()); SkipAheadAreaCache.RemoveRange(0, validIndex - 1); SkipAheadAreaCache.TrimExcess(); } } return valid; }
public static void Move_Draw(Vector3 Spell_Start, Vector3 Spell_End, double Spell_Time, int Distance, int Type) { if (Spell_Start.Distance(Spell_End) > Distance){var dis = Spell_Start.Distance(Spell_End) - Distance;Spell_End = Spell_End.Extend(Spell_Start, +dis);} Render.Circle.DrawCircle(Spell_Start, 50, System.Drawing.Color.PaleVioletRed, 1); Render.Circle.DrawCircle(Spell_End, 50, System.Drawing.Color.LawnGreen, 1); var from = Drawing.WorldToScreen(Spell_Start);var to = Drawing.WorldToScreen(Spell_End); Drawing.DrawLine(from[0], from[1], to[0], to[1], 1, System.Drawing.Color.LawnGreen); Drawing.DrawText(from[0], from[1], System.Drawing.Color.PaleVioletRed, "Start"); Drawing.DrawText(to[0], to[1], System.Drawing.Color.PaleVioletRed, "End"); }
public static Obj_AI_Base GetBestObjectFarFrom(Vector3 position) { var minion = AllyMinionManager.GetFurthestTo(position); var ally = AllyHeroManager.GetFurthestTo(position); var ward = WardManager.GetFurthestTo(position); var miniondistance = minion != null ? position.Distance(minion, true) : 0; var allydistance = ally != null ? position.Distance(ally, true) : 0; var warddistance = ward != null ? position.Distance(ward, true) : 0; var best = Math.Max(miniondistance, Math.Max(allydistance, warddistance)); if (best > 0f) { if (Math.Abs(best - allydistance) < float.Epsilon) { return ally; } if (Math.Abs(best - miniondistance) < float.Epsilon) { return minion; } if (Math.Abs(best - warddistance) < float.Epsilon) { return ward; } } return null; }
public static bool MinionCollideLine(Vector3 lineStart, Vector3 lineFinish, Spell spell) { var minion = MinionManager.GetMinions(spell.Range, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.Health); // Render.Circle.DrawCircle(ObjectManager.Player.Position, 100, System.Drawing.Color.Brown, 2); // Render.Circle.DrawCircle(line_finish, 10, System.Drawing.Color.Red, 2); var d = lineStart.Distance(lineFinish); // dis = (int)(dis /spell.Width); var circles = new List<Circle>(); for (var i = 0; i < d; i += 10) { var dist = i > d ? d : i; var point = lineStart.Extend(lineFinish, +dist); circles.Add(new Circle(point, spell.Width)); } foreach (var c in circles) { foreach (var m in minion) { if (Geometry.CircleCircleIntersection(c.pos.To2D(), m.Position.To2D(), c.range, 100).Count()!=0) { return true; } } } // foreach(Obj_AI_Base m in minion) // { // m. // } // Geometry.cu return false; }
/// <summary> /// Moves to a world position /// (naive, blocks execution, avoid using while in combat) /// </summary> /// <param name="location">where to move to</param> /// <param name="destinationName">name of location for debugging purposes</param> /// <param name="range">how close it should get</param> public static async Task<bool> MoveTo(Vector3 location, string destinationName = "", float range = 10f, Func<bool> stopCondition = null) { var distance = 0f; var name = string.IsNullOrEmpty(destinationName) ? location.ToString() : destinationName; Navigator.PlayerMover.MoveTowards(location); while (ZetaDia.IsInGame && (distance = location.Distance(ZetaDia.Me.Position)) >= range) { if (stopCondition != null && stopCondition()) break; if (ZetaDia.Me.IsDead || Navigator.StuckHandler.IsStuck) break; if (Navigation.IsBlocked) { Log.Verbose("Movement Failed, It looks like we're blocked!", name, distance); break; } Log.Verbose("Moving to {0} Distance={1}", name, distance); await Navigator.MoveTo(location, name); await Coroutine.Yield(); } if (distance <= range) Navigator.PlayerMover.MoveStop(); Log.Verbose("MoveTo Finished. Distance={0}", distance); return true; }
private static void MoveTo(Vector3 position, float holdAreaRadius = -1) { var delay = 100; if (Environment.TickCount - _lastMovement < delay) return; _lastMovement = Environment.TickCount; if (!CanMove()) return; if (player.Position.Distance(position)>50) player.IssueOrder(GameObjectOrder.MoveTo, position); return; if (holdAreaRadius < 0) holdAreaRadius = 20; if (player.ServerPosition.Distance(position) < holdAreaRadius) { if (player.Path.Count() > 1) player.IssueOrder(GameObjectOrder.HoldPosition, player.ServerPosition); return; } if (position.Distance(player.Position) < 200) player.IssueOrder(GameObjectOrder.MoveTo, position); else { var point = player.ServerPosition + 200 * (position.To2D() - player.ServerPosition.To2D()).Normalized().To3D(); player.IssueOrder(GameObjectOrder.MoveTo, point); } }
private void EngageFriendLatern() { if(!W.IsReady()) return; var bestcastposition = new Vector3(0f, 0f, 0f); foreach(var friend in PUC.AllHerosFriend.Where(hero => !hero.IsMe && hero.Distance(PUC.Player) <= W.Range + 300 && hero.Distance(PUC.Player) <= W.Range - 300 && hero.Health / hero.MaxHealth * 100 >= 20 && EnemysinRange(150))) { var center = PUC.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.Distance(friend.Position) <= bestcastposition.Distance(friend.Position)) bestcastposition = friend.Position; } if(!(friend.Distance(PUC.Player) <= W.Range)) continue; W.Cast(bestcastposition, UsePackets()); return; } if(bestcastposition.Distance(new Vector3(0f, 0f, 0f)) >= 100) W.Cast(bestcastposition, UsePackets()); }
private static void PingGround(Vector3 point, PingCategory pingtype) { if (point.Distance(ObjectManager.Player.ServerPosition) > 1000) return; if (Utils.GameTimeTickCount - LastPing < Rand.Next(100, 1100) || NumberOfPings >= Rand.Next(Math.Max(1, Config.Item("maxpings").GetValue<Slider>().Value/2), Config.Item("maxpings").GetValue<Slider>().Value)) return; LastPing = Utils.GameTimeTickCount; NumberOfPings++; Game.SendPing(pingtype, point); }
private static void PingGround(Vector3 point, PingCategory pingtype) { if (point.Distance(Player.Instance.ServerPosition) > 1000) return; if (Environment.TickCount - LastPing < Rnd.Next(100, 1100) || NumberOfPings >= Rnd.Next(Math.Max(1, Config["maxpings"].Cast<Slider>().CurrentValue / 2), Config["maxpings"].Cast<Slider>().CurrentValue)) return; LastPing = Environment.TickCount; NumberOfPings++; TacticalMap.SendPing(pingtype, point); }
static bool CastSpell(Vector3 lanternPos) { if (Spell != null && Spell.IsReady() && lanternPos.Distance(Player.ServerPosition) <= Spell.Range) { Console.WriteLine("Cast spell to lantern"); Spell.Cast(lanternPos); return true; } return false; }
public Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, float range) { if (end.IsValid() && start.Distance(end) <= range) { var newPoint = start.Extend(end, range); return NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall() ? newPoint : Vector3.Zero; } return Vector3.Zero; }
//my condemn logic so far public static Obj_AI_Base GetTarget(Vector3 fromPosition) { var targetList = EntityManager.Heroes.Enemies.Where( h => h.IsValidTarget(Manager.SpellManager.E.Range) && !h.HasBuffOfType(BuffType.SpellShield) && !h.HasBuffOfType(BuffType.SpellImmunity) && h.Health > ObjectManager.Player.GetAutoAttackDamage(h, true) * 2).ToList(); if (!targetList.Any()) { return null; } foreach (var enemy in targetList) { var prediction = Manager.SpellManager.E2.GetPrediction(enemy); var predictionsList = new List<Vector3> { enemy.ServerPosition, enemy.Position, prediction.CastPosition, prediction.UnitPosition }; var wallsFound = 0; foreach (var position in predictionsList) { var distance = fromPosition.Distance(position); for (var i = 0; i < Manager.MenuManager.CondemnPushDistance; i += (int)enemy.BoundingRadius) { var finalPosition = fromPosition.Extend(position, distance + i).To3D(); var j4Flag = Manager.MenuManager.J4Flag && (Variables.IsJ4Flag(finalPosition, enemy)); if (NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Wall) || NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Building) || j4Flag) { wallsFound++; break; } } } if (wallsFound >= Manager.MenuManager.CondemnHitchance) { return enemy; } } return null; }
public static int CountEnemiesInRangeDeley(Vector3 position, float range, float delay) { int count = 0; foreach (var t in HeroManager.Enemies.Where(t => t.IsValidTarget())) { Vector3 prepos = Prediction.GetPrediction(t, delay).CastPosition; if (position.Distance(prepos) < range) count++; } return count; }
public static int CountEnemies(Vector3 from, float Range, GameObjectTeam team) { int Counter = 0; List<Obj_AI_Hero> Enemies = null; Enemies = ObjectHandler.Get<Obj_AI_Hero>().Where(t => t.IsEnemy && !t.IsDead).ToList(); foreach (Obj_AI_Hero hero in Enemies) { if (from.Distance(hero.Position) < Range) { Counter++; } } return Counter; }
public static float Distance(Vector3 a, Vector3 b) { float distance = 0; if (b == Vector3.Zero) { distance = float.MinValue; Logger.WriteVerbose("Position a: {0}", a); Logger.WriteVerbose("Position b: {0}", b); } else { a = Gw2Math.VectorToLarge(a); b = Gw2Math.VectorToLarge(b); distance = a.Distance(b); } return distance; }
/// <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 (Utils.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 (int i = 0; i < start.Distance(end); i += 30) { var currentPosition = start.Extend(end, i); if (wallStart.Intersection(wallEnd, currentPosition.To2D(), start.To2D()).Intersects) { return true; } } return false; }
public static bool Cast(this Spells spell, Vector3 from, Vector3 rangecheckfrom, Obj_AI_Base ToTarget, Spells.HitChances minhitchance = Spells.HitChances.VeryLow, bool UseExtendRadiusSSCirle = true) { if (spell.spellslot.IsReady()) { if (GetHiChance(from, ToTarget, spell) >= spell.MinHitChance && GetHiChance(from, ToTarget, spell) >= minhitchance) { Vector3 y = new Vector3(0, 0, 0); Vector3 pos = Predictions.GetPrediction(from, ToTarget, spell, true); if (rangecheckfrom.Distance(pos) <= spell.range && pos != y) { if (spell.collision == false) return Player.Spellbook.CastSpell(spell.spellslot, pos); else { List<Obj_AI_Base> list = Collisions.GetCollision(from, pos, spell); if (list.Count == 0 || spell == Lux.Q && list.Count <= 1) { Vector3 pos1 = Predictions.GetPrediction(from, ToTarget, spell); return Player.Spellbook.CastSpell(spell.spellslot, pos1); } else return false; } } else if (UseExtendRadiusSSCirle == true && spell.skillshottype == SkillshotType.SkillshotCircle) { Spells x = new Spells(spell.spellslot, spell.skillshottype, spell.range + spell.radius - 20, spell.delay, 20, false, spell.speed); Vector3 y1 = new Vector3(0, 0, 0); Vector3 pos1 = Predictions.GetPrediction(from, ToTarget, x, true); if (rangecheckfrom.Distance(pos1) <= x.range && pos1 != y1) { var pos2 = Player.Position.Extend(pos1, spell.range); return Player.Spellbook.CastSpell(spell.spellslot, pos2); } else return false; } else return false; } else return false; } else return false; }
/// <summary> /// Orders a move onto the player, with the <c>orbwalker</c> parameters. /// </summary> /// <param name="position"> /// The position to <c>orbwalk</c> to /// </param> public static void MoveOrder(Vector3 position) { if (position.Distance(GameObjects.Player.Position) > GameObjects.Player.BoundingRadius + Menu["advanced"]["movementExtraHold"].GetValue<MenuSlider>().Value) { if (position.Distance(GameObjects.Player.Position) > Menu["advanced"]["movementMaximumDistance"].GetValue<MenuSlider>().Value) { var menuItem = Menu["advanced"]["movementMaximumDistance"].GetValue<MenuSlider>(); var randomDistance = new Random(Variables.TickCount).Next(0, 50); position = menuItem.Value - randomDistance <= GameObjects.Player.BoundingRadius ? GameObjects.Player.Position.Extend( position, GameObjects.Player.BoundingRadius + randomDistance) : GameObjects.Player.Position.Extend(position, menuItem.Value - randomDistance); } if (Menu["advanced"]["movementScramble"].GetValue<MenuBool>().Value) { var random = new Random(Variables.TickCount); var angle = 2D * System.Math.PI * random.NextDouble(); var radius = GameObjects.Player.Distance(Game.CursorPos) < 360 ? 0F : GameObjects.Player.BoundingRadius / 2f; var x = (float)(position.X + radius * System.Math.Cos(angle)); var y = (float)(position.Y + radius * System.Math.Sin(angle)); position = new Vector3(x, y, NavMesh.GetHeightForPosition(x, y)); } var eventArgs = new OrbwalkerActionArgs { Position = position, Process = true, Type = OrbwalkerType.Movement }; InvokeAction(eventArgs); if (eventArgs.Process && GameObjects.Player.IssueOrder(GameObjectOrder.MoveTo, eventArgs.Position)) { lastMovementOrderTick = Variables.TickCount; } } }
public static bool inHeroRadius(Vector3 pos) { return ObjectManager.Get<Obj_AI_Hero>().Where(hero => hero.BaseSkinName == following.BaseSkinName).Any(hero => pos.Distance(hero.Position) < _followDistance); }
public static bool inTowerRange(Vector3 pos) { return ObjectManager.Get<Obj_AI_Turret>().Where(tur => tur.IsAlly && tur.Health > 0).Any(tur => pos.Distance(tur.Position) < (500 + myHero.BoundingRadius)); }
private static void Check(bool dash, Obj_AI_Hero sender, Vector3 startPosition, Vector3 endPosition, float endTime, bool targeted) { try { if (!sender.IsValid || !sender.IsEnemy || sender.IsDead) { return; } if (Game.Time - endTime >= 5) { return; } if (endPosition.Distance(ObjectManager.Player.ServerPosition) >= 2000) { return; } foreach (var entry in Menues) { var uniqueId = entry.Key; var menu = entry.Value; if (HeroListManager.Check(entry.Key, sender)) { var distance = menu.Item(menu.Name + ".gap-" + uniqueId + ".distance").GetValue<Slider>().Value; var dangerous = menu.Item(menu.Name + ".gap-" + uniqueId + ".dangerous").GetValue<bool>(); if (startPosition.Distance(ObjectManager.Player.Position) >= distance && (!dangerous || IsDangerous(sender, startPosition, endPosition, targeted))) { var delay = menu.Item(menu.Name + ".gap-" + uniqueId + ".delay").GetValue<Slider>().Value; Utility.DelayAction.Add( Math.Max(1, dash ? delay - 100 : delay), delegate { OnGapcloser.RaiseEvent( null, new GapcloserManagerArgs( uniqueId, sender, startPosition, endPosition, endTime - (delay / 1000f))); }); } } } OnGapcloser.RaiseEvent( null, new GapcloserManagerArgs(string.Empty, sender, startPosition, endPosition, endTime)); } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } }
private static bool IsDangerous(Obj_AI_Hero sender, Vector3 startPosition, Vector3 endPosition, bool targeted) { try { var endDistance = endPosition.Distance(ObjectManager.Player.Position); var startDistance = startPosition.Distance(ObjectManager.Player.Position); if (targeted) { return true; } if (endDistance <= 150f) { return true; } if (startDistance - 100f > endDistance) { var spell = sender.GetSpell(SpellSlot.R); if (spell != null && endDistance <= 600) { return spell.Cooldown >= 20 && spell.IsReady(2500); } if (endDistance <= 500 && ObjectManager.Player.HealthPercent < 50) { return true; } } if (endDistance > startDistance) { return false; } if (endDistance >= 450) { return false; } } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return true; }
private Vector3 BestRFollowLocation(Vector3 position) { try { var center = Vector2.Zero; float radius = -1; var count = 0; var moveDistance = -1f; var maxRelocation = IsSpellUpgraded(R) ? R.Width * 1.2f : R.Width * 0.8f; var targets = GameObjects.EnemyHeroes.Where(t => t.IsValidTarget(1500f)).ToList(); var circle = new Geometry.Polygon.Circle(position, R.Width); if (targets.Any()) { var minDistance = targets.Any(t => circle.IsInside(t)) ? targets.Min(t => t.BoundingRadius) * 2 : 0; var possibilities = ListExtensions.ProduceEnumeration(targets.Select(t => t.Position.To2D()).ToList()) .Where(p => p.Count > 1) .ToList(); if (possibilities.Any()) { foreach (var possibility in possibilities) { var mec = MEC.GetMec(possibility); var distance = position.Distance(mec.Center.To3D()); if (mec.Radius < R.Width && distance < maxRelocation && distance > minDistance) { if (possibility.Count > count || possibility.Count == count && (mec.Radius < radius || distance < moveDistance)) { moveDistance = position.Distance(mec.Center.To3D()); center = mec.Center; radius = mec.Radius; count = possibility.Count; } } } if (!center.Equals(Vector2.Zero)) { return center.To3D(); } } var dTarget = targets.OrderBy(t => t.Distance(position)).FirstOrDefault(); if (dTarget != null && position.Distance(dTarget.Position) > minDistance) { return dTarget.Position; } } } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return Vector3.Zero; }
public static bool IsWallBetween(Vector3 start, Vector3 end, int step = 3) { if (start.IsValid() && end.IsValid() && step > 0) { var distance = start.Distance(end); for (var i = 0; i < distance; i = i + step) { if (NavMesh.GetCollisionFlags(start.Extend(end, i)) == CollisionFlags.Wall) { return true; } } } return false; }
public static void CreateSpellData(Obj_AI_Base hero, Vector3 spellStartPos, Vector3 spellEndPos, SpellData spellData, GameObject obj = null, float extraEndTick = 0.0f, bool processSpell = true, SpellType spellType = SpellType.None, bool checkEndExplosion = true, float spellRadius = 0) { if (checkEndExplosion && spellData.hasEndExplosion) { CreateSpellData(hero, spellStartPos, spellEndPos, spellData, obj, extraEndTick, false, spellData.spellType, false); CreateSpellData(hero, spellStartPos, spellEndPos, spellData, obj, extraEndTick, true, SpellType.Circular, false); return; } if (spellStartPos.Distance(myHero.Position) < spellData.range + 1000) { Vector2 startPosition = spellStartPos.To2D(); Vector2 endPosition = spellEndPos.To2D(); Vector2 direction = (endPosition - startPosition).Normalized(); float endTick = 0; if (spellType == SpellType.None) { spellType = spellData.spellType; } if (spellData.fixedRange) //for diana q { if (endPosition.Distance(startPosition) > spellData.range) { //var heroCastPos = hero.ServerPosition.To2D(); //direction = (endPosition - heroCastPos).Normalized(); endPosition = startPosition + direction * spellData.range; } } if (spellType == SpellType.Line) { endTick = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000; endPosition = startPosition + direction * spellData.range; if (spellData.useEndPosition) { var range = spellEndPos.To2D().Distance(spellStartPos.To2D()); endTick = spellData.spellDelay + (range / spellData.projectileSpeed) * 1000; endPosition = spellEndPos.To2D(); } if (obj != null) endTick -= spellData.spellDelay; } else if (spellType == SpellType.Circular) { endTick = spellData.spellDelay; if (spellData.projectileSpeed == 0) { endPosition = hero.ServerPosition.To2D(); } else if (spellData.projectileSpeed > 0) { if (spellData.spellType == SpellType.Line && spellData.hasEndExplosion && spellData.useEndPosition == false) { endPosition = startPosition + direction * spellData.range; } endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed; } } else if (spellType == SpellType.Arc) { endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed; if (obj != null) endTick -= spellData.spellDelay; } else if (spellType == SpellType.Cone) { return; } else { return; } endTick += extraEndTick; Spell newSpell = new Spell(); newSpell.startTime = EvadeUtils.TickCount; newSpell.endTime = EvadeUtils.TickCount + endTick; newSpell.startPos = startPosition; newSpell.endPos = endPosition; newSpell.height = spellEndPos.Z + spellData.extraDrawHeight; newSpell.direction = direction; newSpell.heroID = hero.NetworkId; newSpell.info = spellData; newSpell.spellType = spellType; newSpell.radius = spellRadius > 0 ? spellRadius : newSpell.GetSpellRadius(); if (obj != null) { newSpell.spellObject = obj; newSpell.projectileID = obj.NetworkId; } int spellID = CreateSpell(newSpell, processSpell); DelayAction.Add((int)(endTick + spellData.extraEndTime), () => DeleteSpell(spellID)); } }
private int GetRangeDelay(Vector3 position, Vector3 lastPosition, int percent) { if (percent > 0 && position.IsValid() && lastPosition.IsValid()) { var distance = position.Distance(lastPosition); if (Helpers.AngleBetween(lastPosition, position) > _random.Next(15, 26) && distance > 200) { var rangeDelay = (int) (distance * _random.Next(75, 86) / 100 / 100 * percent); return Math.Min(_random.Next(1250, 1500) / 100 * percent, rangeDelay); } } return 0; }
public static Geometry.Polygon GetPolyFromVector(Vector3 from, Vector3 to, float width) { var POS = to.Extend(from, from.Distance(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; }
public static bool CheckWalls(Vector3 from, Vector3 to) { var steps = 6f; var stepLength = from.Distance(to)/steps; for (var i = 1; i < steps + 1; i++) { if (from.Extend(to, stepLength*i).IsWall()) { return true; } } return false; }
public static HitChance GetHitChance(SpellSlot spellslot, float range, SkillShotType type, float delay, float speed, float radius,Vector3 fromPoint, Obj_AI_Base target) { // CAN'T MOVE SPELLS /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.GetSpecialSpellEndTime(target) > 0 || target.HasBuff("recall") || (UnitTracker.GetLastStopMoveTime(target) < 0.1d && target.IsRooted)) { return HitChance.High; } // PREPARE MATH /////////////////////////////////////////////////////////////////////////////////// var tempHitchance = HitChance.Low; var lastWaypiont = target.RealPath().Last(); var distanceUnitToWaypoint = lastWaypiont.Distance(target.ServerPosition); var distanceFromToUnit = fromPoint.Distance(target.ServerPosition); var distanceFromToWaypoint = lastWaypiont.Distance(fromPoint); var getAngle = GetAngle(fromPoint, target); float speedDelay = distanceFromToUnit / speed; if (Math.Abs(speed - float.MaxValue) < float.Epsilon) speedDelay = 0; float totalDelay = speedDelay + delay; float moveArea = target.MoveSpeed * totalDelay; float fixRange = moveArea * 0.4f; float pathMinLen = 900 + + moveArea; double angleMove = 31; if (radius > 70) angleMove ++; else if (radius <= 60) angleMove--; if (delay < 0.3) angleMove++; if (UnitTracker.GetLastNewPathTime(target) < 0.1d) { tempHitchance = HitChance.High; pathMinLen = 700f + moveArea; angleMove += 1.5; fixRange = moveArea * 0.3f; } if (type == SkillShotType.Circular) { fixRange -= radius / 2; } // FIX RANGE /////////////////////////////////////////////////////////////////////////////////// if (distanceFromToWaypoint <= distanceFromToUnit) { if (distanceFromToUnit > range - fixRange) { tempHitchance = HitChance.Medium; // return tempHitchance; } } else if (distanceUnitToWaypoint > 350) { angleMove += 1.5; } // SPAM CLICK /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.PathCalc(target)) { //OktwCommon.debug("PRED: SPAM CLICK"); if(distanceFromToUnit < range - fixRange) tempHitchance = HitChance.High; else tempHitchance = HitChance.Medium; // return tempHitchance; } // SPAM POSITION /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.SpamSamePlace(target)) { //OktwCommon.debug("PRED: SPAM POSITION"); return HitChance.High; } // SPECIAL CASES /////////////////////////////////////////////////////////////////////////////////// if (distanceFromToUnit < 250) { //OktwCommon.debug("PRED: SPECIAL CASES NEAR"); return HitChance.High; } else if( target.MoveSpeed < 250) { //OktwCommon.debug("PRED: SPECIAL CASES SLOW"); return HitChance.High; } else if(distanceFromToWaypoint < 250) { //OktwCommon.debug("PRED: SPECIAL CASES ON WAY"); return HitChance.High; } // LONG CLICK DETECTION /////////////////////////////////////////////////////////////////////////////////// if (distanceUnitToWaypoint > pathMinLen) { //OktwCommon.debug("PRED: LONG CLICK DETECTION"); return HitChance.High; } // RUN IN LANE DETECTION /////////////////////////////////////////////////////////////////////////////////// if (getAngle < angleMove && distanceUnitToWaypoint > 260) { //OktwCommon.debug(GetAngle(input.From, target) + " PRED: ANGLE " + angleMove + " DIS " + distanceUnitToWaypoint); return HitChance.High; } // CIRCLE NEW PATH /////////////////////////////////////////////////////////////////////////////////// if (type == SkillShotType.Circular) { if (UnitTracker.GetLastNewPathTime(target) < 0.1d && distanceUnitToWaypoint > fixRange) { //OktwCommon.debug("PRED: CIRCLE NEW PATH"); return HitChance.High; } } // LOW HP DETECTION /////////////////////////////////////////////////////////////////////////////////// if (target.HealthPercent < 20 || ObjectManager.Player.HealthPercent < 20) { tempHitchance = HitChance.Medium; // return HitChance.Medium; } // STOP LOGIC /////////////////////////////////////////////////////////////////////////////////// if (target.RealPath().LastOrDefault() != target.ServerPosition) { if ((UnitTracker.GetLastAutoAttackTime(target) < 0.1 || UnitTracker.GetLastStopMoveTime(target) < 0.1) && totalDelay < 0.6) { //OktwCommon.debug("PRED: STOP LOGIC WINDING"); tempHitchance = HitChance.Medium; } else if (UnitTracker.GetLastStopMoveTime(target) < 0.5) { tempHitchance = HitChance.Medium; } else { //OktwCommon.debug("PRED: STOP LOGIC"); tempHitchance = HitChance.Medium; } return tempHitchance; } //Program.debug("PRED: NO DETECTION"); return tempHitchance; }