Skip to content

Commit ff0d680

Browse files
committed
- Moved health on zombification from cvar to zombie classes
- Added MOTD/server link to scoreboard
1 parent 776faba commit ff0d680

6 files changed

Lines changed: 43 additions & 17 deletions

File tree

cfg/cs2fixes/cs2fixes.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cs2f_fix_game_bans 0 // Whether to fix CS2 game bans spreading to all new jo
2727
cs2f_free_armor 0 // Whether kevlar (1+) and/or helmet (2) are given automatically
2828
cs2f_fix_ladder_gravity 0 // Whether to fix ladders resetting player gravity.
2929
30+
cs2f_motd_url "https://wwww.zombiemod.com" // Server MOTD URL, shows up as a "Server Website" button in scoreboard
3031
cs2f_beacon_particle "particles/cs2fixes/admin_beacon.vpcf" // .vpcf file to be precached and used for player beacon
3132
3233
cs2f_delay_auth_fail_kick 0 // How long in seconds to delay kicking players when their Steam authentication fails, use with sv_steamauth_enforce 0
@@ -192,5 +193,4 @@ zm_ztele_max_human 1 // Max number of times a human is allowed to use ZTele
192193
zm_infinite_ammo 0 // Whether or not ammo gets set to 999 in the mag after first reload.
193194
zm_infinite_ammo_total 9999 // The total amount of actual bullets to count as 'infinite'.
194195
zm_user_prefs_to_file 1 // Whether to save user prefs to a file if cs2f_user_prefs_api is not set [Folder on server needs to be read/writeable by the game and is game/csgo/addons/cs2fixes/data]
195-
zm_run_with_bots 0 // When true, the server will end rounds as normal when only bots exist in the server.
196-
zm_health_on_zombification 0 // When greater than 0, zombies get this much health back when they turn someone else into a zombie.
196+
zm_run_with_bots 0 // When true, the server will end rounds as normal when only bots exist in the server.

configs/zm/playerclass.jsonc.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"knockback": 1.0,
7979
"admin_flag": "",
8080
"health_regen_count": 250,
81-
"health_regen_interval": 5.0
81+
"health_regen_interval": 5.0,
82+
"health_on_zombification": 100
8283
},
8384
// special class that the first batch of zombie will be assigned to
8485
"MotherZombie": {

src/cs2fixes.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandRef cmdHandle, const CCommandCo
626626
RETURN_META(MRES_IGNORED);
627627
}
628628

629+
CConVar<CUtlString> g_cvarMotdUrl("cs2f_motd_url", FCVAR_NONE, "Server MOTD URL, shows up as a \"Server Website\" button in scoreboard", "");
630+
629631
void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession* pSession, const char* pszMapName)
630632
{
631633
g_pEntitySystem = GameEntitySystem();
@@ -645,8 +647,18 @@ void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISou
645647

646648
g_pPanoramaVoteHandler->Reset();
647649
g_pVoteManager->VoteManager_Init();
648-
649650
g_pIdleSystem->Reset();
651+
652+
INetworkStringTable* pInfoPanelTable = g_pNetworkStringTableServer->FindTable("InfoPanel");
653+
654+
if (pInfoPanelTable && V_strcmp(g_cvarMotdUrl.Get(), ""))
655+
{
656+
SetStringUserDataRequest_t pUserData;
657+
pUserData.m_pRawData = (void*)g_cvarMotdUrl.Get().Get();
658+
pUserData.m_cbDataSize = g_cvarMotdUrl.Get().Length() + 1;
659+
660+
pInfoPanelTable->AddString(true, "motd", &pUserData);
661+
}
650662
}
651663

652664
class CGamePlayerEquip;

src/zombiemod.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extern ZRWeaponConfig* g_pZRWeaponConfig;
6060
extern ZRHitgroupConfig* g_pZRHitgroupConfig;
6161

6262
CConVar<bool> g_cvarZMEnable("zm_enable", (FCVAR_REPLICATED | FCVAR_SPONLY | FCVAR_NOTIFY), "ZombieMod enabled or not.", false, ConVarZMEnableChange);
63-
CConVar<CUtlString> g_cvarZMVersion("zm_version", (FCVAR_REPLICATED | FCVAR_SPONLY | FCVAR_NOTIFY), "ZombieMod version", "4.0.0v");
63+
CConVar<CUtlString> g_cvarZMVersion("zm_version", (FCVAR_REPLICATED | FCVAR_SPONLY | FCVAR_NOTIFY), "ZombieMod version", "4.0.0x");
6464
CConVar<CUtlString> g_cvarZMHumanWinOverlayParticle("zm_human_win_overlay_particle", FCVAR_NONE, "Screenspace particle to display when human win", "");
6565
CConVar<CUtlString> g_cvarZMZombieWinOverlayParticle("zm_zombie_win_overlay_particle", FCVAR_NONE, "Screenspace particle to display when zombie win", "");
6666
CConVar<int> g_cvarZMInfectSpawnType("zm_infect_spawn_type", FCVAR_NONE, "Type of Mother Zombies Spawn [0 = MZ spawn where they stand, 1 = MZ get teleported back to spawn on being picked]", (int)EZMSpawnType::ZM_RESPAWN, true, 0, true, 1);
@@ -97,7 +97,6 @@ CConVar<int> g_cvarZMInfiniteAmmoTotal("zm_infinite_ammo_total", FCVAR_NONE, "Th
9797
CConVar<bool> g_cvarZMUserPresToFile("zm_user_prefs_to_file", FCVAR_NONE, "Whether to save user prefs to a file if cs2f_user_prefs_api is not set [Folder on server needs to be read/writeable by the game and is game/csgo/addons/cs2fixes/data]", true);
9898

9999
CConVar<bool> g_cvarZMRunWithBots("zm_run_with_bots", FCVAR_NONE, "When true, the server will end rounds as normal when only bots exist in the server.", false);
100-
CConVar<int> g_cvarZMHealthOnZombification("zm_health_on_zombification", FCVAR_NONE, "When greater than 0, zombies get this much health back when they turn someone else into a zombie.", 0, true, 0, true, 1000);
101100

102101
void ZM_Precache(IEntityResourceManifest* pResourceManifest)
103102
{
@@ -490,17 +489,25 @@ void ZM_Infect(CCSPlayerController* pAttackerController, CCSPlayerController* pV
490489
if (!pVictimPawn)
491490
return;
492491

493-
int health = g_cvarZMHealthOnZombification.Get();
494-
if (health > 0)
492+
ZEPlayer* pAttacker = pAttackerController->GetZEPlayer();
493+
if (pAttacker)
495494
{
496-
CCSPlayerPawn* pAttackerPawn = (CCSPlayerPawn*)pAttackerController->GetPawn();
497-
if (!pAttackerPawn)
498-
return;
495+
int health = 0;
496+
std::shared_ptr<ZRClass> activeClass = pAttacker->GetActiveZRClass();
497+
if (activeClass && activeClass->iTeam == CS_TEAM_T)
498+
health = static_pointer_cast<ZRZombieClass>(activeClass)->iHealthOnZombification;
499499

500-
if (pAttackerPawn->m_iHealth() < pAttackerPawn->m_iMaxHealth())
500+
if (health > 0)
501501
{
502-
int iHealth = pAttackerPawn->m_iHealth() + health;
503-
pAttackerPawn->m_iHealth = pAttackerPawn->m_iMaxHealth() < iHealth ? pAttackerPawn->m_iMaxHealth() : iHealth;
502+
CCSPlayerPawn* pAttackerPawn = (CCSPlayerPawn*)pAttackerController->GetPawn();
503+
if (!pAttackerPawn)
504+
return;
505+
506+
if (pAttackerPawn->m_iHealth() < pAttackerPawn->m_iMaxHealth())
507+
{
508+
int iHealth = pAttackerPawn->m_iHealth() + health;
509+
pAttackerPawn->m_iHealth = pAttackerPawn->m_iMaxHealth() < iHealth ? pAttackerPawn->m_iMaxHealth() : iHealth;
510+
}
504511
}
505512
}
506513

src/zombiereborn.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ void ZRZombieClass::Override(ordered_json jsonKeys, std::string szClassname)
271271
flHealthRegenInterval = jsonKeys["health_regen_interval"].get<float>();
272272
if (jsonKeys.contains("knockback"))
273273
flKnockback = jsonKeys["knockback"].get<float>();
274+
if (jsonKeys.contains("health_on_zombification"))
275+
iHealthOnZombification = jsonKeys["health_on_zombification"].get<int>();
274276
}
275277

276278
bool ZRClass::IsApplicableTo(CCSPlayerController* pController)

src/zombiereborn.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,13 @@ struct ZRZombieClass : ZRClass
202202
int iHealthRegenCount;
203203
float flHealthRegenInterval;
204204
float flKnockback;
205+
int iHealthOnZombification;
205206
ZRZombieClass(std::shared_ptr<ZRZombieClass> pClass) :
206207
ZRClass(pClass, CS_TEAM_T),
207208
iHealthRegenCount(pClass->iHealthRegenCount),
208209
flHealthRegenInterval(pClass->flHealthRegenInterval),
209-
flKnockback(pClass->flKnockback){};
210+
flKnockback(pClass->flKnockback),
211+
iHealthOnZombification(pClass->iHealthOnZombification) {};
210212
ZRZombieClass(ordered_json jsonKeys, std::string szClassname);
211213
void PrintInfo()
212214
{
@@ -235,7 +237,8 @@ struct ZRZombieClass : ZRClass
235237
"\tknockback: %f\n"
236238
"\tadmin flag: %d\n"
237239
"\thealth_regen_count: %d\n"
238-
"\thealth_regen_interval: %f\n",
240+
"\thealth_regen_interval: %f\n"
241+
"\thealth_on_zombification: %d\n",
239242
szClassName.c_str(),
240243
bEnabled,
241244
iHealth,
@@ -246,7 +249,8 @@ struct ZRZombieClass : ZRClass
246249
flKnockback,
247250
iAdminFlag,
248251
iHealthRegenCount,
249-
flHealthRegenInterval);
252+
flHealthRegenInterval,
253+
iHealthOnZombification);
250254
};
251255
void Override(ordered_json jsonKeys, std::string szClassname);
252256
};

0 commit comments

Comments
 (0)