From 435862b29d40e9ed0341c897ffc3779935160882 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Fri, 26 Apr 2019 13:34:30 -0400 Subject: [PATCH] finished scrambles --- src/d_netcmd.c | 3 + src/d_netcmd.h | 2 + src/doomstat.h | 3 + src/g_game.c | 6 +- src/k_kart.c | 5 ++ src/p_setup.c | 9 ++- src/y_inter.c | 149 ++++++++++++++++++++++++++----------------------- 7 files changed, 103 insertions(+), 74 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 46a57b340..2606311af 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -369,7 +369,10 @@ static CV_PossibleValue_t kartvoices_cons_t[] = {{0, "Never"}, {1, "Tasteful"}, consvar_t cv_kartvoices = {"kartvoices", "Tasteful", CV_SAVE, kartvoices_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL|CV_NOSHOWHELP, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_kartusepwrlv = {"kartusepwrlv", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_speedscramble = {"kartscramblespeed", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_encorescramble = {"kartscrambleencore", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugitem_cons_t[] = {{-1, "MIN"}, {NUMKARTITEMS-1, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index aa5f08b2b..24bc0a31b 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -122,6 +122,8 @@ extern consvar_t cv_kartspeedometer; extern consvar_t cv_kartvoices; extern consvar_t cv_karteliminatelast; extern consvar_t cv_kartusepwrlv; +extern consvar_t cv_speedscramble; +extern consvar_t cv_encorescramble; extern consvar_t cv_votetime; diff --git a/src/doomstat.h b/src/doomstat.h index 139660cc9..43cadcda5 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -474,6 +474,9 @@ extern INT16 nospectategrief[MAXPLAYERS]; extern boolean thwompsactive; extern SINT8 spbplace; +extern SINT8 speedscramble; +extern SINT8 encorescramble; + extern boolean legitimateexit; extern boolean comebackshowninfo; extern tic_t curlap, bestlap; diff --git a/src/g_game.c b/src/g_game.c index 95b4c4b8d..39d7f2957 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -274,8 +274,8 @@ boolean thwompsactive; // Thwomps activate on lap 2 SINT8 spbplace; // SPB exists, give the person behind better items // Scrambles -SINT8 speedscramble; -SINT8 encorescramble; +SINT8 speedscramble = -1; +SINT8 encorescramble = -1; // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? @@ -3210,7 +3210,7 @@ INT16 G_SometimesGetDifferentGametype(void) if (encorepossible) { if (encorescramble >= 0) - encorepossible = (boolean)encorescramble; + encorepossible = (boolean)encorescramble; // FORCE to what was scrambled on intermission else { switch (cv_kartvoterulechanges.value) diff --git a/src/k_kart.c b/src/k_kart.c index 8ff2db66d..742c3417a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -545,6 +545,8 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartvoices); CV_RegisterVar(&cv_karteliminatelast); CV_RegisterVar(&cv_kartusepwrlv); + CV_RegisterVar(&cv_speedscramble); + CV_RegisterVar(&cv_encorescramble); CV_RegisterVar(&cv_votetime); CV_RegisterVar(&cv_kartdebugitem); @@ -6137,6 +6139,9 @@ INT16 K_CalculatePowerLevelAvg(void) div++; } + if (!div) + return 0; // No average. + avg /= div; return (INT16)(avg >> FRACBITS); diff --git a/src/p_setup.c b/src/p_setup.c index 9e8cd3c08..5c42b437a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2370,13 +2370,20 @@ static void P_LevelInitStuff(void) if (G_BattleGametype()) gamespeed = 0; else - gamespeed = (UINT8)cv_kartspeed.value; + { + if (cv_speedscramble.value && speedscramble != -1) + gamespeed = (UINT8)speedscramble; + else + gamespeed = (UINT8)cv_kartspeed.value; + } franticitems = (boolean)cv_kartfrantic.value; comeback = (boolean)cv_kartcomeback.value; } for (i = 0; i < 4; i++) battlewanted[i] = -1; + + speedscramble = encorescramble = -1; } // diff --git a/src/y_inter.c b/src/y_inter.c index 67c4b797b..19189e0c3 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -705,7 +705,7 @@ dotimer: if (timer) { INT32 tickdown = (timer+1)/TICRATE; - V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, + V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol|V_SNAPTOBOTTOM, va("%s starts in %d", cv_advancemap.string, tickdown)); } @@ -714,9 +714,9 @@ dotimer: { /*if (cv_scrambleonchange.value && cv_teamscramble.value) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol, M_GetText("Teams will be scrambled next round!"));*/ - if (speedscramble != -1) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, hilicol|V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, - M_GetText("The next race will be %s Speed!", (speedscramble == 2 ? "Hard" : "Normal"))); + if (speedscramble != -1 && speedscramble != gamespeed) + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, hilicol|V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, + va(M_GetText("Next race will be %s Speed!"), kartspeed_cons_t[speedscramble].strvalue)); } } @@ -949,78 +949,87 @@ void Y_StartIntermission(void) powertype = 0; else if (G_BattleGametype()) powertype = 1; + } - // Race scrambles - if ((intertype == int_race) && (cv_speedscramble.value || cv_encorescramble.value)) + // Race scrambles + if (powertype == 0 && (cv_speedscramble.value || cv_encorescramble.value)) + { + boolean hardmode = false; + boolean encore = false; + INT16 avg = 0, min = 0; + UINT8 i, t = 0; + + avg = K_CalculatePowerLevelAvg(); + + for (i = 0; i < MAXPLAYERS; i++) { - boolean hardmode = false; - boolean encore = false; - INT16 avg = 0, min = 0; - UINT8 i, t = 0; + if (min == 0 || clientpowerlevels[i][0] < min) + min = clientpowerlevels[i][0]; + } - avg = K_CalculatePowerLevelAvg(); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (min == 0 || clientpowerlevels[i][0] < min) - min = clientpowerlevels[i][0]; - } - - if (min >= 4000) - { - if (avg >= 5000) - t = 3; - else - t = 2; - } - else if (min >= 2500) - { - if (avg >= 3000) - t = 2; - else - t = 1; - } - else if (min >= 500) - { - if (avg >= 2000) - t = 1; - else - t = 0; - } + if (min >= 6000) + { + if (avg >= 8000) + t = 4; + else + t = 3; + } + else if (min >= 4000) + { + if (avg >= 5000) + t = 3; + else + t = 2; + } + else if (min >= 2500) + { + if (avg >= 3000) + t = 2; + else + t = 1; + } + else if (min >= 500) + { + if (avg >= 2000) + t = 1; else t = 0; - - switch (t) - { - case 3: - hardmode = true; - encore = M_RandomChance(FRACUNIT>>1); - break; - case 2: - hardmode = M_RandomChance((7<>2); - break; - case 1: - hardmode = M_RandomChance((3<>1); + break; + case 2: + hardmode = M_RandomChance((7<>2); + break; + case 1: + hardmode = M_RandomChance((3<