Skip to content

Commit 8ccc0ca

Browse files
authored
Merge pull request #875 from ReactiveDrop/sentry-friendlyfire-kv
add "friendlyfire" keyvalue to sentry tops. Also makes asw_sentry_fri…
2 parents 75e48bf + 6beed13 commit 8ccc0ca

6 files changed

Lines changed: 27 additions & 2 deletions

File tree

reactivedrop/fgd/reactivedrop.fgd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
@PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/flame_top.mdl") = asw_sentry_top_flamer
4646
[
4747
TurretRange(float) : "Turret Range" : "375" : "Maximum distance that it will pick targets."
48+
friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." =
49+
[
50+
0 : "No"
51+
1 : "Yes"
52+
]
4853
]
4954

5055
@PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/freeze_top.mdl") = asw_sentry_top_icer
@@ -56,6 +61,11 @@
5661
[
5762
TurretRange(float) : "Turret Range" : "1000" : "Maximum distance that it will pick targets."
5863
FireRate(float) : "Fire Rate" : "1.75" : "Time in seconds between each shot"
64+
friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." =
65+
[
66+
0 : "No"
67+
1 : "Yes"
68+
]
5969
]
6070

6171
@SolidClass base(Trigger) = trigger_rd_marine_jumpjet :

reactivedrop/fgd/swarm.fgd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,6 +3824,11 @@
38243824
@PointClass base(Targetname, Parentname, Angles, Studiomodel) studioprop("models/sentry_gun/machinegun_top.mdl") = asw_sentry_top_machinegun
38253825
[
38263826
TurretRange(float) : "Turret Range" : "525" : "Maximum distance that it will pick targets."
3827+
friendlyfire(choices) : "Do Friendly Fire" : 1 : "Whether the sentry will inflict friendly fire to marines." =
3828+
[
3829+
0 : "No"
3830+
1 : "Yes"
3831+
]
38273832
]
38283833

38293834
@PointClass sphere() iconsprite("editor/env_shake.vmt") base(Targetname, Parentname) = asw_env_shake :

src/game/server/swarm/asw_marine.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "ammodef.h"
4646
#include "asw_shareddefs.h"
4747
#include "asw_sentry_base.h"
48+
#include "asw_sentry_top.h"
4849
#include "asw_button_area.h"
4950
#include "asw_equipment_list.h"
5051
#include "asw_weapon_parse.h"
@@ -1365,13 +1366,15 @@ int CASW_Marine::OnTakeDamage_Alive( const CTakeDamageInfo &info )
13651366
CTakeDamageInfo newInfo(info);
13661367

13671368
CBaseEntity* pAttacker = newInfo.GetAttacker();
1369+
CBaseEntity* pWeapon = newInfo.GetWeapon();
13681370
if ( asw_debug_marine_damage.GetBool() )
13691371
Msg( "Marine taking premodified damage of %f\n", newInfo.GetDamage() );
13701372

13711373
// scale sentry gun damage
1372-
if ( pAttacker && IsSentryClass( pAttacker->Classify() ) )
1374+
if ( pWeapon && IsSentryClass( pWeapon->Classify() ) )
13731375
{
1374-
if ( asw_sentry_friendly_fire_scale.GetFloat() <= 0 )
1376+
CASW_Sentry_Top *pSentry = dynamic_cast< CASW_Sentry_Top* >( pWeapon );
1377+
if ( asw_sentry_friendly_fire_scale.GetFloat() <= 0 || ( pSentry && !pSentry->m_bFriendlyFire ) )
13751378
return 0;
13761379

13771380
newInfo.ScaleDamage( asw_sentry_friendly_fire_scale.GetFloat() );

src/game/server/swarm/asw_sentry_top.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ BEGIN_DATADESC( CASW_Sentry_Top )
6060
DEFINE_FIELD( m_iSentryAngle, FIELD_INTEGER ),
6161
DEFINE_KEYFIELD( m_flShootRange, FIELD_FLOAT, "TurretRange" ),
6262
DEFINE_FIELD( m_bLowAmmo, FIELD_BOOLEAN ),
63+
DEFINE_KEYFIELD( m_bFriendlyFire, FIELD_BOOLEAN, "friendlyfire" ),
6364
END_DATADESC()
6465

6566
BEGIN_ENT_SCRIPTDESC( CASW_Sentry_Top, CBaseCombatCharacter, "sentry top" )
@@ -78,6 +79,7 @@ CASW_Sentry_Top::CASW_Sentry_Top()
7879
m_iBaseTurnRate = ASW_SENTRY_TURNRATE / 2;
7980
m_iEnemyTurnRate = ASW_SENTRY_TURNRATE;
8081
m_iSentryAngle = ASW_SENTRY_ANGLE;
82+
m_bFriendlyFire = true;
8183

8284
m_iPoseParamPitch = -2;
8385
m_iPoseParamYaw = -2;

src/game/server/swarm/asw_sentry_top.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class CASW_Sentry_Top : public CBaseCombatCharacter
7070
int m_iBaseTurnRate; // angles per second
7171
int m_iEnemyTurnRate;
7272
CNetworkVar( int, m_iSentryAngle );
73+
bool m_bFriendlyFire;
7374

7475
float m_flTimeFirstFired;
7576

src/game/shared/baseentity_shared.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "model_types.h"
1313
#include "gamestringpool.h"
1414
#include "ammodef.h"
15+
#include "asw_shareddefs.h"
1516
#include "takedamageinfo.h"
1617
#include "shot_manipulator.h"
1718
#include "ai_debug_shared.h"
@@ -1991,6 +1992,9 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
19911992
{
19921993
// Damage specified by function parameter
19931994
CTakeDamageInfo dmgInfo( this, pAttacker, flActualDamage, nActualDamageType );
1995+
if ( IsSentryClass( Classify() ) )
1996+
dmgInfo.SetWeapon( this );
1997+
19941998
CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecDir, tr.endpos );
19951999
dmgInfo.ScaleDamageForce( info.m_flDamageForceScale );
19962000
dmgInfo.SetAmmoType( info.m_iAmmoType );

0 commit comments

Comments
 (0)