raze/source/games/blood/src/endgame.cpp

143 lines
3.4 KiB
C++
Raw Normal View History

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.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
2019-09-19 22:42:45 +00:00
#include "build.h"
#include "v_draw.h"
#include "statistics.h"
#include "gstrings.h"
#include "gamestate.h"
#include "raze_sound.h"
#include "d_net.h"
#include "screenjob.h"
#include "blood.h"
2019-09-19 22:42:45 +00:00
BEGIN_BLD_NS
2020-08-02 15:45:03 +00:00
2021-12-29 19:45:55 +00:00
void GameInterface::LevelCompleted(MapRecord* map, int skill)
2019-09-19 22:42:45 +00:00
{
// Save the player state before taking down anything.
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
if (gPlayer[i].actor)
{
memcpy(&gPlayerTemp[i], &gPlayer[i], sizeof(PLAYER));
gHealthTemp[i] = gPlayer[i].actor->xspr.health;
}
}
EndLevel();
Mus_Stop();
SummaryInfo info{};
info.kills = gKillMgr.Kills;
info.maxkills = gKillMgr.TotalKills;
info.secrets = gSecretMgr.Founds;
info.maxsecrets = gSecretMgr.Total;
info.supersecrets = gSecretMgr.Super;
info.endofgame = map == nullptr;
2019-09-19 22:42:45 +00:00
ShowIntermission(currentLevel, map, &info, [=](bool)
{
soundEngine->StopAllChannels();
2021-12-29 19:45:55 +00:00
gameaction = map ? ga_nextlevel : ga_creditsmenu;
});
}
2019-09-19 22:42:45 +00:00
void CKillMgr::SetCount(int nCount)
{
TotalKills = nCount;
2019-09-19 22:42:45 +00:00
}
void CKillMgr::AddNewKill(int nCount)
2019-09-19 22:42:45 +00:00
{
TotalKills += nCount;
2019-09-19 22:42:45 +00:00
}
2021-12-22 15:43:59 +00:00
void CKillMgr::AddKill(DBloodActor* actor)
{
2021-12-22 15:43:59 +00:00
if (actor->spr.statnum == kStatDude && actor->spr.type != kDudeBat && actor->spr.type != kDudeRat && actor->spr.type != kDudeInnocent && actor->spr.type != kDudeBurningInnocent)
Kills++;
}
void CKillMgr::CountTotalKills(void)
2019-09-19 22:42:45 +00:00
{
TotalKills = 0;
2021-08-28 10:11:03 +00:00
BloodStatIterator it(kStatDude);
while (auto actor = it.Next())
{
2021-12-22 15:43:59 +00:00
if (actor->spr.type < kDudeBase || actor->spr.type >= kDudeMax)
2021-08-28 10:11:03 +00:00
I_Error("Non-enemy sprite (%d) in the enemy sprite list.", actor->GetIndex());
2021-12-22 15:43:59 +00:00
if (actor->spr.statnum == kStatDude && actor->spr.type != kDudeBat && actor->spr.type != kDudeRat && actor->spr.type != kDudeInnocent && actor->spr.type != kDudeBurningInnocent)
TotalKills++;
}
2019-09-19 22:42:45 +00:00
}
void CKillMgr::Clear(void)
{
TotalKills = Kills = 0;
2019-09-19 22:42:45 +00:00
}
void CSecretMgr::SetCount(int nCount)
{
Total = nCount;
2019-09-19 22:42:45 +00:00
}
void CSecretMgr::Found(int nType)
{
if (nType == 0) Founds++;
else if (nType < 0) {
viewSetSystemMessage("Invalid secret type %d triggered.", nType);
return;
}
else Super++;
2019-09-19 22:42:45 +00:00
}
void CSecretMgr::Clear(void)
{
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;
END_BLD_NS