diff --git a/README.md b/README.md
index be8152ca..485112cc 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| mp_timeleft | - | - | - | Is the number of time left before the map changes, if you have set mp_timelimit. You just type mp_timeleft in server console, and it tells you the number of time left depending of mp_timelimit. |
| mp_timelimit | 0 | - | - | Period between map rotations.
`0` means no limit |
| mp_forcerespawn | 0 | 0 | - | Players will automatically respawn when killed.
`0` disabled
`>0.00001` time delay to respawn |
-| mp_hostage_hurtable | 1 | 0 | 1 | The hostages can take the damage.
`0` disabled
`1` enabled |
+| mp_hostage_hurtable | 1 | 0 | 1 | The hostages can take damage.
`0` disabled
`1` from any team
`2` only from `CT`
`3` only from `T` |
| mp_show_radioicon | 1 | 0 | 1 | Show radio icon.
`0` disabled
`1` enabled |
| showtriggers | 0 | 0 | 1 | Debug cvar shows triggers. |
| sv_alltalk | 0 | 0 | 3 | When teammates can hear each other.
`0` dead don't hear alive
`1` no restrictions
`2` teammates hear each other
`3` Same as 2, but spectators hear everybody
diff --git a/dist/game.cfg b/dist/game.cfg
index d3575c0c..0577bcd5 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -124,9 +124,11 @@ mp_timelimit 20
// Default value: "0"
mp_forcerespawn 0
-// The hostages can take the damage.
+// The hostages can take damage.
// 0 - disabled
-// 1 - enabled (default behaviour)
+// 1 - from any team (default behaviour)
+// 2 - only from CT
+// 3 - only from T
mp_hostage_hurtable 1
// Show radio icon.
diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp
index ab1ae7a8..f75b02c2 100644
--- a/regamedll/dlls/hostage/hostage.cpp
+++ b/regamedll/dlls/hostage/hostage.cpp
@@ -575,20 +575,43 @@ void CHostage::RePosition()
m_flNextFullThink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);
}
+bool CHostage::CanTakeDamage(entvars_t *pevAttacker)
+{
+ bool bCanTakeDmg = true; // default behaviour
+
+#ifdef REGAMEDLL_ADD
+ CBasePlayer *pAttacker = CBasePlayer::Instance(pevAttacker);
+ switch ((int)hostagehurtable.value)
+ {
+ case 0:
+ bCanTakeDmg = false;
+ break;
+ case 2:
+ bCanTakeDmg = (pAttacker && pAttacker->IsPlayer() && pAttacker->m_iTeam == CT);
+ break;
+ case 3:
+ bCanTakeDmg = (pAttacker && pAttacker->IsPlayer() && pAttacker->m_iTeam == TERRORIST);
+ break;
+ default:
+ break;
+ }
+#endif
+
+ return bCanTakeDmg;
+}
+
void CHostage::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType)
{
-#ifdef REGAMEDLL_ADD
- if (hostagehurtable.value)
-#endif
- {
- CBaseMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType);
- }
+ if (!CanTakeDamage(pevAttacker))
+ return;
+
+ CBaseMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType);
}
BOOL CHostage::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
{
#ifdef REGAMEDLL_ADD
- if (hostagehurtable.value <= 0)
+ if (!CanTakeDamage(pevAttacker))
return FALSE;
#endif
diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h
index fa5d324b..29c8ac01 100644
--- a/regamedll/dlls/hostage/hostage.h
+++ b/regamedll/dlls/hostage/hostage.h
@@ -122,6 +122,7 @@ public:
void NavReady();
void Wiggle();
void PreThink();
+ bool CanTakeDamage(entvars_t *pevAttacker);
// queries
bool IsFollowingSomeone() { return IsFollowing(); }