Skip to content

Commit

Permalink
collectible sound, only play jump sound in cube/robot
Browse files Browse the repository at this point in the history
  • Loading branch information
iAndyHD3 committed Dec 4, 2022
1 parent ebc77d4 commit 64db1d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ warning: buggy and incomplete
- `orbJump01.ogg` played when activating an orb
- `jump01.ogg` played when you jump (bad implemented and very buggy at the moment)
- `padJump01.ogg` played when activating a pad
- `collectItem01.ogg` played when an item is collected (key, coin, heart..)

## Setup

Expand Down
30 changes: 29 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,49 @@ gold01.ogg, gold02.ogg, quitSound_01.ogg
however std::cout is better than randomly playing sounds lol
*/

//orb
void PlayerObject_ringJump(void* self, GameObject* ring) {
matdash::orig<&PlayerObject_ringJump>(self, ring);
if(ring->m_bHasBeenActivated) playSound("orbJump01.ogg");
}

//pad
void GJBaseGameLayer_bumpPlayer(void* self, PlayerObject* player, GameObject* pad) {
matdash::orig<&GJBaseGameLayer_bumpPlayer>(self, player, pad);
if(pad->m_bHasBeenActivated) playSound("padJump01.ogg");
}


//collectible
void EffectGameObject_triggerObject(void* self, void* bgl) {

matdash::orig<&EffectGameObject_triggerObject>(self, bgl);
int objectID = MBO(int, self, 0x360);
//std::cout << fmt::format("trigger object, objid: {}", objectID) << std::endl;
switch(objectID) {

case 1275:
case 1587:
case 1588:
case 1589:
case 1614:
playSound("collectItem01.ogg");
}

}

bool isPlayerCubeOrRobot(PlayerObject* p)
{
return ( MBO(bool, p, 1596) ) || ( !MBO(bool, p, 1592) && !MBO(bool, p, 1593) && !MBO(bool, p, 1594) && !MBO(bool, p, 1595) && !MBO(bool, p, 1597) );
}

//jump
void PlayLayer_update_(gd::PlayLayer* self, float dt) {

auto p1 = self->m_pPlayer1;
if(!isPlayerCubeOrRobot(p1)) return matdash::orig<&PlayLayer_update_, matdash::Thiscall>(self, dt);

//std::cout << fmt::format("isPlayerCubeOrRobot: {}", isPlayerCubeOrRobot(p1)) << std::endl;

bool isFalling = p1->playerIsFalling();
bool isPressingDown = MBO(int, p1, 0x611) != 0;
bool onGround = !p1->m_isOnGround && (int)p1->unk610 == 213;
Expand All @@ -64,5 +91,6 @@ void mod_main(HMODULE) {

matdash::add_hook<&PlayerObject_ringJump>(gd::base + 0x1F4FF0);
matdash::add_hook<&GJBaseGameLayer_bumpPlayer>(gd::base + 0x10ED50);
matdash::add_hook<&EffectGameObject_triggerObject>(gd::base + 0x253D60);
matdash::add_hook<&PlayLayer_update_, matdash::Thiscall>(gd::base + 0x2029C0);
}

0 comments on commit 64db1d1

Please sign in to comment.