New HUD for CTF (#167)

# Conflicts:
#	source/blood/src/blood.cpp
This commit is contained in:
CommonLoon102 2019-09-15 11:59:27 +00:00 committed by Christoph Oelckers
parent 4527da61a2
commit 55de5230ca
5 changed files with 155 additions and 41 deletions

View file

@ -532,6 +532,9 @@ void StartLevel(GAMEOPTIONS *gameOptions)
levelAddUserMap(gPacketStartGame.userMapName);
else
levelSetupOptions(gGameOptions.nEpisode, gGameOptions.nLevel);
gBlueFlagDropped = false;
gRedFlagDropped = false;
}
if (gameOptions->uGameFlags&1)
{
@ -676,6 +679,14 @@ void StartNetworkLevel(void)
gGameOptions.nWeaponSettings = gPacketStartGame.weaponSettings;
gGameOptions.nItemSettings = gPacketStartGame.itemSettings;
gGameOptions.nRespawnSettings = gPacketStartGame.respawnSettings;
///////
gGameOptions.weaponsV10x = gPacketStartGame.weaponsV10x;
///////
gBlueFlagDropped = false;
gRedFlagDropped = false;
if (gPacketStartGame.userMap)
levelAddUserMap(gPacketStartGame.userMapName);
else

View file

@ -492,11 +492,13 @@ void sub_765B8(int nSprite) // 17
case 147:
trTriggerSprite(pOwner->index, pXOwner, 1);
sndStartSample(8003, 255, 2, 0);
gBlueFlagDropped = false;
viewSetMessage("Blue Flag returned to base.");
break;
case 148:
trTriggerSprite(pOwner->index, pXOwner, 1);
sndStartSample(8002, 255, 2, 0);
gRedFlagDropped = false;
viewSetMessage("Red Flag returned to base.");
break;
}

View file

@ -56,6 +56,9 @@ PROFILE gProfile[kMaxPlayers];
PLAYER gPlayer[kMaxPlayers];
PLAYER *gMe, *gView;
bool gBlueFlagDropped = false;
bool gRedFlagDropped = false;
POWERUPINFO gPowerUpInfo[kMaxPowerUps] = {
{ -1, 1, 1, 1 },
{ -1, 1, 1, 1 },
@ -1170,7 +1173,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem)
dword_21EFB0[pPlayer->at2ea] += 10;
dword_21EFD0[pPlayer->at2ea] += 240;
evSend(0, 0, 80, COMMAND_ID_1);
sprintf(buffer, "%s captured Red Flag!", gProfile[pPlayer->at57].name);
sprintf(buffer, "%s captured Blue Flag!", gProfile[pPlayer->at57].name);
sndStartSample(8000, 255, 2, 0);
viewSetMessage(buffer);
#if 0
@ -1191,6 +1194,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem)
evKill(pItem->index, 3, CALLBACK_ID_17);
pPlayer->at90 |= 1;
pPlayer->at91[0] = pItem->index;
gBlueFlagDropped = false;
break;
case 148:
if (gGameOptions.nGameType != 3)
@ -1198,6 +1202,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem)
evKill(pItem->index, 3, CALLBACK_ID_17);
pPlayer->at90 |= 2;
pPlayer->at91[1] = pItem->index;
gRedFlagDropped = false;
break;
case 140:
case 141:
@ -2113,6 +2118,7 @@ spritetype *sub_40A94(PLAYER *pPlayer, int a2)
pSprite = actDropObject(pPlayer->pSprite, 147);
if (pSprite)
pSprite->owner = pPlayer->at91[0];
gBlueFlagDropped = true;
sprintf(buffer, "%s dropped Blue Flag", gProfile[pPlayer->at57].name);
sndStartSample(8005, 255, 2, 0);
viewSetMessage(buffer);
@ -2122,6 +2128,7 @@ spritetype *sub_40A94(PLAYER *pPlayer, int a2)
pSprite = actDropObject(pPlayer->pSprite, 148);
if (pSprite)
pSprite->owner = pPlayer->at91[1];
gRedFlagDropped = true;
sprintf(buffer, "%s dropped Red Flag", gProfile[pPlayer->at57].name);
sndStartSample(8004, 255, 2, 0);
viewSetMessage(buffer);

View file

@ -196,6 +196,9 @@ extern POSTURE gPosture[4][3];
extern PLAYER gPlayer[kMaxPlayers];
extern PLAYER *gMe, *gView;
extern bool gBlueFlagDropped;
extern bool gRedFlagDropped;
extern PROFILE gProfile[kMaxPlayers];
extern int dword_21EFB0[kMaxPlayers];

View file

@ -1312,8 +1312,129 @@ void DrawPackItemInStatusBar2(PLAYER *pPlayer, int x, int y, int x2, int y2, int
DrawStatNumber("%3d", pPlayer->packInfo[pPlayer->at321].at1, kSBarNumberInv, x2, y2, 0, 0, nStat, nScale);
}
void viewDrawPlayerSlots(void)
{
for (int nRows = (gNetPlayers - 1) / 4; nRows >= 0; nRows--)
{
for (int nCol = 0; nCol < 4; nCol++)
{
DrawStatSprite(2229, 40 + nCol * 80, 4 + nRows * 9, 16);
}
}
}
char gTempStr[128];
void viewDrawPlayerFrags(void)
{
viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{
int x = 80 * (i & 3);
int y = 9 * (i / 4);
int col = gPlayer[p].at2ea & 3;
char* name = gProfile[p].name;
if (gProfile[p].skill == 2)
sprintf(gTempStr, "%s", name);
else
sprintf(gTempStr, "%s [%d]", name, gProfile[p].skill);
Bstrupr(gTempStr);
viewDrawText(4, gTempStr, x + 4, y + 1, -128, 11 + col, 0, 0);
sprintf(gTempStr, "%2d", gPlayer[p].at2c6);
viewDrawText(4, gTempStr, x + 76, y + 1, -128, 11 + col, 2, 0);
}
}
void viewDrawPlayerFlags(void)
{
viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{
int x = 80 * (i & 3);
int y = 9 * (i / 4);
int col = gPlayer[p].at2ea & 3;
char* name = gProfile[p].name;
if (gProfile[p].skill == 2)
sprintf(gTempStr, "%s", name);
else
sprintf(gTempStr, "%s [%d]", name, gProfile[p].skill);
Bstrupr(gTempStr);
viewDrawText(4, gTempStr, x + 4, y + 1, -128, 11 + col, 0, 0);
sprintf(gTempStr, "F");
x += 76;
if (gPlayer[p].at90 & 2)
{
viewDrawText(4, gTempStr, x, y + 1, -128, 12, 2, 0);
x -= 6;
}
if (gPlayer[p].at90 & 1)
viewDrawText(4, gTempStr, x, y + 1, -128, 11, 2, 0);
}
}
void viewDrawCtfHudVanilla(ClockTicks arg)
{
int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || ((int)totalclock & 8))
{
viewDrawText(0, "BLUE", x, y, -128, 10, 0, 0, 256);
dword_21EFD0[0] = dword_21EFD0[0] - arg;
if (dword_21EFD0[0] < 0)
dword_21EFD0[0] = 0;
sprintf(gTempStr, "%-3d", dword_21EFB0[0]);
viewDrawText(0, gTempStr, x, y + 10, -128, 10, 0, 0, 256);
}
x = 319;
if (dword_21EFD0[1] == 0 || ((int)totalclock & 8))
{
viewDrawText(0, "RED", x, y, -128, 7, 2, 0, 512);
dword_21EFD0[1] = dword_21EFD0[1] - arg;
if (dword_21EFD0[1] < 0)
dword_21EFD0[1] = 0;
sprintf(gTempStr, "%3d", dword_21EFB0[1]);
viewDrawText(0, gTempStr, x, y + 10, -128, 7, 2, 0, 512);
}
}
void viewDrawCtfHud(void)
{
bool blueFlagTaken = false;
bool redFlagTaken = false;
int blueFlagCarrierColor = 0;
int redFlagCarrierColor = 0;
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{
if ((gPlayer[p].at90 & 1) != 0)
{
blueFlagTaken = true;
blueFlagCarrierColor = gPlayer[p].at2ea & 3;
}
if ((gPlayer[p].at90 & 2) != 0)
{
redFlagTaken = true;
redFlagCarrierColor = gPlayer[p].at2ea & 3;
}
}
bool meHaveBlueFlag = gMe->at90 & 1;
DrawStatMaskedSprite(meHaveBlueFlag ? 3558 : 3559, 320, 75, 0, 10, 0, 65536 * 0.35);
if (gBlueFlagDropped)
DrawStatMaskedSprite(2332, 305, 83, 0, 10, 0, 65536);
else if (blueFlagTaken)
DrawStatMaskedSprite(4097, 307, 77, 0, blueFlagCarrierColor ? 2 : 10, 0, 65536);
DrawStatNumber("%d", dword_21EFB0[0], kSBarNumberInv, 290, 90, 0, 10, 0, 65536 * 0.75);
bool meHaveRedFlag = gMe->at90 & 2;
DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 320, 110, 0, 2, 0, 65536 * 0.35);
if (gRedFlagDropped)
DrawStatMaskedSprite(2332, 305, 117, 0, 2, 0, 65536);
else if (redFlagTaken)
DrawStatMaskedSprite(4097, 307, 111, 0, redFlagCarrierColor ? 2 : 10, 0, 65536);
DrawStatNumber("%d", dword_21EFB0[1], kSBarNumberInv, 290, 125, 0, 2, 0, 65536 * 0.75);
}
void UpdateStatusBar(ClockTicks arg)
{
PLAYER *pPlayer = gView;
@ -1536,49 +1657,19 @@ void UpdateStatusBar(ClockTicks arg)
if (gGameOptions.nGameType == 3)
{
int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || ((int)totalclock & 8))
if (VanillaMode())
{
viewDrawText(0, "BLUE", x, y, -128, 10, 0, 0, 256);
dword_21EFD0[0] = dword_21EFD0[0]-arg;
if (dword_21EFD0[0] < 0)
dword_21EFD0[0] = 0;
sprintf(gTempStr, "%-3d", dword_21EFB0[0]);
viewDrawText(0, gTempStr, x, y+10, -128, 10, 0, 0, 256);
viewDrawCtfHudVanilla(arg);
}
x = 319;
if (dword_21EFD0[1] == 0 || ((int)totalclock & 8))
{
viewDrawText(0, "RED", x, y, -128, 7, 2, 0, 512);
dword_21EFD0[1] = dword_21EFD0[1]-arg;
if (dword_21EFD0[1] < 0)
dword_21EFD0[1] = 0;
sprintf(gTempStr, "%3d", dword_21EFB0[1]);
viewDrawText(0, gTempStr, x, y+10, -128, 7, 2, 0, 512);
}
return;
}
for (int nRows = (gNetPlayers-1) / 4; nRows >= 0; nRows--)
{
for (int nCol = 0; nCol < 4; nCol++)
{
DrawStatSprite(2229, 40+nCol*80, 4+nRows*9, 16);
}
}
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{
int x = 80*(i&3);
int y = 9*(i/4);
int col = gPlayer[p].at2ea&3;
char *name = gProfile[p].name;
if (gProfile[p].skill == 2)
sprintf(gTempStr, "%s", name);
else
sprintf(gTempStr, "%s [%d]", name, gProfile[p].skill);
Bstrupr(gTempStr);
viewDrawText(4, gTempStr, x+4, y+1, -128, 11+col, 0, 0);
sprintf(gTempStr, "%2d", gPlayer[p].at2c6);
viewDrawText(4, gTempStr, x+76, y+1, -128, 11+col, 2, 0);
{
viewDrawCtfHud();
viewDrawPlayerFlags();
}
}
else
{
viewDrawPlayerFrags();
}
}