@@ -190,12 +190,13 @@ public void PrintBenchmarks()
190190 var data = kvp . Value ;
191191 lines . Add ( $ "{ kvp . Key } : Avg={ data . AverageTime : F2} ms, Min={ data . MinTime } ms, Max={ data . MaxTime } ms, Count={ data . CallCount } ") ;
192192 }
193+ var overallFps = iterationCount > 0 && totalTime > 0 ? 1000.0 * iterationCount / totalTime : 0 ;
193194
194- lines . Add ( $ "Overall FPS: { ( 1000.0 / ( ( double ) totalTime / iterationCount ) ) : F2} ") ;
195+ lines . Add ( $ "Overall FPS: { overallFps : F2} ") ;
195196
196197 //File.WriteAllLines("AIManager_Benchmarks.txt", lines);
197198
198- LogManager . Log ( LogManager . LogLevel . Info , string . Join ( Environment . NewLine , lines ) ) ;
199+ Log ( LogLevel . Info , string . Join ( Environment . NewLine , lines ) ) ;
199200 }
200201 }
201202
@@ -982,12 +983,18 @@ private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction clo
982983 private Prediction ? HandleStickyAim ( Prediction ? bestCandidate , List < Prediction > KDPredictions )
983984 {
984985 bool stickyAimEnabled = Dictionary . toggleState [ "Sticky Aim" ] ;
985- if ( ! stickyAimEnabled ) return bestCandidate ;
986+ if ( ! stickyAimEnabled )
987+ {
988+ _currentTarget = bestCandidate ; // update anyway
989+ return bestCandidate ;
990+ }
991+
992+ float thresholdSqr = ( float ) Math . Pow ( Dictionary . sliderSettings [ "Sticky Aim Threshold" ] , 2 ) ;
993+
986994 if ( _currentTarget != null )
987995 {
988996 Prediction ? matchedTarget = null ;
989997 float minSqrDistance = float . MaxValue ;
990- float thresholdSqr = ( float ) Math . Pow ( Dictionary . sliderSettings [ "Sticky Aim Threshold" ] , 2 ) ;
991998
992999 foreach ( var candidate in KDPredictions )
9931000 {
@@ -1002,14 +1009,21 @@ private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction clo
10021009 if ( matchedTarget != null )
10031010 {
10041011 _consecutiveFramesWithoutTarget = 0 ;
1012+ _currentTarget = matchedTarget ;
10051013 return matchedTarget ;
10061014 }
10071015
10081016 if ( ++ _consecutiveFramesWithoutTarget > MAX_FRAMES_WITHOUT_TARGET )
10091017 {
10101018 _currentTarget = null ;
1019+ } else
1020+ {
1021+ return null ; // No match found, keep the current target
10111022 }
10121023 }
1024+
1025+ // acquire a new target
1026+ _currentTarget = bestCandidate ;
10131027 return bestCandidate ;
10141028 }
10151029
0 commit comments