Skip to content

Commit

Permalink
fix lock x, fix timewarp, add indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
theyareonit committed Jun 18, 2024
1 parent a0b80cb commit 05b94e5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The mod comes with its own version of Physics Bypass in the mod options. Be warn
# Known issues

- This mod does not work with bots
- Lock to player X will desync after clicking
- Controller input is not yet supported
- Numpad input is not yet supported

Icon by alex/sincos.
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The mod comes with its own version of Physics Bypass in the mod options. Be warn
# Known issues

- This mod does not work with bots
- Lock to player X will desync after clicking
- Controller input is not yet supported
- Numpad input is not yet supported

Icon by alex/sincos.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.1.8

* Fix Lock to Player X desync
* Add indicator to endscreen
* Fix timewarp

# v1.1.7

* Change getModifiedDelta hook priority for better compatibility with other mods
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gd": {
"win": "2.206"
},
"version": "v1.1.7",
"version": "v1.1.8",
"id": "syzzi.click_between_frames",
"name": "Click Between Frames",
"developer": "syzzi",
Expand Down
37 changes: 33 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Geode/modify/CCDirector.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>
#include <Geode/modify/PlayerObject.hpp>
#include <Geode/modify/EndLevelLayer.hpp>

#include <geode.custom-keybinds/include/Keybinds.hpp>

Expand Down Expand Up @@ -380,11 +381,13 @@ class $modify(GJBaseGameLayer) {

PlayLayer* pl = PlayLayer::get();
if (pl) {
const float timewarpDivisor = std::max(pl->m_gameState.m_timeWarp, 1.0f);
const int stepCount = std::round(std::max(1.0, ((modifiedDelta * 60.0) / std::min(1.0f, timewarpDivisor)) * 4)); // not sure if this is different from (delta * 240) / timewarpDivisor
const float timewarp = pl->m_gameState.m_timeWarp;
const int stepCount = std::round(std::max(1.0, ((modifiedDelta * 60.0) / std::min(1.0f, timewarp)) * 4)); // not sure if this is different from (delta * 240) / timewarpDivisor

if (modifiedDelta > 0.0) updateInputQueueAndTime(stepCount);
else skipUpdate = true;

if (actualDelta) modifiedDelta *= timewarp;
}

return modifiedDelta;
Expand Down Expand Up @@ -416,6 +419,8 @@ class $modify(PlayerObject) {
bool firstLoop = true;

step step = updateDeltaFactorAndInput();
CCPoint p1Pos = PlayerObject::getPosition();
CCPoint p2Pos = pl->m_player2->getPosition();

while (true) {
const float newTimeFactor = timeFactor * step.deltaFactor;
Expand All @@ -430,7 +435,11 @@ class $modify(PlayerObject) {
skipUpdate = false;
}

if (step.endStep) break;
if (step.endStep) {
this->m_lastPosition = p1Pos;
pl->m_player2->m_lastPosition = p2Pos;
break;
}

if (firstLoop) {
this->m_isOnGround = p1StartedOnGround;
Expand All @@ -447,6 +456,26 @@ class $modify(PlayerObject) {
}
};

class $modify(EndLevelLayer) {
void customSetup() {
EndLevelLayer::customSetup();

if (!softToggle) {
cocos2d::CCSize size = cocos2d::CCDirector::sharedDirector()->getWinSize();
CCLabelBMFont *indicator = CCLabelBMFont::create("CBF", "bigFont.fnt");

if (actualDelta) indicator->setString("CBF+PB");

indicator->setPosition({ size.width, size.height });
indicator->setAnchorPoint({ 1.0f, 1.0f });
indicator->setOpacity(90);
indicator->setScale(0.2f);

this->addChild(indicator);
}
}
};

Patch *patch;

void toggleMod(bool disable) {
Expand All @@ -456,7 +485,7 @@ void toggleMod(bool disable) {

VirtualProtect(addr, 4, newProtect, &oldProtect);

if (!patch) patch = Mod::get()->patch(addr, { 0x3d, 0x0a, 0x57, 0x3f }).unwrap();
if (!patch) patch = Mod::get()->patch(addr, { 0x29, 0x5c, 0x4f, 0x3f }).unwrap();

if (disable) patch->disable();
else patch->enable();
Expand Down

0 comments on commit 05b94e5

Please sign in to comment.