Skip to content

Commit 79dd216

Browse files
committed
Changed zm_ztele_max_distance and zm_ztele_allow_humans
Added zm_ztele_human_after Added zm_ztele_delay_zombie Added zm_ztele_delay_human Added zm_ztele_max_zombie Added zm_ztele_max_human
1 parent 6516126 commit 79dd216

File tree

3 files changed

+93
-5
lines changed

3 files changed

+93
-5
lines changed

cfg/cs2fixes/cs2fixes.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,9 @@ zm_napalm_full_damage 50.0 // The amount of damage needed to apply full burn d
180180
zm_default_winner_team 1 // Which team wins when time ran out [1 = Draw, 2 = Zombies, 3 = Humans]
181181
zm_zmtele_max_distance 150.0 // Maximum distance players are allowed to move after starting ztele
182182
zm_zmtele_allow_humans 0 // Whether to allow humans to use ztele
183-
zm_damage_cash_scale 0.0 // Multiplier on cash given when damaging zombies (0.0 = disabled)
183+
zm_damage_cash_scale 0.0 // Multiplier on cash given when damaging zombies (0.0 = disabled)
184+
zm_ztele_human_after 1 // Allow humans to use ZTele after the mother zombie has spawned. 0 if always allowed.
185+
zm_ztele_delay_zombie 3.0 // Time between using ZTele command and teleportation for zombies.
186+
zm_ztele_delay_human 3.0 // Time between using ZTele command and teleportation for humans. [Dependency: zm_ztele_allow_humans]
187+
zm_ztele_max_zombie 3 // Max number of times a zombie is allowed to use ZTele per round.
188+
zm_ztele_max_human 1 // Max number of times a human is allowed to use ZTele per round. [Dependency: zm_ztele_allow_humans]

src/playermanager.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ class ZEPlayer
196196
m_flEntwatchHudX = -7.5f;
197197
m_flEntwatchHudY = -2.0f;
198198
m_flEntwatchHudSize = 60.0f;
199+
m_iTeleUsagesHuman = 0;
200+
m_iTeleUsagesZombie = 0;
199201
}
200202

201203
~ZEPlayer()
@@ -266,6 +268,8 @@ class ZEPlayer
266268
void SetEntwatchHudColor(Color colorHud);
267269
void SetEntwatchHudPos(float x, float y);
268270
void SetEntwatchHudSize(float flSize);
271+
void SetHumanTeleUsages(int usages) { m_iTeleUsagesHuman = usages; }
272+
void SetZombieTeleUsages(int usages) { m_iTeleUsagesZombie = usages; }
269273

270274
uint64 GetAdminFlags() { return m_iAdminFlags; }
271275
int GetAdminImmunity() { return m_iAdminImmunity; }
@@ -315,6 +319,8 @@ class ZEPlayer
315319
float GetEntwatchHudX() { return m_flEntwatchHudX; }
316320
float GetEntwatchHudY() { return m_flEntwatchHudY; }
317321
float GetEntwatchHudSize() { return m_flEntwatchHudSize; }
322+
int GetHumanTeleUsages() { return m_iTeleUsagesHuman; }
323+
int GetZombieTeleUsages() { return m_iTeleUsagesZombie; }
318324

319325
void OnSpawn();
320326
void OnAuthenticated();
@@ -388,6 +394,9 @@ class ZEPlayer
388394
float m_flEntwatchHudX;
389395
float m_flEntwatchHudY;
390396
float m_flEntwatchHudSize;
397+
398+
int m_iTeleUsagesHuman;
399+
int m_iTeleUsagesZombie;
391400
};
392401

393402
class CPlayerManager

src/zombiemod.cpp

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ CConVar<float> g_cvarZMNapalmDuration("zm_napalm_burn_duration", FCVAR_NONE, "Ho
8383
CConVar<float> g_cvarZMNapalmFullDamage("zm_napalm_full_damage", FCVAR_NONE, "The amount of damage needed to apply full burn duration for napalm grenades (max grenade damage is 99)", 50.0f, true, 0.0f, true, 99.0f);
8484
CConVar<float> g_cvarZMDamageCashScale("zm_damage_cash_scale", FCVAR_NONE, "Multiplier on cash given when damaging zombies (0.0 = disabled)", 0.0f, true, 0.0f, false, 100.0f);
8585
CConVar<int> g_cvarZMDefaultWinnerTeam("zm_default_winner_team", FCVAR_NONE, "Which team wins when time ran out [1 = Draw, 2 = Zombies, 3 = Humans]", CS_TEAM_SPECTATOR, true, 1, true, 3);
86-
CConVar<bool> g_cvarZMZteleHuman("zm_zmtele_allow_humans", FCVAR_NONE, "Whether to allow humans to use zmtele", false);
87-
CConVar<float> g_cvarZMMaxZteleDistance("zm_zmtele_max_distance", FCVAR_NONE, "Maximum distance players are allowed to move after starting ztele", 150.0f, true, 0.0f, false, 0.0f);
86+
CConVar<bool> g_cvarZMZteleHuman("zm_ztele_allow_humans", FCVAR_NONE, "Whether to allow humans to use zmtele", false);
87+
CConVar<float> g_cvarZMMaxZteleDistance("zm_ztele_max_distance", FCVAR_NONE, "Maximum distance players are allowed to move after starting ztele", 150.0f, true, 0.0f, false, 0.0f);
88+
CConVar<bool> g_cvarZMTeleHumanAfter("zm_ztele_human_after", FCVAR_NONE, "Allow humans to use ZTele after the mother zombie has spawned. 0 means always allowed.", true);
89+
CConVar<float> g_cvarZMTeleDelayZombie("zm_ztele_delay_zombie", FCVAR_NONE, "Time between using ZTele command and teleportation for zombies. [Dependency: zr_ztele_zombie]", 3.0f, true, 1.0f, true, 100.0f);
90+
CConVar<float> g_cvarZMTeleDelayHuman("zm_ztele_delay_human", FCVAR_NONE, "Time between using ZTele command and teleportation for humans. [Dependency: zm_ztele_allow_humans]", 3.0f, true, 1.0f, true, 100.0f);
91+
CConVar<int> g_cvarZMTeleMaxZombie("zm_ztele_max_zombie", FCVAR_NONE, "Max number of times a zombie is allowed to use ZTele per round.", 3, true, 0, true, 30);
92+
CConVar<int> g_cvarZMTeleMaxHuman("zm_ztele_max_human", FCVAR_NONE, "Max number of times a human is allowed to use ZTele per round. [Dependency: zm_ztele_allow_humans]", 1, true, 0, true, 30);
8893

8994
void ZM_Precache(IEntityResourceManifest* pResourceManifest)
9095
{
@@ -128,9 +133,17 @@ void ZM_RespawnAll()
128133
{
129134
CCSPlayerController* pController = CCSPlayerController::FromSlot(i);
130135

136+
ZEPlayer* pPlayer = pController->GetZEPlayer();
137+
if (pPlayer)
138+
{
139+
pPlayer->SetHumanTeleUsages(0);
140+
pPlayer->SetZombieTeleUsages(0);
141+
}
142+
131143
if (!pController || pController->m_bIsHLTV || (pController->m_iTeamNum() != CS_TEAM_CT && pController->m_iTeamNum() != CS_TEAM_T))
132144
continue;
133145
pController->Respawn();
146+
134147
}
135148
}
136149

@@ -222,6 +235,13 @@ void ZM_OnRoundStart(IGameEvent* pEvent)
222235
if (!pController)
223236
continue;
224237

238+
ZEPlayer* pPlayer = pController->GetZEPlayer();
239+
if (pPlayer)
240+
{
241+
pPlayer->SetHumanTeleUsages(0);
242+
pPlayer->SetZombieTeleUsages(0);
243+
}
244+
225245
CCSPlayerPawn* pPawn = pController->GetPlayerPawn();
226246

227247
// Now we can enable damage back
@@ -799,6 +819,13 @@ void ZM_Hook_ClientPutInServer(CPlayerSlot slot, char const* pszName, int type,
799819
if (!pController)
800820
return;
801821

822+
ZEPlayer* pPlayer = pController->GetZEPlayer();
823+
if (pPlayer)
824+
{
825+
pPlayer->SetHumanTeleUsages(0);
826+
pPlayer->SetZombieTeleUsages(0);
827+
}
828+
802829
ZM_SpawnPlayer(pController);
803830
}
804831

@@ -961,6 +988,9 @@ void ZM_EndRoundAndAddTeamScore(int iTeamNum)
961988
if (!pPlayer || !pPlayer->IsConnected() || !pPlayer->IsInGame() || pPlayer->IsFakeClient())
962989
continue;
963990

991+
pPlayer->SetHumanTeleUsages(0);
992+
pPlayer->SetZombieTeleUsages(0);
993+
964994
bServerIdle = false;
965995
break;
966996
}
@@ -1067,6 +1097,12 @@ CON_COMMAND_CHAT(zmtele, "- Teleport to spawn")
10671097
return;
10681098
}
10691099

1100+
if (g_cvarZMZteleHuman.Get() && g_cvarZMTeleHumanAfter.Get() && player->m_iTeamNum() == CS_TEAM_CT && g_ZMRoundState != EZMRoundState::POST_INFECTION)
1101+
{
1102+
ClientPrint(player, HUD_PRINTTALK, ZM_PREFIX "You can only use this command as a human after a zombie has been chosen.");
1103+
return;
1104+
}
1105+
10701106
std::vector<SpawnPoint*> spawns = ZM_GetSpawns();
10711107
if (!spawns.size())
10721108
{
@@ -1090,14 +1126,52 @@ CON_COMMAND_CHAT(zmtele, "- Teleport to spawn")
10901126
return;
10911127
}
10921128

1129+
int iSlot = player->GetPlayerSlot();
1130+
ZEPlayer* pPlayer = g_playerManager->GetPlayer(iSlot);
1131+
if (!pPlayer)
1132+
{
1133+
Message("Engine failed to find ZEPlayer for ztele");
1134+
return;
1135+
}
1136+
1137+
if (player->m_iTeamNum() == CS_TEAM_CT && pPlayer->GetHumanTeleUsages() >= g_cvarZMTeleMaxHuman.Get())
1138+
{
1139+
ClientPrint(player, HUD_PRINTTALK, ZM_PREFIX "You have already teleported this round more than the maximum allowed number of times for a human (%d)!", g_cvarZMTeleMaxHuman.Get());
1140+
return;
1141+
}
1142+
1143+
if (player->m_iTeamNum() == CS_TEAM_T && pPlayer->GetZombieTeleUsages() >= g_cvarZMTeleMaxZombie.Get())
1144+
{
1145+
ClientPrint(player, HUD_PRINTTALK, ZM_PREFIX "You have already teleported this round more than the maximum allowed number of times for a zombie (%d)!", g_cvarZMTeleMaxZombie.Get());
1146+
return;
1147+
}
1148+
10931149
// Get initial player position so we can do distance check
10941150
Vector initialpos = pPawn->GetAbsOrigin();
10951151

1096-
ClientPrint(player, HUD_PRINTTALK, ZM_PREFIX "Teleporting to spawn in 5 seconds.");
1152+
float timeToTele = 0.0f;
1153+
1154+
if (!pPlayer->IsInfected())
1155+
{
1156+
pPlayer->SetHumanTeleUsages(pPlayer->GetHumanTeleUsages() + 1);
1157+
timeToTele = g_cvarZMTeleDelayHuman.Get();
1158+
}
1159+
else if (pPlayer->IsInfected())
1160+
{
1161+
pPlayer->SetZombieTeleUsages(pPlayer->GetZombieTeleUsages() + 1);
1162+
timeToTele = g_cvarZMTeleDelayZombie.Get();
1163+
}
1164+
else
1165+
{
1166+
// Should not happen but what if...
1167+
timeToTele = 5.0f;
1168+
}
1169+
1170+
ClientPrint(player, HUD_PRINTTALK, ZM_PREFIX "Teleporting to spawn in %.2f seconds.", timeToTele);
10971171

10981172
CHandle<CCSPlayerPawn> pawnHandle = pPawn->GetHandle();
10991173

1100-
CTimer::Create(5.0f, TIMERFLAG_MAP | TIMERFLAG_ROUND, [spawnHandle, pawnHandle, initialpos]() {
1174+
CTimer::Create(timeToTele, TIMERFLAG_MAP | TIMERFLAG_ROUND, [spawnHandle, pawnHandle, initialpos]() {
11011175
CCSPlayerPawn* pPawn = pawnHandle.Get();
11021176
SpawnPoint* pSpawn = spawnHandle.Get();
11031177

0 commit comments

Comments
 (0)