Skip to content

Commit 173fcb9

Browse files
tilgepVauff
andauthored
Add !motherzombies command (#447)
* Add !motherzombies command * grammar tweak --------- Co-authored-by: Vauff <mctehkitti@gmail.com>
1 parent ff451b8 commit 173fcb9

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/zombiereborn.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static bool g_bRespawnEnabled = true;
5656
static CHandle<CBaseEntity> g_hRespawnToggler;
5757
static CHandle<CTeam> g_hTeamCT;
5858
static CHandle<CTeam> g_hTeamT;
59+
std::vector<ZEPlayerHandle> g_MotherZombies;
5960

6061
CZRPlayerClassManager* g_pZRPlayerClassManager = nullptr;
6162
ZRWeaponConfig* g_pZRWeaponConfig = nullptr;
@@ -911,6 +912,8 @@ void ZR_OnRoundPrestart(IGameEvent* pEvent)
911912
if (pPawn)
912913
pPawn->m_bTakesDamage = false;
913914
}
915+
916+
g_MotherZombies.clear();
914917
}
915918

916919
void SetupRespawnToggler()
@@ -1258,6 +1261,8 @@ void ZR_InfectMotherZombie(CCSPlayerController* pVictimController, std::vector<S
12581261

12591262
ZEPlayerHandle hPlayer = pZEPlayer->GetHandle();
12601263
CTimer::Create(rand() % (int)g_cvarMoanInterval.Get(), TIMERFLAG_MAP | TIMERFLAG_ROUND, [hPlayer]() { return ZR_MoanTimer(hPlayer); });
1264+
1265+
g_MotherZombies.push_back(hPlayer);
12611266
}
12621267

12631268
// make players who've been picked as MZ recently less likely to be picked again
@@ -2090,4 +2095,43 @@ CON_COMMAND_CHAT_FLAGS(revive, "- Revive a player", ADMFLAG_GENERIC)
20902095
}
20912096
if (iNumClients > 1)
20922097
PrintMultiAdminAction(nType, strCommandPlayerName, "revived", "", ZR_PREFIX);
2098+
}
2099+
2100+
CON_COMMAND_CHAT(motherzombies, "- Print the current mother zombies to chat")
2101+
{
2102+
if (g_ZRRoundState == EZRRoundState::ROUND_START || g_MotherZombies.size() == 0)
2103+
{
2104+
ClientPrint(player, HUD_PRINTTALK, ZR_PREFIX "There are no mother zombies.");
2105+
return;
2106+
}
2107+
2108+
bool first = true;
2109+
std::string names = "";
2110+
for (int i = g_MotherZombies.size() - 1; i >= 0; i--)
2111+
{
2112+
if (!g_MotherZombies[i].IsValid())
2113+
{
2114+
g_MotherZombies.erase(g_MotherZombies.begin() + i);
2115+
continue;
2116+
}
2117+
2118+
CCSPlayerController* pMZ = CCSPlayerController::FromSlot(g_MotherZombies[i].GetPlayerSlot());
2119+
if (!pMZ)
2120+
continue;
2121+
2122+
if (first)
2123+
{
2124+
names = pMZ->GetPlayerName();
2125+
first = false;
2126+
}
2127+
else
2128+
{
2129+
names += ", " + pMZ->GetPlayerName();
2130+
}
2131+
}
2132+
2133+
if (first)
2134+
ClientPrint(player, HUD_PRINTTALK, ZR_PREFIX "There are no mother zombies.");
2135+
else
2136+
ClientPrint(player, HUD_PRINTTALK, ZR_PREFIX "Mother zombies: %s", names.c_str());
20932137
}

0 commit comments

Comments
 (0)