mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-22 10:01:46 +00:00
Improvements (#151)
More lives fixes, death loop fix, add a null check and add get_dialog_id() add a way to disable rom hack cam collisions expose more sound management functions
This commit is contained in:
parent
ee74afc804
commit
d4417171e4
13 changed files with 269 additions and 9 deletions
|
|
@ -55,7 +55,7 @@ in_files = [
|
|||
]
|
||||
|
||||
override_allowed_functions = {
|
||||
"src/audio/external.h": [ " play_", "fade", "current_background" ],
|
||||
"src/audio/external.h": [ " play_", "fade", "current_background", "stop_" ],
|
||||
"src/game/rumble_init.c": [ "queue_rumble_", "reset_rumble_timers" ],
|
||||
"src/pc/djui/djui_popup.h" : [ "create" ],
|
||||
"src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_erase", "save_file_reload", "save_file_set_star_flags" ],
|
||||
|
|
|
|||
|
|
@ -3257,6 +3257,12 @@ function resolve_geometry_collisions(pos, lastGood)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param enable integer
|
||||
--- @return nil
|
||||
function rom_hack_cam_set_collisions(enable)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param c Camera
|
||||
--- @param cPos Vec3f
|
||||
--- @param avoidYaw Pointer_integer
|
||||
|
|
@ -3809,6 +3815,30 @@ function seq_player_unlower_volume(player, fadeDuration)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param seqId integer
|
||||
--- @return nil
|
||||
function stop_background_music(seqId)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param soundBits integer
|
||||
--- @param pos Vec3f
|
||||
--- @return nil
|
||||
function stop_sound(soundBits, pos)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param pos Vec3f
|
||||
--- @return nil
|
||||
function stop_sounds_from_source(pos)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function stop_sounds_in_continuous_banks()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param m MarioState
|
||||
--- @return integer
|
||||
function does_mario_have_normal_cap_on_head(m)
|
||||
|
|
@ -7634,6 +7664,11 @@ function get_current_save_file_num()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function get_dialog_id()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_environment_region(index)
|
||||
|
|
|
|||
|
|
@ -1084,6 +1084,26 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [rom_hack_cam_set_collisions](#rom_hack_cam_set_collisions)
|
||||
|
||||
### Lua Example
|
||||
`rom_hack_cam_set_collisions(enable)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| enable | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void rom_hack_cam_set_collisions(u8 enable);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [rotate_camera_around_walls](#rotate_camera_around_walls)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -2768,6 +2788,85 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [stop_background_music](#stop_background_music)
|
||||
|
||||
### Lua Example
|
||||
`stop_background_music(seqId)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| seqId | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void stop_background_music(u16 seqId);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [stop_sound](#stop_sound)
|
||||
|
||||
### Lua Example
|
||||
`stop_sound(soundBits, pos)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| soundBits | `integer` |
|
||||
| pos | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void stop_sound(u32 soundBits, f32 *pos);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [stop_sounds_from_source](#stop_sounds_from_source)
|
||||
|
||||
### Lua Example
|
||||
`stop_sounds_from_source(pos)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| pos | [Vec3f](structs.md#Vec3f) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void stop_sounds_from_source(f32 *pos);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [stop_sounds_in_continuous_banks](#stop_sounds_in_continuous_banks)
|
||||
|
||||
### Lua Example
|
||||
`stop_sounds_in_continuous_banks()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void stop_sounds_in_continuous_banks(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from interaction.h
|
||||
|
||||
|
|
|
|||
|
|
@ -6766,6 +6766,24 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_dialog_id](#get_dialog_id)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = get_dialog_id()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s16 get_dialog_id(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_environment_region](#get_environment_region)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
|||
|
|
@ -648,6 +648,7 @@
|
|||
- [random_vec3s](functions-3.md#random_vec3s)
|
||||
- [reset_camera](functions-3.md#reset_camera)
|
||||
- [resolve_geometry_collisions](functions-3.md#resolve_geometry_collisions)
|
||||
- [rom_hack_cam_set_collisions](functions-3.md#rom_hack_cam_set_collisions)
|
||||
- [rotate_camera_around_walls](functions-3.md#rotate_camera_around_walls)
|
||||
- [rotate_in_xz](functions-3.md#rotate_in_xz)
|
||||
- [rotate_in_yz](functions-3.md#rotate_in_yz)
|
||||
|
|
@ -748,6 +749,10 @@
|
|||
- [seq_player_fade_out](functions-3.md#seq_player_fade_out)
|
||||
- [seq_player_lower_volume](functions-3.md#seq_player_lower_volume)
|
||||
- [seq_player_unlower_volume](functions-3.md#seq_player_unlower_volume)
|
||||
- [stop_background_music](functions-3.md#stop_background_music)
|
||||
- [stop_sound](functions-3.md#stop_sound)
|
||||
- [stop_sounds_from_source](functions-3.md#stop_sounds_from_source)
|
||||
- [stop_sounds_in_continuous_banks](functions-3.md#stop_sounds_in_continuous_banks)
|
||||
|
||||
<br />
|
||||
|
||||
|
|
@ -1424,6 +1429,7 @@
|
|||
- [camera_unfreeze](functions-4.md#camera_unfreeze)
|
||||
- [deref_s32_pointer](functions-4.md#deref_s32_pointer)
|
||||
- [get_current_save_file_num](functions-4.md#get_current_save_file_num)
|
||||
- [get_dialog_id](functions-4.md#get_dialog_id)
|
||||
- [get_environment_region](functions-4.md#get_environment_region)
|
||||
- [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)
|
||||
|
|
|
|||
|
|
@ -11749,10 +11749,19 @@ static u8 sRomHackZoom = 1;
|
|||
static s8 sRomHackIsUpdate = 0;
|
||||
static f32 sRomHackWaterFocus = 0;
|
||||
static f32 sRomHackWaterPitchOffset = 0;
|
||||
u8 gRomHackCamSetCollisions = TRUE;
|
||||
|
||||
void rom_hack_cam_set_collisions(u8 enable) {
|
||||
gRomHackCamSetCollisions = enable;
|
||||
}
|
||||
|
||||
static u8 rom_hack_cam_can_see_mario(Vec3f desiredPos) {
|
||||
// do collision checking
|
||||
struct Surface *surf = NULL;
|
||||
if (!gRomHackCamSetCollisions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
f32 floorHeight = find_floor(desiredPos[0], desiredPos[1], desiredPos[2], &surf);
|
||||
if (surf == NULL || floorHeight <= -11000) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -784,5 +784,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);
|
||||
void rom_hack_cam_set_collisions(u8 enable);
|
||||
|
||||
#endif // CAMERA_H
|
||||
|
|
|
|||
|
|
@ -525,6 +525,10 @@ void init_mario_after_warp(void) {
|
|||
network_player_update_course_level(gNetworkPlayerLocal, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex);
|
||||
}
|
||||
|
||||
if (gMarioState->health <= 0x110) {
|
||||
gMarioState->health = 0x880;
|
||||
}
|
||||
|
||||
smlua_call_event_hooks(HOOK_ON_WARP);
|
||||
}
|
||||
|
||||
|
|
@ -845,7 +849,8 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
|||
break;
|
||||
|
||||
case WARP_OP_DEATH:
|
||||
if (m->numLives <= 0) {
|
||||
m->numLives--;
|
||||
if (m->numLives <= -1) {
|
||||
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
||||
}
|
||||
sDelayedWarpTimer = 48;
|
||||
|
|
@ -863,7 +868,8 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
|||
case WARP_OP_WARP_FLOOR:
|
||||
sSourceWarpNodeId = WARP_NODE_WARP_FLOOR;
|
||||
if (area_get_warp_node(sSourceWarpNodeId) == NULL) {
|
||||
if (m->numLives <= 0) {
|
||||
m->numLives--;
|
||||
if (m->numLives <= -1) {
|
||||
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
||||
} else {
|
||||
sSourceWarpNodeId = WARP_NODE_DEATH;
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ s32 act_bubbled(struct MarioState* m) {
|
|||
|
||||
// make invisible on -1 lives
|
||||
if (m->playerIndex == 0) {
|
||||
if (m->numLives == -1) {
|
||||
if (m->numLives <= -1) {
|
||||
m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
|
||||
level_trigger_warp(m, WARP_OP_DEATH);
|
||||
return set_mario_action(m, ACT_SOFT_BONK, 0);
|
||||
|
|
|
|||
|
|
@ -1360,7 +1360,6 @@ s32 act_death_exit(struct MarioState *m) {
|
|||
play_character_sound(m, CHAR_SOUND_OOOF2);
|
||||
#endif
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
m->numLives--;
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
}
|
||||
|
|
@ -1376,7 +1375,6 @@ s32 act_unused_death_exit(struct MarioState *m) {
|
|||
#else
|
||||
play_character_sound(m, CHAR_SOUND_OOOF2);
|
||||
#endif
|
||||
m->numLives--;
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
}
|
||||
|
|
@ -1393,7 +1391,6 @@ s32 act_falling_death_exit(struct MarioState *m) {
|
|||
play_character_sound(m, CHAR_SOUND_OOOF2);
|
||||
#endif
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
m->numLives--;
|
||||
// restore 7.75 units of health
|
||||
m->healCounter = 31;
|
||||
}
|
||||
|
|
@ -1438,7 +1435,6 @@ s32 act_special_death_exit(struct MarioState *m) {
|
|||
|
||||
if (launch_mario_until_land(m, ACT_HARD_BACKWARD_GROUND_KB, MARIO_ANIM_BACKWARD_AIR_KB, -24.0f)) {
|
||||
queue_rumble_data_mario(m, 5, 80);
|
||||
m->numLives--;
|
||||
m->healCounter = 31;
|
||||
}
|
||||
// show Mario
|
||||
|
|
|
|||
|
|
@ -1341,7 +1341,9 @@ void obj_mark_for_deletion(struct Object *obj) {
|
|||
// setting it to 0 could potentially enable unexpected behavior. After an
|
||||
// object is marked for deletion, it still updates on that frame (I think),
|
||||
// so this is worth looking into.
|
||||
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
if (obj != NULL) {
|
||||
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
}
|
||||
}
|
||||
|
||||
void cur_obj_disable(void) {
|
||||
|
|
|
|||
|
|
@ -6450,6 +6450,17 @@ int smlua_func_resolve_geometry_collisions(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_rom_hack_cam_set_collisions(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u8 enable = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'rom_hack_cam_set_collisions'"); return 0; }
|
||||
|
||||
rom_hack_cam_set_collisions(enable);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_rotate_camera_around_walls(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
|
|
@ -7678,6 +7689,66 @@ int smlua_func_seq_player_unlower_volume(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_stop_background_music(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u16 seqId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'stop_background_music'"); return 0; }
|
||||
|
||||
stop_background_music(seqId);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_stop_sound(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 soundBits = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'stop_sound'"); return 0; }
|
||||
|
||||
f32* pos = smlua_get_vec3f_from_buffer();
|
||||
pos[0] = smlua_get_number_field(2, "x");
|
||||
pos[1] = smlua_get_number_field(2, "y");
|
||||
pos[2] = smlua_get_number_field(2, "z");
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2 for function 'stop_sound'"); return 0; }
|
||||
|
||||
stop_sound(soundBits, pos);
|
||||
|
||||
smlua_push_number_field(2, "x", pos[0]);
|
||||
smlua_push_number_field(2, "y", pos[1]);
|
||||
smlua_push_number_field(2, "z", pos[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_stop_sounds_from_source(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
||||
f32* pos = smlua_get_vec3f_from_buffer();
|
||||
pos[0] = smlua_get_number_field(1, "x");
|
||||
pos[1] = smlua_get_number_field(1, "y");
|
||||
pos[2] = smlua_get_number_field(1, "z");
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'stop_sounds_from_source'"); return 0; }
|
||||
|
||||
stop_sounds_from_source(pos);
|
||||
|
||||
smlua_push_number_field(1, "x", pos[0]);
|
||||
smlua_push_number_field(1, "y", pos[1]);
|
||||
smlua_push_number_field(1, "z", pos[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_stop_sounds_in_continuous_banks(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
stop_sounds_in_continuous_banks();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// interaction.h //
|
||||
///////////////////
|
||||
|
|
@ -16817,6 +16888,15 @@ int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_dialog_id(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
lua_pushinteger(L, get_dialog_id());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_environment_region(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
|
@ -18598,6 +18678,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "random_vec3s", smlua_func_random_vec3s);
|
||||
smlua_bind_function(L, "reset_camera", smlua_func_reset_camera);
|
||||
smlua_bind_function(L, "resolve_geometry_collisions", smlua_func_resolve_geometry_collisions);
|
||||
smlua_bind_function(L, "rom_hack_cam_set_collisions", smlua_func_rom_hack_cam_set_collisions);
|
||||
smlua_bind_function(L, "rotate_camera_around_walls", smlua_func_rotate_camera_around_walls);
|
||||
smlua_bind_function(L, "rotate_in_xz", smlua_func_rotate_in_xz);
|
||||
smlua_bind_function(L, "rotate_in_yz", smlua_func_rotate_in_yz);
|
||||
|
|
@ -18688,6 +18769,10 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "seq_player_fade_out", smlua_func_seq_player_fade_out);
|
||||
smlua_bind_function(L, "seq_player_lower_volume", smlua_func_seq_player_lower_volume);
|
||||
smlua_bind_function(L, "seq_player_unlower_volume", smlua_func_seq_player_unlower_volume);
|
||||
smlua_bind_function(L, "stop_background_music", smlua_func_stop_background_music);
|
||||
smlua_bind_function(L, "stop_sound", smlua_func_stop_sound);
|
||||
smlua_bind_function(L, "stop_sounds_from_source", smlua_func_stop_sounds_from_source);
|
||||
smlua_bind_function(L, "stop_sounds_in_continuous_banks", smlua_func_stop_sounds_in_continuous_banks);
|
||||
|
||||
// interaction.h
|
||||
smlua_bind_function(L, "does_mario_have_normal_cap_on_head", smlua_func_does_mario_have_normal_cap_on_head);
|
||||
|
|
@ -19368,6 +19453,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
|
||||
smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ void camera_config_set_deceleration(u32 value);
|
|||
|
||||
bool is_game_paused(void);
|
||||
|
||||
s16 get_dialog_id(void);
|
||||
|
||||
u32 allocate_mario_action(u32 actFlags);
|
||||
|
||||
f32 get_hand_foot_pos_x(struct MarioState* m, u8 index);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue