-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9b80d9
Showing
13 changed files
with
678 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# LR2GAS_pub | ||
|
||
A re-written version of LR2GAS based on [mat's ](https://github.com/MatVeiQaaa/LR2GAS) GAS plugin | ||
|
||
## Functionalities | ||
|
||
- Allows switching between P-Attack, Hazard, Hard, Groove and Easy gauges during normal play. | ||
Gauges higher than the one you chosen will not be switched to. | ||
Disabled when using Battle or G-Battle, during replay or during course mode. | ||
- Records gauge shifts in replay files. | ||
- Allows switching between gauge graphs on result screen by pressing the select key. | ||
- Restores gauge at enter when returning to song select if the in-game gauge has changed. | ||
|
||
## Important | ||
|
||
This plugin works through [injection](https://en.wikipedia.org/wiki/DLL_injection), which may cause undesired side effects not limited to memory corruption or system vulnerabilities. Use it at your own risk! | ||
|
||
lr2.cpp and setupjmp.cpp are intentionally omitted in this repo. | ||
|
||
Please report crashes/bugs found while using. Thanks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include <iostream> | ||
#include <thread> | ||
|
||
#include "setupjmp.h" | ||
#include "lr2.h" | ||
|
||
void Setup(const HMODULE instance) | ||
{ | ||
LR2::initOffsets(); | ||
SetupJmps(); | ||
while (1) | ||
std::this_thread::sleep_for(std::chrono::milliseconds(200)); | ||
FreeLibraryAndExitThread(instance, 0); | ||
} | ||
|
||
BOOL APIENTRY DllMain( HMODULE hModule, | ||
DWORD ul_reason_for_call, | ||
LPVOID lpReserved | ||
) | ||
{ | ||
switch (ul_reason_for_call) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
{ | ||
DisableThreadLibraryCalls(hModule); | ||
const auto thread = CreateThread( | ||
nullptr, | ||
0, | ||
reinterpret_cast<LPTHREAD_START_ROUTINE> (Setup), | ||
hModule, | ||
0, | ||
nullptr | ||
); | ||
|
||
if (thread) { | ||
CloseHandle(thread); | ||
} | ||
} | ||
case DLL_THREAD_ATTACH: | ||
case DLL_THREAD_DETACH: | ||
case DLL_PROCESS_DETACH: | ||
break; | ||
} | ||
return TRUE; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "gas.h" | ||
|
||
unsigned int GAS::notesNum = 0; | ||
double GAS::bmsTotal = 300; | ||
bool GAS::expertMode = false; | ||
GAUGE_TYPE GAS::initialGauge = (GAUGE_TYPE) -1; | ||
std::vector<Gauge> GAS::gaugeArr = std::vector<Gauge>(); | ||
unsigned int GAS::gaugeCycleIdx = 0; | ||
|
||
|
||
void GAS::Init() | ||
{ | ||
gaugeArr.clear(); | ||
gaugeArr.emplace_back(Gauge(GAUGE_P_ATTACK)); | ||
gaugeArr.emplace_back(Gauge(GAUGE_HAZARD)); | ||
gaugeArr.emplace_back(Gauge(GAUGE_HARD)); | ||
gaugeArr.emplace_back(Gauge(GAUGE_GROOVE)); | ||
gaugeArr.emplace_back(Gauge(GAUGE_EASY)); | ||
} | ||
|
||
Gauge& GAS::PickDisplay() | ||
{ | ||
unsigned int i = 0; | ||
for (; i < gaugeArr.size(); i++) | ||
if (gaugeArr[i].getType() == initialGauge) | ||
break; | ||
for (; i < gaugeArr.size(); i++) | ||
if (gaugeArr[i].validForDisplay()) | ||
return gaugeArr[i]; | ||
return gaugeArr[gaugeArr.size() - 1]; | ||
} | ||
|
||
double GAS::GetHealthMultiplier() | ||
{ | ||
double tNotes; | ||
// low notes multiplier | ||
if (notesNum < 20) | ||
tNotes = 10.0; | ||
else if (notesNum < 30) | ||
tNotes = 14.0 - (notesNum / 5.0); | ||
else if (notesNum < 60) | ||
tNotes = 9.0 - (notesNum / 15.0); | ||
else if (notesNum < 125) | ||
tNotes = 5.0 - ((notesNum - 60.0) / 65.0); | ||
else if (notesNum < 250) | ||
tNotes = 5.0 - (notesNum / 125.0); | ||
else if (notesNum < 500) | ||
tNotes = 4.0 - (notesNum / 250.0); | ||
else if (notesNum < 1000) | ||
tNotes = 3.0 - (notesNum / 500.0); | ||
else | ||
tNotes = 1.0; | ||
// low total multiplier | ||
double tTotal = (bmsTotal <= 80) ? (10) : (160.0 / (bmsTotal - 80)); | ||
return std::max(tTotal, tNotes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <algorithm> | ||
|
||
#include "lr2.h" | ||
#include "gauge.h" | ||
|
||
using namespace LR2; | ||
|
||
class GAS | ||
{ | ||
public: | ||
static unsigned int notesNum; | ||
static double bmsTotal; | ||
static bool expertMode; | ||
static GAUGE_TYPE initialGauge; | ||
static std::vector<Gauge> gaugeArr; | ||
static unsigned int gaugeCycleIdx; | ||
|
||
static void Init(); | ||
static Gauge& PickDisplay(); | ||
static double GetHealthMultiplier(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#include "gauge.h" | ||
#include "gas.h" | ||
|
||
Gauge::Gauge(GAUGE_TYPE gaugeType) | ||
{ | ||
failed = false; | ||
this->gaugeType = gaugeType; | ||
double basePerNote = GAS::bmsTotal / GAS::notesNum; | ||
double hardMultplier = GAS::GetHealthMultiplier(); | ||
switch (gaugeType) | ||
{ | ||
case GAUGE_GROOVE: | ||
judgeGaugeIncrements[KPOOR] = -2.0; | ||
judgeGaugeIncrements[POOR] = -6.0; | ||
judgeGaugeIncrements[BAD] = -4.0; | ||
judgeGaugeIncrements[GOOD] = basePerNote / 2; | ||
judgeGaugeIncrements[GREAT] = basePerNote; | ||
judgeGaugeIncrements[PGREAT] = basePerNote; | ||
gaugeValue = 20.0; | ||
isSurvival = false; | ||
break; | ||
case GAUGE_EASY: | ||
judgeGaugeIncrements[KPOOR] = 0.8 * -2.0; | ||
judgeGaugeIncrements[POOR] = 0.8 * -6.0; | ||
judgeGaugeIncrements[BAD] = 0.8 * -4.0; | ||
judgeGaugeIncrements[GOOD] = 1.2 * basePerNote / 2; | ||
judgeGaugeIncrements[GREAT] = 1.2 * basePerNote; | ||
judgeGaugeIncrements[PGREAT] = 1.2 * basePerNote; | ||
gaugeValue = 20.0; | ||
isSurvival = false; | ||
break; | ||
case GAUGE_HARD: | ||
judgeGaugeIncrements[KPOOR] = -2.0 * hardMultplier; | ||
judgeGaugeIncrements[POOR] = -10.0 * hardMultplier; | ||
judgeGaugeIncrements[BAD] = -6.0 * hardMultplier; | ||
judgeGaugeIncrements[GOOD] = 0.1 / 2; | ||
judgeGaugeIncrements[GREAT] = 0.1; | ||
judgeGaugeIncrements[PGREAT] = 0.1; | ||
gaugeValue = 100.0; | ||
isSurvival = true; | ||
break; | ||
case GAUGE_HAZARD: | ||
judgeGaugeIncrements[KPOOR] = 0; | ||
judgeGaugeIncrements[POOR] = -100; | ||
judgeGaugeIncrements[BAD] = -100; | ||
judgeGaugeIncrements[GOOD] = 0; | ||
judgeGaugeIncrements[GREAT] = 0; | ||
judgeGaugeIncrements[PGREAT] = 0; | ||
gaugeValue = 100.0; | ||
isSurvival = true; | ||
break; | ||
case GAUGE_P_ATTACK: | ||
judgeGaugeIncrements[KPOOR] = -100; | ||
judgeGaugeIncrements[POOR] = -100; | ||
judgeGaugeIncrements[BAD] = -100; | ||
judgeGaugeIncrements[GOOD] = -100; | ||
judgeGaugeIncrements[GREAT] = -1.0; | ||
judgeGaugeIncrements[PGREAT] = 0.1; | ||
gaugeValue = 100.0; | ||
isSurvival = true; | ||
break; | ||
case GAUGE_G_ATTACK: | ||
judgeGaugeIncrements[KPOOR] = -2.0 * hardMultplier; | ||
judgeGaugeIncrements[POOR] = -10.0 * hardMultplier; | ||
judgeGaugeIncrements[BAD] = -6.0 * hardMultplier; | ||
judgeGaugeIncrements[GOOD] = 0.1; | ||
judgeGaugeIncrements[GREAT] = -1.0; | ||
judgeGaugeIncrements[PGREAT] = -10.0 * hardMultplier; | ||
gaugeValue = 100.0; | ||
isSurvival = true; | ||
break; | ||
default: | ||
gaugeValue = 0.0; | ||
isSurvival = true; | ||
|
||
} | ||
} | ||
|
||
void Gauge::onJudge(int judge) | ||
{ | ||
if (failed) | ||
return; | ||
|
||
bool applyLowHealthMultiplier = (int(gaugeValue) / 2 * 2 <= 30) | ||
&& (gaugeType != GAUGE_GROOVE && gaugeType != GAUGE_EASY) | ||
&& judge <= BAD; | ||
if (applyLowHealthMultiplier) | ||
gaugeValue += 0.6 * judgeGaugeIncrements[judge]; | ||
else | ||
gaugeValue += judgeGaugeIncrements[judge]; | ||
|
||
if (gaugeValue <= 2.0) | ||
{ | ||
if (isSurvival) | ||
failed = true; | ||
else | ||
gaugeValue = 2.0; | ||
} | ||
if (gaugeValue >= 100.0) | ||
gaugeValue = 100.0; | ||
if (gaugeValue <= 0.0) | ||
gaugeValue = 0.0; | ||
} | ||
|
||
void Gauge::recordGraphSample() | ||
{ | ||
recordGraphSample((int)gaugeValue); | ||
} | ||
|
||
void Gauge::recordGraphSample(int value) | ||
{ | ||
if (graphArrIdx >= GRAPH_SAMPLE_COUNT) | ||
return; | ||
graph[graphArrIdx] = value; | ||
graphArrIdx++; | ||
} | ||
|
||
void Gauge::fillGraph() | ||
{ | ||
while (graphArrIdx < GRAPH_SAMPLE_COUNT) | ||
{ | ||
graph[graphArrIdx] = graph[graphArrIdx-1]; | ||
graphArrIdx++; | ||
} | ||
} | ||
|
||
GAUGE_TYPE Gauge::getType() | ||
{ | ||
return gaugeType; | ||
} | ||
|
||
double Gauge::getValue() | ||
{ | ||
return gaugeValue; | ||
} | ||
|
||
bool Gauge::validForDisplay() | ||
{ | ||
if (isSurvival) | ||
return !failed; | ||
else | ||
return gaugeValue >= 80.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "lr2.h" | ||
|
||
using namespace LR2; | ||
|
||
class Gauge | ||
{ | ||
GAUGE_TYPE gaugeType = (GAUGE_TYPE) -1; | ||
double gaugeValue = 0; | ||
double judgeGaugeIncrements[JUDGE_COUNT] = { 0 }; | ||
bool isSurvival = true; | ||
bool failed = false; | ||
|
||
int graphArrIdx = 0; | ||
|
||
public: | ||
int graph[GRAPH_SAMPLE_COUNT] = { 0 }; | ||
|
||
Gauge(GAUGE_TYPE gaugeType); | ||
|
||
void onJudge(int judge); | ||
void recordGraphSample(); | ||
void recordGraphSample(int); | ||
void fillGraph(); | ||
|
||
GAUGE_TYPE getType(); | ||
double getValue(); | ||
bool validForDisplay(); | ||
|
||
}; |
Oops, something went wrong.