|
1 | 1 | #include "main.hpp" |
2 | 2 | #include "extern/includes/config-utils/shared/config-utils.hpp" |
3 | 3 | #include "ModConfig.hpp" |
| 4 | +#include "GlobalNamespace/IReadonlyBeatmapData.hpp" |
| 5 | +#include "GlobalNamespace/CutScoreBuffer.hpp" |
| 6 | +#include "GlobalNamespace/ScoreModel_NoteScoreDefinition.hpp" |
4 | 7 | #include "GlobalNamespace/ScoreController.hpp" |
5 | 8 | #include "GlobalNamespace/RelativeScoreAndImmediateRankCounter.hpp" |
6 | 9 | #include "GlobalNamespace/StandardLevelScenesTransitionSetupDataSO.hpp" |
|
26 | 29 | #include "GlobalNamespace/BeatmapObjectExecutionRatingsRecorder.hpp" |
27 | 30 | #include "GlobalNamespace/BombNoteController.hpp" |
28 | 31 | #include "GlobalNamespace/Saber.hpp" |
| 32 | +#include "GlobalNamespace/IReadonlyCutScoreBuffer.hpp" |
29 | 33 |
|
30 | 34 | #include "beatsaber-hook/shared/utils/typedefs.h" |
31 | 35 | #include "beatsaber-hook/shared/utils/il2cpp-utils.hpp" |
@@ -86,60 +90,22 @@ MAKE_HOOK_MATCH(BombNoteController_HandleWasCutBySaber, &BombNoteController::Han |
86 | 90 | if(getModConfig().Active.GetValue() && getModConfig().CrashOnBomb.GetValue()) Crash(); |
87 | 91 | } |
88 | 92 |
|
89 | | -std::map<GlobalNamespace::ISaberSwingRatingCounter*, swingRatingCounter_context> swingRatingMap; |
90 | | - |
91 | | -void JudgeNoContext(FlyingScoreEffect* self, NoteCutInfo& noteCutInfo) { |
92 | | - int before; |
93 | | - int after; |
94 | | - int accuracy; |
95 | | - ScoreModel::RawScoreWithoutMultiplier(noteCutInfo.swingRatingCounter, noteCutInfo.cutDistanceToCenter, byref(before), byref(after), byref(accuracy)); |
96 | | - int total = before + after + accuracy; |
97 | | -} |
98 | | - |
99 | | -void Judge(ISaberSwingRatingCounter* counter) { |
100 | | - if(!getModConfig().Active.GetValue()) return; |
101 | | - auto itr = swingRatingMap.find(counter); |
102 | | - if(itr == swingRatingMap.end()) { |
103 | | - getLogger().info("counter was not found in swingRatingMap!"); |
104 | | - return; |
105 | | - } |
106 | | - auto context = itr->second; |
107 | | - |
108 | | - int before; |
109 | | - int after; |
110 | | - int accuracy; |
111 | | - |
112 | | - ScoreModel::RawScoreWithoutMultiplier(context.noteCutInfo.swingRatingCounter, context.noteCutInfo.cutDistanceToCenter, byref(before), byref(after), byref(accuracy)); |
113 | | - int total = before + after + accuracy; |
114 | | - if(getModConfig().CrashOn115.GetValue() && total == 115) Crash(); |
115 | | - if(context.flyingScoreEffect) { |
116 | | - swingRatingMap.erase(itr); |
117 | | - } |
118 | | -} |
119 | | - |
120 | | -MAKE_HOOK_MATCH(InitFlyingScoreEffect, &FlyingScoreEffect::InitAndPresent, void, FlyingScoreEffect* self, ByRef<NoteCutInfo> noteCutInfo, int multiplier, float duration, Vector3 targetPos, Quaternion rotation, Color color) { |
121 | | - |
122 | | - InitFlyingScoreEffect(self, noteCutInfo, multiplier, duration, targetPos, rotation, color); |
123 | | - |
124 | | - auto counter = noteCutInfo.heldRef.swingRatingCounter; |
125 | | - |
126 | | - GlobalNamespace::NoteCutInfo info = noteCutInfo.heldRef; |
127 | | - |
128 | | - swingRatingMap.insert(std::make_pair(counter, swingRatingCounter_context{info, self})); |
129 | | -} |
130 | | - |
131 | | -MAKE_HOOK_MATCH(HandleSwingFinish, &GlobalNamespace::BeatmapObjectExecutionRatingsRecorder_CutScoreHandler::HandleSaberSwingRatingCounterDidFinish, void, GlobalNamespace::BeatmapObjectExecutionRatingsRecorder_CutScoreHandler* self, ISaberSwingRatingCounter* counter) { |
| 93 | +MAKE_HOOK_MATCH(HandleSwingFinish, &GlobalNamespace::CutScoreBuffer::HandleSaberSwingRatingCounterDidFinish, void, GlobalNamespace::CutScoreBuffer* self, ISaberSwingRatingCounter* counter) { |
132 | 94 | HandleSwingFinish(self, counter); |
133 | | - Judge(counter); |
| 95 | + if(!getModConfig().Active.GetValue() || !getModConfig().CrashOn115.GetValue()) return; |
| 96 | + int score = self->dyn__afterCutScore() + self->dyn__beforeCutScore() + self->dyn__centerDistanceCutScore(); |
| 97 | + auto *noteScoreDefinition = self->dyn__noteScoreDefinition(); |
| 98 | + int maxCutScore = noteScoreDefinition->dyn_maxAfterCutScore() + noteScoreDefinition->dyn_maxBeforeCutScore() + noteScoreDefinition->dyn_maxCenterDistanceCutScore(); |
| 99 | + if(score == maxCutScore) Crash(); |
134 | 100 | } |
135 | 101 |
|
136 | 102 | MAKE_HOOK_MATCH(RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank, &RelativeScoreAndImmediateRankCounter::UpdateRelativeScoreAndImmediateRank, void, RelativeScoreAndImmediateRankCounter* self, int score, int modifiedscore, int maxscore, int maxmodfifiedscore) { |
137 | 103 | RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank(self, score, modifiedscore, maxscore, maxmodfifiedscore); |
138 | 104 | if(getModConfig().Active.GetValue() && getModConfig().PercentageActive.GetValue() && self->get_relativeScore() < getModConfig().Percentage.GetValue() / 100) Crash(); |
139 | 105 | } |
140 | 106 |
|
141 | | -MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, &StandardLevelScenesTransitionSetupDataSO::Init, void, StandardLevelScenesTransitionSetupDataSO* self, StringW gameMode, IDifficultyBeatmap* dbm, IPreviewBeatmapLevel* previewBeatmapLevel, OverrideEnvironmentSettings* overrideEnvironmentSettings, ColorScheme* overrideColorScheme, GameplayModifiers* gameplayModifiers, PlayerSpecificSettings* playerSpecificSettings, PracticeSettings* practiceSettings, StringW backButtonText, bool startPaused) { |
142 | | - StandardLevelScenesTransitionSetupDataSO_Init(self, gameMode, dbm, previewBeatmapLevel, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, backButtonText, startPaused); |
| 107 | +MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, &StandardLevelScenesTransitionSetupDataSO::Init, void, StandardLevelScenesTransitionSetupDataSO* self, StringW gameMode, IDifficultyBeatmap* dbm, IPreviewBeatmapLevel* previewBeatmapLevel, OverrideEnvironmentSettings* overrideEnvironmentSettings, ColorScheme* overrideColorScheme, GameplayModifiers* gameplayModifiers, PlayerSpecificSettings* playerSpecificSettings, PracticeSettings* practiceSettings, StringW backButtonText, bool startPaused, bool useTestNoteCutSoundEffects) { |
| 108 | + StandardLevelScenesTransitionSetupDataSO_Init(self, gameMode, dbm, previewBeatmapLevel, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, backButtonText, startPaused, useTestNoteCutSoundEffects); |
143 | 109 | if(getModConfig().Active.GetValue()) { |
144 | 110 | if(getModConfig().CrashOnPlay.GetValue() || getModConfig().CrashOnNoFailOn.GetValue() && gameplayModifiers->get_noFailOn0Energy()) Crash(); |
145 | 111 | if(getModConfig().CrashOnHighBPM.GetValue() && bpm > getModConfig().HighBPMValue.GetValue() || getModConfig().CrashOnLowBPM.GetValue() && bpm < getModConfig().LowBPMValue.GetValue()) Crash(); |
@@ -170,8 +136,8 @@ MAKE_HOOK_MATCH(SceneManager_ActiveSceneChanged, &UnityEngine::SceneManagement:: |
170 | 136 | } |
171 | 137 | } |
172 | 138 |
|
173 | | -MAKE_HOOK_MATCH(ResultsViewController_Init, &ResultsViewController::Init, void, ResultsViewController* self, LevelCompletionResults* result, IDifficultyBeatmap* beatmap, bool practice, bool newHighScore) { |
174 | | - ResultsViewController_Init(self, result, beatmap, practice, newHighScore); |
| 139 | +MAKE_HOOK_MATCH(ResultsViewController_Init, &ResultsViewController::Init, void, ResultsViewController* self, LevelCompletionResults* result, IReadonlyBeatmapData* beatmap, IDifficultyBeatmap* bm, bool practice, bool newHighScore) { |
| 140 | + ResultsViewController_Init(self, result, beatmap, bm, practice, newHighScore); |
175 | 141 | if(getModConfig().Active.GetValue() && ((getModConfig().CrashOnNotFullCombo.GetValue() && !result->dyn_fullCombo()) || (getModConfig().CrashOnNewHighscore.GetValue() && self->dyn__newHighScore()))) Crash(); |
176 | 142 | } |
177 | 143 |
|
@@ -210,7 +176,7 @@ extern "C" void load() { |
210 | 176 | INSTALL_HOOK(logger, StandardLevelScenesTransitionSetupDataSO_Init); |
211 | 177 | INSTALL_HOOK(logger, SceneManager_ActiveSceneChanged); |
212 | 178 | INSTALL_HOOK(logger, ResultsViewController_Init); |
213 | | - INSTALL_HOOK(logger, InitFlyingScoreEffect); |
| 179 | + //INSTALL_HOOK(logger, InitFlyingScoreEffect); |
214 | 180 | INSTALL_HOOK(logger, HandleSwingFinish); |
215 | 181 | INSTALL_HOOK(logger, BombNoteController_HandleWasCutBySaber) |
216 | 182 | //INSTALL_HOOK_OFFSETLESS(logger, PauseController_HandleMenuButtonTriggered, il2cpp_utils::FindMethodUnsafe("", "PauseController", "HandleMenuButtonTriggered", 0)); |
|
0 commit comments