Skip to content

Commit 0386bca

Browse files
V. 0.1.1
1 parent fadbd4f commit 0386bca

File tree

6 files changed

+88
-14
lines changed

6 files changed

+88
-14
lines changed

Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ LOCAL_SHARED_LIBRARIES += codegen_0_5_3
6262
LOCAL_SHARED_LIBRARIES += questui
6363
LOCAL_SHARED_LIBRARIES += custom-types
6464
LOCAL_LDLIBS += -llog
65-
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"CrashMod"' -DVERSION='"0.1.0"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
65+
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"CrashMod"' -DVERSION='"0.1.1"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
6666
LOCAL_CPPFLAGS += -std=c++2a
6767
LOCAL_C_INCLUDES += ./include ./src
6868
include $(BUILD_SHARED_LIBRARY)

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
Crashes the game if you are bad
44

5-
**Features:**
6-
- crash on play, turn, miss and when you are under a certain percentage
7-
- quit instead of crash _why would you even want to do this_
8-
- crash counter which countss how often it crashes your game
9-
- crash your game with a simple button click
10-
115
## Credits
126

137
* [zoller27osu](https://github.com/zoller27osu), [Sc2ad](https://github.com/Sc2ad) and [jakibaki](https://github.com/jakibaki) - [beatsaber-hook](https://github.com/sc2ad/beatsaber-hook)

bmbfmod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "CrashMod",
33
"name": "Crash Mod",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"author": "ComputerElite",
66
"description": [
77
"Crashes the game if you are bad"

buildBMBF copy.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ if (-not ($PSVersionTable.PSEdition -eq "Core")) {
88

99
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk
1010

11-
Compress-Archive -Path "./libs/arm64-v8a/libCrashMod.so", "./bmbfmod.json" -DestinationPath "./CrashMod_v0.1.0.zip" -Update
11+
Compress-Archive -Path "./libs/arm64-v8a/libCrashMod.so", "./bmbfmod.json" -DestinationPath "./CrashMod_v0.1.1.zip" -Update

src/CrashModViewController.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ void onOnCrashActionChange(CrashModViewController* self, bool newValue) {
6464
getConfig().config["OnCrashAction"].SetInt(newValue ? 1 : 0);
6565
}
6666

67+
void onCrashOnGoodCutChange(CrashModViewController* self, bool newValue) {
68+
getConfig().config["CrashOnGoodCut"].SetBool(newValue);
69+
}
70+
71+
void onCrashOnOver5PerBatteryChange(CrashModViewController* self, bool newValue) {
72+
getConfig().config["CrashOnOver5PerBattery"].SetBool(newValue);
73+
}
74+
75+
void onCrashOnNoFailOnChange(CrashModViewController* self, bool newValue) {
76+
getConfig().config["CrashOnNoFailOn"].SetBool(newValue);
77+
}
78+
79+
void onBatteryThresholdChange(CrashModViewController* self, float newValue) {
80+
getConfig().config["BatteryThreshold"].SetFloat(newValue / 100.0f);
81+
}
82+
6783
void onCrashNow(CrashModViewController* self) {
6884
getConfig().config["CrashCounter"].SetInt(getConfig().config["CrashCounter"].GetInt() + 1);
6985
getConfig().Write();
@@ -100,6 +116,12 @@ void CrashModViewController::DidActivate(bool firstActivation, bool addedToHiera
100116
UnityEngine::UI::Toggle* MissCrash = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Crash on Miss", getConfig().config["MissCrash"].GetBool(), MissCrashChange);
101117
QuestUI::BeatSaberUI::AddHoverHint(MissCrash->get_gameObject(), "Crashes the game on a miss");
102118

119+
// CrashOnGoodCut
120+
auto CrashOnGoodCutChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
121+
classof(UnityEngine::Events::UnityAction_1<bool>*), this, onCrashOnGoodCutChange);
122+
UnityEngine::UI::Toggle* CrashOnGoodCut = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Crash on good cut", getConfig().config["CrashOnGoodCut"].GetBool(), CrashOnGoodCutChange);
123+
QuestUI::BeatSaberUI::AddHoverHint(CrashOnGoodCut->get_gameObject(), "Well it crashes the game if you do a good cut");
124+
103125
// CrashOnPlay
104126
auto CrashOnPlayChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
105127
classof(UnityEngine::Events::UnityAction_1<bool>*), this, onCrashOnPlayChange);
@@ -112,6 +134,25 @@ void CrashModViewController::DidActivate(bool firstActivation, bool addedToHiera
112134
UnityEngine::UI::Toggle* CrashOnTurn = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Crash on Turn", getConfig().config["CrashOnTurn"].GetBool(), CrashOnTurnChange);
113135
QuestUI::BeatSaberUI::AddHoverHint(CrashOnTurn->get_gameObject(), "Crashes the game when you turn around in a song");
114136

137+
// CrashOnNoFailOn
138+
auto CrashOnNoFailOnChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
139+
classof(UnityEngine::Events::UnityAction_1<bool>*), this, onCrashOnNoFailOnChange);
140+
UnityEngine::UI::Toggle* CrashOnNoFailOn = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Crash if you start a level with no fail", getConfig().config["CrashOnNoFailOn"].GetBool(), CrashOnNoFailOnChange);
141+
QuestUI::BeatSaberUI::AddHoverHint(CrashOnNoFailOn->get_gameObject(), "No fail is a great feature (especially for torture). So why don't just let you no do it at all?");
142+
143+
144+
// BatteryThreshold
145+
auto BatteryThresholdChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<float>*>(
146+
classof(UnityEngine::Events::UnityAction_1<float>*), this, onBatteryThresholdChange);
147+
QuestUI::IncrementSetting* BatteryThreshold = QuestUI::BeatSaberUI::CreateIncrementSetting(container->get_transform(), "Battery threshold", 0, 1.0, getConfig().config["BatteryThreshold"].GetFloat() * 100.0f, 0.0f, 100.0f, BatteryThresholdChange);
148+
QuestUI::BeatSaberUI::AddHoverHint(BatteryThreshold->get_gameObject(), "Under this percentage your game will crash.");
149+
150+
// CrashOnOver5PerBattery
151+
auto CrashOnOver5PerBatteryChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
152+
classof(UnityEngine::Events::UnityAction_1<bool>*), this, onCrashOnOver5PerBatteryChange);
153+
UnityEngine::UI::Toggle* CrashOnOver5PerBattery = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Crash the game if you have more battery life than the threshold above", getConfig().config["CrashOnOver5PerBattery"].GetBool(), CrashOnOver5PerBatteryChange);
154+
QuestUI::BeatSaberUI::AddHoverHint(CrashOnOver5PerBattery->get_gameObject(), "You'll have to play Beat Saber while your Quest dies");
155+
115156
// CrashOnPause
116157
/*
117158
auto CrashOnPauseChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(

src/main.cpp

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
#include "GlobalNamespace/PlayerTransforms.hpp"
1313
#include "GlobalNamespace/PauseController.hpp"
1414
#include "GlobalNamespace/NoteCutInfo.hpp"
15-
#include "GlobalNamespace/FPSCounter.hpp"
16-
#include "GlobalNamespace/FPSCounterUIController.hpp"
15+
#include "GlobalNamespace/OVRPlugin_OVRP_1_1_0.hpp"
1716

1817
#include "beatsaber-hook/shared/config/config-utils.hpp"
1918

2019
#include "UnityEngine/UI/Image.hpp"
2120
#include "UnityEngine/Application.hpp"
2221
#include "UnityEngine/Resources.hpp"
22+
#include "UnityEngine/SceneManagement/Scene.hpp"
2323

2424
#include "CrashModViewController.hpp"
2525

@@ -59,18 +59,25 @@ void Crash() {
5959
}
6060

6161
MAKE_HOOK_OFFSETLESS(ScoreController_HandleNoteWasMissed, void, ScoreController* self, NoteController* note) {
62+
ScoreController_HandleNoteWasMissed(self, note);
6263
if(getConfig().config["Active"].GetBool()) {
63-
if(getConfig().config["MissCrash"].GetBool()) CRASH_UNLESS(false);
64+
if(getConfig().config["MissCrash"].GetBool()) Crash();
65+
}
66+
}
67+
68+
MAKE_HOOK_OFFSETLESS(ScoreController_HandleNoteWasCut, void, ScoreController* self, NoteController* note, NoteCutInfo* info) {
69+
ScoreController_HandleNoteWasCut(self, note, info);
70+
if(getConfig().config["Active"].GetBool()) {
71+
if(info->get_allIsOK() && getConfig().config["CrashOnGoodCut"].GetBool()) Crash();
6472
}
65-
ScoreController_HandleNoteWasMissed(self, note);
6673
}
6774

6875
MAKE_HOOK_OFFSETLESS(RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank, void, RelativeScoreAndImmediateRankCounter* self, int score, int modifiedscore, int maxscore, int maxmodfifiedscore) {
6976
RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank(self, score, modifiedscore, maxscore, maxmodfifiedscore);
7077
if(getConfig().config["Active"].GetBool()) {
7178

7279
float percentage = self->get_relativeScore();
73-
getLogger().info("current Score percentage: " + std::to_string(percentage));
80+
//getLogger().info("current Score percentage: " + std::to_string(percentage));
7481
if(getConfig().config["PercentageActive"].GetBool()) {
7582
if(percentage < getConfig().config["Percentage"].GetFloat()) Crash();
7683
}
@@ -83,6 +90,9 @@ MAKE_HOOK_OFFSETLESS(StandardLevelScenesTransitionSetupDataSO_Init, void, Standa
8390
if(getConfig().config["CrashOnPlay"].GetBool()) {
8491
Crash();
8592
}
93+
if(getConfig().config["CrashOnNoFailOn"].GetBool()) {
94+
if(gameplayModifiers->noFailOn0Energy) Crash();
95+
}
8696
}
8797
}
8898

@@ -117,6 +127,11 @@ MAKE_HOOK_OFFSETLESS(PauseController_HandlePauseMenuManagerDidFinishResumeAnimat
117127
}
118128
}
119129
}
130+
131+
MAKE_HOOK_OFFSETLESS(SceneManager_ActiveSceneChanged, void, UnityEngine::SceneManagement::Scene previousActiveScene, UnityEngine::SceneManagement::Scene nextActiveScene) {
132+
SceneManager_ActiveSceneChanged(previousActiveScene, nextActiveScene);
133+
if(getConfig().config["Active"].GetBool() && getConfig().config["CrashOnOver5PerBattery"].GetBool() && GlobalNamespace::OVRPlugin::OVRP_1_1_0::ovrp_GetSystemBatteryLevel() > getConfig().config["BatteryThreshold"].GetFloat()) Crash();
134+
}
120135

121136

122137
void createDefaultConfig() {
@@ -159,6 +174,22 @@ void createDefaultConfig() {
159174
getConfig().config.AddMember("OnCrashAction", rapidjson::Value().SetInt(0), allocator);
160175
}
161176

177+
if(getConfig().config.HasMember("Active") && !(getConfig().config.HasMember("CrashOnNoFailOn"))) {
178+
getConfig().config.AddMember("CrashOnNoFailOn", rapidjson::Value().SetBool(true), allocator);
179+
}
180+
181+
if(getConfig().config.HasMember("Active") && !(getConfig().config.HasMember("CrashOnGoodCut"))) {
182+
getConfig().config.AddMember("CrashOnGoodCut", rapidjson::Value().SetBool(true), allocator);
183+
}
184+
185+
if(getConfig().config.HasMember("Active") && !(getConfig().config.HasMember("CrashOnOver5PerBattery"))) {
186+
getConfig().config.AddMember("CrashOnOver5PerBattery", rapidjson::Value().SetBool(false), allocator);
187+
}
188+
189+
if(getConfig().config.HasMember("Active") && !(getConfig().config.HasMember("BatteryThreshold"))) {
190+
getConfig().config.AddMember("BatteryThreshold", rapidjson::Value().SetFloat(0.05f), allocator);
191+
}
192+
162193
if(getConfig().config.HasMember("Active")) {return;}
163194

164195
// Add all the default options
@@ -181,6 +212,12 @@ void createDefaultConfig() {
181212
getConfig().config.AddMember("CrashCounter", rapidjson::Value().SetInt(0), allocator);
182213
getConfig().config.AddMember("OnCrashAction", rapidjson::Value().SetInt(0), allocator);
183214

215+
getConfig().config.AddMember("CrashOnNoFailOn", rapidjson::Value().SetBool(true), allocator);
216+
getConfig().config.AddMember("CrashOnOver5PerBattery", rapidjson::Value().SetBool(false), allocator);
217+
getConfig().config.AddMember("CrashOnGoodCut", rapidjson::Value().SetBool(true), allocator);
218+
getConfig().config.AddMember("BatteryThreshold", rapidjson::Value().SetFloat(0.05f), allocator);
219+
220+
184221
getConfig().Write(); // Write the config back to disk
185222
}
186223

@@ -206,8 +243,10 @@ extern "C" void load() {
206243
// Install our hooks
207244
INSTALL_HOOK_OFFSETLESS(logger, PlayerTransforms_Update, il2cpp_utils::FindMethodUnsafe("", "PlayerTransforms", "Update", 0));
208245
INSTALL_HOOK_OFFSETLESS(logger, ScoreController_HandleNoteWasMissed, il2cpp_utils::FindMethodUnsafe("", "ScoreController", "HandleNoteWasMissed", 1));
246+
INSTALL_HOOK_OFFSETLESS(logger, ScoreController_HandleNoteWasCut, il2cpp_utils::FindMethodUnsafe("", "ScoreController", "HandleNoteWasCut", 2));
209247
INSTALL_HOOK_OFFSETLESS(logger, RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank, il2cpp_utils::FindMethodUnsafe("", "RelativeScoreAndImmediateRankCounter", "UpdateRelativeScoreAndImmediateRank", 4));
210248
INSTALL_HOOK_OFFSETLESS(logger, StandardLevelScenesTransitionSetupDataSO_Init, il2cpp_utils::FindMethodUnsafe("", "StandardLevelScenesTransitionSetupDataSO", "Init", 9));
249+
INSTALL_HOOK_OFFSETLESS(logger, SceneManager_ActiveSceneChanged, il2cpp_utils::FindMethodUnsafe("UnityEngine.SceneManagement", "SceneManager", "Internal_ActiveSceneChanged", 2));
211250
//INSTALL_HOOK_OFFSETLESS(logger, PauseController_HandleMenuButtonTriggered, il2cpp_utils::FindMethodUnsafe("", "PauseController", "HandleMenuButtonTriggered", 0));
212251
//INSTALL_HOOK_OFFSETLESS(logger, PauseController_HandlePauseMenuManagerDidFinishResumeAnimation, il2cpp_utils::FindMethodUnsafe("", "PauseController", "HandlePauseMenuManagerDidFinishResumeAnimation", 0));
213252
getLogger().info("Installed all hooks!");

0 commit comments

Comments
 (0)