CGameRules: Add method bool PlayerCanAttack(base_player)

This commit is contained in:
Marco Cawthorne 2022-04-08 12:37:45 -07:00
parent f6032484e2
commit 4e62e833a3
Signed by: eukara
GPG Key ID: C196CD8BA993248A
3 changed files with 26 additions and 0 deletions

View File

@ -123,6 +123,14 @@ Viewmodel_ApplyBob(entity gun)
sprint = 20 * pSeatLocal->m_flSprintLerp;
gun.angles[0] += sprint;
gun.angles[1] += sprint + (sprint * pViewBob->m_flBob) * 0.25f;
if (pSeat->m_ePlayer.gflags & GF_IS_HEALING) {
pSeatLocal->m_flHealLerp = bound(0.0f, pSeatLocal->m_flHealLerp + clframetime, 1.0f);
} else {
pSeatLocal->m_flHealLerp = bound(0.0f, pSeatLocal->m_flHealLerp - clframetime, 1.0f);
}
gun.angles[0] += pSeatLocal->m_flHealLerp * 45;
gun.origin[2] -= pSeatLocal->m_flHealLerp * 5;
#endif
gun.angles[0] += strength * sintime;

View File

@ -37,6 +37,7 @@ class CGameRules
virtual void(base_player) PlayerPostFrame;
virtual void(base_player) PlayerDeath;
virtual void(base_player) PlayerPain;
virtual bool(base_player) PlayerCanAttack;
/* level transitions */
virtual void(void) LevelNewParms;

View File

@ -221,6 +221,17 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
if (eTarget.flags & FL_CLIENT) {
base_player tp = (base_player)t;
/* don't allow any damage */
if (PlayerCanAttack(tp) == false) {
g_dmg_eAttacker = c;
g_dmg_eTarget = t;
g_dmg_iDamage = 0;
g_dmg_iHitBody = 0;
g_dmg_iFlags = type;
g_dmg_iWeapon = w;
return;
}
/* skip armor */
if not (type & DMG_SKIP_ARMOR)
if (tp.armor && dmg > 0) {
@ -387,3 +398,9 @@ Gamerules_IsTeamPlay(void)
{
return (g_grMode.IsTeamPlay()) ? TRUE : FALSE;
}
bool
CGameRules::PlayerCanAttack(base_player bp)
{
return true;
}