From e2cc19f2070c2d907b1e78f3aa3059828c21f620 Mon Sep 17 00:00:00 2001 From: Pinsplash <39359267+Pinsplash@users.noreply.github.com> Date: Wed, 26 Apr 2023 01:38:23 -0500 Subject: [PATCH] player explosives can now damage helicopters --- sp/src/game/server/hl2/npc_attackchopper.cpp | 13 +++++++++++++ sp/src/game/shared/baseentity_shared.cpp | 18 +++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/sp/src/game/server/hl2/npc_attackchopper.cpp b/sp/src/game/server/hl2/npc_attackchopper.cpp index bc37517a..c4d716cb 100644 --- a/sp/src/game/server/hl2/npc_attackchopper.cpp +++ b/sp/src/game/server/hl2/npc_attackchopper.cpp @@ -3571,6 +3571,7 @@ void CNPC_AttackHelicopter::TraceAttack( const CTakeDamageInfo &info, const Vect // TraceAttack() as a means for delivering blast damage. Usually when the explosive penetrates // the target. (RPG missiles do this sometimes). if ( ( info.GetDamageType() & DMG_AIRBOAT ) || + ( info.GetDamageType() & DMG_BLAST) || ( info.GetInflictor()->Classify() == CLASS_MISSILE ) || ( info.GetAttacker()->Classify() == CLASS_MISSILE ) ) { @@ -3589,6 +3590,7 @@ int CNPC_AttackHelicopter::OnTakeDamage( const CTakeDamageInfo &info ) if( info.GetInflictor() != this ) { if ( ( ( info.GetDamageType() & DMG_AIRBOAT ) == 0 ) && + ((info.GetDamageType() & DMG_BLAST) == 0) && ( info.GetInflictor()->Classify() != CLASS_MISSILE ) && ( info.GetAttacker()->Classify() != CLASS_MISSILE ) ) return 0; @@ -3625,7 +3627,18 @@ int CNPC_AttackHelicopter::OnTakeDamage( const CTakeDamageInfo &info ) return BaseClass::OnTakeDamage( fudgedInfo ); } + //all other explosions do 1/5 of max health in chaos. intended to make it easier to fight helicopters when grenade guns is on. + //this will affect other things like the RPG, but that never comes up in regular gameplay, pretty sure + if (info.GetDamageType() & DMG_BLAST) + { + CTakeDamageInfo fudgedInfo = info; + float damage = GetMaxHealth() / 5; + damage = ceilf(damage); + fudgedInfo.SetDamage(damage); + fudgedInfo.SetMaxDamage(damage); + return BaseClass::OnTakeDamage(fudgedInfo); + } return BaseClass::OnTakeDamage( info ); } diff --git a/sp/src/game/shared/baseentity_shared.cpp b/sp/src/game/shared/baseentity_shared.cpp index 6fe05254..3623875e 100644 --- a/sp/src/game/shared/baseentity_shared.cpp +++ b/sp/src/game/shared/baseentity_shared.cpp @@ -1953,16 +1953,16 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info ) #ifdef GAME_DLL - ApplyMultiDamage(); + if (!chaos_replace_bullets_with_grenades.GetBool())//if grenade guns is on, no real "attack" has actually happened yet, so all of this code would make no sense + { + ApplyMultiDamage(); - if ( IsPlayer() && flCumulativeDamage > 0.0f ) - { - CBasePlayer *pPlayer = static_cast< CBasePlayer * >( this ); - CTakeDamageInfo dmgInfo( this, pAttacker, flCumulativeDamage, nDamageType ); - gamestats->Event_WeaponHit( pPlayer, info.m_bPrimaryAttack, pPlayer->GetActiveWeapon()->GetClassname(), dmgInfo ); - } - if (!chaos_replace_bullets_with_grenades.GetBool())//if grenade guns is on, the bullet trace never actually happened, so tr.endpos is just the origin - { + if (IsPlayer() && flCumulativeDamage > 0.0f) + { + CBasePlayer *pPlayer = static_cast(this); + CTakeDamageInfo dmgInfo(this, pAttacker, flCumulativeDamage, nDamageType); + gamestats->Event_WeaponHit(pPlayer, info.m_bPrimaryAttack, pPlayer->GetActiveWeapon()->GetClassname(), dmgInfo); + } if (chaos_bullet_teleport.GetBool()) { if (IsCombatCharacter())