From 5ffba0a678f61bb2d02c1deca8598fd1215943a3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 2 Apr 2022 14:43:38 -0400 Subject: [PATCH] review --- src/k_bot.c | 25 +++++++------ src/k_grandprix.c | 94 +++++++++++++++++++++++++++++------------------ src/k_grandprix.h | 14 ++----- src/y_inter.c | 13 ++----- 4 files changed, 78 insertions(+), 68 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index b3f73b8ac..aed20e3b5 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -487,7 +487,7 @@ static UINT32 K_BotRubberbandDistance(player_t *player) fixed_t K_BotRubberband(player_t *player) { fixed_t rubberband = FRACUNIT; - fixed_t max, min; + fixed_t rubbermax, rubbermin; player_t *firstplace = NULL; line_t *botController = NULL; UINT8 i; @@ -551,21 +551,21 @@ fixed_t K_BotRubberband(player_t *player) // Lv. 5: x1.4 max // Lv. 9: x1.8 max // Lv. MAX: x2.2 max - max = FRACUNIT + ((FRACUNIT * (player->botvars.difficulty - 1)) / 10); + rubbermax = FRACUNIT + ((FRACUNIT * (player->botvars.difficulty - 1)) / 10); // Lv. 1: x0.75 min // Lv. 5: x0.875 min // Lv. 9: x1.0 min // Lv. MAX: x1.0 min - min = FRACUNIT - (((FRACUNIT/4) * (DIFFICULTBOT - min(DIFFICULTBOT, player->botvars.difficulty))) / (DIFFICULTBOT - 1)); + rubbermin = FRACUNIT - (((FRACUNIT/4) * (DIFFICULTBOT - min(DIFFICULTBOT, player->botvars.difficulty))) / (DIFFICULTBOT - 1)); - if (rubberband > max) + if (rubberband > rubbermax) { - rubberband = max; + rubberband = rubbermax; } - else if (rubberband < min) + else if (rubberband < rubbermin) { - rubberband = min; + rubberband = rubbermin; } return rubberband; @@ -1119,6 +1119,11 @@ static INT32 K_HandleBotTrack(player_t *player, ticcmd_t *cmd, botprediction_t * predict->x, predict->y ); + if (realrad < player->mo->radius) + { + realrad = player->mo->radius; + } + if (anglediff > 0) { // Become more precise based on how hard you need to turn @@ -1447,11 +1452,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) turnamt = bullyTurn; // If already spindashing, wait until we get a relatively OK charge first. - if (player->spindash > 0 && player->spindash <= TICRATE) - { - trySpindash = true; - } - else + if (player->spindash == 0 || player->spindash > TICRATE) { trySpindash = false; cmd->buttons |= BT_ACCELERATE; diff --git a/src/k_grandprix.c b/src/k_grandprix.c index 332224479..bb14edac6 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -513,18 +513,16 @@ void K_IncreaseBotDifficulty(player_t *bot) } /*-------------------------------------------------- - void K_ReplaceBot(player_t *bot) + void K_RetireBots(void) See header file for description. --------------------------------------------------*/ -void K_ReplaceBot(player_t *bot) +void K_RetireBots(void) { const SINT8 defaultbotskin = K_BotDefaultSkin(); SINT8 newDifficulty; boolean skinusable[MAXSKINS]; - UINT8 skinnum; - UINT8 loops = 0; UINT8 i; @@ -555,32 +553,6 @@ void K_ReplaceBot(player_t *bot) } } - 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; @@ -600,14 +572,64 @@ void K_ReplaceBot(player_t *bot) newDifficulty = 1; } - bot->botvars.difficulty = newDifficulty; - bot->botvars.diffincrease = 0; + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *bot = NULL; - SetPlayerSkinByNum(bot - players, skinnum); - bot->skincolor = skins[skinnum].prefcolor; - sprintf(player_names[bot - players], "%s", skins[skinnum].realname); + if (!playeringame[i] || !players[i].bot) + { + continue; + } - bot->score = 0; + bot = players[i]; + + if (bot->spectator) + { + continue; + } + + if (bot->pflags & PF_NOCONTEST) + { + UINT8 skinnum = P_RandomKey(numskins); + UINT8 loops = 0; + + 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; + } + + skinusable[skinnum] = false; + + 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; + bot->pflags &= ~PF_NOCONTEST; + } + } } /*-------------------------------------------------- diff --git a/src/k_grandprix.h b/src/k_grandprix.h index f951860d8..552f75450 100644 --- a/src/k_grandprix.h +++ b/src/k_grandprix.h @@ -106,19 +106,13 @@ void K_IncreaseBotDifficulty(player_t *bot); /*-------------------------------------------------- - void K_ReplaceBot(player_t *bot); + void K_RetireBots(player_t *bot); - "Replaces" a bot, by refreshing their difficulty + Replaces PF_NOCONTEST bots, 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_RetireBots(player_t *bot); /*-------------------------------------------------- @@ -162,7 +156,7 @@ void K_PlayerLoseLife(player_t *player); None Return:- - None + true if can change important gameplay rules, otherwise false. --------------------------------------------------*/ boolean K_CanChangeRules(void); diff --git a/src/y_inter.c b/src/y_inter.c index 69cbf2660..7f48f0798 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -584,7 +584,7 @@ void Y_IntermissionDrawer(void) 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) + if ((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)); @@ -811,15 +811,7 @@ void Y_Ticker(void) { 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]); - } - } - + K_RetireBots(); Y_CalculateMatchData(1, Y_CompareRank); } @@ -1170,6 +1162,7 @@ void Y_StartIntermission(void) // void Y_EndIntermission(void) { + K_RetireBots(); Y_UnloadData(); endtic = -1;