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

Commit

Permalink
startpos switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Jan 21, 2024
1 parent 065848f commit e76472e
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 5 deletions.
4 changes: 4 additions & 0 deletions hacks/level.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@
}
]
},
{
"type": "embedded",
"hack": "startpos_switch"
},
{
"type": "embedded",
"hack": "auto_pickup_coins"
Expand Down
222 changes: 219 additions & 3 deletions src/bindings/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,229 @@

namespace robtop
{
class GameObject
class CCSpritePlus : public cocos2d::CCSprite
{
uint8_t pad_1[0x20];

public:
cocos2d::CCArray *m_followers;
CCSpritePlus *m_followingSprite;
bool m_hasFollower;
bool m_propagateScaleChanges;
bool m_propagateFlipChanges;
};

class GameObject : public CCSpritePlus
{
public:
inline uint32_t get_id()
{
uint32_t id = ((uint32_t*)this)[0xE1];
return id;
return m_objectID;
}
inline cocos2d::CCPoint get_position()
{
return m_startPosition;
}
inline float get_x()
{
return m_startPosition.x;
}
inline float get_y()
{
return m_startPosition.y;
}

uint8_t pad_1[0xf];
bool m_hasExtendedCollision;
uint8_t pad_2[0x13];
cocos2d::CCSprite *m_baseSprite;
cocos2d::CCSprite *m_detailSprite;
uint8_t pad_3[0x64];
std::string m_particleString;
uint8_t pad_4[0x1];
bool m_particleUseObjectColor;
uint8_t pad_5[0x32];
int m_linkedGroup;
uint8_t pad_6[0x23];
int m_uniqueID;
uint32_t m_objectType;
uint8_t pad_7[0x14];
double m_realXPosition;
double m_realYPosition;
cocos2d::CCPoint m_startPosition;
uint8_t pad_8[0x1];
bool m_hasNoAudioScale;
uint8_t pad_9[0x2a];
short m_enterChannel;
short m_objectMaterial;
uint8_t pad_10[0x4];
bool m_hasNoGlow;
int m_targetColor;
int m_objectID;
short m_customColorType;
bool m_isDontEnter;
bool m_isDontFade;
bool m_hasNoEffects;
bool m_hasNoParticles;
uint8_t pad_11[0x16];
int m_property53 = sizeof(std::string);
uint8_t pad_12[0x18];
void *m_baseColor;
void *m_detailColor;
int m_zLayer;
int m_zOrder;
uint8_t pad_13[0x10];
bool m_shouldUpdateColorSprite;
uint8_t pad_14[0x1];
bool m_hasGroupParent;
bool m_hasAreaParent;
float m_scaleX;
float m_scaleY;
std::array<short, 10> *m_groups;
short m_groupCount;
bool m_hasGroupParentsString;
uint8_t pad_15[0xf];
short m_editorLayer;
short m_editorLayer2;
uint8_t pad_16[0x8];
bool m_isNoTouch;
uint8_t pad_17[0x2c];
bool m_isHighDetail;
uint8_t pad_18[0x11];
bool m_isPassable;
bool m_isHide;
bool m_isNonStickX;
bool m_isNonStickY;
bool m_isIceBlock;
bool m_isGripSlope;
bool m_isScaleStick;
bool m_isExtraSticky;
bool m_isDontBoostY;
bool m_isDontBoostX;
uint8_t pad_19[0x11];
int m_property155;
int m_property156;
uint8_t pad_20[0x26];
};

class EnhancedGameObject : public GameObject
{
bool m_hasCustomAnimation;
bool m_hasCustomRotation;
bool m_disableRotation;
float m_rotationSpeed;
bool m_animationRandomizedStart;
float m_animationSpeed;
bool m_animationShouldUseSpeed;
bool m_animateOnTrigger;
bool m_disableDelayedLoop;
bool m_disableAnimShine;
int m_singleFrame;
bool m_animationOffset;
bool m_animateOnlyWhenActive;
bool m_isNoMultiActivate;
bool m_isMultiActivate;
};

class EffectGameObject : public EnhancedGameObject
{
cocos2d::ccColor3B m_triggerTargetColor;
float m_duration;
float m_opacity;
int m_targetGroupID;
int m_centerGroupID;
bool m_isTouchTriggered;
bool m_isSpawnTriggered;
bool m_hasCenterEffect;
float m_shakeStrength;
float m_shakeInterval;
bool m_tintGround;
bool m_usesPlayerColor1;
bool m_usesPlayerColor2;
bool m_usesBlending;
float m_moveOffsetX;
float m_moveOffsetY;
int m_easingType;
float m_easingRate;
bool m_lockToPlayerX;
bool m_lockToPlayerY;
bool m_lockToCameraX;
bool m_lockToCameraY;
bool m_useMoveTarget;
int m_moveTargetMode;
float m_moveModX;
float m_moveModY;
bool m_property393;
bool m_isDirectionFollowSnap360;
int m_targetModCenterID;
float m_directionModeDistance;
bool m_isDynamicMode;
bool m_isSilent;
float m_rotationDegrees;
int m_times360;
bool m_lockObjectRotation;
int m_rotationTargetID;
float m_rotationOffset;
int m_dynamicModeEasing;
float m_followXMod;
float m_followYMod;
float m_followYSpeed;
float m_followYDelay;
int m_followYOffset;
float m_followYMaxSpeed;
float m_fadeInDuration;
float m_holdDuration;
float m_fadeOutDuration;
int m_pulseMode;
int m_pulseTargetType;
cocos2d::ccHSVValue m_hsvValue;
int m_copyColorID;
bool m_copyOpacity;
bool m_pulseMainOnly;
bool m_pulseDetailOnly;
bool m_pulseExclusive;
bool m_property210;
bool m_activateGroup;
bool m_touchHoldMode;
int m_touchToggleMode;
int m_touchPlayerMode;
bool m_isDualMode;
int m_animationID;
bool m_isMultiActivate;
bool m_triggerOnExit;
int m_itemID2;
int m_property534;
int m_itemID;
bool m_targetPlayer1;
bool m_targetPlayer2;
bool m_followCPP;
bool m_subtractCount;
bool m_collectibleIsPickupItem;
bool m_collectibleIsToggleTrigger;
int m_collectibleParticleID;
int m_collectiblePoints;
bool m_hasNoAnimation;
float m_gravityValue;
bool m_isSinglePTouch;
float m_zoomValue;
bool m_cameraIsFreeMode;
bool m_cameraEditCameraSettings;
float m_cameraEasingValue;
float m_cameraPaddingValue;
bool m_cameraDisableGridSnap;
bool m_property118;
float m_timeWarpTimeMod;
bool m_showGamemodeBorders;
int m_ordValue;
int m_channelValue;
bool m_isReverse;
int m_secretCoinID;
bool m_ignoreGroupParent;
bool m_ignoreLinkedObjects;
};

class StartPosObject : public EffectGameObject
{
int m_unknown;
};
}
11 changes: 11 additions & 0 deletions src/bindings/PlayLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace robtop
inline const char *PlayLayer_startPosCheckpoint_pat = "74208B8B^??0000";
inline uintptr_t PlayLayer_startPosCheckpoint_offset;

inline const char *PlayLayer_practiceMode_pat = "E9????8A81^??000084C0";
inline uintptr_t PlayLayer_practiceMode_offset;

class PlayLayer : public cocos2d::CCLayer
{
public:
Expand Down Expand Up @@ -87,5 +90,13 @@ namespace robtop
uintptr_t addr = (uintptr_t)this + PlayLayer_startPosCheckpoint_offset;
*(uintptr_t *)addr = checkpoint;
}
inline bool isPracticeMode()
{
if (!PlayLayer_practiceMode_offset)
return false;

uintptr_t addr = (uintptr_t)this + PlayLayer_practiceMode_offset;
return *(bool *)addr;
}
};
}
5 changes: 3 additions & 2 deletions src/bindings/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace robtop
// used to find the offset of a member variable from code
inline void init_member_offset(const char *name, uintptr_t *ptr, const char *pat, size_t size)
{
uintptr_t addr = patterns::find_pattern(pat);
uintptr_t addr = patterns::find_pattern(pat);
if (!addr)
{
L_ERROR("Failed to find {}", name);
Expand All @@ -42,7 +42,7 @@ namespace robtop
{
result |= bytes[i] << (i * 8);
}

*ptr = result;

L_TRACE("Member offset for {} is 0x{:x}", name, *ptr);
Expand Down Expand Up @@ -71,6 +71,7 @@ namespace robtop
init_binding("PlayLayer::removeAllCheckpoints", (void **)&robtop::PlayLayer_removeAllCheckpoints, robtop::PlayLayer_removeAllCheckpoints_pat);
init_binding("PlayLayer::~PlayLayer", (void **)&robtop::PlayLayer_destructor, robtop::PlayLayer_destructor_pat);
init_member_offset("PlayLayer::startPosCheckpoint", &robtop::PlayLayer_startPosCheckpoint_offset, robtop::PlayLayer_startPosCheckpoint_pat, 4);
init_member_offset("PlayLayer::practiceMode", &robtop::PlayLayer_practiceMode_offset, robtop::PlayLayer_practiceMode_pat, 4);

// LevelEditorLayer
init_binding("LevelEditorLayer::init", (void **)&robtop::LevelEditorLayer_init, robtop::LevelEditorLayer_init_pat);
Expand Down
2 changes: 2 additions & 0 deletions src/hacks/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "discord_rpc.h"
#include "display.h"
#include "auto_safemode.h"
#include "startpos_switch.h"
#include "pickup_coins.h"

namespace hacks
Expand Down Expand Up @@ -351,6 +352,7 @@ namespace hacks
hacks.push_back(new DiscordRPC());
hacks.push_back(new DisplayHack());
hacks.push_back(new AutoSafeMode());
hacks.push_back(new StartposSwitcher());
hacks.push_back(new PickupCoins());

for (auto &hack : hacks)
Expand Down
Loading

0 comments on commit e76472e

Please sign in to comment.