Skip to content

Commit c8b3fbf

Browse files
committed
rename rng namespace + add some easter eggs
1 parent 07bd7d5 commit c8b3fbf

41 files changed

Lines changed: 177 additions & 173 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ namespace horrible {
3737
*
3838
* @param chance The chance setting number
3939
*/
40-
inline constexpr float chanceToDelayPct(int chance = 50) noexcept {
41-
if (chance <= 0) chance = 1;
40+
inline constexpr float chanceToDelayPct(uint8_t chance = 50) noexcept {
41+
if (chance <= 0) chance = 0;
4242
if (chance > 100) chance = 100;
4343

44-
return ((100.f - static_cast<float>(chance)) + 1.f) / 100.f;
44+
return 1.f - (static_cast<float>(chance) / 100.f);
4545
};
4646

4747
// For convenience

src/hooks/Dementia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class $modify(DementiaPlayerObject, PlayerObject) {
3333
if (m_gameLayer) {
3434
auto f = m_fields.self();
3535

36-
auto rnd = randng::fast();
36+
auto rnd = rng::fast();
3737
log::trace("player teleport chance {}", rnd);
3838

3939
if (auto fmod = FMODAudioEngine::sharedEngine()) {

src/hooks/Gambler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class $modify(GamblerPlayLayer, PlayLayer) {
5757
// detect the moment the player first reaches or crosses 95
5858
if (percentage == 95 && !f->triggered) {
5959
// roll a random number between 0 and 1
60-
int roll = randng::get(1);
60+
int roll = rng::get(1);
6161

6262
log::info("Gambler roll: {}", roll);
6363
if (roll == 0) {

src/hooks/Mock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class $modify(MockMenuLayer, MenuLayer) {
3232
auto f = m_fields.self();
3333

3434
// show a lazysprite for the first png found in the save dir
35-
auto rnd = randng::fast();
35+
auto rnd = rng::fast();
3636
log::trace("mock chance {}", rnd);
3737

3838
if (rnd <= f->chance) {
@@ -83,8 +83,8 @@ class $modify(MockMenuLayer, MenuLayer) {
8383

8484
ss->addChild(percLabel);
8585

86-
auto rA = randng::pc();
87-
auto rB = randng::pc();
86+
auto rA = rng::pc();
87+
auto rB = rng::pc();
8888

8989
float yA = s->getScaledContentHeight() * rB; // starting height pos
9090
float yB = s->getScaledContentHeight() * rA; // ending height pos

src/hooks/Placebo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ static auto const o = Option::create(THIS_ID)
1818
->autoRegister();
1919

2020
void placeboEffect() {
21-
auto rnd = randng::fast();
22-
log::debug("placebo effect roll: {}", rnd);
21+
auto rnd = rng::fast();
22+
log::trace("placebo effect roll: {}", rnd);
2323

2424
if (rnd <= 1) { // 1% chance :trol:
2525
log::warn("Placebo effect activated! Toggling all options...");

src/hooks/Sleepy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class $modify(SleepyPlayerObject, PlayerObject) {
3131
bool init(int player, int ship, GJBaseGameLayer* gameLayer, CCLayer* layer, bool playLayer) {
3232
if (!PlayerObject::init(player, ship, gameLayer, layer, playLayer)) return false;
3333

34-
if (playLayer) scheduleOnce(schedule_selector(SleepyPlayerObject::asleep), randng::get(30.f, 5.f) * chanceToDelayPct(m_fields->chance));
34+
if (playLayer) scheduleOnce(schedule_selector(SleepyPlayerObject::asleep), rng::get(30.f, 5.f) * chanceToDelayPct(m_fields->chance));
3535

3636
return true;
3737
};
3838

3939
void startSleepTimer(float) {
40-
scheduleOnce(schedule_selector(SleepyPlayerObject::wakeUpSchedule), randng::get(15.f, 3.f) * chanceToDelayPct(m_fields->chance));
40+
scheduleOnce(schedule_selector(SleepyPlayerObject::wakeUpSchedule), rng::get(15.f, 3.f) * chanceToDelayPct(m_fields->chance));
4141
};
4242

4343
void wakeUpSchedule(float) {

src/hooks/Sticky.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class $modify(StickyPlayerObject, PlayerObject) {
8585

8686
if (m_hasEverJumped) {
8787
if (!wasOnGround && nowOnGround) {
88-
if (randng::fast() < f->chance) {
88+
if (rng::fast() < f->chance) {
8989
f->m_defSpeed = m_playerSpeed;
9090
m_playerSpeed = 0.f;
9191
if (f->m_clickLabel) f->m_clickLabel->setVisible(true);

src/hooks/chances/CrashGame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class $modify(CrashGamePlayLayer, PlayLayer) {
2929
// ignore the anti-cheat spike lmao
3030
if (p1 == m_anticheatSpike && p0 && !p0->m_isDead) return;
3131

32-
auto rnd = randng::fast();
32+
auto rnd = rng::fast();
3333
log::trace("crash destroy chance {}", rnd);
3434

3535
if (rnd <= f->chance) {

src/hooks/chances/Pause.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class $modify(PausePlayerObject, PlayLayer) {
3030

3131
void nextPause() {
3232
log::trace("scheduling pause");
33-
scheduleOnce(schedule_selector(PausePlayerObject::pause), randng::get(15.f, 3.f) * chanceToDelayPct(m_fields->chance));
33+
scheduleOnce(schedule_selector(PausePlayerObject::pause), rng::get(15.f, 3.f) * chanceToDelayPct(m_fields->chance));
3434
};
3535

3636
void pause(float) {

src/hooks/chances/RandomMirror.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class $modify(RandomMirrorPlayLayer, PlayLayer) {
4141

4242
void nextFlipPortal(float) {
4343
log::trace("scheduling flip");
44-
scheduleOnce(schedule_selector(RandomMirrorPlayLayer::flipPortal), randng::get(10.f, 1.f) * chanceToDelayPct(m_fields->chance));
44+
scheduleOnce(schedule_selector(RandomMirrorPlayLayer::flipPortal), rng::get(10.f, 1.f) * chanceToDelayPct(m_fields->chance));
4545
};
4646

4747
void flipPortal(float) {

0 commit comments

Comments
 (0)