|
|
@ -2385,11 +2385,12 @@ void CTriggerCamera::Move() |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Adapted from TWHL - Using mp3s in Steam
|
|
|
|
// Adapted from TWHL - Using mp3s in Steam
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#define SF_REMOVE_ON_FIRE 1 |
|
|
|
class CTargetMP3Audio : public CBaseTrigger |
|
|
|
class CTargetMP3Audio : public CBaseTrigger |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
virtual int Save( CSave &save ); |
|
|
|
int Save( CSave &save ); |
|
|
|
virtual int Restore( CRestore &restore ); |
|
|
|
int Restore( CRestore &restore ); |
|
|
|
static TYPEDESCRIPTION m_SaveData[]; |
|
|
|
static TYPEDESCRIPTION m_SaveData[]; |
|
|
|
|
|
|
|
|
|
|
|
void Spawn( void ); |
|
|
|
void Spawn( void ); |
|
|
@ -2397,15 +2398,16 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
void Touch( CBaseEntity *pOther ); |
|
|
|
void Touch( CBaseEntity *pOther ); |
|
|
|
|
|
|
|
|
|
|
|
int m_iszTrack; |
|
|
|
string_t m_iszTrack; |
|
|
|
BOOL m_bTriggered; |
|
|
|
BOOL m_bPlaying; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS( trigger_mp3audio, CTargetMP3Audio ); |
|
|
|
LINK_ENTITY_TO_CLASS( trigger_mp3audio, CTargetMP3Audio ); |
|
|
|
|
|
|
|
|
|
|
|
TYPEDESCRIPTION CTargetMP3Audio::m_SaveData[] = |
|
|
|
TYPEDESCRIPTION CTargetMP3Audio::m_SaveData[] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
DEFINE_FIELD( CTargetMP3Audio, m_bTriggered, FIELD_BOOLEAN ), |
|
|
|
DEFINE_FIELD( CTargetMP3Audio, m_iszTrack, FIELD_STRING ), |
|
|
|
|
|
|
|
DEFINE_FIELD( CTargetMP3Audio, m_bPlaying, FIELD_BOOLEAN ), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_SAVERESTORE( CTargetMP3Audio, CBaseTrigger ); |
|
|
|
IMPLEMENT_SAVERESTORE( CTargetMP3Audio, CBaseTrigger ); |
|
|
@ -2414,7 +2416,10 @@ void CTargetMP3Audio::KeyValue( KeyValueData *pkvd ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( FStrEq( pkvd->szKeyName, "track" ) ) |
|
|
|
if( FStrEq( pkvd->szKeyName, "track" ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_iszTrack = ALLOC_STRING( pkvd->szValue ); |
|
|
|
if( FStrEq( pkvd->szValue, "hl28.mp3" ) ) |
|
|
|
|
|
|
|
m_iszTrack = MAKE_STRING( "Suspense07.mp3" ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
m_iszTrack = ALLOC_STRING( pkvd->szValue ); |
|
|
|
pkvd->fHandled = TRUE; |
|
|
|
pkvd->fHandled = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -2424,22 +2429,31 @@ void CTargetMP3Audio::KeyValue( KeyValueData *pkvd ) |
|
|
|
void CTargetMP3Audio::Spawn( void ) |
|
|
|
void CTargetMP3Audio::Spawn( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
InitTrigger(); |
|
|
|
InitTrigger(); |
|
|
|
|
|
|
|
m_bPlaying = FALSE; // start out not playing
|
|
|
|
m_bTriggered = FALSE; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CTargetMP3Audio::Touch( CBaseEntity *pOther ) |
|
|
|
void CTargetMP3Audio::Touch( CBaseEntity *pOther ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( m_bTriggered ) |
|
|
|
char command[64]; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !pOther || !pOther->IsPlayer() ) |
|
|
|
if( !pOther || !pOther->IsPlayer() ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
m_bTriggered = TRUE; |
|
|
|
if( !m_bPlaying ) // if we're not playing, start playing!
|
|
|
|
|
|
|
|
|
|
|
|
if( FStrEq( STRING( gpGlobals->mapname ), "ops_17th" ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
CLIENT_COMMAND( pOther->edict(), "play media/Suspense07.mp3\n" ); |
|
|
|
m_bPlaying = TRUE; |
|
|
|
|
|
|
|
// issue the play/loop command
|
|
|
|
|
|
|
|
sprintf( command, "playaudio %s\n", STRING( m_iszTrack ) ); |
|
|
|
|
|
|
|
CLIENT_COMMAND( pOther->edict(), command ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*else
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// if we're already playing, stop the mp3
|
|
|
|
|
|
|
|
m_bPlaying = FALSE; |
|
|
|
|
|
|
|
CLIENT_COMMAND( pOther->edict(), "stopaudio\n" ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( pev->spawnflags & SF_REMOVE_ON_FIRE ) |
|
|
|
|
|
|
|
UTIL_Remove( this ); |
|
|
|
} |
|
|
|
} |
|
|
|