Merge branch 'master' into botplay-light-strums

This commit is contained in:
Spel0
2021-08-08 06:05:24 +03:00
11 changed files with 282 additions and 63 deletions

View File

@ -159,7 +159,10 @@ class PlayState extends MusicBeatState
public static var misses:Int = 0;
public static var campaignMisses:Int = 0;
public static var campaignSicks:Int = 0;
public static var campaignGoods:Int = 0;
public static var campaignBads:Int = 0;
public static var campaignShits:Int = 0;
public var accuracy:Float = 0.00;
@ -292,13 +295,11 @@ class PlayState extends MusicBeatState
if (FlxG.sound.music != null)
FlxG.sound.music.stop();
if (!isStoryMode)
{
sicks = 0;
bads = 0;
shits = 0;
goods = 0;
}
sicks = 0;
bads = 0;
shits = 0;
goods = 0;
misses = 0;
highestCombo = 0;
@ -311,6 +312,7 @@ class PlayState extends MusicBeatState
PlayStateChangeables.scrollSpeed = FlxG.save.data.scrollSpeed;
PlayStateChangeables.botPlay = FlxG.save.data.botplay;
PlayStateChangeables.Optimize = FlxG.save.data.optimize;
PlayStateChangeables.zoom = FlxG.save.data.zoom;
// pre lowercasing the song name (create)
var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase();
@ -397,6 +399,8 @@ class PlayState extends MusicBeatState
FlxG.cameras.add(camSustains);
FlxG.cameras.add(camNotes);
camHUD.zoom = PlayStateChangeables.zoom;
FlxCamera.defaultCameras = [camGame];
persistentUpdate = true;
@ -1568,6 +1572,9 @@ class PlayState extends MusicBeatState
keys[data] = false;
}
public var closestNotes:Array<Note> = [];
private function handleInput(evt:KeyboardEvent):Void
{ // this actually handles press inputs
@ -1623,13 +1630,9 @@ class PlayState extends MusicBeatState
var ana = new Ana(Conductor.songPosition, null, false, "miss", data);
var dataNotes = [];
notes.forEachAlive(function(daNote:Note)
{
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && daNote.noteData == data)
dataNotes.push(daNote);
}); // Collect notes that can be hit
dataNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); // sort by the earliest note
for(i in closestNotes)
if (i.noteData == data)
dataNotes.push(i);
if (dataNotes.length != 0)
{
@ -1679,7 +1682,7 @@ class PlayState extends MusicBeatState
ana.hit = false;
ana.hitJudge = "shit";
ana.nearestNote = [];
health -= 0.10;
health -= 0.30;
}
}
@ -2207,6 +2210,8 @@ class PlayState extends MusicBeatState
perfectMode = false;
#end
if (updateFrame == 4)
{
TimingStruct.clearTimings();
@ -2335,6 +2340,15 @@ class PlayState extends MusicBeatState
if (i <= playerStrums.length)
playerStrums.members[i].visible = p2;
}
camNotes.zoom = camHUD.zoom;
camNotes.x = camHUD.x;
camNotes.y = camHUD.y;
camNotes.angle = camHUD.angle;
camSustains.zoom = camHUD.zoom;
camSustains.x = camHUD.x;
camSustains.y = camHUD.y;
camSustains.angle = camHUD.angle;
}
#end
@ -2574,6 +2588,20 @@ class PlayState extends MusicBeatState
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null)
{
closestNotes = [];
notes.forEachAlive(function(daNote:Note)
{
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
closestNotes.push(daNote);
}); // Collect notes that can be hit
closestNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
if (closestNotes.length != 0)
FlxG.watch.addQuick("Current Note",closestNotes[0].strumTime - Conductor.songPosition);
// Make sure Girlfriend cheers only for certain songs
if (allowedToHeadbang)
{
@ -3002,38 +3030,77 @@ class PlayState extends MusicBeatState
}
// Accessing the animation name directly to play it
var singData:Int = Std.int(Math.abs(daNote.noteData));
dad.playAnim('sing' + dataSuffix[singData] + altAnim, true);
if (FlxG.save.data.cpuStrums)
if (!daNote.isParent && daNote.parent != null)
{
cpuStrums.forEach(function(spr:FlxSprite)
if (daNote.spotInLine != daNote.parent.children.length - 1)
{
if (Math.abs(daNote.noteData) == spr.ID)
var singData:Int = Std.int(Math.abs(daNote.noteData));
dad.playAnim('sing' + dataSuffix[singData] + altAnim, true);
if (FlxG.save.data.cpuStrums)
{
spr.animation.play('confirm', true);
cpuStrums.forEach(function(spr:FlxSprite)
{
if (Math.abs(daNote.noteData) == spr.ID)
{
spr.animation.play('confirm', true);
}
if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school'))
{
spr.centerOffsets();
spr.offset.x -= 13;
spr.offset.y -= 13;
}
else
spr.centerOffsets();
});
}
if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school'))
{
spr.centerOffsets();
spr.offset.x -= 13;
spr.offset.y -= 13;
}
else
spr.centerOffsets();
});
#if windows
if (luaModchart != null)
luaModchart.executeState('playerTwoSing', [Math.abs(daNote.noteData), Conductor.songPosition]);
#end
dad.holdTimer = 0;
if (SONG.needsVoices)
vocals.volume = 1;
}
}
else
{
var singData:Int = Std.int(Math.abs(daNote.noteData));
dad.playAnim('sing' + dataSuffix[singData] + altAnim, true);
#if windows
if (luaModchart != null)
luaModchart.executeState('playerTwoSing', [Math.abs(daNote.noteData), Conductor.songPosition]);
#end
if (FlxG.save.data.cpuStrums)
{
cpuStrums.forEach(function(spr:FlxSprite)
{
if (Math.abs(daNote.noteData) == spr.ID)
{
spr.animation.play('confirm', true);
}
if (spr.animation.curAnim.name == 'confirm' && !curStage.startsWith('school'))
{
spr.centerOffsets();
spr.offset.x -= 13;
spr.offset.y -= 13;
}
else
spr.centerOffsets();
});
}
dad.holdTimer = 0;
#if windows
if (luaModchart != null)
luaModchart.executeState('playerTwoSing', [Math.abs(daNote.noteData), Conductor.songPosition]);
#end
if (SONG.needsVoices)
vocals.volume = 1;
dad.holdTimer = 0;
if (SONG.needsVoices)
vocals.volume = 1;
}
daNote.active = false;
daNote.kill();
@ -3098,13 +3165,13 @@ class PlayState extends MusicBeatState
else
{
if (!daNote.isSustainNote)
health -= 0.10;
health -= 0.20;
vocals.volume = 0;
if (theFunne && !daNote.isSustainNote)
noteMiss(daNote.noteData, daNote);
if (daNote.isParent)
{
health -= 0.20; // give a health punishment for failing a LN
health -= 0.30; // give a health punishment for failing a LN
trace("hold fell over at the start");
for (i in daNote.children)
{
@ -3119,7 +3186,7 @@ class PlayState extends MusicBeatState
&& daNote.sustainActive
&& daNote.spotInLine != daNote.parent.children.length)
{
health -= 0.20; // give a health punishment for failing a LN
health -= 0.30; // give a health punishment for failing a LN
trace("hold fell over at " + daNote.spotInLine);
for (i in daNote.parent.children)
{
@ -3136,14 +3203,14 @@ class PlayState extends MusicBeatState
else
{
if (!daNote.isSustainNote)
health -= 0.10;
health -= 0.20;
vocals.volume = 0;
if (theFunne && !daNote.isSustainNote)
noteMiss(daNote.noteData, daNote);
if (daNote.isParent)
{
health -= 0.20; // give a health punishment for failing a LN
health -= 0.30; // give a health punishment for failing a LN
trace("hold fell over at the start");
for (i in daNote.children)
{
@ -3159,7 +3226,7 @@ class PlayState extends MusicBeatState
&& daNote.sustainActive
&& daNote.spotInLine != daNote.parent.children.length)
{
health -= 0.20; // give a health punishment for failing a LN
health -= 0.40; // give a health punishment for failing a LN
trace("hold fell over at " + daNote.spotInLine);
for (i in daNote.parent.children)
{
@ -3216,6 +3283,7 @@ class PlayState extends MusicBeatState
function endSong():Void
{
endingSong = true;
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput);
FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput);
if (useVideo)
@ -3226,8 +3294,6 @@ class PlayState extends MusicBeatState
PlayState.instance.remove(PlayState.instance.videoSprite);
}
if (isStoryMode)
campaignMisses = misses;
if (!loadRep)
rep.SaveReplay(saveNotes, saveJudge, replayAna);
@ -3285,6 +3351,11 @@ class PlayState extends MusicBeatState
if (isStoryMode)
{
campaignScore += Math.round(songScore);
campaignMisses += misses;
campaignSicks += sicks;
campaignGoods += goods;
campaignBads += bads;
campaignShits += shits;
storyPlaylist.remove(storyPlaylist[0]);
@ -3426,7 +3497,7 @@ class PlayState extends MusicBeatState
score = -300;
combo = 0;
misses++;
health -= 0.06;
health -= 0.1;
ss = false;
shits++;
if (FlxG.save.data.accuracyMod == 0)
@ -3434,7 +3505,7 @@ class PlayState extends MusicBeatState
case 'bad':
daRating = 'bad';
score = 0;
health -= 0.03;
health -= 0.06;
ss = false;
bads++;
if (FlxG.save.data.accuracyMod == 0)
@ -4448,7 +4519,7 @@ class PlayState extends MusicBeatState
}
#end
if (curSong == 'Tutorial' && dad.curCharacter == 'gf')
if (curSong == 'Tutorial' && dad.curCharacter == 'gf' && SONG.notes[Math.floor(curStep / 16)] != null)
{
if (SONG.notes[Math.floor(curStep / 16)].mustHitSection)
dad.dance();