Enable romhack cam by default when in a non-vanilla level
This commit is contained in:
parent
fcd61d6c0e
commit
a32a9c00bd
|
@ -2536,6 +2536,17 @@ SHAKE_SHOCK = 10
|
|||
--- @type integer
|
||||
SHAKE_SMALL_DAMAGE = 3
|
||||
|
||||
--- @class RomhackCameraOverride
|
||||
|
||||
--- @type RomhackCameraOverride
|
||||
RCO_ALL = 0
|
||||
|
||||
--- @type RomhackCameraOverride
|
||||
RCO_ALL_EXCEPT_BOWSER = 1
|
||||
|
||||
--- @type RomhackCameraOverride
|
||||
RCO_NONE = 2
|
||||
|
||||
--- @type integer
|
||||
PALETTE_PRESET_MAX = 33
|
||||
|
||||
|
|
|
@ -8451,6 +8451,12 @@ function camera_reset_overrides()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param rco RomhackCameraOverride
|
||||
--- @return nil
|
||||
function camera_set_romhack_override(rco)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function camera_unfreeze()
|
||||
-- ...
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
- [behavior_table.h](#behavior_tableh)
|
||||
- [enum BehaviorId](#enum-BehaviorId)
|
||||
- [camera.h](#camerah)
|
||||
- [enum RomhackCameraOverride](#enum-RomhackCameraOverride)
|
||||
- [characters.h](#charactersh)
|
||||
- [enum CharacterSound](#enum-CharacterSound)
|
||||
- [enum CharacterType](#enum-CharacterType)
|
||||
|
@ -817,6 +818,13 @@
|
|||
- SHAKE_SHOCK
|
||||
- SHAKE_SMALL_DAMAGE
|
||||
|
||||
### [enum RomhackCameraOverride](#RomhackCameraOverride)
|
||||
| Identifier | Value |
|
||||
| :--------- | :---- |
|
||||
| RCO_ALL | 0 |
|
||||
| RCO_ALL_EXCEPT_BOWSER | 1 |
|
||||
| RCO_NONE | 2 |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
|
|
@ -488,6 +488,26 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [camera_set_romhack_override](#camera_set_romhack_override)
|
||||
|
||||
### Lua Example
|
||||
`camera_set_romhack_override(rco)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| rco | [enum RomhackCameraOverride](constants.md#enum-RomhackCameraOverride) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void camera_set_romhack_override(enum RomhackCameraOverride rco);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [camera_unfreeze](#camera_unfreeze)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -1578,6 +1578,7 @@
|
|||
- [camera_freeze](functions-5.md#camera_freeze)
|
||||
- [camera_is_frozen](functions-5.md#camera_is_frozen)
|
||||
- [camera_reset_overrides](functions-5.md#camera_reset_overrides)
|
||||
- [camera_set_romhack_override](functions-5.md#camera_set_romhack_override)
|
||||
- [camera_unfreeze](functions-5.md#camera_unfreeze)
|
||||
- [course_is_main_course](functions-5.md#course_is_main_course)
|
||||
- [deref_s32_pointer](functions-5.md#deref_s32_pointer)
|
||||
|
|
|
@ -505,6 +505,7 @@ void render_game(void) {
|
|||
|
||||
void get_area_minimum_y(u8* hasMinY, f32* minY) {
|
||||
if (!gCameraUseCourseSpecificSettings) { return; }
|
||||
if (gCamera && gCamera->mode == CAMERA_MODE_ROM_HACK) { return; }
|
||||
switch (gCurrCourseNum) {
|
||||
case COURSE_WF: *hasMinY = TRUE; *minY = 8; break;
|
||||
case COURSE_CCM: *hasMinY = TRUE; *minY = (gCurrAreaIndex == 2) ? -5856 : -5068; break;
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
|
||||
static u8 sSoftResettingCamera = FALSE;
|
||||
u8 gCameraUseCourseSpecificSettings = TRUE;
|
||||
u8 gOverrideFreezeCamera;
|
||||
u8 gOverrideFreezeCamera = FALSE;
|
||||
enum RomhackCameraOverride gOverrideRomhackCamera = RCO_ALL;
|
||||
|
||||
/**
|
||||
* @file camera.c
|
||||
|
@ -964,7 +965,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 (gCameraUseCourseSpecificSettings && gCurrLevelArea == AREA_DDD_SUB) {
|
||||
if (gCameraUseCourseSpecificSettings && c->mode != CAMERA_MODE_ROM_HACK && gCurrLevelArea == AREA_DDD_SUB) {
|
||||
camYaw = clamp_positions_and_find_yaw(pos, focus, 6839.f, 995.f, 5994.f, -3945.f);
|
||||
}
|
||||
|
||||
|
@ -2899,6 +2900,22 @@ void transition_to_camera_mode(struct Camera *c, s16 newMode, s16 numFrames) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool allow_romhack_camera_override_mode(u8 mode) {
|
||||
switch (mode) {
|
||||
case CAMERA_MODE_NONE:
|
||||
case CAMERA_MODE_BEHIND_MARIO:
|
||||
case CAMERA_MODE_C_UP:
|
||||
case CAMERA_MODE_WATER_SURFACE:
|
||||
case CAMERA_MODE_INSIDE_CANNON:
|
||||
case CAMERA_MODE_BOSS_FIGHT:
|
||||
case CAMERA_MODE_NEWCAM:
|
||||
case CAMERA_MODE_ROM_HACK:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to change the camera mode between its default/previous and certain Mario-oriented modes,
|
||||
* namely: C_UP, WATER_SURFACE, CLOSE, and BEHIND_MARIO
|
||||
|
@ -2915,6 +2932,8 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) {
|
|||
struct LinearTransitionPoint *start = &sModeInfo.transitionStart;
|
||||
struct LinearTransitionPoint *end = &sModeInfo.transitionEnd;
|
||||
|
||||
if (c->mode == CAMERA_MODE_ROM_HACK && !allow_romhack_camera_override_mode(mode)) { return; }
|
||||
|
||||
bool returnValue = true;
|
||||
smlua_call_event_hooks_set_camera_mode_params(HOOK_ON_SET_CAMERA_MODE, c, mode, frames, &returnValue);
|
||||
if (!returnValue) {
|
||||
|
@ -3089,6 +3108,21 @@ void update_lakitu(struct Camera *c) {
|
|||
gLakituState.defMode = c->defMode;
|
||||
}
|
||||
|
||||
static void update_romhack_camera_override(struct Camera *c) {
|
||||
if (gOverrideRomhackCamera == RCO_NONE) { return; }
|
||||
if (c->mode == CAMERA_MODE_ROM_HACK) { return; }
|
||||
if (dynos_level_is_vanilla_level(gCurrLevelNum)) { return; }
|
||||
|
||||
if (gOverrideRomhackCamera == RCO_ALL_EXCEPT_BOWSER) {
|
||||
if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allow_romhack_camera_override_mode(c->mode)) { return; }
|
||||
|
||||
set_camera_mode(c, CAMERA_MODE_ROM_HACK, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The main camera update function.
|
||||
|
@ -3105,6 +3139,8 @@ void update_camera(struct Camera *c) {
|
|||
return;
|
||||
}
|
||||
|
||||
update_romhack_camera_override(c);
|
||||
|
||||
if (c->cutscene == 0) {
|
||||
// Only process R_TRIG if 'fixed' is not selected in the menu
|
||||
if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO
|
||||
|
@ -6783,6 +6819,8 @@ static struct CameraTrigger* get_camera_trigger(s16 levelNum) {
|
|||
s16 camera_course_processing(struct Camera *c) {
|
||||
if (!c) { return 0; }
|
||||
if (!gCameraUseCourseSpecificSettings) { return 0; }
|
||||
if (c->mode == CAMERA_MODE_ROM_HACK) { return 0; }
|
||||
|
||||
s16 level = gCurrLevelNum;
|
||||
s16 mode;
|
||||
s8 area = gCurrentArea->index;
|
||||
|
@ -12214,6 +12252,11 @@ void mode_rom_hack_camera(struct Camera *c) {
|
|||
sRomHackZoom = 0;
|
||||
}
|
||||
|
||||
// center
|
||||
if (gMarioStates[0].controller->buttonPressed & L_TRIG) {
|
||||
center_rom_hack_camera();
|
||||
}
|
||||
|
||||
// clamp yaw
|
||||
sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
|
||||
|
||||
|
@ -12298,7 +12341,7 @@ s32 update_rom_hack_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, sAreaYaw);
|
||||
pan_ahead_of_player(c);
|
||||
if (gCameraUseCourseSpecificSettings && gCurrLevelArea == AREA_DDD_SUB) {
|
||||
if (gCameraUseCourseSpecificSettings && c->mode != CAMERA_MODE_ROM_HACK && gCurrLevelArea == AREA_DDD_SUB) {
|
||||
camYaw = clamp_positions_and_find_yaw(pos, focus, 6839.f, 995.f, 5994.f, -3945.f);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,14 @@
|
|||
|
||||
#include "level_table.h"
|
||||
|
||||
enum RomhackCameraOverride {
|
||||
RCO_ALL,
|
||||
RCO_ALL_EXCEPT_BOWSER,
|
||||
RCO_NONE,
|
||||
};
|
||||
|
||||
extern u8 gOverrideFreezeCamera;
|
||||
extern enum RomhackCameraOverride gOverrideRomhackCamera;
|
||||
|
||||
/**
|
||||
* @file camera.h
|
||||
|
|
|
@ -271,6 +271,10 @@ struct BehaviorValues gDefaultBehaviorValues = {
|
|||
|
||||
struct BehaviorValues gBehaviorValues = { 0 };
|
||||
|
||||
//////////////
|
||||
// Painting //
|
||||
//////////////
|
||||
|
||||
struct PaintingValues gDefaultPaintingValues = {
|
||||
.cotmc_painting = &cotmc_painting,
|
||||
.bob_painting = &bob_painting,
|
||||
|
@ -302,7 +306,6 @@ void hardcoded_reset_default_values(void) {
|
|||
gBehaviorValues = gDefaultBehaviorValues;
|
||||
|
||||
memcpy(&cotmc_painting, &default_cotmc_painting, sizeof(struct Painting));
|
||||
|
||||
memcpy(&bob_painting, &default_bob_painting, sizeof(struct Painting));
|
||||
memcpy(&ccm_painting, &default_ccm_painting, sizeof(struct Painting));
|
||||
memcpy(&wf_painting, &default_wf_painting, sizeof(struct Painting));
|
||||
|
@ -317,7 +320,6 @@ void hardcoded_reset_default_values(void) {
|
|||
memcpy(&ttc_painting, &default_ttc_painting, sizeof(struct Painting));
|
||||
memcpy(&sl_painting, &default_sl_painting, sizeof(struct Painting));
|
||||
memcpy(&thi_huge_painting, &default_thi_huge_painting, sizeof(struct Painting));
|
||||
|
||||
memcpy(&ttm_slide_painting, &default_ttm_slide_painting, sizeof(struct Painting));
|
||||
|
||||
gPaintingValues = gDefaultPaintingValues;
|
||||
|
|
|
@ -252,6 +252,10 @@ struct BehaviorValues {
|
|||
|
||||
extern struct BehaviorValues gBehaviorValues;
|
||||
|
||||
//////////////
|
||||
// Painting //
|
||||
//////////////
|
||||
|
||||
struct PaintingValues {
|
||||
struct Painting* cotmc_painting;
|
||||
|
||||
|
@ -275,6 +279,10 @@ struct PaintingValues {
|
|||
|
||||
extern struct PaintingValues gPaintingValues;
|
||||
|
||||
///////////////
|
||||
// Functions //
|
||||
///////////////
|
||||
|
||||
void hardcoded_reset_default_values(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -861,6 +861,9 @@ char gSmluaConstants[] = ""
|
|||
"id_bhvBlueCoinNumber = 537\n"
|
||||
"id_bhvStarNumber = 538\n"
|
||||
"id_bhv_max_count = 539\n"
|
||||
"RCO_ALL = 0\n"
|
||||
"RCO_ALL_EXCEPT_BOWSER = 1\n"
|
||||
"RCO_NONE = 2\n"
|
||||
"CAM_MODE_MARIO_ACTIVE = 0x01\n"
|
||||
"CAM_MODE_LAKITU_WAS_ZOOMED_OUT = 0x02\n"
|
||||
"CAM_MODE_MARIO_SELECTED = 0x04\n"
|
||||
|
@ -4040,4 +4043,4 @@ char gSmluaConstants[] = ""
|
|||
"VERSION_REGION = 'US'\n"
|
||||
"MAX_VERSION_LENGTH = 32\n"
|
||||
"MAX_LOCAL_VERSION_LENGTH = 36\n"
|
||||
;
|
||||
;
|
|
@ -28045,6 +28045,23 @@ int smlua_func_camera_reset_overrides(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_camera_set_romhack_override(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 1) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "camera_set_romhack_override", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rco = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "camera_set_romhack_override"); return 0; }
|
||||
|
||||
camera_set_romhack_override(rco);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_camera_unfreeze(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -31916,6 +31933,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze);
|
||||
smlua_bind_function(L, "camera_is_frozen", smlua_func_camera_is_frozen);
|
||||
smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides);
|
||||
smlua_bind_function(L, "camera_set_romhack_override", smlua_func_camera_set_romhack_override);
|
||||
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
|
||||
smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
|
|
|
@ -249,6 +249,10 @@ bool camera_is_frozen(void) {
|
|||
return gOverrideFreezeCamera;
|
||||
}
|
||||
|
||||
void camera_set_romhack_override(enum RomhackCameraOverride rco) {
|
||||
gOverrideRomhackCamera = rco;
|
||||
}
|
||||
|
||||
bool camera_config_is_free_cam_enabled(void) {
|
||||
#ifdef BETTERCAMERA
|
||||
return sOverrideEnableCamera.override ? sOverrideEnableCamera.value : configEnableCamera;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define SMLUA_MISC_UTILS_H
|
||||
|
||||
#include "dialog_ids.h"
|
||||
#include "game/camera.h"
|
||||
|
||||
u32 get_network_area_timer(void);
|
||||
|
||||
|
@ -45,6 +46,7 @@ void camera_reset_overrides(void);
|
|||
void camera_freeze(void);
|
||||
void camera_unfreeze(void);
|
||||
bool camera_is_frozen(void);
|
||||
void camera_set_romhack_override(enum RomhackCameraOverride rco);
|
||||
|
||||
bool camera_config_is_free_cam_enabled(void);
|
||||
bool camera_config_is_analog_cam_enabled(void);
|
||||
|
|
Loading…
Reference in New Issue