diff --git a/reactivedrop/fgd/reactivedrop.fgd b/reactivedrop/fgd/reactivedrop.fgd index 020274a0a..2694e4023 100644 --- a/reactivedrop/fgd/reactivedrop.fgd +++ b/reactivedrop/fgd/reactivedrop.fgd @@ -45,6 +45,11 @@ @PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/flame_top.mdl") = asw_sentry_top_flamer [ TurretRange(float) : "Turret Range" : "375" : "Maximum distance that it will pick targets." + friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." = + [ + 0 : "No" + 1 : "Yes" + ] ] @PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/freeze_top.mdl") = asw_sentry_top_icer @@ -56,6 +61,11 @@ [ TurretRange(float) : "Turret Range" : "1000" : "Maximum distance that it will pick targets." FireRate(float) : "Fire Rate" : "1.75" : "Time in seconds between each shot" + friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." = + [ + 0 : "No" + 1 : "Yes" + ] ] @SolidClass base(Trigger) = trigger_rd_marine_jumpjet : diff --git a/reactivedrop/fgd/swarm.fgd b/reactivedrop/fgd/swarm.fgd index 853e0c58d..f39aead90 100644 --- a/reactivedrop/fgd/swarm.fgd +++ b/reactivedrop/fgd/swarm.fgd @@ -3824,6 +3824,11 @@ @PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/machinegun_top.mdl") = asw_sentry_top_machinegun [ TurretRange(float) : "Turret Range" : "525" : "Maximum distance that it will pick targets." + friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." = + [ + 0 : "No" + 1 : "Yes" + ] ] @PointClass sphere() iconsprite("editor/env_shake.vmt") base(Targetname, Parentname) = asw_env_shake : diff --git a/src/game/server/swarm/asw_marine.cpp b/src/game/server/swarm/asw_marine.cpp index e5483ca53..4a90d3ea1 100644 --- a/src/game/server/swarm/asw_marine.cpp +++ b/src/game/server/swarm/asw_marine.cpp @@ -45,6 +45,7 @@ #include "ammodef.h" #include "asw_shareddefs.h" #include "asw_sentry_base.h" +#include "asw_sentry_top.h" #include "asw_button_area.h" #include "asw_equipment_list.h" #include "asw_weapon_parse.h" @@ -1365,13 +1366,15 @@ int CASW_Marine::OnTakeDamage_Alive( const CTakeDamageInfo &info ) CTakeDamageInfo newInfo(info); CBaseEntity* pAttacker = newInfo.GetAttacker(); + CBaseEntity* pWeapon = newInfo.GetWeapon(); if ( asw_debug_marine_damage.GetBool() ) Msg( "Marine taking premodified damage of %f\n", newInfo.GetDamage() ); // scale sentry gun damage - if ( pAttacker && IsSentryClass( pAttacker->Classify() ) ) + if ( pWeapon && IsSentryClass( pWeapon->Classify() ) ) { - if ( asw_sentry_friendly_fire_scale.GetFloat() <= 0 ) + CASW_Sentry_Top *pSentry = dynamic_cast< CASW_Sentry_Top* >( pWeapon ); + if ( asw_sentry_friendly_fire_scale.GetFloat() <= 0 || ( pSentry && !pSentry->m_bFriendlyFire ) ) return 0; newInfo.ScaleDamage( asw_sentry_friendly_fire_scale.GetFloat() ); diff --git a/src/game/server/swarm/asw_sentry_top.cpp b/src/game/server/swarm/asw_sentry_top.cpp index df1070689..290a88c2d 100644 --- a/src/game/server/swarm/asw_sentry_top.cpp +++ b/src/game/server/swarm/asw_sentry_top.cpp @@ -60,6 +60,7 @@ BEGIN_DATADESC( CASW_Sentry_Top ) DEFINE_FIELD( m_iSentryAngle, FIELD_INTEGER ), DEFINE_KEYFIELD( m_flShootRange, FIELD_FLOAT, "TurretRange" ), DEFINE_FIELD( m_bLowAmmo, FIELD_BOOLEAN ), + DEFINE_KEYFIELD( m_bFriendlyFire, FIELD_BOOLEAN, "friendlyfire" ), END_DATADESC() BEGIN_ENT_SCRIPTDESC( CASW_Sentry_Top, CBaseCombatCharacter, "sentry top" ) @@ -78,6 +79,7 @@ CASW_Sentry_Top::CASW_Sentry_Top() m_iBaseTurnRate = ASW_SENTRY_TURNRATE / 2; m_iEnemyTurnRate = ASW_SENTRY_TURNRATE; m_iSentryAngle = ASW_SENTRY_ANGLE; + m_bFriendlyFire = true; m_iPoseParamPitch = -2; m_iPoseParamYaw = -2; diff --git a/src/game/server/swarm/asw_sentry_top.h b/src/game/server/swarm/asw_sentry_top.h index 40f921d2a..ae9e94d66 100644 --- a/src/game/server/swarm/asw_sentry_top.h +++ b/src/game/server/swarm/asw_sentry_top.h @@ -70,6 +70,7 @@ class CASW_Sentry_Top : public CBaseCombatCharacter int m_iBaseTurnRate; // angles per second int m_iEnemyTurnRate; CNetworkVar( int, m_iSentryAngle ); + bool m_bFriendlyFire; float m_flTimeFirstFired; diff --git a/src/game/shared/baseentity_shared.cpp b/src/game/shared/baseentity_shared.cpp index 754ca0f97..de8191571 100644 --- a/src/game/shared/baseentity_shared.cpp +++ b/src/game/shared/baseentity_shared.cpp @@ -12,6 +12,7 @@ #include "model_types.h" #include "gamestringpool.h" #include "ammodef.h" +#include "asw_shareddefs.h" #include "takedamageinfo.h" #include "shot_manipulator.h" #include "ai_debug_shared.h" @@ -1991,6 +1992,9 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info ) { // Damage specified by function parameter CTakeDamageInfo dmgInfo( this, pAttacker, flActualDamage, nActualDamageType ); + if ( IsSentryClass( Classify() ) ) + dmgInfo.SetWeapon( this ); + CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecDir, tr.endpos ); dmgInfo.ScaleDamageForce( info.m_flDamageForceScale ); dmgInfo.SetAmmoType( info.m_iAmmoType );