From 6a1ceab5cabcbbdc6a40e3d29d675c6dfb261571 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 14 Jan 2022 20:33:06 -0800 Subject: [PATCH] Made bubble-on-death a server setting --- src/game/interaction.c | 9 ++++++ src/game/level_update.c | 8 ++++-- src/game/mario_actions_airborne.c | 8 ++++-- src/game/mario_actions_cutscene.c | 43 +++++++++++++++++++--------- src/game/mario_actions_submerged.c | 21 ++++++++++---- src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + src/pc/djui/djui_panel_host.c | 8 ++++-- src/pc/network/network.c | 2 ++ src/pc/network/network.h | 1 + src/pc/network/packets/packet_join.c | 2 ++ 11 files changed, 78 insertions(+), 27 deletions(-) diff --git a/src/game/interaction.c b/src/game/interaction.c index 5f03eb85e..cfa9d1458 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2130,6 +2130,15 @@ void mario_process_interactions(struct MarioState *m) { } void check_death_barrier(struct MarioState *m) { + if (!gServerSettings.bubbleDeath) { + if (m->pos[1] < m->floorHeight + 2048.0f) { + if (level_trigger_warp(m, WARP_OP_WARP_FLOOR) == 20 && !(m->flags & MARIO_UNKNOWN_18)) { + play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject); + } + } + return; + } + if (m->pos[1] < m->floorHeight + 2048.0f) { switch (gCurrCourseNum) { case COURSE_COTMC: // (20) Cavern of the Metal Cap diff --git a/src/game/level_update.c b/src/game/level_update.c index 5df1e49ab..2641b100f 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -421,9 +421,11 @@ void init_mario_after_warp(void) { } // enforce bubble on area change - if (i == 0 && gMarioStates[i].numLives == -1) { - mario_set_bubbled(&gMarioStates[i]); - gMarioStates[i].health = 0xFF; + if (gServerSettings.bubbleDeath) { + if (i == 0 && gMarioStates[i].numLives == -1) { + mario_set_bubbled(&gMarioStates[i]); + gMarioStates[i].health = 0xFF; + } } } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 0ff26fa88..5c590752a 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1568,8 +1568,12 @@ s32 act_lava_boost(struct MarioState *m) { // never kill remote marios m->health = 0x100; } else { - m->health = 0xFF; - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + m->health = 0xFF; + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } } } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 54a150585..6260de40f 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -763,8 +763,11 @@ s32 act_fall_after_star_grab(struct MarioState *m) { s32 common_death_handler(struct MarioState *m, s32 animation, s32 frameToDeathWarp) { s32 animFrame = set_mario_animation(m, animation); if (animFrame == frameToDeathWarp) { - //level_trigger_warp(m, WARP_OP_DEATH); - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } } m->marioBodyState->eyeState = MARIO_EYES_DEAD; stop_and_set_height_to_floor(m); @@ -823,8 +826,11 @@ s32 act_quicksand_death(struct MarioState *m) { play_character_sound_if_no_flag(m, CHAR_SOUND_WAAAOOOW, MARIO_MARIO_SOUND_PLAYED); } if ((m->quicksandDepth += 5.0f) >= 180.0f) { - //level_trigger_warp(m, WARP_OP_DEATH); - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } m->actionState = 2; } } @@ -836,15 +842,20 @@ s32 act_quicksand_death(struct MarioState *m) { s32 act_eaten_by_bubba(struct MarioState *m) { play_character_sound_if_no_flag(m, CHAR_SOUND_DYING, MARIO_ACTION_SOUND_PLAYED); set_mario_animation(m, MARIO_ANIM_A_POSE); - //m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; if (m != &gMarioStates[0]) { // never kill remote marios m->health = 0x100; - } else { - m->health = 0xFF; } - if (m->playerIndex == 0) { - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + if (m->playerIndex == 0) { + m->health = 0xFF; + mario_set_bubbled(m); + } + } else { + m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; + if (m->actionTimer++ == 60) { + level_trigger_warp(m, WARP_OP_DEATH); + } } return FALSE; @@ -1714,15 +1725,19 @@ s32 act_squished(struct MarioState *m) { if (m != &gMarioStates[0]) { // never kill remote marios m->health = 0x100; - } else { + } else if (gServerSettings.bubbleDeath) { m->health = 0xFF; } m->hurtCounter = 0; - //level_trigger_warp(m, WARP_OP_DEATH); - // woosh, he's gone! - //set_mario_action(m, ACT_DISAPPEARED, 0); - mario_set_bubbled(m); + + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + // woosh, he's gone! + set_mario_action(m, ACT_DISAPPEARED, 0); + } } stop_and_set_height_to_floor(m); set_mario_animation(m, MARIO_ANIM_A_POSE); diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 0c0c33f2a..711a97b9c 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -924,8 +924,11 @@ static s32 act_drowning(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_DROWNING_PART2); m->marioBodyState->eyeState = MARIO_EYES_DEAD; if (m->marioObj->header.gfx.unk38.animFrame == 30) { - //level_trigger_warp(m, WARP_OP_DEATH); - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } } break; } @@ -945,8 +948,11 @@ static s32 act_water_death(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_WATER_DYING); if (set_mario_animation(m, MARIO_ANIM_WATER_DYING) == 35) { - //level_trigger_warp(m, WARP_OP_DEATH); - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } } return FALSE; @@ -1053,8 +1059,11 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) { if ((marioObj->oMarioWhirlpoolPosY += m->vel[1]) < 0.0f) { marioObj->oMarioWhirlpoolPosY = 0.0f; if (distance < 16.1f && m->actionTimer++ == 16) { - //level_trigger_warp(m, WARP_OP_DEATH); - mario_set_bubbled(m); + if (gServerSettings.bubbleDeath) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + } } } diff --git a/src/pc/configfile.c b/src/pc/configfile.c index f274710d5..71ff03a10 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -94,6 +94,7 @@ bool configCameraMouse = false; bool configSkipIntro = 0; bool configShareLives = 0; bool configEnableCheats = 0; +bool configBubbleDeath = true; bool configHUD = true; #ifdef DISCORDRPC bool configDiscordRPC = true; @@ -160,6 +161,7 @@ static const struct ConfigOption options[] = { {.name = "skip_intro", .type = CONFIG_TYPE_BOOL, .boolValue = &configSkipIntro}, {.name = "share_lives", .type = CONFIG_TYPE_BOOL, .boolValue = &configShareLives}, {.name = "enable_cheats", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCheats}, + {.name = "bubble_death", .type = CONFIG_TYPE_BOOL, .boolValue = &configBubbleDeath}, #ifdef DISCORDRPC {.name = "discordrpc_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configDiscordRPC}, #endif diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 30969de22..7a156c4e8 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -63,6 +63,7 @@ extern bool configHUD; extern bool configSkipIntro; extern bool configShareLives; extern bool configEnableCheats; +extern bool configBubbleDeath; #ifdef DISCORDRPC extern bool configDiscordRPC; #endif diff --git a/src/pc/djui/djui_panel_host.c b/src/pc/djui/djui_panel_host.c index 1e7ea9f46..9d3dc06d1 100644 --- a/src/pc/djui/djui_panel_host.c +++ b/src/pc/djui/djui_panel_host.c @@ -60,9 +60,9 @@ static void djui_panel_host_do_host(struct DjuiBase* caller) { void djui_panel_host_create(struct DjuiBase* caller) { #ifdef DISCORD_SDK - f32 bodyHeight = 32 * 7 + 64 * 2 + 16 * 9; + f32 bodyHeight = 32 * 8 + 64 * 2 + 16 * 10; #else - f32 bodyHeight = 32 * 6 + 64 * 2 + 16 * 8; + f32 bodyHeight = 32 * 7 + 64 * 2 + 16 * 9; #endif struct DjuiBase* defaultBase = NULL; @@ -152,6 +152,10 @@ void djui_panel_host_create(struct DjuiBase* caller) { djui_base_set_size_type(&checkbox4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&checkbox4->base, 1.0f, 32); + struct DjuiCheckbox* checkbox5 = djui_checkbox_create(&body->base, "Bubble on death", &configBubbleDeath); + djui_base_set_size_type(&checkbox5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&checkbox5->base, 1.0f, 32); + struct DjuiRect* rect3 = djui_rect_create(&body->base); djui_base_set_size_type(&rect3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&rect3->base, 1.0f, 64); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 8bb6cb386..6c12b99e4 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -42,6 +42,7 @@ struct ServerSettings gServerSettings = { .skipIntro = 0, .shareLives = 0, .enableCheats = 0, + .bubbleDeath = 1, }; void network_set_system(enum NetworkSystemType nsType) { @@ -68,6 +69,7 @@ bool network_init(enum NetworkType inNetworkType) { gServerSettings.skipIntro = configSkipIntro; gServerSettings.shareLives = configShareLives; gServerSettings.enableCheats = configEnableCheats; + gServerSettings.bubbleDeath = configBubbleDeath; Cheats.EnableCheats = gServerSettings.enableCheats; // initialize the network system diff --git a/src/pc/network/network.h b/src/pc/network/network.h index 20367f4b8..11ee7c573 100644 --- a/src/pc/network/network.h +++ b/src/pc/network/network.h @@ -88,6 +88,7 @@ struct ServerSettings { u8 skipIntro; u8 shareLives; u8 enableCheats; + u8 bubbleDeath; }; // Networking-specific externs diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 17723c0d8..62fe90ffa 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -92,6 +92,7 @@ void network_send_join(struct Packet* joinRequestPacket) { packet_write(&p, &gServerSettings.skipIntro, sizeof(u8)); packet_write(&p, &gServerSettings.shareLives, sizeof(u8)); packet_write(&p, &gServerSettings.enableCheats, sizeof(u8)); + packet_write(&p, &gServerSettings.bubbleDeath, sizeof(u8)); packet_write(&p, eeprom, sizeof(u8) * 512); u8 modCount = string_linked_list_count(&gRegisteredMods); @@ -153,6 +154,7 @@ void network_receive_join(struct Packet* p) { packet_read(p, &gServerSettings.skipIntro, sizeof(u8)); packet_read(p, &gServerSettings.shareLives, sizeof(u8)); packet_read(p, &gServerSettings.enableCheats, sizeof(u8)); + packet_read(p, &gServerSettings.bubbleDeath, sizeof(u8)); packet_read(p, eeprom, sizeof(u8) * 512); packet_read(p, &modCount, sizeof(u8));