mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-05 18:20:33 +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);
|
CGrenade *pGrenade = GetClassPtr<CCSGrenade>((CGrenade *)pevInflictor);
|
||||||
|
|
||||||
if (friendlyfire.value)
|
pAttack = CBasePlayer::Instance(pevAttacker);
|
||||||
{
|
|
||||||
if (pGrenade->m_iTeam == m_iTeam)
|
|
||||||
bTeamAttack = TRUE;
|
|
||||||
|
|
||||||
pAttack = CBasePlayer::Instance(pevAttacker);
|
|
||||||
|
|
||||||
|
if (
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
flDamage *= clamp(((pAttack == this) ?
|
!CSGameRules()->IsFreeForAll() &&
|
||||||
ff_damage_reduction_grenade_self.value :
|
|
||||||
ff_damage_reduction_grenade.value), 0.0f, 1.0f);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
pGrenade->m_iTeam == m_iTeam)
|
||||||
#ifdef REGAMEDLL_ADD
|
|
||||||
else if (CSGameRules()->IsFreeForAll())
|
|
||||||
{
|
{
|
||||||
pAttack = CBasePlayer::Instance(pevAttacker);
|
if (friendlyfire.value)
|
||||||
}
|
|
||||||
#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)
|
|
||||||
{
|
{
|
||||||
|
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;
|
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);
|
pAttack = GetClassPtr<CCSPlayer>((CBasePlayer *)pevAttacker);
|
||||||
|
|
||||||
bool bAttackFFA = CSGameRules()->IsFreeForAll();
|
|
||||||
|
|
||||||
// warn about team attacks
|
// 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
|
#ifndef REGAMEDLL_FIXES
|
||||||
// TODO: this->m_flDisplayHistory!
|
if (!(m_flDisplayHistory & DHF_FRIEND_INJURED))
|
||||||
if (!(m_flDisplayHistory & DHF_FRIEND_INJURED))
|
{
|
||||||
{
|
m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
||||||
m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
}
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (!(pAttack->m_flDisplayHistory & DHF_FRIEND_INJURED))
|
if (!(pAttack->m_flDisplayHistory & DHF_FRIEND_INJURED))
|
||||||
{
|
{
|
||||||
pAttack->m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
pAttack->m_flDisplayHistory |= DHF_FRIEND_INJURED;
|
||||||
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
pAttack->HintMessage("#Hint_try_not_to_injure_teammates");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bTeamAttack = TRUE;
|
bTeamAttack = TRUE;
|
||||||
if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f)
|
if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f)
|
||||||
{
|
|
||||||
CBaseEntity *pEntity = nullptr;
|
|
||||||
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
|
|
||||||
{
|
{
|
||||||
if (FNullEnt(pEntity->edict()))
|
CBaseEntity *pEntity = nullptr;
|
||||||
break;
|
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
|
||||||
|
|
||||||
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));
|
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
|
#ifdef REGAMEDLL_ADD
|
||||||
// bullets hurt teammates less
|
// bullets hurt teammates less
|
||||||
flDamage *= clamp(((bitsDamageType & DMG_BULLET) ?
|
flDamage *= clamp(((bitsDamageType & DMG_BULLET) ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user