Use proper scoring system in GP

This commit is contained in:
Sally Coolatta 2020-05-09 22:33:10 -04:00
parent c1e8cc108f
commit 8bb145e249
4 changed files with 130 additions and 79 deletions

View file

@ -3629,7 +3629,7 @@ void G_AddMapToBuffer(INT16 map)
static void G_DoCompleted(void)
{
INT32 i, j = 0;
SINT8 powertype = PWRLV_DISABLED;
SINT8 powertype = K_UsingPowerLevels();
tokenlist = 0; // Reset the list
@ -3762,14 +3762,6 @@ static void G_DoCompleted(void)
P_AllocMapHeader(nextmap);
// Set up power level gametype scrambles
if (netgame && cv_kartusepwrlv.value)
{
if (G_RaceGametype())
powertype = PWRLV_RACE;
else if (G_BattleGametype())
powertype = PWRLV_BATTLE;
}
K_SetPowerLevelScrambles(powertype);
demointermission:

View file

@ -8,6 +8,7 @@
#include "m_random.h"
#include "m_cond.h" // M_UpdateUnlockablesAndExtraEmblems
#include "p_tick.h" // leveltime
#include "k_grandprix.h"
// Online rankings for the main gametypes.
// This array is saved to the gamedata.
@ -25,6 +26,27 @@ INT16 nospectategrief[MAXPLAYERS];
SINT8 speedscramble = -1;
SINT8 encorescramble = -1;
SINT8 K_UsingPowerLevels(void)
{
SINT8 pt = PWRLV_DISABLED;
if (!cv_kartusepwrlv.value || !netgame || grandprixinfo.roundnum > 0)
{
return PWRLV_DISABLED;
}
if (G_RaceGametype())
{
pt = PWRLV_RACE;
}
else if (G_BattleGametype())
{
pt = PWRLV_BATTLE;
}
return pt;
}
void K_ClearClientPowerLevels(void)
{
UINT8 i, j;

View file

@ -21,6 +21,7 @@ extern UINT16 vspowerlevel[PWRLV_NUMTYPES];
extern UINT16 clientpowerlevels[MAXPLAYERS][PWRLV_NUMTYPES];
extern INT16 nospectategrief[MAXPLAYERS];
SINT8 K_UsingPowerLevels(void);
void K_ClearClientPowerLevels(void);
INT16 K_CalculatePowerLevelInc(INT16 diff);
INT16 K_CalculatePowerLevelAvg(void);

View file

@ -43,6 +43,7 @@
#include "k_pwrlv.h"
#include "console.h" // cons_menuhighlight
#include "lua_hook.h" // IntermissionThinker hook
#include "k_grandprix.h"
#ifdef HWRENDER
#include "hardware/hw_main.h"
@ -198,7 +199,12 @@ static void Y_CompareScore(INT32 i)
static void Y_CompareRank(INT32 i)
{
INT16 increase = ((data.match.increase[i] == INT16_MIN) ? 0 : data.match.increase[i]);
UINT32 score = (powertype != -1 ? clientpowerlevels[i][powertype] : players[i].score);
UINT32 score = players[i].score;
if (powertype != PWRLV_DISABLED)
{
score = clientpowerlevels[i][powertype];
}
if (!(data.match.val[data.match.numplayers] == UINT32_MAX || (score - increase) > data.match.val[data.match.numplayers]))
return;
@ -306,14 +312,18 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
else
data.match.pos[data.match.numplayers] = data.match.numplayers+1;
if ((!rankingsmode && powertype == -1) // Single player rankings (grand prix). Online rank is handled below.
&& !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] < (numplayersingame + numgriefers)))
if ((powertype == PWRLV_DISABLED)
&& (!rankingsmode)
&& !(players[i].pflags & PF_TIMEOVER)
&& (data.match.pos[data.match.numplayers] < (numplayersingame + numgriefers)))
{
// Single player rankings (grand prix). Online rank is handled below.
data.match.increase[i] = (numplayersingame + numgriefers) - data.match.pos[data.match.numplayers];
players[i].score += data.match.increase[i];
}
if (demo.recording && !rankingsmode)
{
G_WriteStanding(
data.match.pos[data.match.numplayers],
data.match.name[data.match.numplayers],
@ -321,6 +331,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
*data.match.color[data.match.numplayers],
data.match.val[data.match.numplayers]
);
}
data.match.numplayers++;
}
@ -440,9 +451,36 @@ void Y_IntermissionDrawer(void)
int y2;
if (data.match.rankingsmode)
timeheader = "PWR.LV";
{
if (powertype == PWRLV_DISABLED)
{
timeheader = "RANK";
}
else
{
timeheader = "PWR.LV";
}
}
else
timeheader = ((intertype == int_race || (intertype == int_match && battlecapsules)) ? "TIME" : "SCORE");
{
switch (intertype)
{
default:
case int_race:
timeheader = "TIME";
break;
case int_match:
if (battlecapsules)
{
timeheader = "TIME";
}
else
{
timeheader = "SCORE";
}
break;
}
}
// draw the level name
V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12, 0, data.match.levelstring);
@ -533,8 +571,11 @@ void Y_IntermissionDrawer(void)
if (data.match.rankingsmode)
{
if (!clientpowerlevels[data.match.num[i]][powertype]) // No power level (splitscreen guests)
if (powertype != PWRLV_DISABLED && !clientpowerlevels[data.match.num[i]][powertype])
{
// No power level (splitscreen guests)
STRBUFCPY(strtime, "----");
}
else
{
if (data.match.increase[data.match.num[i]] != INT16_MIN)
@ -600,7 +641,7 @@ void Y_IntermissionDrawer(void)
}
dotimer:
if (timer)
if (timer && grandprixinfo.roundnum == 0)
{
char *string;
INT32 tickdown = (timer+1)/TICRATE;
@ -705,74 +746,73 @@ void Y_Ticker(void)
if (intertype == int_race || intertype == int_match)
{
if (netgame || multiplayer)
if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays
{
if (sorttic == -1)
sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results
else if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays
if (!data.match.rankingsmode && (intertic >= sorttic + 8))
{
if (!data.match.rankingsmode && (intertic >= sorttic + 8))
Y_CalculateMatchData(1, Y_CompareRank);
Y_CalculateMatchData(1, Y_CompareRank);
}
if (data.match.rankingsmode && intertic > sorttic+16+(2*TICRATE))
if (data.match.rankingsmode && intertic > sorttic+16+(2*TICRATE))
{
INT32 q=0,r=0;
boolean kaching = true;
for (q = 0; q < data.match.numplayers; q++)
{
INT32 q=0,r=0;
boolean kaching = true;
for (q = 0; q < data.match.numplayers; q++)
{
if (data.match.num[q] == MAXPLAYERS
if (data.match.num[q] == MAXPLAYERS
|| !data.match.increase[data.match.num[q]]
|| data.match.increase[data.match.num[q]] == INT16_MIN)
continue;
{
continue;
}
r++;
data.match.jitter[data.match.num[q]] = 1;
r++;
data.match.jitter[data.match.num[q]] = 1;
if (powertype != -1)
if (powertype != PWRLV_DISABLED)
{
// Power Levels
if (abs(data.match.increase[data.match.num[q]]) < 10)
{
// Power Levels
if (abs(data.match.increase[data.match.num[q]]) < 10)
{
// Not a lot of point increase left, just set to 0 instantly
data.match.increase[data.match.num[q]] = 0;
}
else
{
SINT8 remove = 0; // default (should not happen)
if (data.match.increase[data.match.num[q]] < 0)
remove = -10;
else if (data.match.increase[data.match.num[q]] > 0)
remove = 10;
// Remove 10 points at a time
data.match.increase[data.match.num[q]] -= remove;
// Still not zero, no kaching yet
if (data.match.increase[data.match.num[q]] != 0)
kaching = false;
}
// Not a lot of point increase left, just set to 0 instantly
data.match.increase[data.match.num[q]] = 0;
}
else
{
// Basic bitch points
if (data.match.increase[data.match.num[q]])
{
if (--data.match.increase[data.match.num[q]])
kaching = false;
}
SINT8 remove = 0; // default (should not happen)
if (data.match.increase[data.match.num[q]] < 0)
remove = -10;
else if (data.match.increase[data.match.num[q]] > 0)
remove = 10;
// Remove 10 points at a time
data.match.increase[data.match.num[q]] -= remove;
// Still not zero, no kaching yet
if (data.match.increase[data.match.num[q]] != 0)
kaching = false;
}
}
if (r)
{
S_StartSound(NULL, (kaching ? sfx_chchng : sfx_ptally));
Y_CalculateMatchData(2, Y_CompareRank);
}
else
endtic = intertic + 3*TICRATE; // 3 second pause after end of tally
{
// Basic bitch points
if (data.match.increase[data.match.num[q]])
{
if (--data.match.increase[data.match.num[q]])
kaching = false;
}
}
}
if (r)
{
S_StartSound(NULL, (kaching ? sfx_chchng : sfx_ptally));
Y_CalculateMatchData(2, Y_CompareRank);
}
else
endtic = intertic + 3*TICRATE; // 3 second pause after end of tally
}
}
else
@ -1043,19 +1083,11 @@ void Y_StartIntermission(void)
#endif
// set player Power Level type
powertype = PWRLV_DISABLED;
if (netgame && cv_kartusepwrlv.value)
{
if (G_RaceGametype())
powertype = PWRLV_RACE;
else if (G_BattleGametype())
powertype = PWRLV_BATTLE;
}
powertype = K_UsingPowerLevels();
if (!multiplayer)
{
timer = 0;
timer = 20*TICRATE;
if (!majormods && !multiplayer && !demo.playback) // move this once we have a proper time attack screen
{
@ -1074,7 +1106,7 @@ void Y_StartIntermission(void)
}
else
{
if (cv_inttime.value == 0 && gametype == GT_COOP)
if (cv_inttime.value == 0)
timer = 0;
else if (demo.playback) // Override inttime (which is pulled from the replay anyway
timer = 10*TICRATE;
@ -1087,6 +1119,8 @@ void Y_StartIntermission(void)
}
}
sorttic = max((timer/2) - 2*TICRATE, 2*TICRATE); // 8 second pause after match results
if (gametype == GT_MATCH)
intertype = int_match;
else //if (gametype == GT_RACE)
@ -1132,7 +1166,9 @@ void Y_StartIntermission(void)
}
if (powertype != PWRLV_DISABLED)
{
K_UpdatePowerLevels();
}
//if (intertype == int_race || intertype == int_match)
{