- implemented a proper kill counter.

Unfortunately the display is a bit limited by the available font characters.
This commit is contained in:
Christoph Oelckers 2020-08-23 14:39:14 +02:00
parent e75cfd82f9
commit 2a3f7a48c9
19 changed files with 83 additions and 33 deletions

View file

@ -69,6 +69,8 @@ void InitFonts()
fontdata.Insert('0' + i, tileGetTexture(3555 + i));
}
fontdata.Insert('.', tileGetTexture(3548));
fontdata.Insert(':', tileGetTexture(3548)); // we have no colon but need something here.
fontdata.Insert('/', tileGetTexture(3552)); // same here
fontdata.Insert('!', tileGetTexture(3549));
fontdata.Insert('?', tileGetTexture(3550));
fontdata.Insert(',', tileGetTexture(3551));

View file

@ -146,7 +146,7 @@ int BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint8
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nAnubis | 0x90000);
runlist_AddRunRec(NewRun, nAnubis | 0x90000);
nCreaturesLeft++;
nCreaturesTotal++;
return nAnubis | 0x90000;
}
@ -480,7 +480,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
AnubisList[nAnubis].nHealth = 0;
nCreaturesLeft--;
nCreaturesKilled++;
if (nAction < 11)
{

View file

@ -119,7 +119,8 @@ short nFontFirstChar;
short nBackgroundPic;
short nShadowPic;
short nCreaturesLeft = 0;
short nCreaturesKilled = 0, nCreaturesTotal = 0;
int leveltime;
short nFreeze;
@ -552,6 +553,7 @@ void GameTicker()
while (!EndLevel && totalclock >= tclocks + 4)
{
tclocks += 4;
leveltime++;
GameMove();
}
}
@ -770,6 +772,11 @@ bool GameInterface::CanSave()
return !bRecord && !bPlayback && !paused && !bInDemo && nTotalPlayers == 1;
}
::GameStats GameInterface::getStats()
{
return { nCreaturesKilled, nCreaturesTotal, 0, 0, leveltime / 30, 0 };
}
::GameInterface* CreateInterface()
{
return new GameInterface;
@ -779,7 +786,8 @@ bool GameInterface::CanSave()
// This is only the static global data.
static SavegameHelper sgh("exhumed",
SV(besttarget),
SV(nCreaturesLeft), // todo: also maintain a total counter.
SV(nCreaturesTotal),
SV(nCreaturesKilled),
SV(nFreeze),
SV(nSnakeCam),
SV(nLocalSpr),
@ -800,6 +808,7 @@ static SavegameHelper sgh("exhumed",
SV(localclock),
SV(tclocks),
SV(totalclock),
SV(leveltime),
nullptr);
extern short cPupData[300];

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "zstring.h"
#include "filesystem.h"
#include "screenjob.h"
#include "gamestruct.h"
BEGIN_PS_NS
@ -180,7 +181,8 @@ extern short nFontFirstChar;
extern short nBackgroundPic;
extern short nShadowPic;
extern short nCreaturesLeft;
extern short nCreaturesTotal, nCreaturesKilled;
extern int leveltime;
extern int lLocalButtons;
@ -321,7 +323,7 @@ struct GameInterface : ::GameInterface
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
FString statFPS() override;
//GameStats getStats() override;
::GameStats getStats() override;
};

View file

@ -267,7 +267,7 @@ int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nFish | 0x120000);
FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish | 0x120000);
nCreaturesLeft++;
nCreaturesTotal++;
return nFish | 0x120000;
}
@ -361,7 +361,7 @@ void FuncFish(int a, int nDamage, int nRun)
if (FishList[nFish].nHealth <= 0)
{
FishList[nFish].nHealth = 0;
nCreaturesLeft--;
nCreaturesKilled++;
sprite[nSprite].cstat &= 0xFEFE;

View file

@ -85,9 +85,11 @@ uint8_t LoadLevel(int nMap)
// init stuff
{
StopAllSounds();
nCreaturesLeft = 0;
nCreaturesKilled = 0;
nCreaturesTotal = 0;
nFreeze = 0;
nSpiritSprite = -1;
leveltime = 0;
InitLion();
InitRexs();

View file

@ -198,7 +198,7 @@ int BuildLava(short nSprite, int x, int y, int UNUSED(z), short nSector, short n
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLava | 0x150000);
LavaList[nLava].nRun = runlist_AddRunRec(NewRun, nLava | 0x150000);
nCreaturesLeft++;
nCreaturesTotal++;
return nLava | 0x150000;
}
@ -248,7 +248,7 @@ void FuncLava(int a, int nDamage, int nRun)
LavaList[nLava].nAction = 5;
LavaList[nLava].nFrame = 0;
nCreaturesLeft--;
nCreaturesKilled++;
sprite[nSprite].cstat &= 0xFEFE;
}

View file

@ -128,7 +128,7 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
MoveHook[nLion] = runlist_AddRunRec(NewRun, nLion | 0x130000);
nCreaturesLeft++;
nCreaturesTotal++;
return nLion | 0x130000;
}
@ -180,7 +180,7 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nHealth = 0;
nCreaturesLeft--;
nCreaturesKilled++;
if (nAction < 10)
{

View file

@ -122,7 +122,7 @@ int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle)
MummyList[nMummy].H = runlist_AddRunRec(NewRun, nMummy | 0xE0000);
nCreaturesLeft++;
nCreaturesTotal++;
return (nMummy | 0xE0000);
}
@ -432,7 +432,7 @@ void FuncMummy(int a, int nDamage, int nRun)
MummyList[nMummy].nHealth = 300;
MummyList[nMummy].nTarget = -1;
nCreaturesLeft++;
nCreaturesTotal++;
}
return;
}
@ -493,7 +493,7 @@ void FuncMummy(int a, int nDamage, int nRun)
{
MummyList[nMummy].nHealth = 0;
sprite[nSprite].cstat &= 0xFEFE;
nCreaturesLeft--;
nCreaturesKilled++;
DropMagic(nSprite);

View file

@ -1157,7 +1157,7 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
runlist_AddRunRec(NewRun, nQueen | 0x1A0000);
nCreaturesLeft++;
nCreaturesTotal++;
return nQueen | 0x1A0000;
}
@ -1491,7 +1491,7 @@ void FuncQueen(int a, int nDamage, int nRun)
QueenList[nQueen].nHealth = 0;
QueenList[nQueen].field_C = 5;
nCreaturesLeft--;
nCreaturesKilled++;
break;
}

View file

@ -127,7 +127,7 @@ int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, in
// this isn't stored anywhere.
runlist_AddRunRec(NewRun, nRex | 0x180000);
nCreaturesLeft++;
nCreaturesTotal++;
return nRex | 0x180000;
}
@ -185,7 +185,7 @@ void FuncRex(int a, int nDamage, int nRun)
RexList[nRex].nHealth = 0;
nCreaturesLeft--;
nCreaturesKilled++;
if (nAction < 6)
{

View file

@ -128,7 +128,7 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, RoachCount | 0x1C0000);
RoachList[RoachCount].field_A = runlist_AddRunRec(NewRun, RoachCount | 0x1C0000);
nCreaturesLeft++;
nCreaturesTotal++;
return RoachCount | 0x1C0000;
}
@ -195,7 +195,7 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].field_2 = 0;
}
nCreaturesLeft--; // NOTE: This was incrementing in original code. Bug?
nCreaturesKilled++; // NOTE: This was incrementing in original code. Bug?
}
else
{

View file

@ -1630,12 +1630,12 @@ void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage)
return;
}
short nPreCreaturesLeft = nCreaturesLeft;
short nPreCreaturesKilled = nCreaturesKilled;
runlist_SendMessageToRunRec(nRun, (nSprite2 & 0xFFFF) | 0x80000, nDamage * 4);
// is there now one less creature? (has one died)
if (nPreCreaturesLeft > nCreaturesLeft&& nSprite2 > -1)
if (nPreCreaturesKilled > nCreaturesKilled && nSprite2 > -1)
{
if (sprite[nSprite2].statnum != 100) {
return;

View file

@ -133,7 +133,7 @@ int BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nScorp | 0x220000);
scorpion[nScorp].f = runlist_AddRunRec(NewRun, nScorp | 0x220000);
nCreaturesLeft++;
nCreaturesTotal++;
return nScorp | 0x220000;
}
@ -196,7 +196,7 @@ void FuncScorp(int a, int nDamage, int nRun)
sprite[nSprite].zvel = 0;
sprite[nSprite].cstat &= 0xFEFE;
nCreaturesLeft--;
nCreaturesKilled++;
return;
}
else

View file

@ -133,7 +133,7 @@ int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, in
// this isn't stored anywhere.
runlist_AddRunRec(NewRun, nSet | 0x190000);
nCreaturesLeft++;
nCreaturesTotal++;
return nSet | 0x190000;
}
@ -272,7 +272,7 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nHealth = 0;
nCreaturesLeft--;
nCreaturesKilled++;
if (nAction < 10)
{

View file

@ -662,7 +662,7 @@ void UpdateCreepySounds()
nCreepyTimer--;
if (nCreepyTimer <= 0)
{
if (nCreaturesLeft > 0 && !(SectFlag[nPlayerViewSect[nLocalPlayer]] & 0x2000))
if (nCreaturesKilled < nCreaturesTotal && !(SectFlag[nPlayerViewSect[nLocalPlayer]] & 0x2000))
{
int vsi = seq_GetFrameSound(SeqOffsets[kSeqCreepy], totalmoves % SeqSize[SeqOffsets[kSeqCreepy]]);
if (vsi >= 0 && (vsi & 0x1ff) < kMaxSounds)

View file

@ -115,7 +115,7 @@ int BuildSpider(int nSprite, int x, int y, int z, short nSector, int nAngle)
SpiderList[nSpider].nRun = runlist_AddRunRec(NewRun, nSpider | 0xC0000);
nCreaturesLeft++;
nCreaturesTotal++;
return nSpider | 0xC0000;
}
@ -431,7 +431,7 @@ void FuncSpider(int a, int nDamage, int nRun)
sprite[nSprite].cstat &= 0xFEFE;
nCreaturesLeft--;
nCreaturesKilled++;
for (int i = 0; i < 7; i++)
{

View file

@ -822,6 +822,40 @@ private:
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void PrintLevelStats(int bottomy)
{
if (hud_stats)
{
FLevelStats stats{};
stats.fontscale = 1.;
stats.spacing = SmallFont->GetHeight();
stats.screenbottomspace = bottomy;
stats.font = SmallFont;
stats.letterColor = CR_RED;
stats.standardColor = CR_UNTRANSLATED;
stats.completeColor = CR_DARKGREEN;
stats.time = Scale(leveltime, 1000, 30);
stats.kills = nCreaturesKilled;
stats.maxkills = nCreaturesTotal;
stats.frags = -1;
stats.secrets = 0;
stats.maxsecrets = 0;
DBaseStatusBar::PrintLevelStats(stats);
}
}
public:
void Draw()
{
@ -829,6 +863,7 @@ public:
{
DrawStatus();
}
PrintLevelStats(hud_size == Hud_Nothing ? 0 : 40);
}
};

View file

@ -167,7 +167,7 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
WaspList[nWasp].nRun = runlist_AddRunRec(NewRun, nWasp | 0x1E0000);
nCreaturesLeft++;
nCreaturesTotal++;
return nSprite;
}
@ -242,7 +242,7 @@ void FuncWasp(int a, int nDamage, int nRun)
sprite[nSprite].zvel = 512;
nCreaturesLeft--;
nCreaturesKilled++;
}
}
return;