diff --git a/src/Hacks/Thicker Hitboxes.cpp b/src/Hacks/Thicker Hitboxes.cpp index 16cd026..e934fed 100644 --- a/src/Hacks/Thicker Hitboxes.cpp +++ b/src/Hacks/Thicker Hitboxes.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "../Client/Client.h" using namespace geode::prelude; @@ -15,77 +16,72 @@ ColourModule* interact = nullptr; ColourModule* player = nullptr; ColourModule* playerRot = nullptr; -bool myDrawPoly(CCDrawNode* ins, CCPoint *verts, unsigned int count, const ccColor4F &fillColor, float borderWidth, ccColor4F &borderColor) { - if (!thicker) - thicker = Client::GetModule("show-hitboxes")->options[7]; +class $modify (CCDrawNode) +{ + bool drawPolygon(CCPoint *verts, unsigned int count, const ccColor4F &fillColor, float borderWidth, const ccColor4F &borderColor) + { + if (!thicker) + thicker = Client::GetModule("show-hitboxes")->options[7]; - if (!fill) - fill = Client::GetModule("show-hitboxes")->options[8]; + if (!fill) + fill = Client::GetModule("show-hitboxes")->options[8]; - if (!fillOpacity) - fillOpacity = as(Client::GetModule("show-hitboxes")->options[9]); + if (!fillOpacity) + fillOpacity = as(Client::GetModule("show-hitboxes")->options[9]); - if (!solid) - solid = as(Client::GetModule("show-hitboxes")->options[0]); + if (!solid) + solid = as(Client::GetModule("show-hitboxes")->options[0]); - if (!hazard) - hazard = as(Client::GetModule("show-hitboxes")->options[1]); + if (!hazard) + hazard = as(Client::GetModule("show-hitboxes")->options[1]); - if (!passable) - passable = as(Client::GetModule("show-hitboxes")->options[2]); + if (!passable) + passable = as(Client::GetModule("show-hitboxes")->options[2]); - if (!interact) - interact = as(Client::GetModule("show-hitboxes")->options[3]); + if (!interact) + interact = as(Client::GetModule("show-hitboxes")->options[3]); - if (!player) - player = as(Client::GetModule("show-hitboxes")->options[4]); + if (!player) + player = as(Client::GetModule("show-hitboxes")->options[4]); - if (!playerRot) - playerRot = as(Client::GetModule("show-hitboxes")->options[5]); + if (!playerRot) + playerRot = as(Client::GetModule("show-hitboxes")->options[5]); - if (ins->getTag() == -9999) - { - if (borderColor.r == 0 && borderColor.g == 0.25f && borderColor.b == 1) - borderColor = ccc4FFromccc3B(solid->colour); + if (this->getTag() == -9999) + { + auto b = borderColor; + + if (borderColor.r == 0 && borderColor.g == 0.25f && borderColor.b == 1) + b = ccc4FFromccc3B(solid->colour); - else if (borderColor.r == 1 && borderColor.g == 0 && borderColor.b == 0) - borderColor = ccc4FFromccc3B(hazard->colour); + else if (borderColor.r == 1 && borderColor.g == 0 && borderColor.b == 0) + b = ccc4FFromccc3B(hazard->colour); - else if (borderColor.r == 0 && borderColor.g == 1 && borderColor.b == 0) - borderColor = ccc4FFromccc3B(interact->colour); + else if (borderColor.r == 0 && borderColor.g == 1 && borderColor.b == 0) + b = ccc4FFromccc3B(interact->colour); - else if (borderColor.r == 0 && borderColor.g == 1 && borderColor.b == 1) - borderColor = ccc4FFromccc3B(passable->colour); + else if (borderColor.r == 0 && borderColor.g == 1 && borderColor.b == 1) + b = ccc4FFromccc3B(passable->colour); - else if (borderColor.r == 1 && borderColor.g == 1 && borderColor.b == 0) - borderColor = ccc4FFromccc3B(playerRot->colour); + else if (borderColor.r == 1 && borderColor.g == 1 && borderColor.b == 0) + b = ccc4FFromccc3B(playerRot->colour); - else if (borderColor.r == -1 && borderColor.g == -1 && borderColor.b == -1) - borderColor = ccc4FFromccc3B(player->colour); + else if (borderColor.r == -1 && borderColor.g == -1 && borderColor.b == -1) + b = ccc4FFromccc3B(player->colour); - auto c = borderColor; + auto c = b; - c.a = fillOpacity->value; + c.a = fillOpacity->value; - if (borderWidth == 0) - borderWidth = 1; + if (borderWidth == 0) + borderWidth = 1; - return ins->drawPolygon(verts, count, fill->enabled ? c : fillColor, borderWidth * (thicker->enabled ? 2.2f : 1), borderColor); + return CCDrawNode::drawPolygon(verts, count, fill->enabled ? c : fillColor, borderWidth * (thicker->enabled ? 2.2f : 1), borderColor); + } + else + return CCDrawNode::drawPolygon(verts, count, fillColor, borderWidth, borderColor); } - else - return ins->drawPolygon(verts, count, fillColor, borderWidth, borderColor); -} - -$execute { - Mod::get()->hook( - reinterpret_cast( - geode::addresser::getNonVirtual(&CCDrawNode::drawPolygon) - ), - &myDrawPoly, - "cocos2d::CCDrawNode::drawPolygon", - tulip::hook::TulipConvention::Thiscall - ); -} +}; class $modify (GJBaseGameLayer) { @@ -132,4 +128,4 @@ class $modify (GJBaseGameLayer) if (m_player2) drawForPlayer(m_player2); } -}; \ No newline at end of file +};