From 2f1e0473c237f1ee124d77d2a4daf9b4312a97c0 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 4 Oct 2020 19:16:35 -0700 Subject: [PATCH] Offset and separate player intro pipes --- src/game/behaviors/intro_lakitu.inc.c | 1 + src/game/camera.c | 5 +++++ src/game/mario_actions_cutscene.c | 32 +++++++++++++++++++-------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/game/behaviors/intro_lakitu.inc.c b/src/game/behaviors/intro_lakitu.inc.c index 7b12a651..ea1095f0 100644 --- a/src/game/behaviors/intro_lakitu.inc.c +++ b/src/game/behaviors/intro_lakitu.inc.c @@ -138,6 +138,7 @@ void bhv_intro_lakitu_loop(void) { case 3: cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO); vec3f_set(sp58, -1128.f, 560.f, 4664.f); + sp58[0] -= gNetworkPlayers[0].globalIndex * 350.f; gCurrentObject->oMoveAngleYaw += 0x200; gCurrentObject->oIntroLakituUnk100 = approach_f32_asymptotic(gCurrentObject->oIntroLakituUnk100, 100.f, 0.03f); diff --git a/src/game/camera.c b/src/game/camera.c index bab26bbf..cba5bad5 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -29,6 +29,7 @@ #include "engine/graph_node.h" #include "level_table.h" #include "pc/configfile.h" +#include "pc/network/network.h" #define CBUTTON_MASK (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS) @@ -9598,6 +9599,8 @@ s32 intro_peach_move_camera_start_to_pipe(struct Camera *c, struct CutsceneSplin */ posReturn = move_point_along_spline(c->pos, positionSpline, &sCutsceneSplineSegment, &sCutsceneSplineSegmentProgress); focusReturn = move_point_along_spline(c->focus, focusSpline, &sCutsceneSplineSegment, &sCutsceneSplineSegmentProgress); + c->pos[0] += gNetworkPlayers[0].globalIndex * 350.f; + c->focus[0] += gNetworkPlayers[0].globalIndex * 350.f; // The two splines used by this function are reflected in the horizontal plane for some reason, // so they are rotated every frame. Why do this, Nintendo? @@ -9652,6 +9655,8 @@ BAD_RETURN(s32) cutscene_intro_peach_dialog(struct Camera *c) { BAD_RETURN(s32) cutscene_intro_peach_follow_pipe_spline(struct Camera *c) { move_point_along_spline(c->pos, sIntroPipeToDialogPosition, &sCutsceneSplineSegment, &sCutsceneSplineSegmentProgress); move_point_along_spline(c->focus, sIntroPipeToDialogFocus, &sCutsceneSplineSegment, &sCutsceneSplineSegmentProgress); + c->pos[0] -= gNetworkPlayers[0].globalIndex * 350.f; + c->focus[0] -= gNetworkPlayers[0].globalIndex * 350.f; } BAD_RETURN(s32) cutscene_intro_peach_clear_cutscene_status(UNUSED struct Camera *c) { diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index e70a643d..e4bcfbbe 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -36,7 +36,7 @@ // TODO: put this elsewhere enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, /*SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME,*/ SAVE_OPT_CONTINUE_DONT_SAVE }; -static struct Object *sIntroWarpPipeObj; +static struct Object* sIntroWarpPipeObj[MAX_PLAYERS] = { 0 }; static struct Object *sEndPeachObj; static struct Object *sEndRightToadObj; static struct Object *sEndLeftToadObj; @@ -1809,9 +1809,11 @@ static void intro_cutscene_hide_hud_and_mario(struct MarioState *m) { static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) { if ((s16) m->statusForCamera->cameraEvent != CAM_EVENT_START_INTRO) { if (m->actionTimer++ == TIMER_SPAWN_PIPE) { - sIntroWarpPipeObj = + u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex; + if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; } + sIntroWarpPipeObj[globalIndex] = spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_CASTLE_GROUNDS_WARP_PIPE, - bhvStaticObject, -1328, 60, 4664, 0, 180, 0); + bhvStaticObject, -1328 - (350 * globalIndex), 60, 4664, 0, 180, 0); advance_cutscene_step(m); } } @@ -1825,10 +1827,12 @@ static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) { #endif static void intro_cutscene_raise_pipe(struct MarioState *m) { - sIntroWarpPipeObj->oPosY = camera_approach_f32_symmetric(sIntroWarpPipeObj->oPosY, 260.0f, 10.0f); + u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex; + if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; } + sIntroWarpPipeObj[globalIndex]->oPosY = camera_approach_f32_symmetric(sIntroWarpPipeObj[globalIndex]->oPosY, 260.0f, 10.0f); if (m->actionTimer == 0) { - play_sound(SOUND_MENU_EXIT_PIPE, sIntroWarpPipeObj->header.gfx.cameraToObject); + play_sound(SOUND_MENU_EXIT_PIPE, sIntroWarpPipeObj[globalIndex]->header.gfx.cameraToObject); } if (m->actionTimer++ == TIMER_RAISE_PIPE) { @@ -1839,6 +1843,14 @@ static void intro_cutscene_raise_pipe(struct MarioState *m) { #undef TIMER_RAISE_PIPE static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) { + if (m->actionTimer <= 1) { + u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex; + if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; } + m->pos[0] = sIntroWarpPipeObj[globalIndex]->oPosX; + m->pos[1] = sIntroWarpPipeObj[globalIndex]->oPosY; + m->pos[2] = sIntroWarpPipeObj[globalIndex]->oPosZ; + } + if (m->actionTimer == 25) { gHudDisplay.flags = HUD_DISPLAY_DEFAULT; } @@ -1881,14 +1893,16 @@ static void intro_cutscene_land_outside_pipe(struct MarioState *m) { } static void intro_cutscene_lower_pipe(struct MarioState *m) { + u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex; + if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; } if (m->actionTimer++ == 0) { - play_sound(SOUND_MENU_ENTER_PIPE, sIntroWarpPipeObj->header.gfx.cameraToObject); + play_sound(SOUND_MENU_ENTER_PIPE, sIntroWarpPipeObj[globalIndex]->header.gfx.cameraToObject); set_mario_animation(m, MARIO_ANIM_FIRST_PERSON); } - sIntroWarpPipeObj->oPosY -= 5.0f; - if (sIntroWarpPipeObj->oPosY <= 50.0f) { - obj_mark_for_deletion(sIntroWarpPipeObj); + sIntroWarpPipeObj[globalIndex]->oPosY -= 5.0f; + if (sIntroWarpPipeObj[globalIndex]->oPosY <= 50.0f) { + obj_mark_for_deletion(sIntroWarpPipeObj[globalIndex]); advance_cutscene_step(m); }