Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 1a8d4cb

Browse files
committed
hitbox multiplier, uncomplete level, no shaders, instant complete, vsync shortcut
1 parent 9b867ac commit 1a8d4cb

14 files changed

+236
-22
lines changed

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"gd": {
44
"win": "2.204"
55
},
6-
"version": "v2.5.8",
6+
"version": "v2.6.0",
77
"id": "maxnu.gd_mega_overlay",
88
"name": "GD Mega Overlay",
99
"developer": "maxnu & SpaghettDev",

src/Common.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ using namespace geode::prelude;
2525

2626
void Common::calculateFramerate()
2727
{
28+
bool vsync = GameManager::get()->getGameVariable("0030");
29+
CCApplication::sharedApplication()->toggleVerticalSync(vsync);
30+
31+
if(vsync)
32+
return;
33+
2834
float framerate = 60.f;
2935
float interval = 60.f;
3036

@@ -181,7 +187,12 @@ void Common::updateCheating()
181187
bool showHitbox = Settings::get<bool>("level/show_hitbox/enabled", false);
182188
bool onDeath = Settings::get<bool>("level/show_hitbox/on_death", false);
183189

184-
if (speedhack != 1.f || Macrobot::playerMode == 0 || (showHitbox && !onDeath) || Settings::get<bool>("general/hide_pause/menu"))
190+
bool hidePause = Settings::get<bool>("general/hide_pause/menu");
191+
bool noShaders = Settings::get<bool>("level/no_shaders", false);
192+
bool instantComplete = Settings::get<bool>("level/instant_complete", false);
193+
bool hitboxMultiplier = Settings::get<bool>("level/hitbox_multiplier", false);
194+
195+
if (speedhack != 1.f || Macrobot::playerMode == 0 || (showHitbox && !onDeath) || hidePause || hitboxMultiplier || noShaders || instantComplete)
185196
{
186197
isCheating = true;
187198
return;
@@ -219,3 +230,26 @@ class $modify(MenuLayer)
219230
return MenuLayer::init();
220231
}
221232
};
233+
234+
void Common::uncompleteLevel()
235+
{
236+
if(!GameManager::get()->getPlayLayer())
237+
{
238+
FLAlertLayer::create("Error", "Enter a level first!", "Ok")->show();
239+
return;
240+
}
241+
GJGameLevel* level = GameManager::get()->getPlayLayer()->m_level;
242+
243+
//uncompleteLevel()
244+
reinterpret_cast<void(__thiscall *)(GameStatsManager*, GJGameLevel*)>(base::get() + 0x170400)(GameStatsManager::sharedState(), level);
245+
level->m_practicePercent = 0;
246+
level->m_normalPercent = 0;
247+
level->m_newNormalPercent2 = 0;
248+
level->m_orbCompletion = 0;
249+
level->m_54 = 0;
250+
level->m_k111 = 0;
251+
level->m_bestPoints = 0;
252+
level->m_bestTime = 0;
253+
254+
GameLevelManager::sharedState()->saveLevel(level);
255+
}

src/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace Common
2121
void saveIcons();
2222
void loadIcons();
2323

24+
void uncompleteLevel();
25+
2426
float getTPS();
2527

2628
void updateCheating();

src/GUI/Shortcut.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ void GUI::Shortcut::renderWindow()
9595
}
9696
}
9797

98+
bool vsync = GameManager::get()->getGameVariable("0030");
99+
100+
if(GUI::checkbox("Vsync", &vsync))
101+
{
102+
GameManager::get()->setGameVariable("0030", vsync);
103+
Common::calculateFramerate();
104+
}
105+
106+
if(GUI::button("Uncomplete Level"))
107+
Common::uncompleteLevel();
108+
98109
if (GUI::button("Toggle Practice") && GameManager::get()->getPlayLayer())
99110
GameManager::get()->getPlayLayer()->togglePracticeMode(!GameManager::get()->getPlayLayer()->m_isPracticeMode);
100111

src/GUI/Widgets.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,29 @@ bool GUI::inputInt2(const std::string& name, int* value, int min1, int max1, int
309309
return result;
310310
}
311311

312+
bool GUI::inputFloat2(const std::string& name, float* value, float min1, float max1, float min2, float max2)
313+
{
314+
bool result = false;
315+
if (GUI::shouldRender())
316+
{
317+
ImGui::PushItemWidth(90);
318+
result = ImGui::InputFloat2(name.c_str(), value, 0);
319+
ImGui::PopItemWidth();
320+
}
321+
322+
if (value[0] < min1)
323+
value[0] = min1;
324+
if (value[0] > max1)
325+
value[0] = max1;
326+
327+
if (value[1] < min2)
328+
value[1] = min2;
329+
if (value[1] > max2)
330+
value[1] = max2;
331+
332+
return result;
333+
}
334+
312335
bool GUI::inputFloat(const std::string& name, float* value, float min, float max)
313336
{
314337
bool result = false;

src/GUI/Widgets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace GUI
3232
bool inputInt(const std::string&, int*, int = -INT_MAX, int = INT_MAX);
3333
bool inputInt(const std::string&, const std::string&, int, int = -INT_MAX, int = INT_MAX);
3434
bool inputInt2(const std::string&, int*, int = -INT_MAX, int = INT_MAX, int = -INT_MAX, int = INT_MAX);
35+
bool inputFloat2(const std::string&, float*, float = -FLT_MAX, float = FLT_MAX, float = -FLT_MAX, float = FLT_MAX);
3536
bool inputFloat(const std::string&, float*, float = -FLT_MAX, float = FLT_MAX);
3637
bool inputFloat(const std::string&, const std::string&, float, float = -FLT_MAX, float = FLT_MAX);
3738
bool dragInt(const std::string&, int*, int = -INT_MAX, int = INT_MAX);

src/Hacks/HitboxMultiplier.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include "HitboxMultiplier.h"
2+
3+
#include "Settings.hpp"
4+
5+
void scaleRect(cocos2d::CCRect* r, float a, float b)
6+
{
7+
r->origin.x += r->size.width / 2;
8+
r->origin.y += r->size.height / 2;
9+
r->size.width *= a;
10+
r->size.height *= b;
11+
r->origin.x -= r->size.width / 2;
12+
r->origin.y -= r->size.height / 2;
13+
}
14+
15+
cocos2d::CCRect* HitboxMultiplier::GameObjectGetObjectRect(GameObject* obj)
16+
{
17+
bool enabled = Settings::get<bool>("level/hitbox_multiplier", false);
18+
19+
if(!enabled)
20+
return reinterpret_cast<cocos2d::CCRect*(__thiscall*)(GameObject*)>(base::get() + 0x13a570)(obj);
21+
22+
bool all = Settings::get<bool>("level/hitbox_multiplier/scale_all", false);
23+
24+
float x = 1, y = 1;
25+
26+
float scaleSlopes[2] = {Settings::get<float>("level/hitbox_multiplier/scale_slopes/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_slopes/y", 1.f)};
27+
float scaleHazards[2] = {Settings::get<float>("level/hitbox_multiplier/scale_hazards/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_hazards/y", 1.f)};
28+
float scalePlayer[2] = {Settings::get<float>("level/hitbox_multiplier/scale_player/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_player/y", 1.f)};
29+
30+
if(obj == GameManager::get()->getGameLayer()->m_player1 || obj == GameManager::get()->getGameLayer()->m_player2)
31+
{
32+
x = scalePlayer[0];
33+
y = scalePlayer[1];
34+
}
35+
else
36+
{
37+
switch(obj->m_objectType)
38+
{
39+
default:
40+
return reinterpret_cast<cocos2d::CCRect*(__thiscall*)(GameObject*)>(base::get() + 0x13a570)(obj);
41+
case GameObjectType::Hazard:
42+
case GameObjectType::AnimatedHazard:
43+
x = scaleHazards[0];
44+
y = scaleHazards[1];
45+
break;
46+
case GameObjectType::Slope:
47+
x = scaleSlopes[0];
48+
y = scaleSlopes[1];
49+
break;
50+
}
51+
}
52+
53+
cocos2d::CCRect rect = *reinterpret_cast<cocos2d::CCRect*(__thiscall*)(GameObject*)>(base::get() + 0x13a570)(obj);
54+
scaleRect(&rect, x, y);
55+
rectForObject[obj] = rect;
56+
return &rectForObject[obj];
57+
}
58+
59+
$execute
60+
{
61+
Mod::get()->hook(reinterpret_cast<void *>(base::get() + 0x13a570), &HitboxMultiplier::GameObjectGetObjectRect, "GameObject::getObjectRect", tulip::hook::TulipConvention::Thiscall);
62+
}

src/Hacks/HitboxMultiplier.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <Geode/modify/GameObject.hpp>
4+
5+
using namespace geode::prelude;
6+
7+
class CCRect;
8+
9+
namespace HitboxMultiplier
10+
{
11+
//TODO: replace this with a custom rect field in m_fields when geode fixes getobjectrect return type
12+
std::unordered_map<GameObject*, cocos2d::CCRect> rectForObject;
13+
14+
cocos2d::CCRect* GameObjectGetObjectRect(GameObject* obj);
15+
};

src/Hacks/Labels.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,15 @@ class $modify(PlayLayer)
119119
float acc = p * 100.f;
120120
float limit = Settings::get<float>("labels/Noclip Accuracy/limit", 0.f);
121121

122+
pointer->setColor(dead ? ccColor3B(0, 255, 0) : ccColor3B(255, 255, 255));
123+
122124
if (!noclipDead)
123125
{
124126
if (acc <= limit)
125-
{
126-
JsonPatches::togglePatch(JsonPatches::player, "NoClip", false);
127-
128127
noclipDead = true;
129-
}
130128
pointer->setString(
131129
frames == 0
132-
? "Accuracy: 100%"
130+
? "Accuracy: 100.00%"
133131
: cocos2d::CCString::createWithFormat("Accuracy: %.2f%%", acc)->getCString()
134132
);
135133
}
@@ -140,6 +138,7 @@ class $modify(PlayLayer)
140138
setupLabel(
141139
"Noclip Deaths",
142140
[&](cocos2d::CCLabelBMFont* pointer) {
141+
pointer->setColor(dead ? ccColor3B(0, 255, 0) : ccColor3B(255, 255, 255));
143142
pointer->setString(cocos2d::CCString::createWithFormat("Deaths: %i", realDeaths)->getCString());
144143
},
145144
this
@@ -203,11 +202,23 @@ class $modify(PlayLayer)
203202

204203
void destroyPlayer(PlayerObject* player, GameObject* object)
205204
{
205+
if(!anticheatSpike)
206+
anticheatSpike = object;
207+
208+
if(object == anticheatSpike)
209+
return PlayLayer::destroyPlayer(player, object);
210+
211+
if(noclipDead)
212+
JsonPatches::togglePatch(JsonPatches::player, "NoClip", false);
213+
206214
PlayLayer::destroyPlayer(player, object);
207215

216+
if(noclipDead)
217+
JsonPatches::togglePatch(JsonPatches::player, "NoClip", true);
218+
208219
if(player && player->m_isDead)
209220
{
210-
currentRun.second = PlayLayer::getCurrentPercent();
221+
currentRun.second = this->getCurrentPercent();
211222

212223
float currentRunTotal = currentRun.second - currentRun.first;
213224
float bestRunTotal = bestRun.second - bestRun.first;
@@ -216,11 +227,7 @@ class $modify(PlayLayer)
216227
bestRun = currentRun;
217228
}
218229

219-
if(frames > 60)
220-
dead = true;
221-
222-
if(noclipDead)
223-
JsonPatches::togglePatch(JsonPatches::player, "NoClip", true);
230+
dead = true;
224231
}
225232

226233
void levelComplete()
@@ -248,6 +255,8 @@ class $modify(PlayLayer)
248255
currentRun.second = 0;
249256
PlayLayer::resetLevel();
250257

258+
anticheatSpike = nullptr;
259+
251260
currentRun.first = PlayLayer::getCurrentPercent();
252261
}
253262

src/Hacks/Labels.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ inline bool dead = false;
4444
inline bool noclipDead = false;
4545
inline bool lastFrameDead = false;
4646

47+
inline GameObject* anticheatSpike = nullptr;
48+
4749
Label setupLabel(const std::string& labelSettingName, const std::function<void(cocos2d::CCLabelBMFont*)> &function, cocos2d::CCLayer* playLayer);
4850

4951
void calculatePositions();

0 commit comments

Comments
 (0)