From e89f01d35d655bef94957d602ed9a6d850f3116b Mon Sep 17 00:00:00 2001 From: Oleksandr Nemesh Date: Fri, 22 Mar 2024 23:50:12 +0200 Subject: [PATCH] show hitboxes for vanilla --- libs/gd.hpp | 2 +- src/standalone/hooks/CCDrawNode.cpp | 25 ++++++++++++++++++++++++ src/standalone/hooks/GJBaseGameLayer.cpp | 2 ++ src/standalone/hooks/PlayLayer.cpp | 15 ++++++++++++++ src/standalone/hooks/hooks.hpp | 7 +++++-- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/standalone/hooks/CCDrawNode.cpp diff --git a/libs/gd.hpp b/libs/gd.hpp index f723f05..23aaad7 160000 --- a/libs/gd.hpp +++ b/libs/gd.hpp @@ -1 +1 @@ -Subproject commit f723f0501edb7127703742d00284419ba90cbd95 +Subproject commit 23aaad7b3db555d00247cd2dbe6f1e4675dcbeeb diff --git a/src/standalone/hooks/CCDrawNode.cpp b/src/standalone/hooks/CCDrawNode.cpp new file mode 100644 index 0000000..78d46cf --- /dev/null +++ b/src/standalone/hooks/CCDrawNode.cpp @@ -0,0 +1,25 @@ +#include "hooks.hpp" +#include "../../shared/hacks/hitboxes/hitboxes.hpp" + +#include + +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); + } + +} \ No newline at end of file diff --git a/src/standalone/hooks/GJBaseGameLayer.cpp b/src/standalone/hooks/GJBaseGameLayer.cpp index b34e004..759b029 100644 --- a/src/standalone/hooks/GJBaseGameLayer.cpp +++ b/src/standalone/hooks/GJBaseGameLayer.cpp @@ -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) { diff --git a/src/standalone/hooks/PlayLayer.cpp b/src/standalone/hooks/PlayLayer.cpp index 8b7d3e6..d86f20e 100644 --- a/src/standalone/hooks/PlayLayer.cpp +++ b/src/standalone/hooks/PlayLayer.cpp @@ -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 @@ -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(); @@ -49,6 +51,17 @@ 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() { @@ -56,5 +69,7 @@ namespace openhack::hooks::PlayLayer { LOG_HOOK(PlayLayer, resetLevel); LOG_HOOK(PlayLayer, addObject); LOG_HOOK(PlayLayer, destroyPlayer); + LOG_HOOK(PlayLayer, postUpdate); + LOG_HOOK(PlayLayer, fullReset); } } diff --git a/src/standalone/hooks/hooks.hpp b/src/standalone/hooks/hooks.hpp index 80d32ab..0792482 100644 --- a/src/standalone/hooks/hooks.hpp +++ b/src/standalone/hooks/hooks.hpp @@ -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) @@ -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();