From 9ca4362388f4ab3e0795b965d0ed0392a48a8025 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 5 Sep 2020 19:55:38 -0700 Subject: [PATCH] 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. --- src/game/behaviors/mushroom_1up.inc.c | 10 ++++++++-- src/game/mario_actions_automatic.c | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game/behaviors/mushroom_1up.inc.c b/src/game/behaviors/mushroom_1up.inc.c index 1b6b25cb..929f4a58 100644 --- a/src/game/behaviors/mushroom_1up.inc.c +++ b/src/game/behaviors/mushroom_1up.inc.c @@ -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); + } } } diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index dba26859..ab21f122 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -919,8 +919,12 @@ s32 act_bubbled(struct MarioState* m) { m->marioObj->header.gfx.angle[1] = angleToPlayer; // make invisible on -1 lives - if (m->numLives == -1) { - m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; + 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