public static PositionInfo GetBestPositionMovementBlock(Vector2 movePos) { int posChecked = 0; int maxPosToCheck = 50; int posRadius = 50; int radiusIndex = 0; var extraEvadeDistance = ObjectCache.menuCache.cache["ExtraAvoidDistance"].Cast<Slider>().CurrentValue; Vector2 heroPoint = ObjectCache.myHeroCache.serverPos2D; Vector2 lastMovePos = movePos;//Game.CursorPos.To2D(); //movePos List<PositionInfo> posTable = new List<PositionInfo>(); var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"].Cast<Slider>().CurrentValue; var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"].Cast<Slider>().CurrentValue; while (posChecked < maxPosToCheck) { radiusIndex++; int curRadius = radiusIndex * (2 * posRadius); int curCircleChecks = (int)Math.Ceiling((2 * Math.PI * (double)curRadius) / (2 * (double)posRadius)); for (int i = 1; i < curCircleChecks; i++) { posChecked++; var cRadians = (2 * Math.PI / (curCircleChecks - 1)) * i; //check decimals var pos = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians))); //if (pos.Distance(myHero.Position.To2D()) < 100) // dist = 0; var posInfo = CanHeroWalkToPos(pos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer + ObjectCache.gamePing, extraDist); posInfo.isDangerousPos = pos.CheckDangerousPos(6) || CheckMovePath(pos); posInfo.distanceToMouse = pos.GetPositionValue(); posInfo.hasExtraDistance = extraEvadeDistance > 0 ? pos.HasExtraAvoidDistance(extraEvadeDistance) : false; posTable.Add(posInfo); } } var sortedPosTable = posTable.OrderBy(p => p.isDangerousPos) .ThenBy(p => p.posDangerLevel) .ThenBy(p => p.hasExtraDistance) .ThenBy(p => p.distanceToMouse); //.ThenBy(p => p.intersectionTime); foreach (var posInfo in sortedPosTable) { if (CheckPathCollision(myHero, posInfo.position) == false) return posInfo; } return null; }
public static PositionInfo GetBestPositionMovementBlock(Vector2 movePos) { int posChecked = 0; int maxPosToCheck = 50; int posRadius = 50; int radiusIndex = 0; var extraEvadeDistance = ConfigValue.ExtraSpellRadius.GetInt(); Vector2 heroPoint = GameData.HeroInfo.ServerPos2D; Vector2 lastMovePos = movePos;//Game.CursorPos.To2D(); //movePos List<PositionInfo> posTable = new List<PositionInfo>(); var extraDist = ConfigValue.ExtraCpaDistance.GetInt(); var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer); while (posChecked < maxPosToCheck) { radiusIndex++; int curRadius = radiusIndex * (2 * posRadius); int curCircleChecks = (int)Math.Ceiling((2 * Math.PI * (double)curRadius) / (2 * (double)posRadius)); for (int i = 1; i < curCircleChecks; i++) { posChecked++; var cRadians = (2 * Math.PI / (curCircleChecks - 1)) * i; //check decimals var pos = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians))); //if (pos.Distance(myHero.Position.To2D()) < 100) // dist = 0; var posInfo = CanHeroWalkToPos(pos, GameData.HeroInfo.MoveSpeed, extraDelayBuffer + Game.Ping, extraDist); posInfo.IsDangerousPos = pos.CheckDangerousPos(6) || CheckMovePath(pos); posInfo.DistanceToMouse = pos.GetPositionValue(); posInfo.HasExtraDistance = extraEvadeDistance > 0 ? pos.HasExtraAvoidDistance(extraEvadeDistance) : false; posTable.Add(posInfo); } } var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos) .ThenBy(p => p.PosDangerLevel) .ThenBy(p => p.HasExtraDistance) .ThenBy(p => p.DistanceToMouse); //.ThenBy(p => p.intersectionTime); foreach (var posInfo in sortedPosTable) { if (CheckPathCollision(MyHero, posInfo.Position) == true) return posInfo; } return null; }