2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
2020-07-31 18:39:02 +00:00
|
|
|
#include "v_draw.h"
|
2019-11-12 21:59:51 +00:00
|
|
|
#include "statistics.h"
|
2019-12-09 01:01:30 +00:00
|
|
|
#include "gstrings.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
2020-04-12 06:09:38 +00:00
|
|
|
#include "raze_sound.h"
|
2020-09-01 17:49:05 +00:00
|
|
|
#include "d_net.h"
|
2020-09-01 19:27:32 +00:00
|
|
|
#include "screenjob.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "blood.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-08-02 15:45:03 +00:00
|
|
|
|
2021-04-28 18:16:13 +00:00
|
|
|
void GameInterface::LevelCompleted(MapRecord *map, int skill)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-04-28 18:16:13 +00:00
|
|
|
EndLevel();
|
|
|
|
Mus_Stop();
|
2020-09-01 19:27:32 +00:00
|
|
|
|
2021-04-28 18:16:13 +00:00
|
|
|
SummaryInfo info{};
|
2020-09-01 19:27:32 +00:00
|
|
|
|
2021-04-28 18:16:13 +00:00
|
|
|
info.kills = gKillMgr.Kills;
|
|
|
|
info.maxkills = gKillMgr.TotalKills;
|
|
|
|
info.secrets = gSecretMgr.Founds;
|
|
|
|
info.maxsecrets = gSecretMgr.Total;
|
|
|
|
info.time = gSecretMgr.Super;
|
|
|
|
info.endofgame = map == nullptr;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2021-04-28 18:16:13 +00:00
|
|
|
ShowIntermission(currentLevel, map, &info, [=](bool)
|
2020-09-01 19:27:32 +00:00
|
|
|
{
|
|
|
|
soundEngine->StopAllChannels();
|
2021-04-28 18:16:13 +00:00
|
|
|
gameaction = map? ga_nextlevel : ga_creditsmenu;
|
2020-09-01 19:27:32 +00:00
|
|
|
});
|
2020-09-04 18:46:44 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
CKillMgr::CKillMgr()
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Clear();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKillMgr::SetCount(int nCount)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 19:27:32 +00:00
|
|
|
void CKillMgr::AddNewKill(int nCount)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills += nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-10-13 22:29:19 +00:00
|
|
|
void CKillMgr::AddKill(spritetype* pSprite)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
if (pSprite->statnum == kStatDude && pSprite->type != kDudeBat && pSprite->type != kDudeRat && pSprite->type != kDudeInnocent && pSprite->type != kDudeBurningInnocent)
|
|
|
|
Kills++;
|
2019-10-13 22:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 19:27:32 +00:00
|
|
|
void CKillMgr::CountTotalKills(void)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = 0;
|
2020-10-15 15:15:45 +00:00
|
|
|
int nSprite;
|
|
|
|
StatIterator it(kStatDude);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-09-01 19:27:32 +00:00
|
|
|
{
|
|
|
|
spritetype* pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax)
|
2020-10-11 10:22:36 +00:00
|
|
|
I_Error("Non-enemy sprite (%d) in the enemy sprite list.", nSprite);
|
2020-09-01 19:27:32 +00:00
|
|
|
if (pSprite->statnum == kStatDude && pSprite->type != kDudeBat && pSprite->type != kDudeRat && pSprite->type != kDudeInnocent && pSprite->type != kDudeBurningInnocent)
|
|
|
|
TotalKills++;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKillMgr::Clear(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = Kills = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSecretMgr::CSecretMgr(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Clear();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::SetCount(int nCount)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Total = nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::Found(int nType)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
if (nType == 0) Founds++;
|
|
|
|
else if (nType < 0) {
|
|
|
|
viewSetSystemMessage("Invalid secret type %d triggered.", nType);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else Super++;
|
|
|
|
|
|
|
|
if (gGameOptions.nGameType == 0) {
|
|
|
|
viewSetMessage(GStrings(FStringf("TXTB_SECRET%d", Random(2))), 0, MESSAGE_PRIORITY_SECRET);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::Clear(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Total = Founds = Super = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 12:05:17 +00:00
|
|
|
void SerializeGameStats(FSerializer& arc)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-22 12:05:17 +00:00
|
|
|
if (arc.BeginObject("gamestats"))
|
|
|
|
{
|
|
|
|
arc("secrets", gSecretMgr.Total)
|
|
|
|
("secretsfound", gSecretMgr.Founds)
|
|
|
|
("super", gSecretMgr.Super)
|
|
|
|
("totalkills", gKillMgr.TotalKills)
|
|
|
|
("kills", gKillMgr.Kills)
|
|
|
|
.EndObject();
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSecretMgr gSecretMgr;
|
|
|
|
CKillMgr gKillMgr;
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|