From 191857d7004365329d33ab68fb71b21530fe46be Mon Sep 17 00:00:00 2001
From: AlexSwartz <46033301+AlexSwartz@users.noreply.github.com>
Date: Tue, 22 Jun 2021 04:48:55 -0700
Subject: [PATCH] Add new CVar `mp_free_armor` (#609)
---
README.md | 1 +
dist/game.cfg | 8 ++++++++
regamedll/dlls/game.cpp | 2 ++
regamedll/dlls/game.h | 1 +
regamedll/dlls/player.cpp | 11 +++++++++++
5 files changed, 23 insertions(+)
diff --git a/README.md b/README.md
index aab17eec..4306a0d3 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_ct_default_weapons_secondary | "usp" | "" | - | The default secondary (pistol) weapon that the CTs will spawn with. |
| mp_give_player_c4 | 1 | 0 | 1 | Whether this map should spawn a C4 bomb for a player or not.
`0` disabled
`1` enabled |
| mp_weapons_allow_map_placed | 1 | 0 | 1 | When set, map weapons (located on the floor by map) will be shown.
`0` hide all map weapons.
`1` enabled
`NOTE`: Effect will work after round restart. |
+| mp_free_armor | 0 | 0 | 2 | Give free armor on player spawn.
`0` disabled
`1` Give Kevlar
`2` Give Kevlar + Helmet |
| mp_fadetoblack | 0 | 0 | 2 | Observer's screen will fade to black on kill event or permanent.
`0` No fade.
`1` Fade to black and won't be able to watch anybody.
`2` fade to black only on kill moment. |
| mp_falldamage | 1 | 0 | 1 | Damage from falling.
`0` disabled
`1` enabled |
diff --git a/dist/game.cfg b/dist/game.cfg
index 7fc23e0f..2abc7fd2 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -447,3 +447,11 @@ mp_ct_default_weapons_primary ""
//
// Default value: "usp"
mp_ct_default_weapons_secondary "usp"
+
+// Give the player free armor on player spawn
+// 0 - No armor (default behavior)
+// 1 - Give Kevlar
+// 2 - Give Kevlar and Helmet
+//
+// Default value: "0"
+mp_free_armor 0
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index f93345a9..0abecf17 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -157,6 +157,7 @@ cvar_t t_default_grenades = { "mp_t_default_grenades", "", 0, 0.0
cvar_t t_give_player_knife = { "mp_t_give_player_knife", "1", 0, 1.0f, nullptr };
cvar_t t_default_weapons_secondary = { "mp_t_default_weapons_secondary", "glock18", 0, 0.0f, nullptr };
cvar_t t_default_weapons_primary = { "mp_t_default_weapons_primary", "", 0, 0.0f, nullptr };
+cvar_t free_armor = { "mp_free_armor", "0", 0, 0.0f, nullptr };
void GameDLL_Version_f()
{
@@ -383,6 +384,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&t_give_player_knife);
CVAR_REGISTER(&t_default_weapons_secondary);
CVAR_REGISTER(&t_default_weapons_primary);
+ CVAR_REGISTER(&free_armor);
// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index f99f6618..3f6d2d98 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -183,6 +183,7 @@ extern cvar_t t_default_grenades;
extern cvar_t t_give_player_knife;
extern cvar_t t_default_weapons_secondary;
extern cvar_t t_default_weapons_primary;
+extern cvar_t free_armor;
#endif
diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp
index b59badc5..41618966 100644
--- a/regamedll/dlls/player.cpp
+++ b/regamedll/dlls/player.cpp
@@ -9991,6 +9991,17 @@ void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipG
{
GiveDefaultItems();
}
+
+#ifdef REGAMEDLL_ADD
+ if(!m_bIsVIP)
+ {
+ switch (static_cast((int)free_armor.value))
+ {
+ case ARMOR_KEVLAR: GiveNamedItem("item_kevlar"); break;
+ case ARMOR_VESTHELM: GiveNamedItem("item_assaultsuit"); break;
+ }
+ }
+#endif
}
void CBasePlayer::HideTimer()