Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nemesis mode + 'convar' #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ zr_knockback_scale 5.0 // Global knockback scale
zr_ztele_max_distance 150.0 // Maximum distance players are allowed to move after starting ztele
zr_ztele_allow_humans 0 // Whether to allow humans to use ztele
zr_infect_spawn_type 1 // Type of Mother Zombies Spawn [0 = MZ spawn where they stand, 1 = MZ get teleported back to spawn on being picked]
zr_nemesis_mode 0 // Whether to enable Nemesis mode (CTs die but do not swap teams when stabbed)
zr_infect_spawn_time_min 15 // Minimum time in which Mother Zombies should be picked, after round start
zr_infect_spawn_time_max 15 // Maximum time in which Mother Zombies should be picked, after round start
zr_infect_spawn_mz_ratio 7 // Ratio of all Players to Mother Zombies to be spawned at round start
Expand Down
27 changes: 24 additions & 3 deletions src/zombiereborn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,19 @@ void ZR_RespawnAll()
}
}

static bool g_bNemesisMode = false;
CON_COMMAND_F(zr_nemesis_mode, "Whether to enable Nemesis mode (CTs die but do not swap teams when stabbed)", FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY)
{
if (args.ArgC() < 2)
{
Msg("zr_nemesis_mode %b\n", g_bNemesisMode);
return;
}
g_bNemesisMode = V_StringToBool(args[1], false);
if (g_bEnableZR && !g_bNemesisMode && g_bRespawnEnabled)
ZR_RespawnAll(); // Respawn all dead CTs that hadn't swapped teams
}

void ToggleRespawn(bool force = false, bool value = false)
{
if ((!force && !g_bRespawnEnabled) || (force && value))
Expand Down Expand Up @@ -969,7 +982,7 @@ void ZR_OnRoundStart(IGameEvent* pEvent)
void ZR_OnPlayerSpawn(CCSPlayerController* pController)
{
// delay infection a bit
bool bInfect = g_ZRRoundState == EZRRoundState::POST_INFECTION;
bool bInfect = g_ZRRoundState == EZRRoundState::POST_INFECTION && (!g_bNemesisMode || pController->m_iTeamNum == CS_TEAM_T);

// We're infecting this guy with a delay, disable all damage as they have 100 hp until then
// also set team immediately in case the spawn teleport is team filtered
Expand Down Expand Up @@ -1369,7 +1382,10 @@ bool ZR_Hook_OnTakeDamage_Alive(CTakeDamageInfo *pInfo, CCSPlayerPawn *pVictimPa
const char *pszAbilityClass = pInfo->m_hAbility.Get() ? pInfo->m_hAbility.Get()->GetClassname() : "";
if (pAttackerPawn->m_iTeamNum() == CS_TEAM_T && pVictimPawn->m_iTeamNum() == CS_TEAM_CT && !V_strncmp(pszAbilityClass, "weapon_knife", 12))
{
ZR_Infect(pAttackerController, pVictimController, false);
if (g_bNemesisMode)
pVictimPawn->m_iHealth(0);
else
ZR_Infect(pAttackerController, pVictimController, false);
return true; // nullify the damage
}

Expand Down Expand Up @@ -1527,7 +1543,8 @@ void ZR_OnPlayerDeath(IGameEvent* pEvent)
new CTimer(g_flRespawnDelay < 0.0f ? 2.0f : g_flRespawnDelay, false, false, [handle]()
{
CCSPlayerController* pController = (CCSPlayerController*)handle.Get();
if (!pController || !g_bRespawnEnabled || pController->m_iTeamNum < CS_TEAM_T)
if (!pController || !g_bRespawnEnabled || pController->m_iTeamNum < CS_TEAM_T ||
(g_bNemesisMode && pController->m_iTeamNum == CS_TEAM_CT && g_ZRRoundState == EZRRoundState::POST_INFECTION))
return -1.0f;
pController->Respawn();
return -1.0f;
Expand Down Expand Up @@ -1572,6 +1589,10 @@ bool ZR_CheckTeamWinConditions(int iTeamNum)
if (g_ZRRoundState == EZRRoundState::ROUND_END || (iTeamNum == CS_TEAM_CT && g_bRespawnEnabled) || (iTeamNum != CS_TEAM_T && iTeamNum != CS_TEAM_CT))
return false;

ConVar* cvar = g_pCVar->GetConVar(g_pCVar->FindConVar("mp_respawn_on_death_ct"));
if (iTeamNum == CS_TEAM_T && g_bNemesisMode && *(bool*)&cvar->values)
return false;

// check the opposite team
if (ZR_IsTeamAlive(iTeamNum == CS_TEAM_CT ? CS_TEAM_T : CS_TEAM_CT))
return false;
Expand Down