Merge branch 'item-spy-always' into 'master'

Nametag stuff

See merge request KartKrew/Kart!2421
This commit is contained in:
Oni 2024-08-23 06:54:51 +00:00
commit 9213ea6f2b
6 changed files with 150 additions and 43 deletions

View file

@ -664,7 +664,7 @@ enum GameTypeRules
GTR_PAPERITEMS = 1<<6, // Replaces item boxes with paper item spawners GTR_PAPERITEMS = 1<<6, // Replaces item boxes with paper item spawners
GTR_POWERSTONES = 1<<7, // Battle Emerald collectables. GTR_POWERSTONES = 1<<7, // Battle Emerald collectables.
GTR_KARMA = 1<<8, // Enables the Karma system if you're out of bumpers GTR_KARMA = 1<<8, // Enables the Karma system if you're out of bumpers
GTR_ITEMARROWS = 1<<9, // Show item box arrows above players // 1<<9 - UNUSED
// Bonus gametype rules // Bonus gametype rules
GTR_CHECKPOINTS = 1<<10, // Player respawns at specific checkpoints GTR_CHECKPOINTS = 1<<10, // Player respawns at specific checkpoints

View file

@ -3241,7 +3241,7 @@ static gametype_t defaultgametypes[] =
{ {
"Battle", "Battle",
"GT_BATTLE", "GT_BATTLE",
GTR_SPHERES|GTR_BUMPERS|GTR_PAPERITEMS|GTR_POWERSTONES|GTR_KARMA|GTR_ITEMARROWS|GTR_PRISONS|GTR_BATTLESTARTS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_CLOSERPLAYERS, GTR_SPHERES|GTR_BUMPERS|GTR_PAPERITEMS|GTR_POWERSTONES|GTR_KARMA|GTR_PRISONS|GTR_BATTLESTARTS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_CLOSERPLAYERS,
TOL_BATTLE, TOL_BATTLE,
int_scoreortimeattack, int_scoreortimeattack,
KARTSPEED_EASY, KARTSPEED_EASY,

View file

@ -205,7 +205,7 @@ static patch_t *kp_itemminimap;
static patch_t *kp_alagles[10]; static patch_t *kp_alagles[10];
static patch_t *kp_blagles[6]; static patch_t *kp_blagles[6];
static patch_t *kp_cpu; static patch_t *kp_cpu[2];
static patch_t *kp_nametagstem; static patch_t *kp_nametagstem;
@ -818,7 +818,8 @@ void K_LoadKartHUDGraphics(void)
HU_UpdatePatch(&kp_blagles[i], "%s", buffer); HU_UpdatePatch(&kp_blagles[i], "%s", buffer);
} }
HU_UpdatePatch(&kp_cpu, "K_CPU"); HU_UpdatePatch(&kp_cpu[0], "K_CPU1");
HU_UpdatePatch(&kp_cpu[1], "K_CPU2");
HU_UpdatePatch(&kp_nametagstem, "K_NAMEST"); HU_UpdatePatch(&kp_nametagstem, "K_NAMEST");
@ -3874,19 +3875,6 @@ static boolean K_ShowPlayerNametag(player_t *p)
return true; return true;
} }
static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id, UINT32 flags)
{
UINT8 blink = ((leveltime / 7) & 1);
UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, static_cast<skincolornum_t>(p->skincolor), GTC_CACHE);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_localtag[id][blink], colormap);
}
static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y, UINT32 flags)
{
UINT8 blink = ((leveltime / 7) & 1);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_rival[blink], NULL);
}
static void K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p, INT32 flags) static void K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p, INT32 flags)
{ {
if (p->typing_duration > duration) if (p->typing_duration > duration)
@ -3929,23 +3917,43 @@ static void K_DrawNameTagItemSpy(INT32 x, INT32 y, player_t *p, INT32 flags)
box.colorize(p->skincolor).patch(kp_itembg[tiny ? 4 : 2]); box.colorize(p->skincolor).patch(kp_itembg[tiny ? 4 : 2]);
if (!(p->itemflags & IF_ITEMOUT) || (leveltime & 1)) INT32 item_type = KITEM_NONE;
if (p->itemRoulette.active == true && p->itemRoulette.ringbox == false)
{ {
switch (p->itemtype) item_type = 1 + (leveltime % (NUMKARTITEMS - 1));
}
else if (!(p->itemflags & IF_ITEMOUT) || (leveltime & 1))
{ {
item_type = p->itemtype;
}
switch (item_type)
{
case KITEM_NONE:
{
break;
}
case KITEM_INVINCIBILITY: case KITEM_INVINCIBILITY:
{
box.patch(kp_invincibility[((leveltime % (6*3)) / 3) + (tiny ? 13 : 7)]); box.patch(kp_invincibility[((leveltime % (6*3)) / 3) + (tiny ? 13 : 7)]);
break; break;
}
case KITEM_ORBINAUT: case KITEM_ORBINAUT:
{
box.patch(kp_orbinaut[4 + tiny]); box.patch(kp_orbinaut[4 + tiny]);
break; break;
}
default: default:
if (patch_t *ico = K_GetCachedItemPatch(p->itemtype, 1 + tiny)) {
if (patch_t *ico = K_GetCachedItemPatch(item_type, 1 + tiny))
{ {
box.patch(ico); box.patch(ico);
} }
break;
} }
} }
@ -3992,7 +4000,77 @@ static void K_DrawNameTagSphereMeter(INT32 x, INT32 y, INT32 width, INT32 sphere
} }
} }
static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flags) static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id, UINT32 flags)
{
UINT8 blink = ((leveltime / 7) & 1);
UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, static_cast<skincolornum_t>(p->skincolor), GTC_CACHE);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_localtag[id][blink], colormap);
}
static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT32 flags)
{
if ((p->itemtype != KITEM_NONE && p->itemamount != 0)
|| (p->itemRoulette.active == true && p->itemRoulette.ringbox == false))
{
INT32 barx = 0, bary = 0;
barx = (x * vid.dupx) / FRACUNIT;
bary = (y * vid.dupy) / FRACUNIT;
barx += (16 * vid.dupx);
bary -= (25 * vid.dupx);
// Center it if necessary
if (vid.width != BASEVIDWIDTH * vid.dupx)
{
barx += (vid.width - (BASEVIDWIDTH * vid.dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * vid.dupy)
{
bary += (vid.height - (BASEVIDHEIGHT * vid.dupy)) / 2;
}
K_DrawNameTagItemSpy(barx, bary, p, flags);
}
UINT8 blink = ((leveltime / 7) & 1);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_rival[blink], NULL);
}
static void K_DrawCPUTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT32 flags)
{
if ((p->itemtype != KITEM_NONE && p->itemamount != 0)
|| (p->itemRoulette.active == true && p->itemRoulette.ringbox == false))
{
INT32 barx = 0, bary = 0;
barx = (x * vid.dupx) / FRACUNIT;
bary = (y * vid.dupy) / FRACUNIT;
barx += (16 * vid.dupx);
bary -= (25 * vid.dupx);
// Center it if necessary
if (vid.width != BASEVIDWIDTH * vid.dupx)
{
barx += (vid.width - (BASEVIDWIDTH * vid.dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * vid.dupy)
{
bary += (vid.height - (BASEVIDHEIGHT * vid.dupy)) / 2;
}
K_DrawNameTagItemSpy(barx, bary, p, flags);
}
UINT8 blink = ((leveltime / 7) & 1);
V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_cpu[blink], NULL);
}
static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT32 flags)
{ {
const INT32 clr = skincolors[p->skincolor].chatcolor; const INT32 clr = skincolors[p->skincolor].chatcolor;
const INT32 namelen = V_ThinStringWidth(player_names[p - players], 0); const INT32 namelen = V_ThinStringWidth(player_names[p - players], 0);
@ -4042,7 +4120,8 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag
} }
// see also K_CullTargetList // see also K_CullTargetList
if ((gametyperules & GTR_ITEMARROWS) && p->itemtype != KITEM_NONE && p->itemamount != 0) if ((p->itemtype != KITEM_NONE && p->itemamount != 0)
|| (p->itemRoulette.active == true && p->itemRoulette.ringbox == false))
{ {
K_DrawNameTagItemSpy(barx, bary, p, flags); K_DrawNameTagItemSpy(barx, bary, p, flags);
} }
@ -4079,6 +4158,10 @@ playertagtype_t K_WhichPlayerTag(player_t *p)
{ {
return PLAYERTAG_RIVAL; return PLAYERTAG_RIVAL;
} }
else if (K_ShowPlayerNametag(p) == true)
{
return PLAYERTAG_CPU;
}
} }
else if (netgame || demo.playback) else if (netgame || demo.playback)
{ {
@ -4098,17 +4181,22 @@ void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, bo
switch (type) switch (type)
{ {
case PLAYERTAG_LOCAL: case PLAYERTAG_LOCAL:
flags |= V_HUDTRANS|V_SPLITSCREEN; flags |= V_SPLITSCREEN;
K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players), flags); K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players), flags);
break; break;
case PLAYERTAG_RIVAL: case PLAYERTAG_RIVAL:
flags |= V_HUDTRANS|V_SPLITSCREEN; flags |= V_SPLITSCREEN;
K_DrawRivalTagForPlayer(x, y, flags); K_DrawRivalTagForPlayer(x, y, p, flags);
break;
case PLAYERTAG_CPU:
flags |= V_SPLITSCREEN;
flags |= foreground ? 0 : V_60TRANS;
K_DrawCPUTagForPlayer(x, y, p, flags);
break; break;
case PLAYERTAG_NAME: case PLAYERTAG_NAME:
// We only care about the trans flag here (based?) as well as V_VFLIP.
flags |= foreground ? 0 : V_60TRANS; flags |= foreground ? 0 : V_60TRANS;
K_DrawNameTagForPlayer(x, y, p, flags); K_DrawNameTagForPlayer(x, y, p, flags);
K_DrawTypingNotifier(x, y, p, flags); K_DrawTypingNotifier(x, y, p, flags);

View file

@ -119,6 +119,7 @@ typedef enum
{ {
PLAYERTAG_NONE, PLAYERTAG_NONE,
PLAYERTAG_LOCAL, PLAYERTAG_LOCAL,
PLAYERTAG_CPU,
PLAYERTAG_RIVAL, PLAYERTAG_RIVAL,
PLAYERTAG_NAME, PLAYERTAG_NAME,
} }

View file

@ -735,11 +735,28 @@ void K_CullTargetList(std::vector<TargetTracking>& targetList)
bit = 2; // nametags will cull on a separate plane bit = 2; // nametags will cull on a separate plane
// see also K_DrawNameTagForPlayer // see also K_DrawNameTagForPlayer
if ((gametyperules & GTR_ITEMARROWS) && p->itemtype != KITEM_NONE && p->itemamount != 0) if ((p->itemtype != KITEM_NONE && p->itemamount != 0)
|| (p->itemRoulette.active == true && p->itemRoulette.ringbox == false))
{ {
x1 -= 24 * FRACUNIT; x1 -= 24 * FRACUNIT;
} }
} }
else if (tr.nametag == PLAYERTAG_RIVAL || tr.nametag == PLAYERTAG_CPU)
{
const player_t* p = tr.mobj->player;
x1 = tr.result.x - (14 * FRACUNIT);
x2 = tr.result.x + (14 * FRACUNIT);
y1 = tr.result.y - (20 * FRACUNIT);
y2 = tr.result.y - (4 * FRACUNIT);
bit = 2; // nametags will cull on a separate plane
// see also K_DrawNameTagForPlayer
if (p->itemtype != KITEM_NONE && p->itemamount != 0)
{
y1 -= 23 * FRACUNIT;
}
}
else if (tr.nametag != PLAYERTAG_NONE) else if (tr.nametag != PLAYERTAG_NONE)
{ {
return; return;

View file

@ -478,6 +478,7 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
INT32 hilicol = highlightflags; INT32 hilicol = highlightflags;
patch_t *resbar = static_cast<patch_t*>(W_CachePatchName("R_RESBAR", PU_PATCH)); // Results bars for players patch_t *resbar = static_cast<patch_t*>(W_CachePatchName("R_RESBAR", PU_PATCH)); // Results bars for players
patch_t *cpu = static_cast<patch_t*>(W_CachePatchName("K_CPU", PU_PATCH));
if (drawping || standings->rankingsmode != 0) if (drawping || standings->rankingsmode != 0)
{ {
@ -710,11 +711,11 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
{ {
if (players[pnum].bot) if (players[pnum].bot)
{ {
/*V_DrawScaledPatch( V_DrawScaledPatch(
x2, y-1, x2-2 + (datarightofcolumn ? 2 : -2), y-2,
0, 0,
kp_cpu cpu
);*/ );
} }
else else
{ {