Skip to content

Commit 94e1fa9

Browse files
committed
mapper-placed pick-upable sentries
1 parent ef2b317 commit 94e1fa9

File tree

3 files changed

+65
-28
lines changed

3 files changed

+65
-28
lines changed

reactivedrop/fgd/reactivedrop.fgd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,3 +914,22 @@ asw_pickup_50calmg : "50cal Machine Gun"
914914
input TurnOff(void)
915915
input Toggle(void)
916916
]
917+
918+
@PointClass base(Targetname, Parentname, Angles) studio("models/sentry_gun/sentry_base.mdl") = asw_sentry_base : "Pre-built IAF sentry"
919+
[
920+
GunType(choices) : "Gun type" : 0 =
921+
[
922+
0 : "Machine Gun"
923+
1 : "Grenade Launcher"
924+
2 : "Flamer"
925+
3 : "Cryo Cannon"
926+
4 : "Railgun"
927+
]
928+
IsAssembled(choices) : "Fully assembled" : 0 =
929+
[
930+
0 : "No"
931+
1 : "Yes"
932+
]
933+
AssembleProgress(float) : "Assembly progress" : "0.0" : "Number between 0 (just placed) and 1 (almost fully assembled). Ignored if fully assembled."
934+
Ammo(integer) : "Ammo" : "-1" : "Remaining ammo in gun. -1 = full (automatically changed to the gun type's max ammo). Max ammo for each type: machine gun = 450, grenade launcher = 40, flamer = 1200, cryo cannon = 800, railgun = 300"
935+
]

src/game/server/swarm/asw_sentry_base.cpp

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
#include "tier0/memdbgon.h"
1818

1919
#define SENTRY_BASE_MODEL "models/sentry_gun/sentry_base.mdl"
20-
//#define SENTRY_BASE_MODEL "models/swarm/droneprops/DronePropIdle.mdl"
2120

2221
extern int g_sModelIndexFireball; // (in combatweapon.cpp) holds the index for the smoke cloud
2322

24-
2523
ConVar asw_sentry_gun_type("asw_sentry_gun_type", "-1", FCVAR_CHEAT, "Force the type of sentry guns built to this. -1, the default, reads from the marine attributes.");
2624
ConVar asw_sentry_infinite_ammo( "asw_sentry_infinite_ammo", "0", FCVAR_CHEAT );
2725
ConVar asw_sentry_health_base( "asw_sentry_health_base", "300", FCVAR_CHEAT );
@@ -53,12 +51,14 @@ END_SEND_TABLE()
5351
BEGIN_DATADESC( CASW_Sentry_Base )
5452
DEFINE_THINKFUNC( AnimThink ),
5553
DEFINE_FIELD( m_hSentryTop, FIELD_EHANDLE ),
56-
DEFINE_FIELD( m_bAssembled, FIELD_BOOLEAN ),
54+
DEFINE_KEYFIELD( m_bAssembled, FIELD_BOOLEAN, "IsAssembled" ),
5755
DEFINE_FIELD( m_bIsInUse, FIELD_BOOLEAN ),
58-
DEFINE_FIELD( m_fAssembleProgress, FIELD_FLOAT ),
56+
DEFINE_KEYFIELD( m_fAssembleProgress, FIELD_FLOAT, "AssembleProgress" ),
5957
DEFINE_FIELD( m_fAssembleCompleteTime, FIELD_TIME ),
6058
DEFINE_FIELD( m_hDeployer, FIELD_EHANDLE ),
6159
DEFINE_FIELD( m_hLastDisassembler, FIELD_EHANDLE ),
60+
DEFINE_KEYFIELD( m_iAmmo, FIELD_INTEGER, "Ammo" ),
61+
DEFINE_KEYFIELD( m_nGunType, FIELD_INTEGER, "GunType" ),
6262
END_DATADESC()
6363

6464
BEGIN_ENT_SCRIPTDESC( CASW_Sentry_Base, CBaseAnimating, "sentry" )
@@ -156,6 +156,24 @@ void CASW_Sentry_Base::Spawn( void )
156156
{
157157
m_iAmmo = m_iMaxAmmo;
158158
}
159+
160+
// mapper-placed sentries
161+
SetGunType( m_nGunType ); // set skin
162+
if ( m_bAssembled )
163+
{
164+
Assert( !m_hSentryTop );
165+
m_fAssembleProgress = 1.0f;
166+
m_fAssembleCompleteTime = gpGlobals->curtime;
167+
168+
CASW_Sentry_Top *pSentryTop = dynamic_cast< CASW_Sentry_Top * >( CreateEntityByName( GetEntityNameForGunType( GetGunType() ) ) );
169+
m_hSentryTop = pSentryTop;
170+
if ( pSentryTop )
171+
{
172+
pSentryTop->SetSentryBase( this );
173+
pSentryTop->SetAbsAngles( GetAbsAngles() );
174+
DispatchSpawn( pSentryTop );
175+
}
176+
}
159177
}
160178

161179
void CASW_Sentry_Base::PlayDeploySound()
@@ -328,30 +346,6 @@ void CASW_Sentry_Base::NPCStartedUsing( CASW_Inhabitable_NPC *pNPC )
328346
{
329347
EmitSound( "ASW_Sentry.SetupLoop" );
330348

331-
if ( GetModelPtr() && GetModelPtr()->numskinfamilies() >= kGUNTYPE_MAX + 2 ) // modeller guy says 2 first textures are a must
332-
{
333-
switch ( GetGunType() )
334-
{
335-
case kAUTOGUN:
336-
this->m_nSkin = 2;
337-
break;
338-
case kCANNON:
339-
this->m_nSkin = 5;
340-
break;
341-
case kFLAME:
342-
this->m_nSkin = 4;
343-
break;
344-
case kICE:
345-
this->m_nSkin = 3;
346-
break;
347-
#ifdef RD_7A_WEAPONS
348-
case kRAILGUN:
349-
this->m_nSkin = 6;
350-
break;
351-
#endif
352-
}
353-
}
354-
355349
if ( !m_bIsInUse && m_fAssembleProgress < 1.0f )
356350
{
357351
IGameEvent *event = gameeventmanager->CreateEvent( "sentry_start_building" );

src/game/server/swarm/asw_sentry_base.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,30 @@ inline void CASW_Sentry_Base::SetGunType( int iType )
115115
inline void CASW_Sentry_Base::SetGunType( GunType_t iType )
116116
{
117117
m_nGunType = iType;
118+
119+
if ( GetModelPtr() && GetModelPtr()->numskinfamilies() >= kGUNTYPE_MAX + 2 ) // modeller guy says 2 first textures are a must
120+
{
121+
switch ( GetGunType() )
122+
{
123+
case kAUTOGUN:
124+
m_nSkin = 2;
125+
break;
126+
case kCANNON:
127+
m_nSkin = 5;
128+
break;
129+
case kFLAME:
130+
m_nSkin = 4;
131+
break;
132+
case kICE:
133+
m_nSkin = 3;
134+
break;
135+
#ifdef RD_7A_WEAPONS
136+
case kRAILGUN:
137+
m_nSkin = 6;
138+
break;
139+
#endif
140+
}
141+
}
118142
}
119143

120144
#endif /* ASW_SENTRY_BASE_H */

0 commit comments

Comments
 (0)