mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
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.
This commit is contained in:
parent
d2172fc54b
commit
efc8ce335c
1 changed files with 45 additions and 6 deletions
51
src/k_bot.c
51
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue