mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Improvements to power level updating & forfeit handling
This commit is contained in:
parent
e22c6448fe
commit
a55fb0729d
2 changed files with 135 additions and 77 deletions
14
src/k_kart.c
14
src/k_kart.c
|
|
@ -5783,8 +5783,9 @@ INT16 K_CalculatePowerLevelInc(INT16 diff)
|
||||||
return (INT16)(increment >> FRACBITS);
|
return (INT16)(increment >> FRACBITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_PlayerForfeit(UINT8 playernum, boolean nopointloss)
|
void K_PlayerForfeit(UINT8 playernum, boolean pointloss)
|
||||||
{
|
{
|
||||||
|
UINT8 p = 0;
|
||||||
INT32 powertype = -1;
|
INT32 powertype = -1;
|
||||||
UINT16 yourpower = 5000;
|
UINT16 yourpower = 5000;
|
||||||
UINT16 theirpower = 5000;
|
UINT16 theirpower = 5000;
|
||||||
|
|
@ -5800,6 +5801,15 @@ void K_PlayerForfeit(UINT8 playernum, boolean nopointloss)
|
||||||
if (gamestate != GS_LEVEL || leveltime <= starttime+(20*TICRATE))
|
if (gamestate != GS_LEVEL || leveltime <= starttime+(20*TICRATE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (playeringame[i] && !players[i].spectator)
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p < 2) // no players
|
||||||
|
return;
|
||||||
|
|
||||||
if (G_RaceGametype())
|
if (G_RaceGametype())
|
||||||
powertype = 0;
|
powertype = 0;
|
||||||
else if (G_BattleGametype())
|
else if (G_BattleGametype())
|
||||||
|
|
@ -5815,7 +5825,7 @@ void K_PlayerForfeit(UINT8 playernum, boolean nopointloss)
|
||||||
// Set up the point compensation.
|
// Set up the point compensation.
|
||||||
nospectategrief[playernum] = yourpower;
|
nospectategrief[playernum] = yourpower;
|
||||||
|
|
||||||
if (nopointloss) // This is set for stuff like sync-outs, which shouldn't be so harsh on the victim!
|
if (!pointloss) // This is set for stuff like sync-outs, which shouldn't be so harsh on the victim!
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
|
|
||||||
198
src/y_inter.c
198
src/y_inter.c
|
|
@ -196,10 +196,7 @@ static void Y_CompareRank(INT32 i)
|
||||||
INT16 increase = ((data.match.increase[i] == INT16_MIN) ? 0 : data.match.increase[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 = (powertype != -1 ? clientpowerlevels[i][powertype] : players[i].score);
|
||||||
|
|
||||||
if (!(data.match.val[data.match.numplayers] == UINT32_MAX))
|
if (!(data.match.val[data.match.numplayers] == UINT32_MAX || (score - increase) > data.match.val[data.match.numplayers]))
|
||||||
return;
|
|
||||||
|
|
||||||
if (powertype == -1 && (players[i].score - increase) > data.match.val[data.match.numplayers])
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data.match.val[data.match.numplayers] = (score - increase);
|
data.match.val[data.match.numplayers] = (score - increase);
|
||||||
|
|
@ -314,103 +311,151 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
|
||||||
|
|
||||||
data.match.numplayers++;
|
data.match.numplayers++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Y_UpdatePowerLevels(void)
|
||||||
|
{
|
||||||
|
INT32 i, j;
|
||||||
|
INT32 numplayersingame = 0, numgriefers = 0;
|
||||||
|
INT16 increment[MAXPLAYERS];
|
||||||
|
|
||||||
// Compare every single player against each other for power level increases.
|
// Compare every single player against each other for power level increases.
|
||||||
// Every player you won against gives you more points, and vice versa.
|
// Every player you won against gives you more points, and vice versa.
|
||||||
// The amount of points won per match-up depends on the difference between the loser's power and the winner's power.
|
// The amount of points won per match-up depends on the difference between the loser's power and the winner's power.
|
||||||
// See K_CalculatePowerLevelInc for more info.
|
// See K_CalculatePowerLevelInc for more info.
|
||||||
// (I'm bad at understanding this code, so I had no idea how to incorporate it with the above loop properly.)
|
|
||||||
|
|
||||||
if (!rankingsmode && powertype != -1)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < numplayersingame; i++)
|
increment[i] = 0;
|
||||||
|
|
||||||
|
if (nospectategrief[i] != -1)
|
||||||
|
numgriefers++;
|
||||||
|
|
||||||
|
if (!playeringame[i] || players[i].spectator)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
numplayersingame++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < numplayersingame; i++)
|
||||||
|
{
|
||||||
|
UINT16 yourpower = 5000;
|
||||||
|
UINT16 theirpower = 5000;
|
||||||
|
INT16 diff = 0; // Loser PWR.LV - Winner PWR.LV
|
||||||
|
INT16 inc = 0; // Total pt increment
|
||||||
|
UINT8 ipnum = data.match.num[i];
|
||||||
|
UINT8 jpnum;
|
||||||
|
|
||||||
|
CONS_Printf("Power Level Gain for player %d:\n", ipnum);
|
||||||
|
|
||||||
|
if (clientpowerlevels[ipnum][powertype] == 0) // splitscreen guests don't record power level changes
|
||||||
|
continue;
|
||||||
|
yourpower = clientpowerlevels[ipnum][powertype];
|
||||||
|
|
||||||
|
CONS_Printf("Player %d's PWR.LV: %d\n", ipnum, yourpower);
|
||||||
|
|
||||||
|
for (j = 0; j < numplayersingame; j++)
|
||||||
{
|
{
|
||||||
UINT16 yourpower = 5000;
|
boolean won = false;
|
||||||
UINT16 theirpower = 5000;
|
|
||||||
INT16 diff = 0; // Loser PWR.LV - Winner PWR.LV
|
|
||||||
INT16 inc = 0; // Total pt increment
|
|
||||||
|
|
||||||
if (clientpowerlevels[i][powertype] == 0) // splitscreen guests don't record power level changes
|
jpnum = data.match.num[j];
|
||||||
|
|
||||||
|
if (i == j || ipnum == jpnum) // Same person
|
||||||
continue;
|
continue;
|
||||||
yourpower = clientpowerlevels[i][powertype];
|
|
||||||
|
|
||||||
for (j = 0; j < numplayersingame; j++)
|
CONS_Printf("Player %d VS Player %d:\n", ipnum, jpnum);
|
||||||
|
|
||||||
|
if (data.match.val[i] == data.match.val[j]) // Tie -- neither get any points for this match up.
|
||||||
{
|
{
|
||||||
boolean won = false;
|
CONS_Printf("TIE, no change.\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == j) // Same person
|
theirpower = 5000;
|
||||||
|
if (clientpowerlevels[jpnum][powertype] != 0) // No power level acts as 5000 (used for splitscreen guests)
|
||||||
|
theirpower = clientpowerlevels[jpnum][powertype];
|
||||||
|
CONS_Printf("Player %d's PWR.LV: %d\n", jpnum, theirpower);
|
||||||
|
|
||||||
|
if (G_RaceGametype())
|
||||||
|
{
|
||||||
|
if (data.match.val[i] < data.match.val[j])
|
||||||
|
won = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (data.match.val[i] > data.match.val[j])
|
||||||
|
won = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (won) // This player won!
|
||||||
|
{
|
||||||
|
diff = theirpower - yourpower;
|
||||||
|
inc += K_CalculatePowerLevelInc(diff);
|
||||||
|
CONS_Printf("WON! Diff is %d, total increment is %d\n", diff, inc);
|
||||||
|
}
|
||||||
|
else // This player lost...
|
||||||
|
{
|
||||||
|
diff = yourpower - theirpower;
|
||||||
|
inc -= K_CalculatePowerLevelInc(diff);
|
||||||
|
CONS_Printf("LOST... Diff is %d, total increment is %d\n", diff, inc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numgriefers != 0) // Automatic win against quitters.
|
||||||
|
{
|
||||||
|
for (jpnum = 0; jpnum < MAXPLAYERS; jpnum++)
|
||||||
|
{
|
||||||
|
if (nospectategrief[jpnum] == -1) // Empty slot
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (data.match.val[i] == data.match.val[j]) // Tie -- neither get any points for this match up.
|
if (ipnum == jpnum) // Same person
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
CONS_Printf("Player %d VS Player %d (griefer):\n", ipnum, jpnum);
|
||||||
|
|
||||||
theirpower = 5000;
|
theirpower = 5000;
|
||||||
if (clientpowerlevels[j][powertype] != 0) // No power level acts as 5000 (used for splitscreen guests)
|
if (nospectategrief[jpnum] != 0) // No power level acts as 5000 (used for splitscreen guests)
|
||||||
theirpower = clientpowerlevels[j][powertype];
|
theirpower = nospectategrief[jpnum];
|
||||||
|
CONS_Printf("Player %d's PWR.LV: %d\n", jpnum, theirpower);
|
||||||
|
|
||||||
if (G_RaceGametype())
|
diff = theirpower - yourpower;
|
||||||
{
|
inc += K_CalculatePowerLevelInc(diff);
|
||||||
if (data.match.val[i] < data.match.val[j])
|
CONS_Printf("AUTO-WON! Diff is %d, total increment is %d\n", diff, inc);
|
||||||
won = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (data.match.val[i] > data.match.val[j])
|
|
||||||
won = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (won) // This player won!
|
|
||||||
{
|
|
||||||
diff = theirpower - yourpower;
|
|
||||||
inc += K_CalculatePowerLevelInc(diff);
|
|
||||||
}
|
|
||||||
else // This player lost...
|
|
||||||
{
|
|
||||||
diff = yourpower - theirpower;
|
|
||||||
inc -= K_CalculatePowerLevelInc(diff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (numgriefers != 0) // Automatic win against quitters.
|
if (inc == 0)
|
||||||
{
|
{
|
||||||
for (j = 0; j < MAXPLAYERS; j++)
|
data.match.increase[ipnum] = INT16_MIN;
|
||||||
{
|
CONS_Printf("Total Result: No increment, no change.\n");
|
||||||
if (nospectategrief[j] == -1) // Empty slot
|
continue;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (i == j) // Yourself??
|
if (yourpower + inc > 9999)
|
||||||
continue;
|
inc -= ((yourpower + inc) - 9999);
|
||||||
|
if (yourpower + inc < 1)
|
||||||
|
inc -= ((yourpower + inc) - 1);
|
||||||
|
|
||||||
theirpower = 5000;
|
CONS_Printf("Total Result: Increment of %d.\n", inc);
|
||||||
if (nospectategrief[j] != 0) // No power level acts as 5000 (used for splitscreen guests)
|
increment[ipnum] = inc;
|
||||||
theirpower = nospectategrief[j];
|
}
|
||||||
|
|
||||||
diff = theirpower - yourpower;
|
CONS_Printf("Setting final power levels...\n", inc);
|
||||||
inc += K_CalculatePowerLevelInc(diff);
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
}
|
{
|
||||||
}
|
if (increment[i] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (inc == 0)
|
data.match.increase[i] = increment[i];
|
||||||
{
|
clientpowerlevels[i][powertype] += data.match.increase[i];
|
||||||
data.match.increase[i] = INT16_MIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (yourpower + inc > 9999)
|
if (i == consoleplayer)
|
||||||
inc -= ((yourpower + inc) - 9999);
|
{
|
||||||
if (yourpower + inc < 1)
|
CONS_Printf("Player %d is you! Saving...\n", i);
|
||||||
inc -= ((yourpower + inc) - 1);
|
vspowerlevel[powertype] = clientpowerlevels[i][powertype];
|
||||||
|
if (M_UpdateUnlockablesAndExtraEmblems(true))
|
||||||
data.match.increase[i] = inc;
|
S_StartSound(NULL, sfx_ncitem);
|
||||||
clientpowerlevels[i][powertype] += data.match.increase[i];
|
G_SaveGameData(true);
|
||||||
|
|
||||||
if (i == consoleplayer)
|
|
||||||
{
|
|
||||||
vspowerlevel[powertype] = clientpowerlevels[i][powertype];
|
|
||||||
if (M_UpdateUnlockablesAndExtraEmblems(true))
|
|
||||||
S_StartSound(NULL, sfx_ncitem);
|
|
||||||
G_SaveGameData(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -939,6 +984,9 @@ void Y_StartIntermission(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (powertype != -1)
|
||||||
|
Y_UpdatePowerLevels();
|
||||||
|
|
||||||
//if (intertype == int_race || intertype == int_match)
|
//if (intertype == int_race || intertype == int_match)
|
||||||
{
|
{
|
||||||
//bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
|
//bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue