Skip to content

Commit d44ed23

Browse files
committed
Add 'If locked, play locked sound on use' for doors
1 parent 361b88d commit d44ed23

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

dlls/doors.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CBaseDoor : public CBaseToggle
6969
void EXPORT DoorTouch( CBaseEntity *pOther );
7070

7171
// local functions
72-
int DoorActivate();
72+
int DoorActivate(bool activatedByUse = false);
7373
void EXPORT DoorGoUp( void );
7474
void EXPORT DoorGoDown( void );
7575
void EXPORT DoorHitTop( void );
@@ -109,6 +109,7 @@ class CBaseDoor : public CBaseToggle
109109

110110
float m_returnSpeed;
111111
bool m_ignoreCorpses;
112+
bool m_playLockedSoundOnUse;
112113
short m_blockerRecheck;
113114

114115
float SoundAttenuation() const
@@ -155,6 +156,7 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] =
155156

156157
DEFINE_FIELD( CBaseDoor, m_returnSpeed, FIELD_FLOAT ),
157158
DEFINE_FIELD( CBaseDoor, m_ignoreCorpses, FIELD_BOOLEAN ),
159+
DEFINE_FIELD( CBaseDoor, m_playLockedSoundOnUse, FIELD_BOOLEAN ),
158160
DEFINE_FIELD( CBaseDoor, m_blockerRecheck, FIELD_SHORT ),
159161
};
160162

@@ -390,6 +392,11 @@ void CBaseDoor::KeyValue( KeyValueData *pkvd )
390392
m_ignoreCorpses = atoi(pkvd->szValue) != 0;
391393
pkvd->fHandled = true;
392394
}
395+
else if ( FStrEq(pkvd->szKeyName, "locked_play_on_use") )
396+
{
397+
m_playLockedSoundOnUse = atoi(pkvd->szValue) != 0;
398+
pkvd->fHandled = true;
399+
}
393400
else if ( FStrEq(pkvd->szKeyName, "blocker_recheck") )
394401
{
395402
m_blockerRecheck = (short)atoi(pkvd->szValue);
@@ -785,7 +792,7 @@ void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
785792
}
786793

787794
if( shouldActivate )
788-
DoorActivate();
795+
DoorActivate(true);
789796
}
790797

791798
float CBaseDoor::InputByMonster(CBaseMonster *pMonster)
@@ -850,10 +857,16 @@ NODE_LINKENT CBaseDoor::HandleLinkEnt(int afCapMask, bool nodeQueryStatic)
850857
//
851858
// Causes the door to "do its thing", i.e. start moving, and cascade activation.
852859
//
853-
int CBaseDoor::DoorActivate()
860+
int CBaseDoor::DoorActivate(bool activatedByUse)
854861
{
855862
if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) )
863+
{
864+
if (activatedByUse && m_playLockedSoundOnUse)
865+
{
866+
PlayLockSounds( pev, &m_ls, true, false );
867+
}
856868
return 0;
869+
}
857870

858871
if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) && (m_toggle_state == TS_AT_TOP || (m_iObeyTriggerMode == 2 && m_toggle_state == TS_GOING_UP)) )
859872
{

fgd/halflife.fgd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@
903903
0 : "Collide with corpses"
904904
1 : "Don't collide with corpses"
905905
]
906+
locked_play_on_use(choices) : "If locked, play locked sound on use" : : "By default if door is locked by a master and is set to 'Use only' or triggered by something it won't play the locked sound. Set this option to change the behavior" =
907+
[
908+
0 : "No"
909+
1 : "Yes"
910+
]
906911
blocker_recheck(choices) : "Continue moving if blocker is crushed" =
907912
[
908913
0 : "Default (as globally configured)"
@@ -2750,9 +2755,9 @@
27502755
_minlight(string) : "Minimum light level"
27512756
]
27522757

2753-
@SolidClass base(Door, ZHLT, EntityUsePolicy) = func_door : "Basic door" []
2758+
@SolidClass base(Door, EntityUsePolicy, ZHLT) = func_door : "Basic door" []
27542759

2755-
@SolidClass base(Door, ZHLT, EntityUsePolicy) = func_door_rotating : "Rotating door"
2760+
@SolidClass base(Door, EntityUsePolicy, ZHLT) = func_door_rotating : "Rotating door"
27562761
[
27572762
spawnflags(flags) =
27582763
[

0 commit comments

Comments
 (0)