Synchronized 1-up collection

Collecting a 1-up gives a life to both. This can bring back a bubbled
player who had no lives remaining.
This commit is contained in:
MysterD 2020-09-05 19:55:38 -07:00
parent 8c3014b120
commit 13d9ae0313
2 changed files with 14 additions and 4 deletions

View file

@ -1,13 +1,19 @@
// mushroom_1up.c.inc
void bhv_1up_interact(void) {
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { return; }
UNUSED s32 sp1C;
struct MarioState* marioState = nearest_mario_state_to_object(o);
if (marioState->playerIndex == 0 && obj_check_if_collided_with_object(o, marioState->marioObj) == 1) {
u8 hitLocalPlayer = (marioState->playerIndex == 0) && (obj_check_if_collided_with_object(o, marioState->marioObj) == 1);
if (hitLocalPlayer || (o->oInteractStatus & INT_STATUS_INTERACTED)) {
play_sound(SOUND_GENERAL_COLLECT_1UP, gDefaultSoundArgs);
marioState->numLives++;
gMarioState[0].numLives++;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
if (hitLocalPlayer) {
network_send_collect_item(o);
}
}
}

View file

@ -919,8 +919,12 @@ s32 act_bubbled(struct MarioState* m) {
m->marioObj->header.gfx.angle[1] = angleToPlayer;
// make invisible on -1 lives
if (m->playerIndex == 0) {
if (m->numLives == -1) {
m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
} else {
m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
}
}
// pop bubble