mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Re-implement debugitemodds
This commit is contained in:
parent
9e3ded610d
commit
b0537de79e
4 changed files with 41 additions and 79 deletions
|
|
@ -339,6 +339,7 @@ struct itemroulette_t
|
||||||
size_t itemListLen;
|
size_t itemListLen;
|
||||||
SINT8 *itemList;
|
SINT8 *itemList;
|
||||||
|
|
||||||
|
UINT8 useOdds;
|
||||||
size_t index;
|
size_t index;
|
||||||
UINT8 sound;
|
UINT8 sound;
|
||||||
|
|
||||||
|
|
|
||||||
92
src/k_hud.c
92
src/k_hud.c
|
|
@ -4468,13 +4468,7 @@ K_drawMiniPing (void)
|
||||||
|
|
||||||
static void K_drawDistributionDebugger(void)
|
static void K_drawDistributionDebugger(void)
|
||||||
{
|
{
|
||||||
#if 1
|
patch_t *patches[NUMKARTRESULTS] = {
|
||||||
// TODO: Create a roulette struct and initialize it,
|
|
||||||
// and use that to draw the data, instead of recalculating
|
|
||||||
// most of it.
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
patch_t *items[NUMKARTRESULTS] = {
|
|
||||||
kp_sadface[1],
|
kp_sadface[1],
|
||||||
kp_sneaker[1],
|
kp_sneaker[1],
|
||||||
kp_rocketsneaker[1],
|
kp_rocketsneaker[1],
|
||||||
|
|
@ -4506,87 +4500,47 @@ static void K_drawDistributionDebugger(void)
|
||||||
kp_orbinaut[4],
|
kp_orbinaut[4],
|
||||||
kp_jawz[1]
|
kp_jawz[1]
|
||||||
};
|
};
|
||||||
UINT8 useodds = 0;
|
|
||||||
UINT8 pingame = 0, bestbumper = 0;
|
itemroulette_t rouletteData = {0};
|
||||||
UINT32 pdis = 0;
|
|
||||||
INT32 i;
|
const INT32 space = 32;
|
||||||
INT32 x = -9, y = -9;
|
const INT32 pad = 9;
|
||||||
|
|
||||||
|
INT32 x = -pad, y = -pad;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (stplyr != &players[displayplayers[0]]) // only for p1
|
if (stplyr != &players[displayplayers[0]]) // only for p1
|
||||||
return;
|
|
||||||
|
|
||||||
if (K_ForcedSPB(stplyr) == true)
|
|
||||||
{
|
{
|
||||||
V_DrawScaledPatch(x, y, V_SNAPTOTOP, items[KITEM_SPB]);
|
|
||||||
V_DrawThinString(x+11, y+31, V_ALLOWLOWERCASE|V_SNAPTOTOP, "EX");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice
|
K_StartItemRoulette(stplyr, &rouletteData);
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
|
for (i = 0; i < rouletteData.itemListLen; i++)
|
||||||
{
|
{
|
||||||
if (!playeringame[i] || players[i].spectator)
|
const kartitems_t item = rouletteData.itemList[i];
|
||||||
continue;
|
UINT8 amount = 1;
|
||||||
pingame++;
|
|
||||||
if (players[i].bumpers > bestbumper)
|
|
||||||
bestbumper = players[i].bumpers;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lovely double loop......
|
V_DrawScaledPatch(x, y, V_SNAPTOTOP, patches[item]);
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
{
|
|
||||||
if (playeringame[i] && !players[i].spectator
|
|
||||||
&& players[i].position == 1)
|
|
||||||
{
|
|
||||||
// This player is first! Yay!
|
|
||||||
pdis = stplyr->distancetofinish - players[i].distancetofinish;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pdis = K_ScaleItemDistance(pdis, pingame);
|
|
||||||
|
|
||||||
if (stplyr->bot && stplyr->botvars.rival)
|
|
||||||
{
|
|
||||||
// Rival has better odds :)
|
|
||||||
pdis = (15 * pdis) / 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
useodds = K_FindUseodds(stplyr, pdis);
|
|
||||||
|
|
||||||
for (i = 1; i < NUMKARTRESULTS; i++)
|
|
||||||
{
|
|
||||||
INT32 itemodds = K_KartGetItemOdds(
|
|
||||||
useodds, i,
|
|
||||||
stplyr->distancetofinish,
|
|
||||||
0,
|
|
||||||
stplyr->bot, (stplyr->bot && stplyr->botvars.rival)
|
|
||||||
);
|
|
||||||
INT32 amount = 1;
|
|
||||||
|
|
||||||
if (itemodds <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
V_DrawScaledPatch(x, y, V_SNAPTOTOP, items[i]);
|
|
||||||
V_DrawThinString(x+11, y+31, V_SNAPTOTOP, va("%d", itemodds));
|
|
||||||
|
|
||||||
// Display amount for multi-items
|
// Display amount for multi-items
|
||||||
amount = K_ItemResultToAmount(i);
|
amount = K_ItemResultToAmount(item);
|
||||||
if (amount > 1)
|
if (amount > 1)
|
||||||
{
|
{
|
||||||
V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|V_SNAPTOTOP, va("x%d", amount));
|
V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|V_SNAPTOTOP, va("x%d", amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 32;
|
y += space;
|
||||||
if (x >= 297)
|
if (y > BASEVIDHEIGHT - space - pad)
|
||||||
{
|
{
|
||||||
x = -9;
|
x += space;
|
||||||
y += 32;
|
y = -pad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
V_DrawString(0, 0, V_SNAPTOTOP, va("USEODDS %d", useodds));
|
V_DrawString(0, 0, V_ALLOWLOWERCASE|V_SNAPTOTOP, va("Table #%d", rouletteData.useOdds));
|
||||||
#endif
|
|
||||||
|
Z_Free(rouletteData.itemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void K_DrawWaypointDebugger(void)
|
static void K_DrawWaypointDebugger(void)
|
||||||
|
|
|
||||||
|
|
@ -736,9 +736,11 @@ static void K_InitRoulette(itemroulette_t *const roulette)
|
||||||
|
|
||||||
roulette->itemListLen = 0;
|
roulette->itemListLen = 0;
|
||||||
roulette->index = 0;
|
roulette->index = 0;
|
||||||
|
roulette->useOdds = UINT8_MAX;
|
||||||
|
|
||||||
roulette->elapsed = 0;
|
roulette->elapsed = 0;
|
||||||
roulette->tics = roulette->speed = ROULETTE_SPEED_FASTEST; // Some default speed
|
roulette->tics = roulette->speed = ROULETTE_SPEED_FASTEST; // Some default speed
|
||||||
|
|
||||||
roulette->active = true;
|
roulette->active = true;
|
||||||
roulette->eggman = false;
|
roulette->eggman = false;
|
||||||
}
|
}
|
||||||
|
|
@ -828,7 +830,6 @@ void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette)
|
||||||
UINT8 playing = 0;
|
UINT8 playing = 0;
|
||||||
UINT32 playerDist = UINT32_MAX;
|
UINT32 playerDist = UINT32_MAX;
|
||||||
|
|
||||||
UINT8 useOdds = 0;
|
|
||||||
UINT32 spawnChance[NUMKARTRESULTS] = {0};
|
UINT32 spawnChance[NUMKARTRESULTS] = {0};
|
||||||
UINT32 totalSpawnChance = 0;
|
UINT32 totalSpawnChance = 0;
|
||||||
size_t rngRoll = 0;
|
size_t rngRoll = 0;
|
||||||
|
|
@ -903,12 +904,12 @@ void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette)
|
||||||
|
|
||||||
playerDist = K_GetItemRouletteDistance(player, playing);
|
playerDist = K_GetItemRouletteDistance(player, playing);
|
||||||
|
|
||||||
useOdds = K_FindUseodds(player, playerDist);
|
roulette->useOdds = K_FindUseodds(player, playerDist);
|
||||||
|
|
||||||
for (i = 1; i < NUMKARTRESULTS; i++)
|
for (i = 1; i < NUMKARTRESULTS; i++)
|
||||||
{
|
{
|
||||||
INT32 thisItemsOdds = K_KartGetItemOdds(
|
INT32 thisItemsOdds = K_KartGetItemOdds(
|
||||||
useOdds, i,
|
roulette->useOdds, i,
|
||||||
player->distancetofinish,
|
player->distancetofinish,
|
||||||
player->bot, (player->bot && player->botvars.rival)
|
player->bot, (player->bot && player->botvars.rival)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -416,10 +416,13 @@ static void P_NetArchivePlayers(void)
|
||||||
{
|
{
|
||||||
WRITESINT8(save_p, players[i].itemRoulette.itemList[j]);
|
WRITESINT8(save_p, players[i].itemRoulette.itemList[j]);
|
||||||
}
|
}
|
||||||
|
WRITEUINT8(save_p, players[i].itemRoulette.useOdds);
|
||||||
WRITEUINT32(save_p, players[i].itemRoulette.index);
|
WRITEUINT32(save_p, players[i].itemRoulette.index);
|
||||||
|
WRITEUINT8(save_p, players[i].itemRoulette.sound);
|
||||||
WRITEUINT32(save_p, players[i].itemRoulette.speed);
|
WRITEUINT32(save_p, players[i].itemRoulette.speed);
|
||||||
WRITEUINT32(save_p, players[i].itemRoulette.tics);
|
WRITEUINT32(save_p, players[i].itemRoulette.tics);
|
||||||
WRITEUINT32(save_p, players[i].itemRoulette.elapsed);
|
WRITEUINT32(save_p, players[i].itemRoulette.elapsed);
|
||||||
|
WRITEUINT8(save_p, players[i].itemRoulette.eggman);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -721,9 +724,9 @@ static void P_NetUnArchivePlayers(void)
|
||||||
players[i].botvars.spindashconfirm = READUINT32(save_p);
|
players[i].botvars.spindashconfirm = READUINT32(save_p);
|
||||||
|
|
||||||
// itemroulette_t
|
// itemroulette_t
|
||||||
players[i].itemRoulette.active = READUINT8(save_p);
|
players[i].itemRoulette.active = (boolean)READUINT8(save_p);
|
||||||
players[i].itemRoulette.itemListCap = READUINT32(save_p);
|
players[i].itemRoulette.itemListCap = (size_t)READUINT32(save_p);
|
||||||
players[i].itemRoulette.itemListLen = READUINT32(save_p);
|
players[i].itemRoulette.itemListLen = (size_t)READUINT32(save_p);
|
||||||
|
|
||||||
if (players[i].itemRoulette.itemList == NULL)
|
if (players[i].itemRoulette.itemList == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -748,10 +751,13 @@ static void P_NetUnArchivePlayers(void)
|
||||||
players[i].itemRoulette.itemList[j] = READSINT8(save_p);
|
players[i].itemRoulette.itemList[j] = READSINT8(save_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
players[i].itemRoulette.index = READUINT32(save_p);
|
players[i].itemRoulette.useOdds = READUINT8(save_p);
|
||||||
players[i].itemRoulette.speed = READUINT32(save_p);
|
players[i].itemRoulette.index = (size_t)READUINT32(save_p);
|
||||||
players[i].itemRoulette.tics = READUINT32(save_p);
|
players[i].itemRoulette.sound = READUINT8(save_p);
|
||||||
players[i].itemRoulette.elapsed = READUINT32(save_p);
|
players[i].itemRoulette.speed = (tic_t)READUINT32(save_p);
|
||||||
|
players[i].itemRoulette.tics = (tic_t)READUINT32(save_p);
|
||||||
|
players[i].itemRoulette.elapsed = (tic_t)READUINT32(save_p);
|
||||||
|
players[i].itemRoulette.eggman = (boolean)READUINT8(save_p);
|
||||||
|
|
||||||
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
|
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue