@@ -133,6 +133,9 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] =
133
133
#if FEATURE_NIGHTVISION
134
134
DEFINE_FIELD (CBasePlayer, m_fNVGisON, FIELD_BOOLEAN),
135
135
#endif
136
+ DEFINE_FIELD (CBasePlayer, m_fFlashlightON, FIELD_BOOLEAN),
137
+ DEFINE_FIELD (CBasePlayer, m_fFlashlightFlicker, FIELD_BOOLEAN),
138
+ DEFINE_FIELD (CBasePlayer, m_flNextFlashlightFlick, FIELD_TIME),
136
139
#if FEATURE_ROPE
137
140
DEFINE_FIELD (CBasePlayer, m_hRope, FIELD_EHANDLE),
138
141
#endif
@@ -2607,6 +2610,20 @@ void CBasePlayer::PreThink( void )
2607
2610
}
2608
2611
}
2609
2612
2613
+ if (m_fFlashlightON && m_fFlashlightFlicker && gpGlobals->time >= m_flNextFlashlightFlick)
2614
+ {
2615
+ if (FBitSet (pev->effects , EF_DIMLIGHT))
2616
+ {
2617
+ ClearBits (pev->effects , EF_DIMLIGHT);
2618
+ }
2619
+ else
2620
+ {
2621
+ SetBits (pev->effects , EF_DIMLIGHT);
2622
+ }
2623
+
2624
+ m_flNextFlashlightFlick = gpGlobals->time + RANDOM_FLOAT (0 .1f , 0 .5f );
2625
+ }
2626
+
2610
2627
if ( g_fGameOver )
2611
2628
return ; // intermission or finale
2612
2629
@@ -4428,6 +4445,12 @@ void CBasePlayer::FlashlightTurnOn()
4428
4445
{
4429
4446
EmitSoundScript (Player::flashlightOnSoundScript);
4430
4447
SetBits ( pev->effects , EF_DIMLIGHT );
4448
+ m_fFlashlightON = true ;
4449
+
4450
+ if (m_fFlashlightFlicker)
4451
+ {
4452
+ m_flNextFlashlightFlick = gpGlobals->time + 0 .2f ;
4453
+ }
4431
4454
4432
4455
NVGTurnOff (false );
4433
4456
UpdateSuitLightBattery (true );
@@ -4442,6 +4465,7 @@ void CBasePlayer::FlashlightTurnOff( bool playOffSound )
4442
4465
EmitSoundScript (Player::flashlightOffSoundScript);
4443
4466
4444
4467
ClearBits ( pev->effects , EF_DIMLIGHT );
4468
+ m_fFlashlightON = false ;
4445
4469
UpdateSuitLightBattery (false );
4446
4470
}
4447
4471
}
@@ -7655,6 +7679,35 @@ class CPlayerHevSentence : public CPointEntity
7655
7679
7656
7680
LINK_ENTITY_TO_CLASS ( player_hevsentence, CPlayerHevSentence )
7657
7681
7682
+ class CPlayerFlicker : public CPointEntity
7683
+ {
7684
+ public:
7685
+ void Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
7686
+ };
7687
+
7688
+ LINK_ENTITY_TO_CLASS ( player_flicker, CPlayerFlicker )
7689
+
7690
+ void CPlayerFlicker::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
7691
+ {
7692
+ CBasePlayer* pPlayer = g_pGameRules->EffectivePlayer (pActivator);
7693
+ if (pPlayer)
7694
+ {
7695
+ if (ShouldToggle (useType, pPlayer->m_fFlashlightFlicker ))
7696
+ {
7697
+ pPlayer->m_fFlashlightFlicker = !pPlayer->m_fFlashlightFlicker ;
7698
+ if (pPlayer->m_fFlashlightFlicker && pPlayer->FlashlightIsOn ())
7699
+ {
7700
+ pPlayer->m_flNextFlashlightFlick = gpGlobals->time + 0 .2f ;
7701
+ }
7702
+ // Make sure the dimlight flag is set on player if the flashlight is supposed to be turned on
7703
+ if (!pPlayer->m_fFlashlightFlicker && pPlayer->FlashlightIsOn ())
7704
+ {
7705
+ SetBits (pPlayer->pev ->effects , EF_DIMLIGHT);
7706
+ }
7707
+ }
7708
+ }
7709
+ }
7710
+
7658
7711
static void DisableChangelevels ()
7659
7712
{
7660
7713
CBaseEntity* pEntity = 0 ;
0 commit comments