Speed/Encore scrambles based on power level

Did not test yet
This commit is contained in:
TehRealSalt 2019-04-24 01:47:43 -04:00
parent 6f6bc3333f
commit 5abe25d0a5
4 changed files with 140 additions and 15 deletions

View file

@ -273,6 +273,10 @@ INT16 nospectategrief[MAXPLAYERS]; // Which players spec-scummed, and their powe
boolean thwompsactive; // Thwomps activate on lap 2 boolean thwompsactive; // Thwomps activate on lap 2
SINT8 spbplace; // SPB exists, give the person behind better items SINT8 spbplace; // SPB exists, give the person behind better items
// Scrambles
SINT8 speedscramble;
SINT8 encorescramble;
// Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) // 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? boolean legitimateexit; // Did this client actually finish the match?
boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message? boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message?
@ -3194,9 +3198,10 @@ boolean G_BattleGametype(void)
// //
INT16 G_SometimesGetDifferentGametype(void) INT16 G_SometimesGetDifferentGametype(void)
{ {
boolean encorepossible = (M_SecretUnlocked(SECRET_ENCORE) && G_RaceGametype()); boolean encorepossible = ((M_SecretUnlocked(SECRET_ENCORE) || encorescramble == 1) && G_RaceGametype());
if (!cv_kartvoterulechanges.value) // never if (!cv_kartvoterulechanges.value // never
&& encorescramble != 1) // destroying the code for this one instance
return gametype; return gametype;
if (randmapbuffer[NUMMAPS] > 0 && (encorepossible || cv_kartvoterulechanges.value != 3)) if (randmapbuffer[NUMMAPS] > 0 && (encorepossible || cv_kartvoterulechanges.value != 3))
@ -3204,18 +3209,23 @@ INT16 G_SometimesGetDifferentGametype(void)
randmapbuffer[NUMMAPS]--; randmapbuffer[NUMMAPS]--;
if (encorepossible) if (encorepossible)
{ {
switch (cv_kartvoterulechanges.value) if (encorescramble >= 0)
encorepossible = (boolean)encorescramble;
else
{ {
case 3: // always switch (cv_kartvoterulechanges.value)
randmapbuffer[NUMMAPS] = 0; // gotta prep this in case it isn't already set {
break; case 3: // always
case 2: // frequent randmapbuffer[NUMMAPS] = 0; // gotta prep this in case it isn't already set
encorepossible = M_RandomChance(FRACUNIT>>1); break;
break; case 2: // frequent
case 1: // sometimes encorepossible = M_RandomChance(FRACUNIT>>1);
default: break;
encorepossible = M_RandomChance(FRACUNIT>>2); case 1: // sometimes
break; default:
encorepossible = M_RandomChance(FRACUNIT>>2);
break;
}
} }
if (encorepossible != (boolean)cv_kartencore.value) if (encorepossible != (boolean)cv_kartencore.value)
return (gametype|0x80); return (gametype|0x80);
@ -3223,6 +3233,9 @@ INT16 G_SometimesGetDifferentGametype(void)
return gametype; return gametype;
} }
if (!cv_kartvoterulechanges.value) // never (again)
return gametype;
switch (cv_kartvoterulechanges.value) // okay, we're having a gametype change! when's the next one, luv? switch (cv_kartvoterulechanges.value) // okay, we're having a gametype change! when's the next one, luv?
{ {
case 3: // always case 3: // always

View file

@ -6109,6 +6109,39 @@ INT16 K_CalculatePowerLevelInc(INT16 diff)
return (INT16)(increment >> FRACBITS); return (INT16)(increment >> FRACBITS);
} }
INT16 K_CalculatePowerLevelAvg(void)
{
fixed_t avg = 0;
UINT8 div = 0;
SINT8 t = -1;
UINT8 i;
if (!netgame || !cv_kartusepwrlv.value)
return 0; // No average.
if (G_RaceGametype())
t = 0;
else if (G_BattleGametype())
t = 1;
if (t == -1)
return 0; // Hmm?!
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator
|| clientpowerlevels[i][t] == 0)
continue;
avg += clientpowerlevels[i][t];
div++;
}
avg /= div;
return (INT16)(avg >> FRACBITS);
}
void K_PlayerForfeit(UINT8 playernum, boolean pointloss) void K_PlayerForfeit(UINT8 playernum, boolean pointloss)
{ {
UINT8 p = 0; UINT8 p = 0;

View file

@ -66,6 +66,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground);
void K_CalculateBattleWanted(void); void K_CalculateBattleWanted(void);
void K_CheckBumpers(void); void K_CheckBumpers(void);
INT16 K_CalculatePowerLevelInc(INT16 diff); INT16 K_CalculatePowerLevelInc(INT16 diff);
INT16 K_CalculatePowerLevelAvg(void);
void K_PlayerForfeit(UINT8 playernum, boolean nopointloss); void K_PlayerForfeit(UINT8 playernum, boolean nopointloss);
void K_CheckSpectateStatus(void); void K_CheckSpectateStatus(void);

View file

@ -710,8 +710,14 @@ dotimer:
} }
// Make it obvious that scrambling is happening next round. // Make it obvious that scrambling is happening next round.
if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) if ((intertic/TICRATE) & 1)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol, M_GetText("Teams will be scrambled next round!")); {
/*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")));
}
} }
// //
@ -943,6 +949,78 @@ void Y_StartIntermission(void)
powertype = 0; powertype = 0;
else if (G_BattleGametype()) else if (G_BattleGametype())
powertype = 1; powertype = 1;
// Race scrambles
if ((intertype == int_race) && (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++)
{
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;
}
else
t = 0;
switch (t)
{
case 3:
hardmode = true;
encore = M_RandomChance(FRACUNIT>>1);
break;
case 2:
hardmode = M_RandomChance((7<<FRACBITS)/10);
encore = M_RandomChance(FRACUNIT>>2);
break;
case 1:
hardmode = M_RandomChance((3<<FRACBITS)/10);
encore = false;
break;
case 0:
default:
hardmode = false;
encore = false;
break;
}
if (cv_speedscramble.value)
speedscramble = (hardmode ? 2 : 1);
else
speedscramble = -1;
if (cv_encorescramble.value)
encorescramble = (encore ? 1 : 0);
else
encorescramble = -1;
}
} }
if (!multiplayer) if (!multiplayer)