Skip to content

Commit 18b86cb

Browse files
placebooooo
1 parent d317e47 commit 18b86cb

1 file changed

Lines changed: 52 additions & 23 deletions

File tree

src/hooks/PlayLayer/Placebo.cpp

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,69 @@
22

33
#include <Geode/Geode.hpp>
44

5-
#include <Geode/modify/PlayLayer.hpp>
5+
#include <Geode/modify/LevelPage.hpp>
6+
#include <Geode/modify/LevelInfoLayer.hpp>
67

78
using namespace geode::prelude;
89
using namespace horrible;
910

10-
class $modify(PlaceboPlayLayer, PlayLayer) {
11-
struct Fields {
12-
bool enabled = horribleMod->getSavedValue<bool>("placebo", false);
11+
struct Fields
12+
{
13+
bool enabled = horribleMod->getSavedValue<bool>("placebo", false);
14+
};
15+
16+
Fields m_fields;
17+
18+
void placeboEffect();
19+
20+
class $modify(PlaceboLevelPage, LevelPage)
21+
{
22+
23+
void onPlay(CCObject *sender)
24+
{
25+
placeboEffect();
26+
LevelPage::onPlay(sender);
1327
};
28+
};
1429

15-
bool init(GJGameLevel * level, bool useReplay, bool dontCreateObjects)
30+
class $modify(PlaceboLevelInfoLayer, LevelInfoLayer)
31+
{
32+
33+
void onPlay(CCObject *sender)
1634
{
17-
if (!PlayLayer::init(level, useReplay, dontCreateObjects))
18-
return false;
19-
if (m_fields->enabled)
35+
placeboEffect();
36+
LevelInfoLayer::onPlay(sender);
37+
};
38+
};
39+
40+
41+
42+
void placeboEffect()
43+
{
44+
if (horribleMod && m_fields.enabled)
45+
{
46+
int rnd = Rand::tiny() % 1000;
47+
log::info("placebo effect roll: {}", rnd);
48+
49+
if (rnd < 10)
2050
{
21-
int rnd = Rand::get(1000); // 0.05% chance
22-
log::debug("placebo init called {}", rnd);
23-
if (rnd < 1) // if rng is < 1
51+
log::info("Placebo effect activated! Enabling all horrible mod options...");
52+
53+
for (const auto& option : modOptions)
2454
{
25-
log::debug("placebo activated, you feel stronger");
26-
// make every options enabled
27-
for (auto& option : modOptions) {
28-
horribleMod->setSavedValue<bool>(option.id, true);
29-
}
55+
horribleMod->setSavedValue<bool>(option.id, true);
56+
log::debug("Enabled option: {}", option.id);
3057
}
31-
if (rnd < 5) {
32-
log::debug("placebo overactivated, you feel invincible");
33-
// make every options disabled
34-
for (auto& option : modOptions) {
35-
horribleMod->setSavedValue<bool>(option.id, false);
36-
}
58+
}
59+
60+
if (rnd < 5) {
61+
log::info("Placebo effect activated! Disabling all horrible mod options...");
62+
63+
for (const auto& option : modOptions)
64+
{
65+
horribleMod->setSavedValue<bool>(option.id, false);
66+
log::debug("Disabled option: {}", option.id);
3767
}
3868
}
39-
return true;
4069
};
4170
};

0 commit comments

Comments
 (0)