Make bots RETIRE when they NO CONTEST

They get replaced with another bot when they NO CONTEST, swapping their skin and resetting their difficulty & points.
This commit is contained in:
Sally Coolatta 2022-03-31 18:21:03 -04:00
parent 76bb14bd3e
commit af3499c024
3 changed files with 173 additions and 26 deletions

View file

@ -95,6 +95,25 @@ INT16 K_CalculateGPRankPoints(UINT8 position, UINT8 numplayers)
return points; return points;
} }
/*--------------------------------------------------
SINT8 K_BotDefaultSkin(void)
See header file for description.
--------------------------------------------------*/
SINT8 K_BotDefaultSkin(void)
{
const char *defaultbotskinname = "eggrobo";
SINT8 defaultbotskin = R_SkinAvailable(defaultbotskinname);
if (defaultbotskin == -1)
{
// This shouldn't happen, but just in case
defaultbotskin = 0;
}
return defaultbotskin;
}
/*-------------------------------------------------- /*--------------------------------------------------
void K_InitGrandPrixBots(void) void K_InitGrandPrixBots(void)
@ -102,8 +121,7 @@ INT16 K_CalculateGPRankPoints(UINT8 position, UINT8 numplayers)
--------------------------------------------------*/ --------------------------------------------------*/
void K_InitGrandPrixBots(void) void K_InitGrandPrixBots(void)
{ {
const char *defaultbotskinname = "eggrobo"; const SINT8 defaultbotskin = K_BotDefaultSkin();
SINT8 defaultbotskin = R_SkinAvailable(defaultbotskinname);
const UINT8 startingdifficulty = K_BotStartingDifficulty(grandprixinfo.gamespeed); const UINT8 startingdifficulty = K_BotStartingDifficulty(grandprixinfo.gamespeed);
UINT8 difficultylevels[MAXPLAYERS]; UINT8 difficultylevels[MAXPLAYERS];
@ -121,12 +139,6 @@ void K_InitGrandPrixBots(void)
UINT8 newplayernum = 0; UINT8 newplayernum = 0;
UINT8 i, j; UINT8 i, j;
if (defaultbotskin == -1)
{
// This shouldn't happen, but just in case
defaultbotskin = 0;
}
memset(competitors, MAXPLAYERS, sizeof (competitors)); memset(competitors, MAXPLAYERS, sizeof (competitors));
memset(botskinlist, defaultbotskin, sizeof (botskinlist)); memset(botskinlist, defaultbotskin, sizeof (botskinlist));
@ -144,7 +156,7 @@ void K_InitGrandPrixBots(void)
} }
#if MAXPLAYERS != 16 #if MAXPLAYERS != 16
I_Error("GP bot difficulty levels need rebalacned for the new player count!\n"); I_Error("GP bot difficulty levels need rebalanced for the new player count!\n");
#endif #endif
if (grandprixinfo.masterbots) if (grandprixinfo.masterbots)
@ -500,6 +512,98 @@ void K_IncreaseBotDifficulty(player_t *bot)
} }
} }
/*--------------------------------------------------
void K_ReplaceBot(player_t *bot)
See header file for description.
--------------------------------------------------*/
void K_ReplaceBot(player_t *bot)
{
const SINT8 defaultbotskin = K_BotDefaultSkin();
SINT8 newDifficulty;
boolean skinusable[MAXSKINS];
UINT8 skinnum;
UINT8 loops = 0;
UINT8 i;
// init usable bot skins list
for (i = 0; i < MAXSKINS; i++)
{
if (i < numskins)
{
skinusable[i] = true;
}
else
{
skinusable[i] = false;
}
}
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !players[i].spectator)
{
skinusable[players[i].skin] = false;
}
}
skinnum = P_RandomKey(numskins);
while (!skinusable[skinnum])
{
if (loops >= numskins)
{
// no more skins
break;
}
skinnum++;
if (skinnum >= numskins)
{
skinnum = 0;
}
loops++;
}
if (loops >= numskins)
{
// Use default skin
skinnum = defaultbotskin;
}
if (!grandprixinfo.gp) // Sure, let's let this happen all the time :)
{
newDifficulty = cv_kartbot.value;
}
else
{
const UINT8 startingdifficulty = K_BotStartingDifficulty(grandprixinfo.gamespeed);
newDifficulty = startingdifficulty - 3 + (grandprixinfo.roundnum - 1);
}
if (newDifficulty > MAXBOTDIFFICULTY)
{
newDifficulty = MAXBOTDIFFICULTY;
}
else if (newDifficulty < 1)
{
newDifficulty = 1;
}
bot->botvars.difficulty = newDifficulty;
bot->botvars.diffincrease = 0;
SetPlayerSkinByNum(bot - players, skinnum);
bot->skincolor = skins[skinnum].prefcolor;
sprintf(player_names[bot - players], "%s", skins[skinnum].realname);
bot->score = 0;
}
/*-------------------------------------------------- /*--------------------------------------------------
void K_FakeBotResults(player_t *bot) void K_FakeBotResults(player_t *bot)

View file

@ -62,6 +62,16 @@ UINT8 K_BotStartingDifficulty(SINT8 value);
INT16 K_CalculateGPRankPoints(UINT8 position, UINT8 numplayers); INT16 K_CalculateGPRankPoints(UINT8 position, UINT8 numplayers);
/*--------------------------------------------------
SINT8 K_BotDefaultSkin(void);
Returns the skin number of the skin the game
uses as a fallback option.
--------------------------------------------------*/
SINT8 K_BotDefaultSkin(void);
/*-------------------------------------------------- /*--------------------------------------------------
void K_InitGrandPrixBots(void); void K_InitGrandPrixBots(void);
@ -95,6 +105,22 @@ void K_UpdateGrandPrixBots(void);
void K_IncreaseBotDifficulty(player_t *bot); void K_IncreaseBotDifficulty(player_t *bot);
/*--------------------------------------------------
void K_ReplaceBot(player_t *bot);
"Replaces" a bot, by refreshing their difficulty
and changing their skin.
Input Arguments:-
bot - Player to do this for.
Return:-
None
--------------------------------------------------*/
void K_ReplaceBot(player_t *bot);
/*-------------------------------------------------- /*--------------------------------------------------
void K_FakeBotResults(player_t *bot); void K_FakeBotResults(player_t *bot);

View file

@ -316,8 +316,9 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
data.pos[data.numplayers] = data.numplayers+1; data.pos[data.numplayers] = data.numplayers+1;
} }
if (!rankingsmode)
{
if ((powertype == PWRLV_DISABLED) if ((powertype == PWRLV_DISABLED)
&& (!rankingsmode)
&& !(players[i].pflags & PF_NOCONTEST) && !(players[i].pflags & PF_NOCONTEST)
&& (data.pos[data.numplayers] < (numplayersingame + numgriefers))) && (data.pos[data.numplayers] < (numplayersingame + numgriefers)))
{ {
@ -326,7 +327,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
players[i].score += data.increase[i]; players[i].score += data.increase[i];
} }
if (demo.recording && !rankingsmode) if (demo.recording)
{ {
G_WriteStanding( G_WriteStanding(
data.pos[data.numplayers], data.pos[data.numplayers],
@ -336,6 +337,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
data.val[data.numplayers] data.val[data.numplayers]
); );
} }
}
data.numplayers++; data.numplayers++;
} }
@ -582,6 +584,12 @@ void Y_IntermissionDrawer(void)
V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE));
} }
if (!data.rankingsmode && (players[data.num[i]].pflags & PF_NOCONTEST) && players[data.num[i]].bot)
{
// RETIRED!!
V_DrawScaledPatch(x+12, y-7, 0, W_CachePatchName("K_NOBLNS", PU_CACHE));
}
STRBUFCPY(strtime, data.name[i]); STRBUFCPY(strtime, data.name[i]);
y2 = y; y2 = y;
@ -803,6 +811,15 @@ void Y_Ticker(void)
{ {
if (!data.rankingsmode && sorttic != -1 && (intertic >= sorttic + 8)) if (!data.rankingsmode && sorttic != -1 && (intertic >= sorttic + 8))
{ {
UINT8 i;
for (i = 0; i < MAXPLAYERS; i++)
{
if ((players[i].pflags & PF_NOCONTEST) && players[i].bot)
{
K_ReplaceBot(&players[i]);
}
}
Y_CalculateMatchData(1, Y_CompareRank); Y_CalculateMatchData(1, Y_CompareRank);
} }