Skip to content

Commit 74b21ce

Browse files
dementia
1 parent 669e6d0 commit 74b21ce

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

mod.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,23 @@
277277
"big-arrows": true,
278278
"big-arrow-step": 20
279279
}
280+
},
281+
"dementia-chance": {
282+
"type": "int",
283+
"name": "Dementia Chance",
284+
"description": "<cj>Dementia</c> - Chance of your player randomly teleports back.",
285+
"default": 10,
286+
"min": 0,
287+
"max": 100,
288+
"control": {
289+
"input": true,
290+
"slider": true,
291+
"slider-step": 1,
292+
"arrows": true,
293+
"arrow-step": 10,
294+
"big-arrows": true,
295+
"big-arrow-step": 20
296+
}
280297
}
281298
}
282299
}

src/hooks/TeleportPlayer.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <Horrible.hpp>
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#include <Geode/modify/PlayerObject.hpp>
6+
7+
using namespace geode::prelude;
8+
using namespace horrible;
9+
10+
class $modify(TeleportPlayerObject, PlayerObject)
11+
{
12+
struct Fields
13+
{
14+
bool enabled = horribleMod->getSavedValue<bool>("dementia", false);
15+
float chance = static_cast<int>(horribleMod->getSettingValue<int64_t>("dementia-chance"));
16+
float lastX = 0.f; // last recorded X position
17+
float lastY = 0.f; // last recorded Y position
18+
};
19+
20+
bool pushButton(PlayerButton p0)
21+
{
22+
if (auto playLayer = PlayLayer::get())
23+
{
24+
if (m_fields->enabled)
25+
{
26+
auto rnd = Rand::fast();
27+
log::debug("player teleport chance {}", rnd);
28+
29+
auto onGround = m_isOnGround || m_isOnGround2 || m_isOnGround3 || m_isOnGround4;
30+
// dementia
31+
if (rnd <= m_fields->chance)
32+
{
33+
setPosition(cocos2d::CCPoint(m_fields->lastX, m_fields->lastY));
34+
log::debug("player has dementia to ({}, {})", m_fields->lastX, m_fields->lastY);
35+
return PlayerObject::pushButton(p0);
36+
}
37+
else if (onGround) // save the position only if on ground
38+
{
39+
m_fields->lastX = getPositionX();
40+
m_fields->lastY = getPositionY();
41+
log::debug("player position recorded to ({}, {})", m_fields->lastX, m_fields->lastY);
42+
}
43+
}
44+
}
45+
46+
return PlayerObject::pushButton(p0);
47+
};
48+
};

src/menu/HorribleMenuPopup.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool>>
137137
"Blinking Icon",
138138
"Your icon will start to randomly blink.\n<cy>Credit: DragonixGD</c>",
139139
SillyTier::Low,
140-
false} };
140+
false},
141+
{"dementia",
142+
"Dementia",
143+
"Chance of your player randomly teleports back. This is more like player lagging to be honest!\n<cy>Credit: imdissapearinghelp</c>",
144+
SillyTier::Medium,
145+
false}
146+
};
141147
};
142148

143149
// silly tier filter

0 commit comments

Comments
 (0)