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
This commit is contained in:
Sunk 2024-10-06 23:43:04 -04:00 committed by GitHub
parent 260a429285
commit b2bf9abafa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 62 additions and 5 deletions

View file

@ -8226,6 +8226,12 @@ function djui_set_popup_disabled_override(value)
-- ... -- ...
end end
--- @param localIndex integer
--- @return string
function get_coopnet_id(localIndex)
-- ...
end
--- @return integer --- @return integer
function get_current_save_file_num() function get_current_save_file_num()
-- ... -- ...

View file

@ -2122,6 +2122,26 @@
<br /> <br />
## [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:](#)
<br />
## [get_current_save_file_num](#get_current_save_file_num) ## [get_current_save_file_num](#get_current_save_file_num)
### Lua Example ### Lua Example

View file

@ -1728,6 +1728,7 @@
- [djui_popup_create_global](functions-5.md#djui_popup_create_global) - [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_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) - [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_current_save_file_num](functions-5.md#get_current_save_file_num)
- [get_date_and_time](functions-5.md#get_date_and_time) - [get_date_and_time](functions-5.md#get_date_and_time)
- [get_dialog_box_state](functions-5.md#get_dialog_box_state) - [get_dialog_box_state](functions-5.md#get_dialog_box_state)

View file

@ -157,7 +157,7 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) {
} }
if (interaction == 0 && action & ACT_FLAG_ATTACKING) { 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) { if (m->flags & flags) {
s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; 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 (!is_player_active(m2)) { continue; }
if (m2->marioObj == NULL) { continue; } if (m2->marioObj == NULL) { continue; }
if (m2->marioObj != m->interactObj) { 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; } if (m2->flags & MARIO_METAL_CAP) { scaler *= 1.25f; }
break; break;
} }
@ -1316,10 +1317,11 @@ static u8 resolve_player_collision(struct MarioState* m, struct MarioState* m2)
} }
u8 determine_player_damage_value(u32 interaction) { 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_KICK) { return 2; }
if (interaction & INT_ATTACK_SLIDE) { return 1; } if (interaction & INT_SLIDE_KICK) { return 2; }
return 2; return 1;
} }
u8 player_is_sliding(struct MarioState* m) { u8 player_is_sliding(struct MarioState* m) {

View file

@ -30295,6 +30295,23 @@ int smlua_func_djui_set_popup_disabled_override(lua_State* L) {
return 1; 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) { int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
if (L == NULL) { return 0; } 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_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_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, "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_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_date_and_time", smlua_func_get_date_and_time);
smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state);

View file

@ -27,6 +27,7 @@
#include "game/first_person_cam.h" #include "game/first_person_cam.h"
#include "pc/lua/utils/smlua_math_utils.h" #include "pc/lua/utils/smlua_math_utils.h"
#include "pc/lua/utils/smlua_audio_utils.h" #include "pc/lua/utils/smlua_audio_utils.h"
#include "pc/network/socket/socket.h"
#ifdef DISCORD_SDK #ifdef DISCORD_SDK
#include "pc/discord/discord.h" #include "pc/discord/discord.h"
@ -426,6 +427,14 @@ const char* get_local_discord_id(void) {
#endif #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) { f32 get_volume_master(void) {

View file

@ -112,6 +112,7 @@ u32 get_global_timer(void);
s32 get_dialog_response(void); s32 get_dialog_response(void);
const char* get_local_discord_id(void); const char* get_local_discord_id(void);
const char* get_coopnet_id(s8 localIndex);
f32 get_volume_master(void); f32 get_volume_master(void);
f32 get_volume_level(void); f32 get_volume_level(void);