multiple improvements (#176)

This commit is contained in:
Isaac0-dev 2022-09-13 13:00:51 +10:00 committed by GitHub
parent a864e2d3ba
commit c7bdeef8d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 223 additions and 37 deletions

View file

@ -235,6 +235,8 @@ else
endif endif
ifeq ($(TARGET_RPI),1) ifeq ($(TARGET_RPI),1)
$(info Compiling for Raspberry Pi)
DISCORD_SDK := 0
machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown') machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
# Raspberry Pi B+, Zero, etc # Raspberry Pi B+, Zero, etc
@ -244,6 +246,7 @@ ifeq ($(TARGET_RPI),1)
# Raspberry Pi 2 and 3 in ARM 32bit mode # Raspberry Pi 2 and 3 in ARM 32bit mode
ifneq (,$(findstring armv7l,$(machine))) ifneq (,$(findstring armv7l,$(machine)))
$(info ARM 32bit mode)
model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown')
ifneq (,$(findstring 3,$(model))) ifneq (,$(findstring 3,$(model)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3 OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3
@ -255,6 +258,7 @@ ifeq ($(TARGET_RPI),1)
# RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT. # RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT.
# DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM. # DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM.
ifneq (,$(findstring aarch64,$(machine))) ifneq (,$(findstring aarch64,$(machine)))
$(info ARM64 mode)
model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown')
ifneq (,$(findstring 3,$(model))) ifneq (,$(findstring 3,$(model)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -O3 OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -O3
@ -347,11 +351,6 @@ ifeq ($(HEADLESS),1)
CONTROLLER_API := CONTROLLER_API :=
endif endif
ifeq ($(TARGET_RPI),1)
$(info Compiling for Raspberry Pi)
DISCORD_SDK := 0
endif
# NON_MATCHING - whether to build a matching, identical copy of the ROM # NON_MATCHING - whether to build a matching, identical copy of the ROM
# 1 - enable some alternate, more portable code that does not produce a matching ROM # 1 - enable some alternate, more portable code that does not produce a matching ROM
# 0 - build a matching ROM # 0 - build a matching ROM
@ -626,7 +625,11 @@ else ifeq ($(OSX_BUILD),1)
# This really shouldn't be required, but I got tired of trying to do it the "right way" # This really shouldn't be required, but I got tired of trying to do it the "right way"
BASS_LIBS := lib/bass/bass.dylib lib/bass/libbass.dylib lib/bass/bass_fx.dylib lib/bass/libbass_fx.dylib BASS_LIBS := lib/bass/bass.dylib lib/bass/libbass.dylib lib/bass/bass_fx.dylib lib/bass/libbass_fx.dylib
else ifeq ($(TARGET_RPI),1) else ifeq ($(TARGET_RPI),1)
BASS_LIBS := lib/bass/arm/libbass.so lib/bass/arm/libbass_fx.so ifneq (,$(findstring aarch64,$(machine)))
BASS_LIBS := lib/bass/arm/aarch64/libbass.so lib/bass/arm/aarch64/libbass_fx.so
else
BASS_LIBS := lib/bass/arm/libbass.so lib/bass/arm/libbass_fx.so
endif
else else
BASS_LIBS := lib/bass/libbass.so lib/bass/libbass_fx.so BASS_LIBS := lib/bass/libbass.so lib/bass/libbass_fx.so
endif endif
@ -922,7 +925,11 @@ ifeq ($(WINDOWS_BUILD),1)
else ifeq ($(OSX_BUILD),1) else ifeq ($(OSX_BUILD),1)
LDFLAGS += -L./lib/lua/mac/ -l lua53 LDFLAGS += -L./lib/lua/mac/ -l lua53
else ifeq ($(TARGET_RPI),1) else ifeq ($(TARGET_RPI),1)
LDFLAGS += -Llib/lua/linux -l:liblua53-arm.a ifneq (,$(findstring aarch64,$(machine)))
LDFLAGS += -Llib/lua/linux -l:liblua53-arm64.a
else
LDFLAGS += -Llib/lua/linux -l:liblua53-arm.a
endif
else else
LDFLAGS += -Llib/lua/linux -l:liblua53.a LDFLAGS += -Llib/lua/linux -l:liblua53.a
endif endif

View file

@ -7937,7 +7937,10 @@ HOOK_ON_PACKET_RECEIVE = 22
HOOK_USE_ACT_SELECT = 23 HOOK_USE_ACT_SELECT = 23
--- @type LuaHookedEventType --- @type LuaHookedEventType
HOOK_MAX = 24 HOOK_ON_CHANGE_CAMERA_ANGLE = 24
--- @type LuaHookedEventType
HOOK_MAX = 25
--- @class HudDisplayFlags --- @class HudDisplayFlags

View file

@ -3023,6 +3023,11 @@ function camera_set_use_course_specific_settings(enable)
-- ... -- ...
end end
--- @return nil
function center_rom_hack_camera()
-- ...
end
--- @param from Vec3f --- @param from Vec3f
--- @param to Vec3f --- @param to Vec3f
--- @param maxPitch integer --- @param maxPitch integer
@ -7720,6 +7725,11 @@ function get_hand_foot_pos_z(m, index)
-- ... -- ...
end end
--- @return integer
function get_last_star_or_key()
-- ...
end
--- @return integer --- @return integer
function get_network_area_timer() function get_network_area_timer()
-- ... -- ...
@ -7806,6 +7816,12 @@ function set_environment_region(index, value)
-- ... -- ...
end end
--- @param value integer
--- @return nil
function set_last_star_or_key(value)
-- ...
end
--- @param far number --- @param far number
--- @return nil --- @return nil
function set_override_far(far) function set_override_far(far)

View file

@ -2803,7 +2803,8 @@
| HOOK_ON_DEATH | 21 | | HOOK_ON_DEATH | 21 |
| HOOK_ON_PACKET_RECEIVE | 22 | | HOOK_ON_PACKET_RECEIVE | 22 |
| HOOK_USE_ACT_SELECT | 23 | | HOOK_USE_ACT_SELECT | 23 |
| HOOK_MAX | 24 | | HOOK_ON_CHANGE_CAMERA_ANGLE | 24 |
| HOOK_MAX | 25 |
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -378,6 +378,24 @@
<br /> <br />
## [center_rom_hack_camera](#center_rom_hack_camera)
### Lua Example
`center_rom_hack_camera()`
### Parameters
- None
### Returns
- None
### C Prototype
`void center_rom_hack_camera(void);`
[:arrow_up_small:](#)
<br />
## [clamp_pitch](#clamp_pitch) ## [clamp_pitch](#clamp_pitch)
### Lua Example ### Lua Example

View file

@ -6908,6 +6908,24 @@
<br /> <br />
## [get_last_star_or_key](#get_last_star_or_key)
### Lua Example
`local integerValue = get_last_star_or_key()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`s32 get_last_star_or_key(void);`
[:arrow_up_small:](#)
<br />
## [get_network_area_timer](#get_network_area_timer) ## [get_network_area_timer](#get_network_area_timer)
### Lua Example ### Lua Example
@ -7171,6 +7189,26 @@
<br /> <br />
## [set_last_star_or_key](#set_last_star_or_key)
### Lua Example
`set_last_star_or_key(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `integer` |
### Returns
- None
### C Prototype
`void set_last_star_or_key(u8 value);`
[:arrow_up_small:](#)
<br />
## [set_override_far](#set_override_far) ## [set_override_far](#set_override_far)
### Lua Example ### Lua Example

View file

@ -615,6 +615,7 @@
- [camera_approach_s16_symmetric_bool](functions-3.md#camera_approach_s16_symmetric_bool) - [camera_approach_s16_symmetric_bool](functions-3.md#camera_approach_s16_symmetric_bool)
- [camera_course_processing](functions-3.md#camera_course_processing) - [camera_course_processing](functions-3.md#camera_course_processing)
- [camera_set_use_course_specific_settings](functions-3.md#camera_set_use_course_specific_settings) - [camera_set_use_course_specific_settings](functions-3.md#camera_set_use_course_specific_settings)
- [center_rom_hack_camera](functions-3.md#center_rom_hack_camera)
- [clamp_pitch](functions-3.md#clamp_pitch) - [clamp_pitch](functions-3.md#clamp_pitch)
- [clamp_positions_and_find_yaw](functions-3.md#clamp_positions_and_find_yaw) - [clamp_positions_and_find_yaw](functions-3.md#clamp_positions_and_find_yaw)
- [collide_with_walls](functions-3.md#collide_with_walls) - [collide_with_walls](functions-3.md#collide_with_walls)
@ -1438,6 +1439,7 @@
- [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x) - [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x)
- [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y) - [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y)
- [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z) - [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z)
- [get_last_star_or_key](functions-4.md#get_last_star_or_key)
- [get_network_area_timer](functions-4.md#get_network_area_timer) - [get_network_area_timer](functions-4.md#get_network_area_timer)
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer) - [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
- [hud_get_value](functions-4.md#hud_get_value) - [hud_get_value](functions-4.md#hud_get_value)
@ -1451,6 +1453,7 @@
- [play_transition](functions-4.md#play_transition) - [play_transition](functions-4.md#play_transition)
- [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot) - [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot)
- [set_environment_region](functions-4.md#set_environment_region) - [set_environment_region](functions-4.md#set_environment_region)
- [set_last_star_or_key](functions-4.md#set_last_star_or_key)
- [set_override_far](functions-4.md#set_override_far) - [set_override_far](functions-4.md#set_override_far)
- [set_override_fov](functions-4.md#set_override_fov) - [set_override_fov](functions-4.md#set_override_fov)
- [set_override_near](functions-4.md#set_override_near) - [set_override_near](functions-4.md#set_override_near)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,16 +1,10 @@
camera_set_use_course_specific_settings(false) camera_set_use_course_specific_settings(false)
sOverrideCameraModes = { sOverrideCameraModes = {
[CAMERA_MODE_RADIAL] = true, [CAMERA_MODE_RADIAL] = true,
[CAMERA_MODE_OUTWARD_RADIAL] = true, [CAMERA_MODE_OUTWARD_RADIAL] = true,
[CAMERA_MODE_BEHIND_MARIO] = true,
[CAMERA_MODE_CLOSE] = true, [CAMERA_MODE_CLOSE] = true,
--[CAMERA_MODE_C_UP] = true,
[CAMERA_MODE_WATER_SURFACE] = true,
[CAMERA_MODE_SLIDE_HOOT] = true, [CAMERA_MODE_SLIDE_HOOT] = true,
--[CAMERA_MODE_INSIDE_CANNON] = true,
--[CAMERA_MODE_BOSS_FIGHT] = true,
[CAMERA_MODE_PARALLEL_TRACKING] = true, [CAMERA_MODE_PARALLEL_TRACKING] = true,
[CAMERA_MODE_FIXED] = true, [CAMERA_MODE_FIXED] = true,
[CAMERA_MODE_8_DIRECTIONS] = true, [CAMERA_MODE_8_DIRECTIONS] = true,
@ -18,8 +12,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true, [CAMERA_MODE_SPIRAL_STAIRS] = true,
} }
local m = gMarioStates[0]
function override_camera() function override_camera()
local m = gMarioStates[0]
local np = gNetworkPlayers[0] local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then if sOverrideCameraModes[m.area.camera.mode] == nil then
@ -34,8 +29,6 @@ function override_camera()
end end
function on_set_camera_mode(c, mode, frames) function on_set_camera_mode(c, mode, frames)
local m = gMarioStates[0]
if mode == CAMERA_MODE_ROM_HACK then if mode == CAMERA_MODE_ROM_HACK then
return true return true
end end
@ -54,3 +47,8 @@ function on_set_camera_mode(c, mode, frames)
end end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
hook_event(HOOK_UPDATE, function()
if (m.controller.buttonPressed & L_TRIG) ~= 0 then
center_rom_hack_camera()
end
end)

View file

@ -10,8 +10,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true, [CAMERA_MODE_SPIRAL_STAIRS] = true,
} }
local m = gMarioStates[0]
function override_camera() function override_camera()
local m = gMarioStates[0]
local np = gNetworkPlayers[0] local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then if sOverrideCameraModes[m.area.camera.mode] == nil then
@ -26,8 +27,6 @@ function override_camera()
end end
function on_set_camera_mode(c, mode, frames) function on_set_camera_mode(c, mode, frames)
local m = gMarioStates[0]
if mode == CAMERA_MODE_ROM_HACK then if mode == CAMERA_MODE_ROM_HACK then
return true return true
end end
@ -46,3 +45,8 @@ function on_set_camera_mode(c, mode, frames)
end end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
hook_event(HOOK_UPDATE, function()
if (m.controller.buttonPressed & L_TRIG) ~= 0 then
center_rom_hack_camera()
end
end)

View file

@ -10,8 +10,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true, [CAMERA_MODE_SPIRAL_STAIRS] = true,
} }
local m = gMarioStates[0]
function override_camera() function override_camera()
local m = gMarioStates[0]
local np = gNetworkPlayers[0] local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then if sOverrideCameraModes[m.area.camera.mode] == nil then
@ -26,8 +27,6 @@ function override_camera()
end end
function on_set_camera_mode(c, mode, frames) function on_set_camera_mode(c, mode, frames)
local m = gMarioStates[0]
if mode == CAMERA_MODE_ROM_HACK then if mode == CAMERA_MODE_ROM_HACK then
return true return true
end end
@ -46,3 +45,8 @@ function on_set_camera_mode(c, mode, frames)
end end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
hook_event(HOOK_UPDATE, function()
if (m.controller.buttonPressed & L_TRIG) ~= 0 then
center_rom_hack_camera()
end
end)

View file

@ -45,6 +45,8 @@ void bhv_bowser_key_loop(void) {
} else { } else {
obj_set_hitbox(o, &sBowserKeyHitbox); obj_set_hitbox(o, &sBowserKeyHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) { if (o->oInteractStatus & INT_STATUS_INTERACTED) {
extern u8 gLastCollectedStarOrKey;
gLastCollectedStarOrKey = 1;
mark_obj_for_deletion(o); mark_obj_for_deletion(o);
o->oInteractStatus = 0; o->oInteractStatus = 0;
} }

View file

@ -61,7 +61,7 @@ void bhv_scuttlebug_loop(void) {
case 1: case 1:
o->oForwardVel = 5.0f; o->oForwardVel = 5.0f;
if (cur_obj_lateral_dist_from_obj_to_home(player) > 1000.0f) { if (cur_obj_lateral_dist_from_obj_to_home(player) > 1000.0f) {
//angleToPlayer = angleToPlayer; angleToPlayer = cur_obj_angle_to_home();
} else { } else {
if (o->oScuttlebugUnkF8 == 0) { if (o->oScuttlebugUnkF8 == 0) {
o->oScuttlebugUnkFC = 0; o->oScuttlebugUnkFC = 0;

View file

@ -35,6 +35,8 @@ void bhv_spawned_star_init(void) {
void set_sparkle_spawn_star_hitbox(void) { void set_sparkle_spawn_star_hitbox(void) {
obj_set_hitbox(o, &sSparkleSpawnStarHitbox); obj_set_hitbox(o, &sSparkleSpawnStarHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) { if (o->oInteractStatus & INT_STATUS_INTERACTED) {
extern u8 gLastCollectedStarOrKey;
gLastCollectedStarOrKey = 0;
mark_obj_for_deletion(o); mark_obj_for_deletion(o);
o->oInteractStatus = 0; o->oInteractStatus = 0;
} }

View file

@ -31,6 +31,8 @@ void bhv_collect_star_loop(void) {
o->oFaceAngleYaw += 0x800; o->oFaceAngleYaw += 0x800;
if (o->oInteractStatus & INT_STATUS_INTERACTED) { if (o->oInteractStatus & INT_STATUS_INTERACTED) {
extern u8 gLastCollectedStarOrKey;
gLastCollectedStarOrKey = 0;
mark_obj_for_deletion(o); mark_obj_for_deletion(o);
o->oInteractStatus = 0; o->oInteractStatus = 0;
} }

View file

@ -3066,10 +3066,17 @@ void update_camera(struct Camera *c) {
#endif #endif
) { ) {
if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) { if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) {
bool returnValue = true;
if (set_cam_angle(0) == CAM_ANGLE_LAKITU) { if (set_cam_angle(0) == CAM_ANGLE_LAKITU) {
set_cam_angle(CAM_ANGLE_MARIO); smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_MARIO, &returnValue);
if (returnValue) {
set_cam_angle(CAM_ANGLE_MARIO);
}
} else { } else {
set_cam_angle(CAM_ANGLE_LAKITU); smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_LAKITU, &returnValue);
if (returnValue) {
set_cam_angle(CAM_ANGLE_LAKITU);
}
} }
} }
} }
@ -11847,6 +11854,11 @@ void rom_hack_cam_walk(Vec3f pos, Vec3f dir, f32 dist) {
static s16 sRomHackOffset = 0; static s16 sRomHackOffset = 0;
void center_rom_hack_camera(void) {
sRomHackYaw = DEGREES(180 + 90) - gMarioStates[0].intendedYaw;
sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
}
/** /**
* A mode that has 8 camera angles, 45 degrees apart, that is slightly smarter * A mode that has 8 camera angles, 45 degrees apart, that is slightly smarter
*/ */
@ -11892,12 +11904,6 @@ void mode_rom_hack_camera(struct Camera *c) {
sRomHackZoom = 0; sRomHackZoom = 0;
} }
// center camera
if (gMarioStates[0].controller->buttonPressed & L_TRIG) {
sRomHackYaw = DEGREES(180 + 90) - gMarioStates[0].intendedYaw;
sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
}
// clamp yaw // clamp yaw
sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45); sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);

View file

@ -785,5 +785,6 @@ s32 set_camera_mode_fixed(struct Camera* c, s16 x, s16 y, s16 z);
void camera_set_use_course_specific_settings(u8 enable); void camera_set_use_course_specific_settings(u8 enable);
void rom_hack_cam_set_collisions(u8 enable); void rom_hack_cam_set_collisions(u8 enable);
void center_rom_hack_camera(void);
#endif // CAMERA_H #endif // CAMERA_H

View file

@ -47,6 +47,7 @@ s16 gCutsceneMsgYOffset;
extern u8 gLastCompletedCourseNum; extern u8 gLastCompletedCourseNum;
extern u8 gLastCompletedStarNum; extern u8 gLastCompletedStarNum;
u8 gLastCollectedStarOrKey = 0;
enum DialogBoxState { enum DialogBoxState {
DIALOG_STATE_OPENING, DIALOG_STATE_OPENING,
@ -3111,7 +3112,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
print_generic_string(63, 167, textCourse); print_generic_string(63, 167, textCourse);
print_generic_string(CRS_NUM_X3, 167, strCourseNum); print_generic_string(CRS_NUM_X3, 167, strCourseNum);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end); gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
} else if (gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) { } else if ((gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) && gLastCollectedStarOrKey == 1) {
name = segmented_to_virtual(courseNameTbl[gLastCompletedCourseNum - 1]); name = segmented_to_virtual(courseNameTbl[gLastCompletedCourseNum - 1]);
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha); gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha);

View file

@ -57,6 +57,8 @@ static s8 D_8032CBE4 = 0;
static s8 D_8032CBE8 = 0; static s8 D_8032CBE8 = 0;
static s8 D_8032CBEC[7] = { 2, 3, 2, 1, 2, 3, 2 }; static s8 D_8032CBEC[7] = { 2, 3, 2, 1, 2, 3, 2 };
extern u8 gLastCollectedStarOrKey;
static BehaviorScript* localDialogNPCBehavior = NULL; static BehaviorScript* localDialogNPCBehavior = NULL;
/** /**
@ -1288,8 +1290,8 @@ s32 act_exit_land_save_dialog(struct MarioState *m) {
if (!(m->flags & MARIO_CAP_ON_HEAD)) { if (!(m->flags & MARIO_CAP_ON_HEAD)) {
m->actionState = 2; // star exit without cap m->actionState = 2; // star exit without cap
} }
if (gLastCompletedCourseNum == COURSE_BITDW if ((gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS)
|| gLastCompletedCourseNum == COURSE_BITFS) { && gLastCollectedStarOrKey == 1) {
m->actionState = 1; // key exit m->actionState = 1; // key exit
} }
} }

View file

@ -2822,7 +2822,8 @@ char gSmluaConstants[] = ""
"HOOK_ON_DEATH = 21\n" "HOOK_ON_DEATH = 21\n"
"HOOK_ON_PACKET_RECEIVE = 22\n" "HOOK_ON_PACKET_RECEIVE = 22\n"
"HOOK_USE_ACT_SELECT = 23\n" "HOOK_USE_ACT_SELECT = 23\n"
"HOOK_MAX = 24\n" "HOOK_ON_CHANGE_CAMERA_ANGLE = 24\n"
"HOOK_MAX = 25\n"
"ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n" "ACTION_HOOK_MAX = 2\n"

View file

@ -5786,6 +5786,15 @@ int smlua_func_camera_set_use_course_specific_settings(lua_State* L) {
return 1; return 1;
} }
int smlua_func_center_rom_hack_camera(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
center_rom_hack_camera();
return 1;
}
int smlua_func_clamp_pitch(lua_State* L) { int smlua_func_clamp_pitch(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 4)) { return 0; } if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
@ -16991,6 +17000,15 @@ int smlua_func_get_hand_foot_pos_z(lua_State* L) {
return 1; return 1;
} }
int smlua_func_get_last_star_or_key(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, get_last_star_or_key());
return 1;
}
int smlua_func_get_network_area_timer(UNUSED lua_State* L) { int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; } if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
@ -17150,6 +17168,17 @@ int smlua_func_set_environment_region(lua_State* L) {
return 1; return 1;
} }
int smlua_func_set_last_star_or_key(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
u8 value = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'set_last_star_or_key'"); return 0; }
set_last_star_or_key(value);
return 1;
}
int smlua_func_set_override_far(lua_State* L) { int smlua_func_set_override_far(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; } if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
@ -18695,6 +18724,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "camera_approach_s16_symmetric_bool", smlua_func_camera_approach_s16_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_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, "camera_set_use_course_specific_settings", smlua_func_camera_set_use_course_specific_settings);
smlua_bind_function(L, "center_rom_hack_camera", smlua_func_center_rom_hack_camera);
smlua_bind_function(L, "clamp_pitch", smlua_func_clamp_pitch); 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, "clamp_positions_and_find_yaw", smlua_func_clamp_positions_and_find_yaw);
smlua_bind_function(L, "collide_with_walls", smlua_func_collide_with_walls); smlua_bind_function(L, "collide_with_walls", smlua_func_collide_with_walls);
@ -19515,6 +19545,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y); smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z); smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key);
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer); smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer); smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value); smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
@ -19528,6 +19559,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "play_transition", smlua_func_play_transition); smlua_bind_function(L, "play_transition", smlua_func_play_transition);
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot); smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
smlua_bind_function(L, "set_last_star_or_key", smlua_func_set_last_star_or_key);
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); smlua_bind_function(L, "set_override_near", smlua_func_set_override_near);

View file

@ -477,6 +477,35 @@ void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookT
} }
} }
void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
*returnValue = true;
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
for (int i = 0; i < hook->count; i++) {
s32 prevTop = lua_gettop(L);
// push the callback onto the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
// push params
lua_pushinteger(L, mode);
// call the callback
if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i])) {
LOG_LUA("Failed to call the callback: %u", hookType);
continue;
}
// output the return value
if (lua_type(L, -1) == LUA_TBOOLEAN) {
*returnValue = smlua_to_boolean(L, -1);
}
lua_settop(L, prevTop);
}
}
void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex) { void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex) {
lua_State* L = gLuaState; lua_State* L = gLuaState;
if (L == NULL) { return; } if (L == NULL) { return; }

View file

@ -35,6 +35,7 @@ enum LuaHookedEventType {
HOOK_ON_DEATH, HOOK_ON_DEATH,
HOOK_ON_PACKET_RECEIVE, HOOK_ON_PACKET_RECEIVE,
HOOK_USE_ACT_SELECT, HOOK_USE_ACT_SELECT,
HOOK_ON_CHANGE_CAMERA_ANGLE,
HOOK_MAX, HOOK_MAX,
}; };
@ -63,6 +64,7 @@ static const char* LuaHookedEventTypeName[] = {
"HOOK_ON_DEATH", "HOOK_ON_DEATH",
"HOOK_ON_PACKET_RECEIVE", "HOOK_ON_PACKET_RECEIVE",
"HOOK_USE_ACT_SELECT", "HOOK_USE_ACT_SELECT",
"HOOK_ON_CHANGE_CAMERA_ANGLE",
"HOOK_MAX" "HOOK_MAX"
}; };
@ -94,6 +96,7 @@ void smlua_call_event_hooks_interact_params_ret_bool(enum LuaHookedEventType hoo
void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struct Object* obj); void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struct Object* obj);
bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* returnValue); bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* returnValue);
void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue); void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue);
void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue);
void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex); void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex);
void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue); void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue);

View file

@ -47,6 +47,15 @@ void hud_show(void) {
gOverrideHideHud = 0; gOverrideHideHud = 0;
} }
extern u8 gLastCollectedStarOrKey;
s32 get_last_star_or_key(void) {
return gLastCollectedStarOrKey;
}
void set_last_star_or_key(u8 value) {
gLastCollectedStarOrKey = value;
}
s32 hud_get_value(enum HudDisplayValue type) { s32 hud_get_value(enum HudDisplayValue type) {
switch (type) { switch (type) {
case HUD_DISPLAY_LIVES: return gHudDisplay.lives; case HUD_DISPLAY_LIVES: return gHudDisplay.lives;

View file

@ -65,6 +65,8 @@ bool is_game_paused(void);
bool is_transition_playing(void); bool is_transition_playing(void);
s16 get_dialog_id(void); s16 get_dialog_id(void);
s32 get_last_star_or_key(void);
void set_last_star_or_key(u8 value);
u32 allocate_mario_action(u32 actFlags); u32 allocate_mario_action(u32 actFlags);

View file

@ -19,6 +19,7 @@
#include "pc/mods/mods.h" #include "pc/mods/mods.h"
#include "pc/crash_handler.h" #include "pc/crash_handler.h"
#include "pc/debuglog.h" #include "pc/debuglog.h"
#include "game/camera.h"
// fix warnings when including rendering_graph_node // fix warnings when including rendering_graph_node
#undef near #undef near
@ -531,6 +532,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
extern s16 gChangeLevel; extern s16 gChangeLevel;
gChangeLevel = LEVEL_CASTLE_GROUNDS; gChangeLevel = LEVEL_CASTLE_GROUNDS;
network_player_init(); network_player_init();
camera_set_use_course_specific_settings(true);
free_vtx_scroll_targets(); free_vtx_scroll_targets();
struct Controller* cnt = gMarioStates[0].controller; struct Controller* cnt = gMarioStates[0].controller;