Skip to content

Commit a93cbee

Browse files
editor probie
1 parent d41f09b commit a93cbee

3 files changed

Lines changed: 136 additions & 13 deletions

File tree

src/ideas/CrashGame.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ class $modify(CrashGamePlayLayer, PlayLayer)
1111
{
1212
bool enabled = horribleMod->getSavedValue<bool>("crash_death", false);
1313
int chance = static_cast<int>(horribleMod->getSettingValue<int64_t>("crash_death-chance"));
14+
bool m_dontCreateObjects = false;
15+
GameObject *m_destroyingObject;
1416
};
1517

1618
void destroyPlayer(PlayerObject *p0, GameObject *p1)
1719
{
1820
if (m_fields->enabled)
1921
{
22+
// ignore the anti-cheat spike lmao
23+
if (p1 == m_anticheatSpike && p0 && !p0->m_isDead)
24+
return;
25+
if (!m_fields->m_destroyingObject)
26+
m_fields->m_destroyingObject = p1;
27+
2028
auto rnd = Rand::fast();
2129
log::debug("crash destroy chance {}", rnd);
2230
if (rnd <= m_fields->chance)

src/ideas/ParryObjects.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <Horrible.hpp>
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#include <Geode/modify/PlayerObject.hpp>
6+
#include <Geode/modify/PlayLayer.hpp>
7+
#include <Geode/binding/GameObject.hpp>
8+
#include <Geode/binding/PlayLayer.hpp>
9+
#include <Geode/cocos/cocoa/CCArray.h>
10+
11+
using namespace geode::prelude;
12+
using namespace horrible;
13+
14+
// Shared parry state accessible by both player and play layer hooks
15+
static GameObject *s_pendingKiller = nullptr;
16+
static bool s_parryActive = false;
17+
bool isIntersects = false;
18+
19+
class $modify(ParryPlayerObject, PlayerObject)
20+
{
21+
struct Fields
22+
{
23+
bool enabled = horribleMod->getSavedValue<bool>("parry", false);
24+
};
25+
26+
void update(float p0)
27+
{
28+
if (m_fields->enabled)
29+
{
30+
if (auto pl = PlayLayer::get())
31+
{
32+
// ignore anti-noclip spike
33+
34+
CCObject *objRaw = nullptr;
35+
CCARRAY_FOREACH(pl->m_objects, objRaw)
36+
{
37+
auto obj = static_cast<GameObject *>(objRaw);
38+
if (!obj)
39+
continue;
40+
41+
// Only consider intersections with the object that is about to kill the player
42+
if (s_parryActive && s_pendingKiller && obj != s_pendingKiller)
43+
{
44+
continue; // skip non-hazard objects
45+
}
46+
47+
// Use object rects for reliable collision checks in GD/Geode context
48+
if (this->getObjectRect().intersectsRect(obj->getObjectRect()))
49+
{
50+
isIntersects = true;
51+
s_parryActive = true;
52+
log::debug("Player intersects with a spike/hazard object");
53+
}
54+
}
55+
}
56+
}
57+
PlayerObject::update(p0);
58+
}
59+
};
60+
61+
class $modify(ParryPlayLayer, PlayLayer)
62+
{
63+
struct Fields
64+
{
65+
bool enabled = horribleMod->getSavedValue<bool>("parry", false);
66+
float parryTimer = 0.f;
67+
};
68+
69+
void update(float dt)
70+
{
71+
PlayLayer::update(dt);
72+
73+
if (!m_fields->enabled)
74+
return;
75+
76+
if (s_parryActive && isIntersects)
77+
{
78+
log::debug("Parry active");
79+
m_fields->parryTimer -= dt;
80+
if (m_fields->parryTimer <= 0.f)
81+
{
82+
// do stuff
83+
}
84+
}
85+
}
86+
};

src/main.cpp

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <Geode/modify/CCScene.hpp>
66
#include <Geode/modify/CCMenuItem.hpp>
77
#include <Geode/modify/GJGameLevel.hpp>
8+
#include <Geode/modify/LevelEditorLayer.hpp>
89

910
#include <Geode/binding/FMODAudioEngine.hpp>
1011

@@ -13,12 +14,16 @@ using namespace horrible;
1314

1415
bool isFlipped = false;
1516

16-
class $modify(HorribleCCScene, CCScene) {
17-
bool init() {
18-
if (!CCScene::init()) return false;
17+
class $modify(HorribleCCScene, CCScene)
18+
{
19+
bool init()
20+
{
21+
if (!CCScene::init())
22+
return false;
1923

2024
#if !defined(GEODE_IS_MACOS) && !defined(GEODE_IS_IOS)
21-
if (typeinfo_cast<CCTransitionFade*>(this)) {
25+
if (typeinfo_cast<CCTransitionFade *>(this))
26+
{
2227
log::debug("scene is a CCTransitionFade");
2328
return true;
2429
};
@@ -31,16 +36,21 @@ class $modify(HorribleCCScene, CCScene) {
3136
};
3237

3338
// modify CCMenuItem so it plays the sound whenever a button is clicked regardless of the layer
34-
class $modify(HorribleCCMenuItem, CCMenuItem) {
35-
void activate() {
39+
class $modify(HorribleCCMenuItem, CCMenuItem)
40+
{
41+
void activate()
42+
{
3643
auto rnd = Rand::fast();
3744
log::debug("button menu chance {}", rnd);
3845

39-
if (horribleMod && horribleMod->getSavedValue<bool>("achieve", true)) {
40-
if (auto fmod = FMODAudioEngine::sharedEngine()) {
46+
if (horribleMod && horribleMod->getSavedValue<bool>("achieve", true))
47+
{
48+
if (auto fmod = FMODAudioEngine::sharedEngine())
49+
{
4150

4251
// @geode-ignore(unknown-resource)
43-
if (rnd <= static_cast<int>(horribleMod->getSettingValue<int64_t>("achieve-chance"))) fmod->playEffect("achievement_01.ogg");
52+
if (rnd <= static_cast<int>(horribleMod->getSettingValue<int64_t>("achieve-chance")))
53+
fmod->playEffect("achievement_01.ogg");
4454
};
4555
};
4656

@@ -49,12 +59,31 @@ class $modify(HorribleCCMenuItem, CCMenuItem) {
4959
};
5060

5161
// safe mode
52-
class $modify(HorribleGJGameLevel, GJGameLevel) {
53-
void savePercentage(int percent, bool isPracticeMode, int clicks, int attempts, bool isChkValid) {
54-
if (horribleMod->getSettingValue<bool>("safe-mode")) {
62+
class $modify(HorribleGJGameLevel, GJGameLevel)
63+
{
64+
void savePercentage(int percent, bool isPracticeMode, int clicks, int attempts, bool isChkValid)
65+
{
66+
if (horribleMod->getSettingValue<bool>("safe-mode"))
67+
{
5568
log::warn("Safe mode is enabled, progress will not be saved");
56-
} else {
69+
}
70+
else
71+
{
5772
GJGameLevel::savePercentage(percent, isPracticeMode, clicks, attempts, isChkValid);
5873
};
5974
};
75+
};
76+
77+
// WOMP WOMP BROKEN PLAYTEST
78+
class $modify(HorribleLevelEditorLayer, LevelEditorLayer)
79+
{
80+
void onPlaytest()
81+
{
82+
FLAlertLayer::create(
83+
"Playtest Disabled",
84+
"<cy>Horrible Ideas Mod</c> has <cr>completely broken</c> the Playtest function which prevents the player from testing the level.\n<cg>I recommend disabling the mod while editing levels.</c>",
85+
"OK")
86+
->show();
87+
LevelEditorLayer::onPlaytest();
88+
};
6089
};

0 commit comments

Comments
 (0)