Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
show hitboxes for vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Mar 22, 2024
1 parent 7bca282 commit e89f01d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/standalone/hooks/CCDrawNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "hooks.hpp"
#include "../../shared/hacks/hitboxes/hitboxes.hpp"

#include <dash/hook/cocos/CCDrawNode.hpp>

namespace openhack::hooks::CCDrawNode {

bool drawPolygon(cocos2d::CCDrawNode *self, gd::cocos2d::CCPoint *verts, unsigned int count, const cocos2d::ccColor4F &fillColor,
float borderWidth, const cocos2d::ccColor4F &borderColor) {
hacks::Hitboxes::modifyDraw((gui::Color &) fillColor, borderWidth, (gui::Color &) borderColor);
return hook::CCDrawNode::drawPolygon(self, verts, count, fillColor, borderWidth, borderColor);
}

bool drawCircle(cocos2d::CCDrawNode *self, cocos2d::CCPoint const &position, float radius, cocos2d::_ccColor4F const &color,
float borderWidth, cocos2d::_ccColor4F const &borderColor, unsigned int segments) {
hacks::Hitboxes::modifyDraw((gui::Color &) color, borderWidth, (gui::Color &) borderColor);
return hook::CCDrawNode::drawCircle(self, position, radius, color, borderWidth, borderColor, segments);
}

void installHooks() {
LOG_HOOK(CCDrawNode, drawPolygon);
LOG_HOOK(CCDrawNode, drawCircle);
}

}
2 changes: 2 additions & 0 deletions src/standalone/hooks/GJBaseGameLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
#include "../../shared/hacks/noclip-limit/noclip-limit.hpp"
#include "../../shared/hacks/frame-stepper/frame-stepper.hpp"
#include "../../shared/hacks/zephyrus/replays.hpp"
#include "../../shared/hacks/hitboxes/hitboxes.hpp"

namespace openhack::hooks::GJBaseGameLayer {
void processCommands(gd::GJBaseGameLayer *self) {
hacks::Labels::gameUpdate();
hacks::NoclipLimit::processCommands();
gd::hook::GJBaseGameLayer::processCommands(self);
hacks::Hitboxes::processCommands();
}

void update(gd::GJBaseGameLayer *self, float dt) {
Expand Down
15 changes: 15 additions & 0 deletions src/standalone/hooks/PlayLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../../shared/hacks/noclip-limit/noclip-limit.hpp"
#include "../../shared/hacks/zephyrus/replays.hpp"
#include "../../shared/hacks/random-seed/random-seed.hpp"
#include "../../shared/hacks/hitboxes/hitboxes.hpp"

#include <dash/hook/PlayLayer.hpp>

Expand All @@ -30,6 +31,7 @@ namespace openhack::hooks::PlayLayer {
hacks::NoclipLimit::resetLevel();
hacks::Labels::beforeResetLevel();
hook::PlayLayer::resetLevel(self);
hacks::Hitboxes::resetLevel();
hacks::InstantComplete::resetLevel();
hacks::Display::playLayerReset();
hacks::AutoPickupCoins::resetLevel();
Expand All @@ -49,12 +51,25 @@ namespace openhack::hooks::PlayLayer {
hacks::NoclipLimit::destroyPlayer(object);
hook::PlayLayer::destroyPlayer(self, player, object);
hacks::NoclipLimit::postDestroyPlayer();
hacks::Hitboxes::destroyPlayer();
}

void postUpdate(gd::PlayLayer *self, float dt) {
hook::PlayLayer::postUpdate(self, dt);
hacks::Hitboxes::postUpdate();
}

void fullReset(gd::PlayLayer *self) {
hook::PlayLayer::fullReset(self);
hacks::Hitboxes::fullReset();
}

void installHooks() {
LOG_HOOK(PlayLayer, init);
LOG_HOOK(PlayLayer, resetLevel);
LOG_HOOK(PlayLayer, addObject);
LOG_HOOK(PlayLayer, destroyPlayer);
LOG_HOOK(PlayLayer, postUpdate);
LOG_HOOK(PlayLayer, fullReset);
}
}
7 changes: 5 additions & 2 deletions src/standalone/hooks/hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
namespace openhack::hooks {
using namespace gd;

INSTALL_NAMESPACE(CCEGLView)

INSTALL_NAMESPACE(AppDelegate)
INSTALL_NAMESPACE(CCDrawNode)
INSTALL_NAMESPACE(CCEGLView)
INSTALL_NAMESPACE(CCScheduler)
INSTALL_NAMESPACE(ChannelControl)
INSTALL_NAMESPACE(GameStatsManager)
Expand All @@ -30,8 +32,9 @@ namespace openhack::hooks {
L_TRACE("Installing hooks...");
MH_Initialize();

CCEGLView::installHooks();
AppDelegate::installHooks();
CCDrawNode::installHooks();
CCEGLView::installHooks();
CCScheduler::installHooks();
ChannelControl::installHooks();
GameStatsManager::installHooks();
Expand Down

1 comment on commit e89f01d

@Rustring
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?? Show hitboxes was a geode only feature?

Please sign in to comment.