mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-09 02:11:49 +00:00
Sort wanted players by bumpers & emeralds first
This commit is contained in:
parent
ea14d6bb1c
commit
7bff7931ed
2 changed files with 40 additions and 29 deletions
|
|
@ -58,24 +58,19 @@ boolean K_IsPlayerWanted(player_t *player)
|
||||||
|
|
||||||
void K_CalculateBattleWanted(void)
|
void K_CalculateBattleWanted(void)
|
||||||
{
|
{
|
||||||
UINT8 numingame = 0, numplaying = 0, numwanted = 0;
|
UINT8 numingame = 0, numwanted = 0;
|
||||||
SINT8 bestbumperplayer = -1, bestbumper = -1;
|
|
||||||
SINT8 camppos[MAXPLAYERS]; // who is the biggest camper
|
SINT8 camppos[MAXPLAYERS]; // who is the biggest camper
|
||||||
UINT8 ties = 0, nextcamppos = 0;
|
UINT8 ties = 0, nextcamppos = 0;
|
||||||
boolean setbumper = false;
|
|
||||||
UINT8 i, j;
|
UINT8 i, j;
|
||||||
|
|
||||||
if (!(gametyperules & GTR_WANTED))
|
if (!(gametyperules & GTR_WANTED))
|
||||||
{
|
{
|
||||||
for (i = 0; i < 4; i++)
|
memset(battlewanted, -1, sizeof (battlewanted));
|
||||||
battlewanted[i] = -1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wantedcalcdelay = wantedfrequency;
|
wantedcalcdelay = wantedfrequency;
|
||||||
|
memset(camppos, -1, sizeof (camppos)); // initialize
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
camppos[i] = -1; // initialize
|
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -87,33 +82,38 @@ void K_CalculateBattleWanted(void)
|
||||||
if (players[i].exiting) // We're done, don't calculate.
|
if (players[i].exiting) // We're done, don't calculate.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
numplaying++;
|
|
||||||
|
|
||||||
if (players[i].bumpers <= 0) // Not alive, so don't do anything else
|
if (players[i].bumpers <= 0) // Not alive, so don't do anything else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
numingame++;
|
numingame++;
|
||||||
|
|
||||||
if (bestbumper == -1 || players[i].bumpers > bestbumper)
|
|
||||||
{
|
|
||||||
bestbumper = players[i].bumpers;
|
|
||||||
bestbumperplayer = i;
|
|
||||||
}
|
|
||||||
else if (players[i].bumpers == bestbumper)
|
|
||||||
bestbumperplayer = -1; // Tie, no one has best bumper.
|
|
||||||
|
|
||||||
for (j = 0; j < MAXPLAYERS; j++)
|
for (j = 0; j < MAXPLAYERS; j++)
|
||||||
{
|
{
|
||||||
if (!playeringame[j] || players[j].spectator)
|
if (!playeringame[j] || players[j].spectator)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (players[j].bumpers <= 0)
|
if (players[j].bumpers <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (j == i)
|
if (j == i)
|
||||||
continue;
|
continue;
|
||||||
if (players[j].kartstuff[k_wanted] == players[i].kartstuff[k_wanted] && players[j].marescore > players[i].marescore)
|
|
||||||
|
if (K_NumEmeralds(&players[j]) > K_NumEmeralds(&players[i]))
|
||||||
|
{
|
||||||
position++;
|
position++;
|
||||||
|
}
|
||||||
|
else if (players[j].bumpers > players[i].bumpers)
|
||||||
|
{
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
else if (players[j].marescore > players[i].marescore)
|
||||||
|
{
|
||||||
|
position++;
|
||||||
|
}
|
||||||
else if (players[j].kartstuff[k_wanted] > players[i].kartstuff[k_wanted])
|
else if (players[j].kartstuff[k_wanted] > players[i].kartstuff[k_wanted])
|
||||||
|
{
|
||||||
position++;
|
position++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
position--; // Make zero based
|
position--; // Make zero based
|
||||||
|
|
@ -124,7 +124,7 @@ void K_CalculateBattleWanted(void)
|
||||||
camppos[position] = i;
|
camppos[position] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numplaying <= 2 || (numingame <= 2 && bestbumper == 1)) // In 1v1s then there's no need for WANTED. In bigger netgames, don't show anyone as WANTED when they're equally matched.
|
if (numingame <= 2) // In 1v1s then there's no need for WANTED.
|
||||||
numwanted = 0;
|
numwanted = 0;
|
||||||
else
|
else
|
||||||
numwanted = min(4, 1 + ((numingame-2) / 4));
|
numwanted = min(4, 1 + ((numingame-2) / 4));
|
||||||
|
|
@ -132,19 +132,11 @@ void K_CalculateBattleWanted(void)
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (i+1 > numwanted) // Not enough players for this slot to be wanted!
|
if (i+1 > numwanted) // Not enough players for this slot to be wanted!
|
||||||
battlewanted[i] = -1;
|
|
||||||
else if (bestbumperplayer != -1 && !setbumper) // If there's a player who has an untied bumper lead over everyone else, they are the first to be wanted.
|
|
||||||
{
|
{
|
||||||
battlewanted[i] = bestbumperplayer;
|
battlewanted[i] = -1;
|
||||||
setbumper = true; // Don't set twice
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Don't accidentally set the same player, if the bestbumperplayer is also a huge camper.
|
|
||||||
while (bestbumperplayer != -1 && camppos[nextcamppos] != -1
|
|
||||||
&& bestbumperplayer == camppos[nextcamppos])
|
|
||||||
nextcamppos++;
|
|
||||||
|
|
||||||
// Do not add *any* more people if there's too many times that are tied with others.
|
// Do not add *any* more people if there's too many times that are tied with others.
|
||||||
// This could theoretically happen very easily if people don't hit each other for a while after the start of a match.
|
// This could theoretically happen very easily if people don't hit each other for a while after the start of a match.
|
||||||
// (I will be sincerely impressed if more than 2 people tie after people start hitting each other though)
|
// (I will be sincerely impressed if more than 2 people tie after people start hitting each other though)
|
||||||
|
|
@ -377,6 +369,24 @@ void K_DropEmeraldsFromPlayer(player_t *player, UINT32 emeraldType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT8 K_NumEmeralds(player_t *player)
|
||||||
|
{
|
||||||
|
UINT8 i;
|
||||||
|
UINT8 num = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 14; i++)
|
||||||
|
{
|
||||||
|
UINT32 emeraldFlag = (1 << i);
|
||||||
|
|
||||||
|
if (player->powers[pw_emeralds] & emeraldFlag)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
void K_RunPaperItemSpawners(void)
|
void K_RunPaperItemSpawners(void)
|
||||||
{
|
{
|
||||||
const boolean overtime = (battleovertime.enabled >= 10*TICRATE);
|
const boolean overtime = (battleovertime.enabled >= 10*TICRATE);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ void K_CheckBumpers(void);
|
||||||
void K_CheckEmeralds(player_t *player);
|
void K_CheckEmeralds(player_t *player);
|
||||||
mobj_t *K_SpawnChaosEmerald(mobj_t *parent, angle_t angle, SINT8 flip, UINT32 emeraldType);
|
mobj_t *K_SpawnChaosEmerald(mobj_t *parent, angle_t angle, SINT8 flip, UINT32 emeraldType);
|
||||||
void K_DropEmeraldsFromPlayer(player_t *player, UINT32 emeraldType);
|
void K_DropEmeraldsFromPlayer(player_t *player, UINT32 emeraldType);
|
||||||
|
UINT8 K_NumEmeralds(player_t *player);
|
||||||
void K_RunPaperItemSpawners(void);
|
void K_RunPaperItemSpawners(void);
|
||||||
void K_RunBattleOvertime(void);
|
void K_RunBattleOvertime(void);
|
||||||
void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj);
|
void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue