From efc8ce335c6709c774bef31955b3ece48c0d70d8 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 7 May 2020 04:07:13 -0400 Subject: [PATCH] Rubberbanding spacing was reworked Instead of the spacing being completely difficulty dependent (which would cause them not to rubberband to 1st place if they were any difficulty lower than 9), it's based on their difficulty & overall race standings & a little bit of port priority instead. This enables you to see a pesudo "rival" even when every bot is the same difficulty. --- src/k_bot.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 13f5873ea..3c66a0092 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -354,6 +354,41 @@ boolean K_BotCanTakeCut(player_t *player) return false; } +static UINT32 K_BotRubberbandDistance(player_t *player) +{ + const UINT32 spacing = 2048; + const UINT8 portpriority = player - players; + UINT8 pos = 0; + UINT8 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == portpriority) + { + continue; + } + + if (playeringame[i] && players[i].bot) + { + // First check difficulty levels, then score, then settle it with port priority! + if (player->botvars.difficulty < players[i].botvars.difficulty) + { + pos++; + } + else if (player->score < players[i].score) + { + pos++; + } + else if (i < portpriority) + { + pos++; + } + } + } + + return (pos * spacing); +} + fixed_t K_BotRubberband(player_t *player) { fixed_t rubberband = FRACUNIT; @@ -385,14 +420,18 @@ fixed_t K_BotRubberband(player_t *player) if (firstplace != NULL) { - const UINT32 spacing = 4096; - UINT32 easiness = (MAXBOTDIFFICULTY - player->botvars.difficulty); - UINT32 wanteddist = firstplace->distancetofinish + (spacing * easiness); + const UINT32 wanteddist = firstplace->distancetofinish + K_BotRubberbandDistance(player); + const INT32 distdiff = player->distancetofinish - wanteddist; - if (wanteddist < player->distancetofinish) + if (wanteddist > player->distancetofinish) { - // Catch up to 1st! - rubberband += (2*player->botvars.difficulty) * (player->distancetofinish - wanteddist); + // Whoa, you're too far ahead! + rubberband += (MAXBOTDIFFICULTY - player->botvars.difficulty) * distdiff; + } + else + { + // Catch up to your position! + rubberband += (2*player->botvars.difficulty) * distdiff; } }