Allow ability to disable vanilla course-specific settings for camera

This commit is contained in:
MysterD 2022-04-10 01:55:11 -07:00
parent 4f9a48620d
commit 15d6dc3a9c
6 changed files with 50 additions and 1 deletions

View file

@ -3012,6 +3012,12 @@ function camera_course_processing(c)
-- ...
end
--- @param enable integer
--- @return nil
function camera_set_use_course_specific_settings(enable)
-- ...
end
--- @param from Vec3f
--- @param to Vec3f
--- @param maxPitch integer

View file

@ -602,6 +602,7 @@
- [camera_approach_f32_symmetric_bool](#camera_approach_f32_symmetric_bool)
- [camera_approach_s16_symmetric_bool](#camera_approach_s16_symmetric_bool)
- [camera_course_processing](#camera_course_processing)
- [camera_set_use_course_specific_settings](#camera_set_use_course_specific_settings)
- [clamp_pitch](#clamp_pitch)
- [clamp_positions_and_find_yaw](#clamp_positions_and_find_yaw)
- [collide_with_walls](#collide_with_walls)
@ -12146,6 +12147,26 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
<br />
## [camera_set_use_course_specific_settings](#camera_set_use_course_specific_settings)
### Lua Example
`camera_set_use_course_specific_settings(enable)`
### Parameters
| Field | Type |
| ----- | ---- |
| enable | `integer` |
### Returns
- None
### C Prototype
`void camera_set_use_course_specific_settings(u8 enable);`
[:arrow_up_small:](#)
<br />
## [clamp_pitch](#clamp_pitch)
### Lua Example

View file

@ -461,6 +461,7 @@ void render_game(void) {
}
void get_area_minimum_y(u8* hasMinY, f32* minY) {
if (!gCameraUseCourseSpecificSettings) { return; }
switch (gCurrCourseNum) {
case COURSE_WF: *hasMinY = TRUE; *minY = 8; break;
case COURSE_CCM: *hasMinY = TRUE; *minY = (gCurrAreaIndex == 2) ? -5856 : -5068; break;

View file

@ -35,6 +35,7 @@
#define CBUTTON_MASK (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)
static u8 sSoftResettingCamera = FALSE;
u8 gCameraUseCourseSpecificSettings = TRUE;
/**
* @file camera.c
@ -948,7 +949,7 @@ s32 update_8_directions_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
calc_y_to_curr_floor(&posY, 1.f, 200.f, &focusY, 0.9f, 200.f);
focus_on_mario(focus, pos, posY + yOff, focusY + yOff, sLakituDist + baseDist, pitch, camYaw);
pan_ahead_of_player(c);
if (gCurrLevelArea == AREA_DDD_SUB) {
if (gCameraUseCourseSpecificSettings && gCurrLevelArea == AREA_DDD_SUB) {
camYaw = clamp_positions_and_find_yaw(pos, focus, 6839.f, 995.f, 5994.f, -3945.f);
}
@ -6598,6 +6599,7 @@ struct CutsceneSplinePoint sEndingLookAtSkyFocus[] = {
* @return the camera's mode after processing, although this is unused in the code
*/
s16 camera_course_processing(struct Camera *c) {
if (!gCameraUseCourseSpecificSettings) { return 0; }
s16 level = gCurrLevelNum;
s16 mode;
s8 area = gCurrentArea->index;
@ -11700,6 +11702,10 @@ void obj_rotate_towards_point(struct Object *o, Vec3f point, s16 pitchOff, s16 y
o->oMoveAngleYaw = approach_s16_asymptotic(o->oMoveAngleYaw, yaw + yawOff, yawDiv);
}
void camera_set_use_course_specific_settings(u8 enable) {
gCameraUseCourseSpecificSettings = enable;
}
#include "behaviors/intro_peach.inc.c"
#include "behaviors/intro_lakitu.inc.c"
#include "behaviors/end_birds_1.inc.c"

View file

@ -674,6 +674,7 @@ extern s32 gObjCutsceneDone;
extern struct Camera *gCamera;
#endif
extern u8 gCameraUseCourseSpecificSettings;
extern struct Object *gCutsceneFocus;
extern struct Object *gSecondCameraFocus;
extern u8 gRecentCutscene;
@ -778,4 +779,6 @@ Gfx *geo_camera_fov(s32 callContext, struct GraphNode *g, UNUSED void *context);
s32 set_camera_mode_fixed(struct Camera* c, s16 x, s16 y, s16 z);
void camera_set_use_course_specific_settings(u8 enable);
#endif // CAMERA_H

View file

@ -5795,6 +5795,17 @@ int smlua_func_camera_course_processing(lua_State* L) {
return 1;
}
int smlua_func_camera_set_use_course_specific_settings(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u8 enable = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { return 0; }
camera_set_use_course_specific_settings(enable);
return 1;
}
int smlua_func_clamp_pitch(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
@ -16252,6 +16263,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "camera_approach_f32_symmetric_bool", smlua_func_camera_approach_f32_symmetric_bool);
smlua_bind_function(L, "camera_approach_s16_symmetric_bool", smlua_func_camera_approach_s16_symmetric_bool);
smlua_bind_function(L, "camera_course_processing", smlua_func_camera_course_processing);
smlua_bind_function(L, "camera_set_use_course_specific_settings", smlua_func_camera_set_use_course_specific_settings);
smlua_bind_function(L, "clamp_pitch", smlua_func_clamp_pitch);
smlua_bind_function(L, "clamp_positions_and_find_yaw", smlua_func_clamp_positions_and_find_yaw);
smlua_bind_function(L, "collide_with_walls", smlua_func_collide_with_walls);