Beispiel #1
0
 private void SynchronizeToGameFps(GController gc, bool bForce = false)
 {
     if (bForce || syncFpsWatch.ElapsedMilliseconds >= 30000)
     {
         var bitmap = gc.ScreenCapture();
         while (Util.Equals(bitmap, gc.ScreenCapture(), 1000))
         {
         }
         syncFramesProcessed = 0;
         syncFpsWatch.Restart();
     }
 }
Beispiel #2
0
 private void StartDetectorThread()
 {
     new Thread(() =>
     {
         Thread.CurrentThread.IsBackground = true;
         var gc = new GController(s);
         SynchronizeToGameFps(gc, true);
         while (true)
         {
             if (!aimEnabled)
             {
                 continue;
             }
             if (trackSkippedFrames > MaxFramesToResetTarget && targetDetected != null)
             {
                 NewTargetFound(null);
             }
             //if (true) // no sync
             if (IsNewFrameReady()) // update enemy info
             {
                 syncFramesProcessed++;
                 var newFrame = gc.ScreenCapture();
                 // do tracking
                 //if (trackSkippedFrames <= TrackMaxSkippedFrames)
                 //{
                 //    var tmp = nn.Track(newFrame);
                 //    // no target, lets predict
                 //    if (tmp == null)
                 //    {
                 //        trackSkippedFrames++;
                 //        //PredictTarget();
                 //    }
                 //    // found smth focusing on it
                 //    else
                 //    {
                 //        NewTargetFound(tmp);
                 //        UpdateSpeed(true);
                 //    }
                 //}
                 //// using regular search
                 //else
                 {
                     var confidence = IsAiming() ? 0.2f : 0.4f;
                     var enemies    = nn.GetItems(newFrame, confidence);
                     if (enemies == null || !enemies.Any())
                     {
                         trackSkippedFrames++;
                         if (trackSkippedFrames <= TrackMaxSkippedFrames)
                         {
                             //PredictTarget();
                         }
                         else
                         {
                             UpdateSpeed(false);
                         }
                     }
                     else
                     {
                         trackSkippedFrames = 0;
                         var tmp            = GetClosestEnemy(enemies);
                         NewTargetFound(tmp);
                         UpdateSpeed(true);
                     }
                 }
             }
             else // no need to update enemy info
             {
                 SynchronizeToGameFps(gc);
                 SleepTillNextFrame();
             }
         }
     }).Start();
 }