Skip to content

Commit f76b764

Browse files
releasing overdrive releases holds, better base score calc
1 parent dfb1409 commit f76b764

File tree

4 files changed

+54
-26
lines changed

4 files changed

+54
-26
lines changed

Encore/include/game/player.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ double overdriveActiveTime = 0.0;
5656
float uvOffsetX = 0;
5757
float uvOffsetY = 0;
5858

59-
int stars() {
60-
int baseScore = 1080+720+360+((notes-30) * 144);
61-
59+
int stars(int baseScore) {
6260
float starPercent = (float)score/(float)baseScore;
6361
if (starPercent < xStarThreshold[0]) {return 0;}
6462
else if (starPercent < xStarThreshold[1]) { return 1; }

Encore/include/song/chart.h

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <vector>
3+
#include <string>
34
#include "midifile/MidiFile.h"
45
#include "song.h"
56
struct Note
@@ -18,6 +19,7 @@ struct Note
1819
bool accounted = false;
1920
bool countedForODPhrase = false;
2021
bool perfect = false;
22+
bool renderAsOD = false;
2123
double hitTime = 0;
2224
//For plastic support later
2325
bool forceStrum;
@@ -40,6 +42,7 @@ class Chart
4042
std::vector<std::vector<int>> diffNotes = { {60,63,66,69}, {72,75,78,81}, {84,87,90,93}, {96,100,102,106} };
4143
public:
4244
std::vector<Note> notes;
45+
int baseScore = 0;
4346
int findNoteIdx(double time, int lane) {
4447
for (int i = 0; i < notes.size();i++) {
4548
if (notes[i].time == time && notes[i].lane == lane)
@@ -48,7 +51,7 @@ class Chart
4851
return -1;
4952
}
5053
std::vector<odPhrase> odPhrases;
51-
void parseNotes(smf::MidiFile& midiFile, int trkidx, smf::MidiEventList events, int diff) {
54+
void parseNotes(smf::MidiFile& midiFile, int trkidx, smf::MidiEventList events, int diff, int instrument) {
5255
std::vector<bool> notesOn{ false,false,false,false,false};
5356
bool odOn = false;
5457
std::vector<double> noteOnTime{ 0.0, 0.0, 0.0, 0.0, 0.0};
@@ -57,7 +60,6 @@ class Chart
5760
int odNote = 116;
5861
int curODPhrase = -1;
5962
int curBPM = 0;
60-
6163
for (int i = 0; i < events.getSize(); i++) {
6264
if (events[i].isNoteOn()) {
6365
double time = midiFile.getTimeInSeconds(trkidx, i);
@@ -147,5 +149,19 @@ class Chart
147149
odPhrases[curODPhrase].noteCount++;
148150
}
149151
}
152+
int mult = 1;
153+
int multCtr = 0;
154+
int noteIdx = 0;
155+
bool isBassOrVocal = (instrument == 1 || instrument == 3);
156+
for (Note& note : notes) {
157+
baseScore += (36 * mult);
158+
baseScore += (note.beatsLen * 12) * mult;
159+
if (noteIdx == 9) mult = 2;
160+
else if (noteIdx == 19) mult = 3;
161+
else if (noteIdx == 29) mult = 4;
162+
else if (noteIdx == 39 && isBassOrVocal) mult = 5;
163+
else if (noteIdx == 49 && isBassOrVocal) mult = 6;
164+
noteIdx++;
165+
}
150166
}
151167
};

Encore/include/song/song.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@ enum SongParts {
5858

5959

6060
std::unordered_map<std::string, SongParts> midiNameToEnum = {
61-
6261
{"PART DRUMS",SongParts::PartDrums},
6362
{"PART BASS",SongParts::PartBass},
6463
{"PART GUITAR",SongParts::PartGuitar},
6564
{"PART VOCALS",SongParts::PartVocals},
6665
{"PLASTIC DRUMS",SongParts::PlasticDrums},
6766
{"PLASTIC BASS",SongParts::PlasticBass},
68-
{"PLASTIC GUITAR",SongParts::PlasticGuitar},
69-
67+
{"PLASTIC GUITAR",SongParts::PlasticGuitar}
7068
};
69+
7170
static SongParts partFromString(const std::string& str)
7271
{
7372
auto it = midiNameToEnum.find(str);

Encore/src/main.cpp

+33-18
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ static void notesCallback(GLFWwindow* wind, int key, int scancode, int action, i
191191
!curNote.hit) {
192192
for (int lane = 0; lane < 5; lane++) {
193193
int chordLane = curChart.findNoteIdx(curNote.time, lane);
194-
std::cout << "lane " << lane << " at " << chordLane << std::endl;
195194
if (chordLane != -1) {
196195
Note& chordNote = curChart.notes[chordLane];
197196
if ((chordNote.time) - (goodBackend)+InputOffset < eventTime &&
@@ -245,8 +244,23 @@ static void notesCallback(GLFWwindow* wind, int key, int scancode, int action, i
245244
}
246245
}
247246
overdriveLiftAvailable = false;
247+
}
248+
}
249+
if (action == GLFW_RELEASE && curNote.held && (curNote.len) > 0) {
250+
for (int lane = 0; lane < 5; lane++) {
251+
if (overdriveLanesHit[lane]) {
252+
int chordLane = curChart.findNoteIdx(curNote.time, lane);
253+
if (chordLane != -1) {
254+
Note& chordNote = curChart.notes[chordLane];
255+
if (chordNote.held && chordNote.len > 0) {
256+
chordNote.held = false;
257+
score += sustainScoreBuffer[chordNote.lane];
258+
sustainScoreBuffer[chordNote.lane] = 0;
259+
mute = true;
260+
}
261+
}
262+
}
248263
}
249-
250264
}
251265
}
252266

@@ -302,8 +316,8 @@ int main(int argc, char* argv[])
302316
float timeCounter = 0.0f;
303317

304318
int targetFPS = targetFPSArg == 0 ? GetMonitorRefreshRate(GetCurrentMonitor()) : targetFPSArg;
305-
std::vector<string> songPartsList{ "Drums","Bass","Guitar","Vocals" };
306-
std::vector<string> diffList{ "Easy","Medium","Hard","Expert" };
319+
std::vector<std::string> songPartsList{ "Drums","Bass","Guitar","Vocals" };
320+
std::vector<std::string> diffList{ "Easy","Medium","Hard","Expert" };
307321
TraceLog(LOG_INFO, "Target FPS: %d", targetFPS);
308322

309323
InitAudioDevice();
@@ -563,13 +577,14 @@ int main(int argc, char* argv[])
563577
}
564578
else {
565579
if (songPart != SongParts::Invalid) {
566-
songList.songs[curPlayingSong].parts[(int)songPart]->hasPart = true;
567580
for (int diff = 0; diff < 4; diff++) {
568581
Chart newChart;
569-
newChart.parseNotes(midiFile, i, midiFile[i], diff);
570-
std::sort(newChart.notes.begin(), newChart.notes.end(), compareNotes);
571-
std::vector<BPM>& bpms = songList.songs[curPlayingSong].bpms;
572-
songList.songs[curPlayingSong].parts[(int)songPart]->charts.push_back(newChart);
582+
newChart.parseNotes(midiFile, i, midiFile[i], diff,(int)songPart);
583+
if (newChart.notes.size() > 0) {
584+
songList.songs[curPlayingSong].parts[(int)songPart]->hasPart = true;
585+
std::sort(newChart.notes.begin(), newChart.notes.end(), compareNotes);
586+
songList.songs[curPlayingSong].parts[(int)songPart]->charts.push_back(newChart);
587+
}
573588
}
574589
}
575590
}
@@ -622,7 +637,7 @@ int main(int argc, char* argv[])
622637
}
623638
}
624639
else if (selectStage == 4) {
625-
int starsval = stars();
640+
int starsval = stars(songList.songs[curPlayingSong].parts[instrument]->charts[diff].baseScore);
626641
char* starsDisplay = (char*) "";
627642
if (starsval == 5) {
628643
starsDisplay = (char*) "*****";
@@ -655,7 +670,7 @@ int main(int argc, char* argv[])
655670
}
656671
else {
657672
char* starsDisplay = (char*) "";
658-
int starsval = stars();
673+
int starsval = stars(songList.songs[curPlayingSong].parts[instrument]->charts[diff].baseScore);
659674
if (starsval == 5) {
660675
starsDisplay = (char*) "*****";
661676
} else if (starsval == 4) {
@@ -898,7 +913,7 @@ int main(int argc, char* argv[])
898913
}
899914
for (int i = curNoteIdx; i < curChart.notes.size(); i++) {
900915
Note& curNote = curChart.notes[i];
901-
bool od = false;
916+
902917
if (curChart.odPhrases.size() > 0) {
903918
if (curNote.time >= curChart.odPhrases[curODPhrase].start && curNote.time <= curChart.odPhrases[curODPhrase].end && !curChart.odPhrases[curODPhrase].missed) {
904919
if (curNote.miss) {
@@ -910,7 +925,7 @@ int main(int argc, char* argv[])
910925
curNote.countedForODPhrase = true;
911926
}
912927
}
913-
od = true;
928+
curNote.renderAsOD = true;
914929
}
915930
if (curChart.odPhrases[curODPhrase].notesHit == curChart.odPhrases[curODPhrase].noteCount && !curChart.odPhrases[curODPhrase].added && overdriveFill < 1.0f) {
916931
overdriveFill += 0.25f;
@@ -937,7 +952,7 @@ int main(int argc, char* argv[])
937952
if (curNote.lift && !curNote.hit) {
938953
// lifts // distance between notes
939954
// (furthest left - lane distance)
940-
if (od) // 1.6f 0.8
955+
if (curNote.renderAsOD) // 1.6f 0.8
941956
DrawModel(assets.liftModelOD, Vector3{ diffDistance - (1.0f * curNote.lane),0,smasherPos + (highwayLength * (float)relTime) }, 1.1f, WHITE);
942957
// energy phrase
943958
else
@@ -972,17 +987,17 @@ int main(int argc, char* argv[])
972987
Color SustainColor = Color{ 172,82,217,255 };
973988
}*/
974989

975-
if (curNote.held && !od) {
990+
if (curNote.held && !curNote.renderAsOD) {
976991
DrawCylinderEx(Vector3{ diffDistance - (1.0f * curNote.lane), 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ diffDistance - (1.0f * curNote.lane),0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 230,100,230,255 });
977992
}
978-
if (od && curNote.held) {
993+
if (curNote.renderAsOD && curNote.held) {
979994
DrawCylinderEx(Vector3{ diffDistance - (1.0f * curNote.lane), 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ diffDistance - (1.0f * curNote.lane),0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 255, 255, 180 ,255 });
980995
}
981996
if (!curNote.held && curNote.hit || curNote.miss) {
982997
DrawCylinderEx(Vector3{ diffDistance - (1.0f * curNote.lane), 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ diffDistance - (1.0f * curNote.lane),0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 69,69,69,255 });
983998
}
984999
if (!curNote.hit && !curNote.accounted && !curNote.miss) {
985-
if (od) {
1000+
if (curNote.renderAsOD) {
9861001
DrawCylinderEx(Vector3{ diffDistance - (1.0f * curNote.lane), 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ diffDistance - (1.0f * curNote.lane),0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 200, 170, 70 ,255 });
9871002
}
9881003
else {
@@ -999,7 +1014,7 @@ int main(int argc, char* argv[])
9991014
}
10001015
// regular notes
10011016
if (((curNote.len) > 0 && (curNote.held || !curNote.hit)) || ((curNote.len) == 0 && !curNote.hit)) {
1002-
if (od) {
1017+
if (curNote.renderAsOD) {
10031018
if ((!curNote.held && !curNote.miss) || !curNote.hit) {
10041019
DrawModel(assets.noteModelOD, Vector3{ diffDistance - (1.0f * curNote.lane),0,smasherPos + (highwayLength * (float)relTime) }, 1.1f, WHITE);
10051020
};

0 commit comments

Comments
 (0)