From 187706c71c267f18559b37f8b166e9f4da65241a Mon Sep 17 00:00:00 2001
From: MtH <mth@mth.moe>
Date: Wed, 8 Sep 2021 19:28:11 +0200
Subject: [PATCH] note hit, scoring windows & stricter sustain note holding
 this is some big impact shit so feel it out first

---
 source/Conductor.hx |  3 ---
 source/Note.hx      | 17 ++++++++++++-----
 source/PlayState.hx |  6 +++---
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/source/Conductor.hx b/source/Conductor.hx
index 9f3f50031..49d2cd290 100644
--- a/source/Conductor.hx
+++ b/source/Conductor.hx
@@ -23,9 +23,6 @@ class Conductor
 	public static var lastSongPos:Float;
 	public static var offset:Float = 0;
 
-	public static var safeFrames:Int = 10;
-	public static var safeZoneOffset:Float = (safeFrames / 60) * 1000; // is calculated in create(), is safeFrames in milliseconds
-
 	public static var bpmChangeMap:Array<BPMChangeEvent> = [];
 
 	public function new()
diff --git a/source/Note.hx b/source/Note.hx
index ef57dc6f1..acde0b250 100644
--- a/source/Note.hx
+++ b/source/Note.hx
@@ -34,7 +34,6 @@ class Note extends FlxSprite
 	public var isSustainNote:Bool = false;
 
 	public var colorSwap:ColorSwap;
-	public var noteScore:Float = 1;
 
 	public static var swagWidth:Float = 160 * 0.7;
 	public static var PURP_NOTE:Int = 0;
@@ -42,6 +41,15 @@ class Note extends FlxSprite
 	public static var BLUE_NOTE:Int = 1;
 	public static var RED_NOTE:Int = 3;
 
+	// SCORING STUFF
+	public static var safeFrames:Int = 10;
+	public static var HIT_WINDOW:Float = (safeFrames / 60) * 1000; // 166.67 ms hit window
+	// anything above bad threshold is shit
+	public static var BAD_THRESHOLD:Float = 0.8; // 	125ms	, 8 frames
+	public static var GOOD_THRESHOLD:Float = 0.55; // 	91.67ms	, 5.5 frames
+	public static var SICK_THRESHOLD:Float = 0.2; // 	33.33ms	, 2 frames
+	// anything below sick threshold is sick
+
 	public static var arrowColors:Array<Float> = [1, 1, 1, 1];
 
 	public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false)
@@ -145,7 +153,6 @@ class Note extends FlxSprite
 
 		if (isSustainNote && prevNote != null)
 		{
-			noteScore * 0.2;
 			alpha = 0.6;
 
 			if (PreferencesMenu.getPref('downscroll'))
@@ -224,9 +231,9 @@ class Note extends FlxSprite
 			}
 			else
 			{
-				if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset)
-				{ // The * 0.5 is so that it's easier to hit them too late, instead of too early
-					if (strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5))
+				if (strumTime > Conductor.songPosition - HIT_WINDOW)
+				{ // * 0.2 if sustain note, so u have to keep holding it closer to all the way thru!
+					if (strumTime < Conductor.songPosition + (HIT_WINDOW * (isSustainNote ? 0.2 : 1)))
 						canBeHit = true;
 				}
 				else
diff --git a/source/PlayState.hx b/source/PlayState.hx
index 51ea7d0d1..832c6d42a 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -2339,19 +2339,19 @@ class PlayState extends MusicBeatState
 
 		var isSick:Bool = true;
 
-		if (noteDiff > Conductor.safeZoneOffset * 0.9)
+		if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD)
 		{
 			daRating = 'shit';
 			score = 50;
 			isSick = false; // shitty copypaste on this literally just because im lazy and tired lol!
 		}
-		else if (noteDiff > Conductor.safeZoneOffset * 0.75)
+		else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD)
 		{
 			daRating = 'bad';
 			score = 100;
 			isSick = false;
 		}
-		else if (noteDiff > Conductor.safeZoneOffset * 0.2)
+		else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD)
 		{
 			daRating = 'good';
 			score = 200;