From b2bf9abafab84b5b4559dab7036bc9d907e8acfa Mon Sep 17 00:00:00 2001 From: Sunk <69110309+Sunketchupm@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:43:04 -0400 Subject: [PATCH] Add some suggestions from issues (#354) * Make dives knockback based on speed Suggestion from issue #349 * Add `get_local_coopnet_id` Suggestion from issue #264 * Readd breakdancing as an attack Suggestion not only from me but also from a few players I talked with. However this was not a suggestion that came from issues. * Change around pvp damage Suggestion from issue #343 and some changes from talking with the creator of the suggestion * Change `get_local_coopnet_id` The function can now take in any local id and has been renamed to just `get_coopnet_id` * Suggested fixes --- autogen/lua_definitions/functions.lua | 6 ++++++ docs/lua/functions-5.md | 20 ++++++++++++++++++++ docs/lua/functions.md | 1 + src/game/interaction.c | 12 +++++++----- src/pc/lua/smlua_functions_autogen.c | 18 ++++++++++++++++++ src/pc/lua/utils/smlua_misc_utils.c | 9 +++++++++ src/pc/lua/utils/smlua_misc_utils.h | 1 + 7 files changed, 62 insertions(+), 5 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 31c147565..4d06ebda9 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -8226,6 +8226,12 @@ function djui_set_popup_disabled_override(value) -- ... end +--- @param localIndex integer +--- @return string +function get_coopnet_id(localIndex) + -- ... +end + --- @return integer function get_current_save_file_num() -- ... diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 95f66b394..8a59fe588 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -2122,6 +2122,26 @@
+## [get_coopnet_id](#get_coopnet_id) + +### Lua Example +`local stringValue = get_coopnet_id(localIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| localIndex | `integer` | + +### Returns +- `string` + +### C Prototype +`const char* get_coopnet_id(s8 localIndex);` + +[:arrow_up_small:](#) + +
+ ## [get_current_save_file_num](#get_current_save_file_num) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index c1245be90..2bd607054 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1728,6 +1728,7 @@ - [djui_popup_create_global](functions-5.md#djui_popup_create_global) - [djui_reset_popup_disabled_override](functions-5.md#djui_reset_popup_disabled_override) - [djui_set_popup_disabled_override](functions-5.md#djui_set_popup_disabled_override) + - [get_coopnet_id](functions-5.md#get_coopnet_id) - [get_current_save_file_num](functions-5.md#get_current_save_file_num) - [get_date_and_time](functions-5.md#get_date_and_time) - [get_dialog_box_state](functions-5.md#get_dialog_box_state) diff --git a/src/game/interaction.c b/src/game/interaction.c index ee526e13f..3f7603355 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -157,7 +157,7 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) { } if (interaction == 0 && action & ACT_FLAG_ATTACKING) { - u32 flags = (o->oInteractType & INTERACT_PLAYER) ? (MARIO_PUNCHING | MARIO_KICKING) : (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING); + u32 flags = (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING); if (m->flags & flags) { s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; @@ -671,7 +671,8 @@ u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { if (!is_player_active(m2)) { continue; } if (m2->marioObj == NULL) { continue; } if (m2->marioObj != m->interactObj) { continue; } - if (m2->action == ACT_JUMP_KICK) { scaler = 2; } + if (m2->action == ACT_JUMP_KICK) { scaler = 2.0f; } + if (m2->action == ACT_DIVE) { scaler += fabs(m2->forwardVel * 0.01); } if (m2->flags & MARIO_METAL_CAP) { scaler *= 1.25f; } break; } @@ -1316,10 +1317,11 @@ static u8 resolve_player_collision(struct MarioState* m, struct MarioState* m2) } u8 determine_player_damage_value(u32 interaction) { - if (interaction & INT_GROUND_POUND_OR_TWIRL) { return 3; } + if (interaction & INT_GROUND_POUND) { return 4; } + if (interaction & (INT_TWIRL | INT_PUNCH | INT_TRIP)) { return 3; } if (interaction & INT_KICK) { return 2; } - if (interaction & INT_ATTACK_SLIDE) { return 1; } - return 2; + if (interaction & INT_SLIDE_KICK) { return 2; } + return 1; } u8 player_is_sliding(struct MarioState* m) { diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index b19fdae38..0039855ef 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -30295,6 +30295,23 @@ int smlua_func_djui_set_popup_disabled_override(lua_State* L) { return 1; } +int smlua_func_get_coopnet_id(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", "get_coopnet_id", 1, top); + return 0; + } + + s8 localIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_coopnet_id"); return 0; } + + lua_pushstring(L, get_coopnet_id(localIndex)); + + return 1; +} + int smlua_func_get_current_save_file_num(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -34724,6 +34741,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_popup_create_global", smlua_func_djui_popup_create_global); smlua_bind_function(L, "djui_reset_popup_disabled_override", smlua_func_djui_reset_popup_disabled_override); smlua_bind_function(L, "djui_set_popup_disabled_override", smlua_func_djui_set_popup_disabled_override); + smlua_bind_function(L, "get_coopnet_id", smlua_func_get_coopnet_id); smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num); smlua_bind_function(L, "get_date_and_time", smlua_func_get_date_and_time); smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 3f41ec827..599262fe0 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -27,6 +27,7 @@ #include "game/first_person_cam.h" #include "pc/lua/utils/smlua_math_utils.h" #include "pc/lua/utils/smlua_audio_utils.h" +#include "pc/network/socket/socket.h" #ifdef DISCORD_SDK #include "pc/discord/discord.h" @@ -426,6 +427,14 @@ const char* get_local_discord_id(void) { #endif } +const char* get_coopnet_id(s8 localIndex) { + if (!gNetworkSystem || gNetworkSystem == &gNetworkSystemSocket) { return "-1"; } + if (localIndex < 0 || localIndex > MAX_PLAYERS - 1) { return "-1"; } + struct NetworkPlayer* np = &gNetworkPlayers[localIndex]; + if (np == NULL || !np->connected) { return "-1"; } + return gNetworkSystem->get_id_str(np->localIndex); +} + /// f32 get_volume_master(void) { diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index d09d292b0..b9a11d2eb 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -112,6 +112,7 @@ u32 get_global_timer(void); s32 get_dialog_response(void); const char* get_local_discord_id(void); +const char* get_coopnet_id(s8 localIndex); f32 get_volume_master(void); f32 get_volume_level(void);