player explosives can now damage helicopters

This commit is contained in:
Pinsplash 2023-04-26 01:38:23 -05:00
parent 0b7132cbd1
commit e2cc19f207
2 changed files with 22 additions and 9 deletions

View File

@ -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 );
}

View File

@ -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<CBasePlayer *>(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())