Files
HackerSM64/levels/castle_inside/camera.inc.c
2021-09-24 14:55:49 +01:00

139 lines
5.8 KiB
C

/**
* Sets the fixed mode pos offset so that the camera faces the doorway when Mario is near the entrance
* to the castle lobby
*/
void cam_castle_lobby_entrance(UNUSED struct Camera *c) {
vec3f_set(sCastleEntranceOffset, -813.f - sFixedModeBasePosition[0],
378.f - sFixedModeBasePosition[1], 1103.f - sFixedModeBasePosition[2]);
}
/**
* Make the camera look up the stairs from the 2nd to 3rd floor of the castle
*/
void cam_castle_look_upstairs(struct Camera *c) {
struct Surface *floor;
f32 floorHeight = find_floor(c->pos[0], c->pos[1], c->pos[2], &floor);
// If Mario is on the first few steps, fix the camera pos, making it look up
if ((sMarioGeometry.currFloorHeight > 1229.f) && (floorHeight < 1229.f)
&& (sCSideButtonYaw == 0)) {
vec3f_set(c->pos, -227.f, 1425.f, 1533.f);
}
}
/**
* Make the camera look down the stairs towards the basement star door
*/
void cam_castle_basement_look_downstairs(struct Camera *c) {
struct Surface *floor;
f32 floorHeight = find_floor(c->pos[0], c->pos[1], c->pos[2], &floor);
// Fix the camera pos, making it look downwards. Only active on the top few steps
if ((floorHeight > -110.f) && (sCSideButtonYaw == 0)) {
vec3f_set(c->pos, -980.f, 249.f, -1398.f);
}
}
/**
* Enter the fixed-mode castle lobby. A trigger for this is placed in every entrance so that the camera
* changes to fixed mode.
*/
void cam_castle_enter_lobby(struct Camera *c) {
if (c->mode != CAMERA_MODE_FIXED) {
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT;
set_fixed_cam_axis_sa_lobby(c->mode);
c->mode = CAMERA_MODE_FIXED;
}
}
/**
* Starts spiral stairs mode.
*/
void cam_castle_enter_spiral_stairs(struct Camera *c) {
transition_to_camera_mode(c, CAMERA_MODE_SPIRAL_STAIRS, 20);
}
/**
* unused, starts close mode if the camera is in spiral stairs mode.
* This was replaced with cam_castle_close_mode
*/
static UNUSED void cam_castle_leave_spiral_stairs(struct Camera *c) {
if (c->mode == CAMERA_MODE_SPIRAL_STAIRS) {
transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 30);
} else {
set_camera_mode_close_cam(&c->mode);
}
}
/**
* The default mode when outside of the lobby and spiral staircase. A trigger for this is placed at
* every door leaving the lobby and spiral staircase.
*/
void cam_castle_close_mode(struct Camera *c) {
set_camera_mode_close_cam(&c->mode);
}
/**
* Functions the same as cam_castle_close_mode, but sets doorStatus so that the camera will enter
* fixed-mode when Mario leaves the room.
*/
void cam_castle_leave_lobby_sliding_door(struct Camera *c) {
cam_castle_close_mode(c);
c->doorStatus = DOOR_ENTER_LOBBY;
}
/**
* Just calls cam_castle_enter_lobby
*/
void cam_castle_enter_lobby_sliding_door(struct Camera *c) {
cam_castle_enter_lobby(c);
}
/**
* The Castle triggers are used to set the camera to fixed mode when entering the lobby, and to set it
* to close mode when leaving it. They also set the mode to spiral staircase.
*
* There are two triggers for looking up and down straight staircases when Mario is at the start,
* and one trigger that starts the enter pool cutscene when Mario enters HMC.
*/
struct CameraTrigger sCamCastle[] = {
{ 1, cam_castle_close_mode, -1100, 657, -1346, 300, 150, 300, 0 },
{ 1, cam_castle_enter_lobby, -1099, 657, -803, 300, 150, 300, 0 },
{ 1, cam_castle_close_mode, -2304, -264, -4072, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, -2304, 145, -1344, 140, 150, 140, 0 },
{ 1, cam_castle_enter_lobby, -2304, 145, -802, 140, 150, 140, 0 },
//! Sets the camera mode when leaving secret aquarium
{ 1, cam_castle_close_mode, 2816, 1200, -256, 100, 100, 100, 0 },
{ 1, cam_castle_close_mode, 256, -161, -4226, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, 256, 145, -1344, 140, 150, 140, 0 },
{ 1, cam_castle_enter_lobby, 256, 145, -802, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, -1023, 44, -4870, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, -459, 145, -1020, 140, 150, 140, 0x6000 },
{ 1, cam_castle_enter_lobby, -85, 145, -627, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, -1589, 145, -1020, 140, 150, 140, -0x6000 },
{ 1, cam_castle_enter_lobby, -1963, 145, -627, 140, 150, 140, 0 },
{ 1, cam_castle_leave_lobby_sliding_door, -2838, 657, -1659, 200, 150, 150, 0x2000 },
{ 1, cam_castle_enter_lobby_sliding_door, -2319, 512, -1266, 300, 150, 300, 0x2000 },
{ 1, cam_castle_close_mode, 844, 759, -1657, 40, 150, 40, -0x2000 },
{ 1, cam_castle_enter_lobby, 442, 759, -1292, 140, 150, 140, -0x2000 },
{ 2, cam_castle_enter_spiral_stairs, -1000, 657, 1740, 200, 300, 200, 0 },
{ 2, cam_castle_enter_spiral_stairs, -996, 1348, 1814, 200, 300, 200, 0 },
{ 2, cam_castle_close_mode, -946, 657, 2721, 50, 150, 50, 0 },
{ 2, cam_castle_close_mode, -996, 1348, 907, 50, 150, 50, 0 },
{ 2, cam_castle_close_mode, -997, 1348, 1450, 140, 150, 140, 0 },
{ 1, cam_castle_close_mode, -4942, 452, -461, 140, 150, 140, 0x4000 },
{ 1, cam_castle_close_mode, -3393, 350, -793, 140, 150, 140, 0x4000 },
{ 1, cam_castle_enter_lobby, -2851, 350, -792, 140, 150, 140, 0x4000 },
{ 1, cam_castle_enter_lobby, 803, 350, -228, 140, 150, 140, -0x4000 },
//! Duplicate camera trigger outside JRB door
{ 1, cam_castle_enter_lobby, 803, 350, -228, 140, 150, 140, -0x4000 },
{ 1, cam_castle_close_mode, 1345, 350, -229, 140, 150, 140, 0x4000 },
{ 1, cam_castle_close_mode, -946, -929, 622, 300, 150, 300, 0 },
{ 2, cam_castle_look_upstairs, -205, 1456, 2508, 210, 928, 718, 0 },
{ 1, cam_castle_basement_look_downstairs, -1027, -587, -718, 318, 486, 577, 0 },
{ 1, cam_castle_lobby_entrance, -1023, 376, 1830, 300, 400, 300, 0 },
{ 3, cam_castle_hmc_start_pool_cutscene, 2485, -1689, -2659, 600, 50, 600, 0 },
NULL_TRIGGER
};