Skip to content

Commit

Permalink
mapper-placed pick-upable sentries
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLubar committed Nov 16, 2024
1 parent ef2b317 commit 94e1fa9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 28 deletions.
19 changes: 19 additions & 0 deletions reactivedrop/fgd/reactivedrop.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -914,3 +914,22 @@ asw_pickup_50calmg : "50cal Machine Gun"
input TurnOff(void)
input Toggle(void)
]

@PointClass base(Targetname, Parentname, Angles) studio("models/sentry_gun/sentry_base.mdl") = asw_sentry_base : "Pre-built IAF sentry"
[
GunType(choices) : "Gun type" : 0 =
[
0 : "Machine Gun"
1 : "Grenade Launcher"
2 : "Flamer"
3 : "Cryo Cannon"
4 : "Railgun"
]
IsAssembled(choices) : "Fully assembled" : 0 =
[
0 : "No"
1 : "Yes"
]
AssembleProgress(float) : "Assembly progress" : "0.0" : "Number between 0 (just placed) and 1 (almost fully assembled). Ignored if fully assembled."
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"
]
50 changes: 22 additions & 28 deletions src/game/server/swarm/asw_sentry_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
#include "tier0/memdbgon.h"

#define SENTRY_BASE_MODEL "models/sentry_gun/sentry_base.mdl"
//#define SENTRY_BASE_MODEL "models/swarm/droneprops/DronePropIdle.mdl"

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


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.");
ConVar asw_sentry_infinite_ammo( "asw_sentry_infinite_ammo", "0", FCVAR_CHEAT );
ConVar asw_sentry_health_base( "asw_sentry_health_base", "300", FCVAR_CHEAT );
Expand Down Expand Up @@ -53,12 +51,14 @@ END_SEND_TABLE()
BEGIN_DATADESC( CASW_Sentry_Base )
DEFINE_THINKFUNC( AnimThink ),
DEFINE_FIELD( m_hSentryTop, FIELD_EHANDLE ),
DEFINE_FIELD( m_bAssembled, FIELD_BOOLEAN ),
DEFINE_KEYFIELD( m_bAssembled, FIELD_BOOLEAN, "IsAssembled" ),
DEFINE_FIELD( m_bIsInUse, FIELD_BOOLEAN ),
DEFINE_FIELD( m_fAssembleProgress, FIELD_FLOAT ),
DEFINE_KEYFIELD( m_fAssembleProgress, FIELD_FLOAT, "AssembleProgress" ),
DEFINE_FIELD( m_fAssembleCompleteTime, FIELD_TIME ),
DEFINE_FIELD( m_hDeployer, FIELD_EHANDLE ),
DEFINE_FIELD( m_hLastDisassembler, FIELD_EHANDLE ),
DEFINE_KEYFIELD( m_iAmmo, FIELD_INTEGER, "Ammo" ),
DEFINE_KEYFIELD( m_nGunType, FIELD_INTEGER, "GunType" ),
END_DATADESC()

BEGIN_ENT_SCRIPTDESC( CASW_Sentry_Base, CBaseAnimating, "sentry" )
Expand Down Expand Up @@ -156,6 +156,24 @@ void CASW_Sentry_Base::Spawn( void )
{
m_iAmmo = m_iMaxAmmo;
}

// mapper-placed sentries
SetGunType( m_nGunType ); // set skin
if ( m_bAssembled )
{
Assert( !m_hSentryTop );
m_fAssembleProgress = 1.0f;
m_fAssembleCompleteTime = gpGlobals->curtime;

CASW_Sentry_Top *pSentryTop = dynamic_cast< CASW_Sentry_Top * >( CreateEntityByName( GetEntityNameForGunType( GetGunType() ) ) );
m_hSentryTop = pSentryTop;
if ( pSentryTop )
{
pSentryTop->SetSentryBase( this );
pSentryTop->SetAbsAngles( GetAbsAngles() );
DispatchSpawn( pSentryTop );
}
}
}

void CASW_Sentry_Base::PlayDeploySound()
Expand Down Expand Up @@ -328,30 +346,6 @@ void CASW_Sentry_Base::NPCStartedUsing( CASW_Inhabitable_NPC *pNPC )
{
EmitSound( "ASW_Sentry.SetupLoop" );

if ( GetModelPtr() && GetModelPtr()->numskinfamilies() >= kGUNTYPE_MAX + 2 ) // modeller guy says 2 first textures are a must
{
switch ( GetGunType() )
{
case kAUTOGUN:
this->m_nSkin = 2;
break;
case kCANNON:
this->m_nSkin = 5;
break;
case kFLAME:
this->m_nSkin = 4;
break;
case kICE:
this->m_nSkin = 3;
break;
#ifdef RD_7A_WEAPONS
case kRAILGUN:
this->m_nSkin = 6;
break;
#endif
}
}

if ( !m_bIsInUse && m_fAssembleProgress < 1.0f )
{
IGameEvent *event = gameeventmanager->CreateEvent( "sentry_start_building" );
Expand Down
24 changes: 24 additions & 0 deletions src/game/server/swarm/asw_sentry_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ inline void CASW_Sentry_Base::SetGunType( int iType )
inline void CASW_Sentry_Base::SetGunType( GunType_t iType )
{
m_nGunType = iType;

if ( GetModelPtr() && GetModelPtr()->numskinfamilies() >= kGUNTYPE_MAX + 2 ) // modeller guy says 2 first textures are a must
{
switch ( GetGunType() )
{
case kAUTOGUN:
m_nSkin = 2;
break;
case kCANNON:
m_nSkin = 5;
break;
case kFLAME:
m_nSkin = 4;
break;
case kICE:
m_nSkin = 3;
break;
#ifdef RD_7A_WEAPONS
case kRAILGUN:
m_nSkin = 6;
break;
#endif
}
}
}

#endif /* ASW_SENTRY_BASE_H */

0 comments on commit 94e1fa9

Please sign in to comment.