mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-27 14:08:00 +03:00
Minor refactoring CBasePlayer::TakeDamage
Fix cvar ff_damage_reduction_grenade: don't reduce damage to enemies
This commit is contained in:
parent
62cb200a3b
commit
3d21b74897
@ -855,37 +855,35 @@ 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);
|
||||
pAttack = CBasePlayer::Instance(pevAttacker);
|
||||
|
||||
if (
|
||||
#ifdef REGAMEDLL_ADD
|
||||
flDamage *= clamp(((pAttack == this) ?
|
||||
ff_damage_reduction_grenade_self.value :
|
||||
ff_damage_reduction_grenade.value), 0.0f, 1.0f);
|
||||
!CSGameRules()->IsFreeForAll() &&
|
||||
#endif
|
||||
}
|
||||
#ifdef REGAMEDLL_ADD
|
||||
else if (CSGameRules()->IsFreeForAll())
|
||||
pGrenade->m_iTeam == m_iTeam)
|
||||
{
|
||||
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)
|
||||
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
|
||||
}
|
||||
else if (pAttack == this)
|
||||
{
|
||||
#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;
|
||||
}
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
flDamage *= clamp(ff_damage_reduction_grenade_self.value, 0.0f, 1.0f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1026,49 +1024,46 @@ 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;
|
||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||
}
|
||||
if (!(m_flDisplayHistory & DHF_FRIEND_INJURED))
|
||||
{
|
||||
m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||
}
|
||||
#else
|
||||
if (!(pAttack->m_flDisplayHistory & DHF_FRIEND_INJURED))
|
||||
{
|
||||
pAttack->m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||
}
|
||||
if (!(pAttack->m_flDisplayHistory & DHF_FRIEND_INJURED))
|
||||
{
|
||||
pAttack->m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||
}
|
||||
#endif
|
||||
|
||||
bTeamAttack = TRUE;
|
||||
if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f)
|
||||
{
|
||||
CBaseEntity *pEntity = nullptr;
|
||||
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
|
||||
bTeamAttack = TRUE;
|
||||
if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f)
|
||||
{
|
||||
if (FNullEnt(pEntity->edict()))
|
||||
break;
|
||||
|
||||
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
|
||||
|
||||
if (pPlayer->m_iTeam == m_iTeam)
|
||||
CBaseEntity *pEntity = nullptr;
|
||||
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
|
||||
{
|
||||
ClientPrint(pPlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname));
|
||||
if (FNullEnt(pEntity->edict()))
|
||||
break;
|
||||
|
||||
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
|
||||
|
||||
if (pPlayer->m_iTeam == m_iTeam)
|
||||
{
|
||||
ClientPrint(pPlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname));
|
||||
}
|
||||
}
|
||||
|
||||
pAttack->m_flLastAttackedTeammate = gpGlobals->time;
|
||||
}
|
||||
|
||||
pAttack->m_flLastAttackedTeammate = gpGlobals->time;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAttackFFA && pAttack->m_iTeam == m_iTeam)
|
||||
{
|
||||
#ifdef REGAMEDLL_ADD
|
||||
// bullets hurt teammates less
|
||||
flDamage *= clamp(((bitsDamageType & DMG_BULLET) ?
|
||||
|
Loading…
x
Reference in New Issue
Block a user