Skip to content

Commit e60eecd

Browse files
committed
tweak some options
1 parent c8b3fbf commit e60eecd

7 files changed

Lines changed: 89 additions & 90 deletions

File tree

src/hooks/Dementia.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,36 @@ class $modify(DementiaPlayerObject, PlayerObject) {
3030
};
3131

3232
bool pushButton(PlayerButton p0) {
33-
if (m_gameLayer) {
34-
auto f = m_fields.self();
33+
if (!m_gameLayer) return PlayerObject::pushButton(p0);
3534

36-
auto rnd = rng::fast();
37-
log::trace("player teleport chance {}", rnd);
35+
auto f = m_fields.self();
3836

39-
if (auto fmod = FMODAudioEngine::sharedEngine()) {
40-
FMOD::Channel* musicChannel = nullptr;
37+
auto rnd = rng::fast();
38+
log::trace("player teleport chance {}", rnd);
4139

42-
auto bgchannel = fmod->m_backgroundMusicChannel;
43-
auto channel = bgchannel->getChannel(0, &musicChannel);
40+
if (auto fmod = FMODAudioEngine::sharedEngine()) {
41+
FMOD::Channel* musicChannel = nullptr;
4442

45-
auto onGround = m_isOnGround || m_isOnGround2 || m_isOnGround3 || m_isOnGround4;
46-
// dementia
47-
if (rnd <= f->chance) {
48-
setPosition({f->lastX, f->lastY});
49-
log::trace("player has dementia to ({}, {}), play time {}", f->lastX, f->lastY, f->lastMusicTime);
43+
auto bgchannel = fmod->m_backgroundMusicChannel;
44+
auto channel = bgchannel->getChannel(0, &musicChannel);
5045

51-
// set the music time back to the last recorded time
52-
if (musicChannel) musicChannel->setPosition(f->lastMusicTime, FMOD_TIMEUNIT_MS);
46+
auto onGround = m_isOnGround || m_isOnGround2 || m_isOnGround3 || m_isOnGround4;
47+
// dementia
48+
if (rnd <= f->chance) {
49+
setPosition({f->lastX, f->lastY});
50+
log::trace("player has dementia to ({}, {}), play time {}", f->lastX, f->lastY, f->lastMusicTime);
5351

54-
return PlayerObject::pushButton(p0);
55-
} else if (onGround) { // save the position only if on ground
56-
f->lastX = getPositionX();
57-
f->lastY = getPositionY();
52+
// set the music time back to the last recorded time
53+
if (musicChannel) musicChannel->setPosition(f->lastMusicTime, FMOD_TIMEUNIT_MS);
5854

59-
f->lastMusicTime = fmod->getMusicTimeMS(1);
55+
return PlayerObject::pushButton(p0);
56+
} else if (onGround) { // save the position only if on ground
57+
f->lastX = getPositionX();
58+
f->lastY = getPositionY();
6059

61-
log::trace("position recorded to ({}, {}) and music time {}", f->lastX, f->lastY, f->lastMusicTime);
62-
};
60+
f->lastMusicTime = fmod->getMusicTimeMS(1);
61+
62+
log::trace("position recorded to ({}, {}) and music time {}", f->lastX, f->lastY, f->lastMusicTime);
6363
};
6464
};
6565

src/hooks/Gambler.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ class $modify(GamblerPlayLayer, PlayLayer) {
2121

2222
struct Fields {
2323
bool triggered = false;
24-
bool tricked = false;
2524
};
2625

2726
bool init(GJGameLevel* level, bool useReplay, bool dontCreateObjects) {
2827
if (!PlayLayer::init(level, useReplay, dontCreateObjects)) return false;
2928

3029
auto f = m_fields.self();
3130

32-
log::debug("gambler enabled");
33-
3431
// check every frame so we can detect each percentage change
3532
if (!f->triggered) schedule(schedule_selector(GamblerPlayLayer::gamblerCheck), 0.f);
3633

@@ -41,47 +38,45 @@ class $modify(GamblerPlayLayer, PlayLayer) {
4138
void fullReset() {
4239
PlayLayer::fullReset();
4340
m_fields->triggered = false;
44-
log::debug("gambler full reset");
41+
log::trace("gambler full reset");
4542
};
4643

4744
void resetLevel() {
4845
PlayLayer::resetLevel();
4946
m_fields->triggered = false;
50-
log::debug("gambler level reset");
47+
log::trace("gambler level reset");
5148
};
5249

5350
void gamblerCheck(float) {
5451
auto f = m_fields.self();
5552

56-
int percentage = getCurrentPercentInt();
5753
// detect the moment the player first reaches or crosses 95
58-
if (percentage == 95 && !f->triggered) {
54+
if (getCurrentPercentInt() >= 95 && !f->triggered) {
5955
// roll a random number between 0 and 1
60-
int roll = rng::get(1);
56+
auto roll = rng::get(1);
6157

6258
log::info("Gambler roll: {}", roll);
63-
if (roll == 0) {
59+
if (roll <= 0) {
6460
log::info("Gambler lost the bet!");
6561

6662
sfx::play(sfx::file::pop);
6763
Notification::create("Unlucky!", NotificationIcon::Error)->show();
6864

6965
// reverse the player
7066
m_player1->reversePlayer(nullptr);
71-
m_player1->m_gravity = 0.01f; // reduce gravity to simulate a bounce
7267

7368
// force player to jump
7469
if (auto gjbgl = GJBaseGameLayer::get()) gjbgl->handleButton(true, 1, true);
7570

7671
f->triggered = true;
77-
f->tricked = true;
7872
} else {
7973
log::info("Gambler won the bet! instant win.");
8074

8175
sfx::play(sfx::file::good);
8276
Notification::create("You got lucky this time...", NotificationIcon::Success)->show();
8377

8478
levelComplete();
79+
8580
f->triggered = true;
8681
};
8782
};

src/hooks/obstructive/Confetti.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class $modify(ConfettiPlayLayer, PlayLayer) {
5353
log::info("unleashing confetti!");
5454

5555
sfx::play(sfx::file::bad);
56-
shakeCamera(1.25f, 2.5f, 0.00875f);
56+
shakeCamera(0.875f, 2.5f, 0.00875f);
5757

5858
for (int i = 0; i < rng::get(150, 75); i++) createConfetti();
5959

@@ -69,8 +69,10 @@ class $modify(ConfettiPlayLayer, PlayLayer) {
6969
useY ? getScaledContentWidth() + conf->getScaledContentWidth() : getScaledContentWidth() * rng::pc(),
7070
useY ? getScaledContentHeight() * rng::pc() : getScaledContentHeight() + conf->getScaledContentHeight());
7171

72-
auto move = CCEaseSineOut::create(CCMoveTo::create(0.875f + rng::pc() * 2.5f, endPos));
73-
auto rotate = CCEaseSineOut::create(CCRotateBy::create(0.875f + rng::pc() * 2.5f, 360.f * (rng::get(1) > 0 ? 1.f : -1.f)));
72+
auto dur = 0.875f + rng::pc() * 2.5f;
73+
74+
auto move = CCEaseSineOut::create(CCMoveTo::create(dur, endPos));
75+
auto rotate = CCEaseSineOut::create(CCRotateBy::create(dur * rng::get(2.5f, 1.f), (360.f * (rng::get(1) > 0 ? 1.f : -1.f)) * rng::get(3.75f, 0.875f)));
7476

7577
auto seq = CCSequence::createWithTwoActions(
7678
CCSpawn::createWithTwoActions(move, rotate),

src/hooks/randoms/RandomIcon.cpp

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using namespace horrible::prelude;
1111

1212
static auto const o = Option::create(THIS_ID)
1313
->setName("Random Icon Change")
14-
->setDescription("Randomly change your icon every time you jump.\n<cl>suggested by JompyDoJump</c>")
14+
->setDescription("Chance to randomly change your icon whenever you jump.\n<cl>suggested by JompyDoJump</c>")
1515
->setCategory(category::randoms)
1616
->setSillyTier(SillyTier::Low)
1717
->autoRegister();
@@ -20,35 +20,29 @@ class $modify(RandomIconPlayerObject, PlayerObject) {
2020
HORRIBLE_DELEGATE_HOOKS(THIS_ID);
2121

2222
bool pushButton(PlayerButton p0) {
23+
if (p0 != PlayerButton::Jump || !m_gameLayer) return PlayerObject::pushButton(p0);
24+
2325
// jump pls
24-
if (m_gameLayer && p0 == PlayerButton::Jump) {
25-
auto gm = GameManager::sharedState();
26-
auto rnd = rng::tiny();
27-
28-
// count the icons i guess
29-
auto maxIcons = 0;
30-
if (gm) maxIcons = gm->countForType(IconType::Cube);
31-
if (maxIcons <= 0) maxIcons = 38;
32-
33-
// pick random icons that is unlocked
34-
auto tries = 0;
35-
auto newIcon = rnd % maxIcons + 1;
36-
37-
while (tries < 20 && gm && !gm->isIconUnlocked(newIcon, IconType::Cube)) {
38-
newIcon = rnd % maxIcons + 1;
39-
tries++;
40-
};
26+
if (auto gm = GameManager::sharedState()) {
27+
if (rng::fast() <= 50) {
28+
// count the icons i guess
29+
auto maxIcons = 0;
30+
maxIcons = gm->countForType(IconType::Cube);
31+
if (maxIcons <= 0) maxIcons = 38;
32+
33+
auto newIcon = rng::get(maxIcons);
4134

42-
// randomize the colors of the icon
43-
auto r = rng::get(256);
44-
auto g = rng::get(256);
45-
auto b = rng::get(256);
35+
#define RANDOM_COLOR {rng::get<uint8_t>(255), rng::get<uint8_t>(255), rng::get<uint8_t>(255)}
4636

47-
setColor(ccc3(r, g, b));
48-
updatePlayerGlow();
37+
setColor(RANDOM_COLOR);
38+
setSecondColor(RANDOM_COLOR);
39+
setGlowColor(RANDOM_COLOR);
4940

50-
updatePlayerFrame(newIcon);
51-
log::debug("Changed player icon to {}", newIcon);
41+
updatePlayerGlow();
42+
updatePlayerFrame(newIcon);
43+
44+
log::debug("Changed player icon to {}", newIcon);
45+
};
5246
};
5347

5448
return PlayerObject::pushButton(p0);

src/hooks/randoms/SizeChanger.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ class $modify(SizeChangerPlayerObject, PlayerObject) {
2525
bool scaled = false;
2626
};
2727

28-
bool pushButton(PlayerButton button) {
29-
if (m_gameLayer) {
30-
auto f = m_fields.self();
31-
32-
// log::debug("size changer jump detected");
33-
34-
if (rng::fast() <= f->chance) {
35-
if (f->scaled) {
36-
log::debug("change scale big");
37-
togglePlayerScale(f->scaled, false);
38-
f->scaled = false;
39-
} else {
40-
log::debug("change scale small");
41-
togglePlayerScale(f->scaled, false);
42-
f->scaled = true;
43-
};
28+
bool pushButton(PlayerButton p0) {
29+
if (!m_gameLayer) return PlayerObject::pushButton(p0);
30+
31+
auto f = m_fields.self();
32+
33+
// log::debug("size changer jump detected");
34+
35+
if (rng::fast() <= f->chance) {
36+
if (f->scaled) {
37+
log::debug("change scale big");
38+
togglePlayerScale(f->scaled, false);
39+
f->scaled = false;
40+
} else {
41+
log::debug("change scale small");
42+
togglePlayerScale(f->scaled, false);
43+
f->scaled = true;
4444
};
4545
};
4646

47-
return PlayerObject::pushButton(button);
47+
return PlayerObject::pushButton(p0);
4848
};
4949
};

src/ui/src/Menu.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,17 @@ bool Menu::init() {
466466
socialContainer->setLayout(socialContainerLayout);
467467

468468
auto socialBtns = std::to_array<SocialBtnData>(
469-
{{"accountBtn_myLists_001.png",
470-
"credits-btn",
471-
[this](auto) {
472-
if (auto popup = MenuCredits::create(m_impl->theme)) popup->show();
473-
},
474-
0.55f},
475-
{"gj_discordIcon_001.png",
469+
{
470+
{
471+
"accountBtn_myLists_001.png",
472+
"credits-btn",
473+
[this](auto) {
474+
if (auto popup = MenuCredits::create(m_impl->theme)) popup->show();
475+
},
476+
0.55f,
477+
},
478+
{
479+
"gj_discordIcon_001.png",
476480
"discord-btn",
477481
[](auto) {
478482
createQuickPopup(
@@ -483,12 +487,16 @@ bool Menu::init() {
483487
[](auto, bool ok) {
484488
if (ok) web::openLinkInBrowser("https://www.dsc.gg/cubic");
485489
});
486-
}},
487-
{"geode.loader/gift.png",
490+
},
491+
},
492+
{
493+
"geode.loader/gift.png",
488494
"support-btn",
489495
[](auto) {
490496
openSupportPopup(mod);
491-
}}});
497+
},
498+
},
499+
});
492500

493501
for (auto& socialBtn : socialBtns) {
494502
if (auto btn = Button::createWithSpriteFrameName(

src/ui/src/MenuOptionCell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ bool MenuOptionCell::init(CCSize const& size, std::weak_ptr<Option> option, ZStr
225225
(m_impl->compatible) ? (onlineCompat ? "GJ_infoIcon_001.png" : "geode.loader/info-warning.png") : "geode.loader/info-alert.png",
226226
[this](auto) {
227227
if (auto o = m_impl->option.lock()) {
228-
auto formatDesc = fmt::format("{}\n\n{}\n{}", (o->getDescription().size() > 0) ? o->getDescription() : "<cc>No description provided.</c>", o->isOnline() ? "<co>An internet connection is required.</c>\n" : "", m_impl->getTierDescString(o->getSillyTier(), m_impl->compatible));
228+
auto formatDesc = fmt::format("{}\n\n{}{}", (o->getDescription().size() > 0) ? o->getDescription() : "<cc>No description provided.</c>", o->isOnline() ? "<co>An internet connection is required.</c>\n" : "", m_impl->getTierDescString(o->getSillyTier(), m_impl->compatible));
229229

230230
createQuickPopup(
231231
o->getName().c_str(),

0 commit comments

Comments
 (0)