Minor refactoring CBasePlayer::TakeDamage

Fix cvar ff_damage_reduction_grenade: don't reduce damage to enemies
This commit is contained in:
s1lentq 2019-06-08 23:22:56 +07:00
parent 62cb200a3b
commit 3d21b74897

View File

@ -855,38 +855,36 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
{
CGrenade *pGrenade = GetClassPtr<CCSGrenade>((CGrenade *)pevInflictor);
if (friendlyfire.value)
{
if (pGrenade->m_iTeam == m_iTeam)
bTeamAttack = TRUE;
pAttack = CBasePlayer::Instance(pevAttacker);
if (
#ifdef REGAMEDLL_ADD
!CSGameRules()->IsFreeForAll() &&
#endif
pGrenade->m_iTeam == m_iTeam)
{
if (friendlyfire.value)
{
bTeamAttack = TRUE;
#ifdef REGAMEDLL_ADD
flDamage *= clamp(((pAttack == this) ?
ff_damage_reduction_grenade_self.value :
ff_damage_reduction_grenade.value), 0.0f, 1.0f);
#endif
}
#ifdef REGAMEDLL_ADD
else if (CSGameRules()->IsFreeForAll())
else if (pAttack == this)
{
pAttack = CBasePlayer::Instance(pevAttacker);
}
#endif
else if (pGrenade->m_iTeam == m_iTeam)
{
// if cvar friendlyfire is disabled
// and if the victim is teammate then ignore this damage
if (&edict()->v != pevAttacker)
{
return FALSE;
}
#ifdef REGAMEDLL_ADD
flDamage *= clamp(ff_damage_reduction_grenade_self.value, 0.0f, 1.0f);
#endif
}
else
{
// if cvar friendlyfire is disabled
// and if the victim is teammate then ignore this damage
return FALSE;
}
}
}
}
@ -1026,13 +1024,12 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
{
pAttack = GetClassPtr<CCSPlayer>((CBasePlayer *)pevAttacker);
bool bAttackFFA = CSGameRules()->IsFreeForAll();
// warn about team attacks
if (!bAttackFFA && pAttack != this && pAttack->m_iTeam == m_iTeam)
if (!CSGameRules()->IsFreeForAll() && pAttack->m_iTeam == m_iTeam)
{
if (pAttack != this)
{
#ifndef REGAMEDLL_FIXES
// TODO: this->m_flDisplayHistory!
if (!(m_flDisplayHistory & DHF_FRIEND_INJURED))
{
m_flDisplayHistory |= DHF_FRIEND_INJURED;
@ -1067,8 +1064,6 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
}
}
if (!bAttackFFA && pAttack->m_iTeam == m_iTeam)
{
#ifdef REGAMEDLL_ADD
// bullets hurt teammates less
flDamage *= clamp(((bitsDamageType & DMG_BULLET) ?