Patch out toxic gas camera from romhacks (#462)

* Patch out toxic gas camera from romhacks

* Allow toxic gas camera in romhacks to be disabled with camera_allow_toxic_gas_camera()

In romhacks only. Toxic gas camera in vanilla levels will always remain active.
Passing in 0 means enable toxic gas camera.

* Reset gOverrideAllowToxicGasCamera to network_shutdown()

* Swap order

I too have a hard time reading my own code
This commit is contained in:
Sunk 2023-09-20 13:12:08 -04:00 committed by GitHub
parent 23c7e0fbc8
commit 718be07a79
9 changed files with 59 additions and 4 deletions

View File

@ -8359,6 +8359,12 @@ function allocate_mario_action(actFlags)
-- ...
end
--- @param allow integer
--- @return nil
function camera_allow_toxic_gas_camera(allow)
-- ...
end
--- @param enable boolean
--- @return nil
function camera_config_enable_analog_cam(enable)

View File

@ -54,6 +54,26 @@
<br />
## [camera_allow_toxic_gas_camera](#camera_allow_toxic_gas_camera)
### Lua Example
`camera_allow_toxic_gas_camera(allow)`
### Parameters
| Field | Type |
| ----- | ---- |
| allow | `integer` |
### Returns
- None
### C Prototype
`void camera_allow_toxic_gas_camera(u8 allow);`
[:arrow_up_small:](#)
<br />
## [camera_config_enable_analog_cam](#camera_config_enable_analog_cam)
### Lua Example

View File

@ -1560,6 +1560,7 @@
- smlua_misc_utils.h
- [add_scroll_target](functions-5.md#add_scroll_target)
- [allocate_mario_action](functions-5.md#allocate_mario_action)
- [camera_allow_toxic_gas_camera](functions-5.md#camera_allow_toxic_gas_camera)
- [camera_config_enable_analog_cam](functions-5.md#camera_config_enable_analog_cam)
- [camera_config_enable_free_cam](functions-5.md#camera_config_enable_free_cam)
- [camera_config_enable_mouse_look](functions-5.md#camera_config_enable_mouse_look)

View File

@ -42,6 +42,7 @@ u8 gCameraUseCourseSpecificSettings = TRUE;
u8 gOverrideFreezeCamera = FALSE;
enum RomhackCameraOverride gOverrideRomhackCamera = RCO_ALL;
u8 gRomhackCameraAllowCentering = TRUE;
u8 gOverrideAllowToxicGasCamera = FALSE;
/**
* @file camera.c
@ -2366,10 +2367,12 @@ s16 update_default_camera(struct Camera *c) {
}
// Make Lakitu fly above the gas
gasHeight = find_poison_gas_level(cPos[0], cPos[2]);
if (gasHeight != gLevelValues.floorLowerLimit) {
if ((gasHeight += 130.f) > c->pos[1]) {
c->pos[1] = gasHeight;
if (gOverrideAllowToxicGasCamera || dynos_level_is_vanilla_level(gCurrLevelNum)) {
gasHeight = find_poison_gas_level(cPos[0], cPos[2]);
if (gasHeight != gLevelValues.floorLowerLimit) {
if ((gasHeight += 130.f) > c->pos[1]) {
c->pos[1] = gasHeight;
}
}
}

View File

@ -19,6 +19,7 @@ enum RomhackCameraOverride {
extern u8 gOverrideFreezeCamera;
extern enum RomhackCameraOverride gOverrideRomhackCamera;
extern u8 gRomhackCameraAllowCentering;
extern u8 gOverrideAllowToxicGasCamera;
/**
* @file camera.h

View File

@ -27767,6 +27767,23 @@ int smlua_func_allocate_mario_action(lua_State* L) {
return 1;
}
int smlua_func_camera_allow_toxic_gas_camera(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_allow_toxic_gas_camera", 1, top);
return 0;
}
u8 allow = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "camera_allow_toxic_gas_camera"); return 0; }
camera_allow_toxic_gas_camera(allow);
return 1;
}
int smlua_func_camera_config_enable_analog_cam(lua_State* L) {
if (L == NULL) { return 0; }
@ -32070,6 +32087,7 @@ void smlua_bind_functions_autogen(void) {
// smlua_misc_utils.h
smlua_bind_function(L, "add_scroll_target", smlua_func_add_scroll_target);
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
smlua_bind_function(L, "camera_allow_toxic_gas_camera", smlua_func_camera_allow_toxic_gas_camera);
smlua_bind_function(L, "camera_config_enable_analog_cam", smlua_func_camera_config_enable_analog_cam);
smlua_bind_function(L, "camera_config_enable_free_cam", smlua_func_camera_config_enable_free_cam);
smlua_bind_function(L, "camera_config_enable_mouse_look", smlua_func_camera_config_enable_mouse_look);

View File

@ -265,6 +265,10 @@ void camera_romhack_allow_centering(u8 allow) {
gRomhackCameraAllowCentering = allow;
}
void camera_allow_toxic_gas_camera(u8 allow) {
gOverrideAllowToxicGasCamera = allow;
}
bool camera_config_is_free_cam_enabled(void) {
#ifdef BETTERCAMERA
return sOverrideEnableCamera.override ? sOverrideEnableCamera.value : configEnableCamera;

View File

@ -48,6 +48,7 @@ void camera_unfreeze(void);
bool camera_is_frozen(void);
void camera_set_romhack_override(enum RomhackCameraOverride rco);
void camera_romhack_allow_centering(u8 allow);
void camera_allow_toxic_gas_camera(u8 allow);
bool camera_config_is_free_cam_enabled(void);
bool camera_config_is_analog_cam_enabled(void);

View File

@ -660,6 +660,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
gOverrideDialogPos = 0;
gOverrideDialogColor = 0;
gDialogMinWidth = 0;
gOverrideAllowToxicGasCamera = FALSE;
struct Controller* cnt = gMarioStates[0].controller;
cnt->rawStickX = 0;