mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-26 17:46:08 -05:00
Apply judgements through a seperate function to applyScore
Also adds more to the HitNoteScriptEvent, such as the noteDiff and also isComboBreak. noteDiff is important as it lets you create stuff like notes with reduced hitboxes (i.e mines/"hurt notes") or millisecond hit displays. isComboBreak lets you set whether the judge combo broke, so you could in theory create custom judgements in scripts now with these changes (killer reimplementation in scripts? more likely than you'd think!)
This commit is contained in:
parent
f5143c2d78
commit
2eaea3cdc5
3 changed files with 57 additions and 57 deletions
|
@ -140,16 +140,29 @@ class HitNoteScriptEvent extends NoteScriptEvent
|
||||||
*/
|
*/
|
||||||
public var score:Int;
|
public var score:Int;
|
||||||
|
|
||||||
public function new(note:NoteSprite, healthChange:Float, score:Int, judgement:String, comboCount:Int = 0):Void
|
/**
|
||||||
|
* Whether the judgement caused a combo break.
|
||||||
|
*/
|
||||||
|
public var isComboBreak:Bool = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time difference when the player hit the note
|
||||||
|
*/
|
||||||
|
public var hitDiff:Float = 0;
|
||||||
|
|
||||||
|
public function new(note:NoteSprite, healthChange:Float, score:Int, judgement:String, isComboBreak:Bool, comboCount:Int = 0, hitDiff:Float = 0):Void
|
||||||
{
|
{
|
||||||
super(NOTE_HIT, note, healthChange, comboCount, true);
|
super(NOTE_HIT, note, healthChange, comboCount, true);
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.judgement = judgement;
|
this.judgement = judgement;
|
||||||
|
this.isComboBreak = isComboBreak;
|
||||||
|
this.hitDiff = hitDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function toString():String
|
public override function toString():String
|
||||||
{
|
{
|
||||||
return 'HitNoteScriptEvent(note=' + note + ', comboCount=' + comboCount + ', judgement=' + judgement + ', score=' + score + ')';
|
return 'HitNoteScriptEvent(note=' + note + ', comboCount=' + comboCount + ', judgement=' + judgement + ', score=' + score + ', isComboBreak='
|
||||||
|
+ isComboBreak + ', hitDiff=' + hitDiff + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2080,7 +2080,8 @@ class PlayState extends MusicBeatSubState
|
||||||
|
|
||||||
// Call an event to allow canceling the note hit.
|
// Call an event to allow canceling the note hit.
|
||||||
// NOTE: This is what handles the character animations!
|
// NOTE: This is what handles the character animations!
|
||||||
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', 0);
|
|
||||||
|
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', false, 0);
|
||||||
dispatchEvent(event);
|
dispatchEvent(event);
|
||||||
|
|
||||||
// Calling event.cancelEvent() skips all the other logic! Neat!
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
||||||
|
@ -2176,7 +2177,7 @@ class PlayState extends MusicBeatSubState
|
||||||
|
|
||||||
// Call an event to allow canceling the note hit.
|
// Call an event to allow canceling the note hit.
|
||||||
// NOTE: This is what handles the character animations!
|
// NOTE: This is what handles the character animations!
|
||||||
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', 0);
|
var event:NoteScriptEvent = new HitNoteScriptEvent(note, 0.0, 0, 'perfect', false, 0);
|
||||||
dispatchEvent(event);
|
dispatchEvent(event);
|
||||||
|
|
||||||
// Calling event.cancelEvent() skips all the other logic! Neat!
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
||||||
|
@ -2381,27 +2382,40 @@ class PlayState extends MusicBeatSubState
|
||||||
var daRating = Scoring.judgeNote(noteDiff, PBOT1);
|
var daRating = Scoring.judgeNote(noteDiff, PBOT1);
|
||||||
|
|
||||||
var healthChange = 0.0;
|
var healthChange = 0.0;
|
||||||
|
var isComboBreak = false;
|
||||||
switch (daRating)
|
switch (daRating)
|
||||||
{
|
{
|
||||||
case 'sick':
|
case 'sick':
|
||||||
healthChange = Constants.HEALTH_SICK_BONUS;
|
healthChange = Constants.HEALTH_SICK_BONUS;
|
||||||
|
isComboBreak = Constants.JUDGEMENT_SICK_COMBO_BREAK;
|
||||||
case 'good':
|
case 'good':
|
||||||
healthChange = Constants.HEALTH_GOOD_BONUS;
|
healthChange = Constants.HEALTH_GOOD_BONUS;
|
||||||
|
isComboBreak = Constants.JUDGEMENT_GOOD_COMBO_BREAK;
|
||||||
case 'bad':
|
case 'bad':
|
||||||
healthChange = Constants.HEALTH_BAD_BONUS;
|
healthChange = Constants.HEALTH_BAD_BONUS;
|
||||||
|
isComboBreak = Constants.JUDGEMENT_BAD_COMBO_BREAK;
|
||||||
case 'shit':
|
case 'shit':
|
||||||
|
isComboBreak = Constants.JUDGEMENT_SHIT_COMBO_BREAK;
|
||||||
healthChange = Constants.HEALTH_SHIT_BONUS;
|
healthChange = Constants.HEALTH_SHIT_BONUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the note hit event.
|
// Send the note hit event.
|
||||||
var event:HitNoteScriptEvent = new HitNoteScriptEvent(note, healthChange, score, daRating, Highscore.tallies.combo + 1);
|
var event:HitNoteScriptEvent = new HitNoteScriptEvent(note, healthChange, score, daRating, isComboBreak, Highscore.tallies.combo + 1, noteDiff);
|
||||||
dispatchEvent(event);
|
dispatchEvent(event);
|
||||||
|
|
||||||
// Calling event.cancelEvent() skips all the other logic! Neat!
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
||||||
if (event.eventCanceled) return;
|
if (event.eventCanceled) return;
|
||||||
|
|
||||||
|
Highscore.tallies.totalNotesHit++;
|
||||||
|
// Display the hit on the strums
|
||||||
|
playerStrumline.hitNote(note, !isComboBreak);
|
||||||
|
if (daRating == 'sick') playerStrumline.playNoteSplash(note.noteData.getDirection());
|
||||||
|
if (note.isHoldNote && note.holdNoteSprite != null) playerStrumline.playNoteHoldCover(note.holdNoteSprite);
|
||||||
|
vocals.playerVolume = 1;
|
||||||
|
|
||||||
// Display the combo meter and add the calculation to the score.
|
// Display the combo meter and add the calculation to the score.
|
||||||
popUpScore(note, event.score, event.judgement, event.healthChange);
|
applyScore(event.score, event.judgement, event.healthChange, event.isComboBreak);
|
||||||
|
popUpScore(event.judgement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2412,9 +2426,6 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
// If we are here, we already CALLED the onNoteMiss script hook!
|
// If we are here, we already CALLED the onNoteMiss script hook!
|
||||||
|
|
||||||
health += healthChange;
|
|
||||||
songScore -= 10;
|
|
||||||
|
|
||||||
if (!isPracticeMode)
|
if (!isPracticeMode)
|
||||||
{
|
{
|
||||||
// messy copy paste rn lol
|
// messy copy paste rn lol
|
||||||
|
@ -2454,14 +2465,9 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
vocals.playerVolume = 0;
|
vocals.playerVolume = 0;
|
||||||
|
|
||||||
Highscore.tallies.missed++;
|
if (Highscore.tallies.combo != 0) if (Highscore.tallies.combo >= 10) comboPopUps.displayCombo(0);
|
||||||
|
|
||||||
if (Highscore.tallies.combo != 0)
|
applyScore(-10, 'miss', healthChange, true);
|
||||||
{
|
|
||||||
// Break the combo.
|
|
||||||
if (Highscore.tallies.combo >= 10) comboPopUps.displayCombo(0);
|
|
||||||
Highscore.tallies.combo = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playSound)
|
if (playSound)
|
||||||
{
|
{
|
||||||
|
@ -2593,46 +2599,24 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles health, score, and rating popups when a note is hit.
|
* Handles applying health, score, and ratings.
|
||||||
*/
|
*/
|
||||||
function popUpScore(daNote:NoteSprite, score:Int, daRating:String, healthChange:Float):Void
|
function applyScore(score:Int, daRating:String, healthChange:Float, isComboBreak:Bool)
|
||||||
{
|
{
|
||||||
if (daRating == 'miss')
|
|
||||||
{
|
|
||||||
// If daRating is 'miss', that means we made a mistake and should not continue.
|
|
||||||
FlxG.log.warn('popUpScore judged a note as a miss!');
|
|
||||||
// TODO: Remove this.
|
|
||||||
// comboPopUps.displayRating('miss');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vocals.playerVolume = 1;
|
|
||||||
|
|
||||||
var isComboBreak = false;
|
|
||||||
switch (daRating)
|
switch (daRating)
|
||||||
{
|
{
|
||||||
case 'sick':
|
case 'sick':
|
||||||
Highscore.tallies.sick += 1;
|
Highscore.tallies.sick += 1;
|
||||||
Highscore.tallies.totalNotesHit++;
|
|
||||||
isComboBreak = Constants.JUDGEMENT_SICK_COMBO_BREAK;
|
|
||||||
case 'good':
|
case 'good':
|
||||||
Highscore.tallies.good += 1;
|
Highscore.tallies.good += 1;
|
||||||
Highscore.tallies.totalNotesHit++;
|
|
||||||
isComboBreak = Constants.JUDGEMENT_GOOD_COMBO_BREAK;
|
|
||||||
case 'bad':
|
case 'bad':
|
||||||
Highscore.tallies.bad += 1;
|
Highscore.tallies.bad += 1;
|
||||||
Highscore.tallies.totalNotesHit++;
|
|
||||||
isComboBreak = Constants.JUDGEMENT_BAD_COMBO_BREAK;
|
|
||||||
case 'shit':
|
case 'shit':
|
||||||
Highscore.tallies.shit += 1;
|
Highscore.tallies.shit += 1;
|
||||||
Highscore.tallies.totalNotesHit++;
|
case 'miss':
|
||||||
isComboBreak = Constants.JUDGEMENT_SHIT_COMBO_BREAK;
|
Highscore.tallies.missed += 1;
|
||||||
default:
|
|
||||||
FlxG.log.error('Wuh? Buh? Guh? Note hit judgement was $daRating!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
health += healthChange;
|
health += healthChange;
|
||||||
|
|
||||||
if (isComboBreak)
|
if (isComboBreak)
|
||||||
{
|
{
|
||||||
// Break the combo, but don't increment tallies.misses.
|
// Break the combo, but don't increment tallies.misses.
|
||||||
|
@ -2644,15 +2628,23 @@ class PlayState extends MusicBeatSubState
|
||||||
Highscore.tallies.combo++;
|
Highscore.tallies.combo++;
|
||||||
if (Highscore.tallies.combo > Highscore.tallies.maxCombo) Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
if (Highscore.tallies.combo > Highscore.tallies.maxCombo) Highscore.tallies.maxCombo = Highscore.tallies.combo;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerStrumline.hitNote(daNote, !isComboBreak);
|
|
||||||
|
|
||||||
if (daRating == 'sick')
|
|
||||||
{
|
|
||||||
playerStrumline.playNoteSplash(daNote.noteData.getDirection());
|
|
||||||
}
|
|
||||||
|
|
||||||
songScore += score;
|
songScore += score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles rating popups when a note is hit.
|
||||||
|
*/
|
||||||
|
function popUpScore(daRating:String, ?combo:Int):Void
|
||||||
|
{
|
||||||
|
if (daRating == 'miss')
|
||||||
|
{
|
||||||
|
// If daRating is 'miss', that means we made a mistake and should not continue.
|
||||||
|
FlxG.log.warn('popUpScore judged a note as a miss!');
|
||||||
|
// TODO: Remove this.
|
||||||
|
// comboPopUps.displayRating('miss');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (combo == null) combo = Highscore.tallies.combo;
|
||||||
|
|
||||||
if (!isPracticeMode)
|
if (!isPracticeMode)
|
||||||
{
|
{
|
||||||
|
@ -2692,12 +2684,7 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
comboPopUps.displayRating(daRating);
|
comboPopUps.displayRating(daRating);
|
||||||
if (Highscore.tallies.combo >= 10 || Highscore.tallies.combo == 0) comboPopUps.displayCombo(Highscore.tallies.combo);
|
if (combo >= 10 || combo == 0) comboPopUps.displayCombo(combo);
|
||||||
|
|
||||||
if (daNote.isHoldNote && daNote.holdNoteSprite != null)
|
|
||||||
{
|
|
||||||
playerStrumline.playNoteHoldCover(daNote.holdNoteSprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
vocals.playerVolume = 1;
|
vocals.playerVolume = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6304,7 +6304,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
var tempNote:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault());
|
var tempNote:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault());
|
||||||
tempNote.noteData = noteData;
|
tempNote.noteData = noteData;
|
||||||
tempNote.scrollFactor.set(0, 0);
|
tempNote.scrollFactor.set(0, 0);
|
||||||
var event:NoteScriptEvent = new HitNoteScriptEvent(tempNote, 0.0, 0, 'perfect', 0);
|
var event:NoteScriptEvent = new HitNoteScriptEvent(tempNote, 0.0, 0, 'perfect', false, 0);
|
||||||
dispatchEvent(event);
|
dispatchEvent(event);
|
||||||
|
|
||||||
// Calling event.cancelEvent() skips all the other logic! Neat!
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
||||||
|
|
Loading…
Reference in a new issue