Exemple #1
0
        public static void setNextStart()
        {
//            Logger.WriteLine($"setting the next start");
            currentArea = GetRandomArea();
            var startRect = GetRandomRect(currentArea);
            var start     = GetRandomPoint(startRect);
            var startZ    = GetGroundHeightMagic(start);

            Game.Player.Character.IsInvincible = true;
            Logger.WriteLine($"{startZ} is ground height of {start}");
            var newPosition = new Vector3(start.X, start.Y, startZ + 2);    // so we have some reserve, when setting to ground z coord, it falls through

            if (Game.Player.Character.IsInVehicle())
            {
                Game.Player.Character.CurrentVehicle.Position = newPosition;
            }
            else
            {
                Game.Player.Character.Position = newPosition;
            }
            targetsFromSameStart     = 0;
            currentlyDrivingToTarget = false;
            Logger.WriteLine($"setting next start in {newPosition}");
            VisionExport.UINotify($"setting next start in {newPosition}");
        }
Exemple #2
0
        public static void setNextTarget()
        {
            if (currentlyDrivingToTarget)
            {
                return;
            }

//            setting the new start in new area after some number of targets from same start
//            var targetsPerArea = 10;
            var targetsPerArea = 5; //5 for testing purpose

            if (targetsPerArea < targetsFromSameStart || currentArea == null)
            {
                setNextStart();
            }

//                firstly, select some area and for a while, perform random walk in that area, then randomly selct other area
//                at first, I'll randomly sample rectangle from area, then randomly sample point from that rectangle
//                sampling rectangles is in ratio corresponsing to their sizes, so smaller rectangle is not sampled more often

//                because vehicle is driving onroad for longer routes, generated target shall be max. 200 meters from start, behaving as a "waypoint" on randomly sampled route
            Vector2 target;
            var     playerPos = Game.Player.Character.Position;

            do
            {
                var targetRect = GetRandomRect(currentArea);
                target = GetRandomPoint(targetRect);
            } while (target.DistanceTo(new Vector2(playerPos.X, playerPos.Y)) > 200);
            Logger.WriteLine($"setting next target in {target}");
            VisionExport.UINotify($"setting next target in {target}");
            DriveToPoint(target);

            currentlyDrivingToTarget = true;
            currentTarget            = target;
            targetsFromSameStart    += 1;
            VisionExport.clearStuckCheckers();
            VisionExport.LongFarFromTarget.center = currentTarget.Value;
        }