diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index 3ec69973..718595d6 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -111,7 +111,7 @@ int CHudFlashlight::Draw( float flTime ) if( gEngfuncs.IsSpectateOnly() ) return 1; - if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_FLASHLIGHT ) ) ) ) return 1; if( m_fOn ) diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index 0aafafbd..a848a785 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -40,6 +40,6 @@ #define HUD_PRINTTALK 3 #define HUD_PRINTCENTER 4 - +#define WEAPON_FLASHLIGHT 30 #define WEAPON_SUIT 31 #endif diff --git a/dlls/items.cpp b/dlls/items.cpp index 20279011..b88a711e 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -70,6 +70,9 @@ void CWorldItem::Spawn( void ) case 45: // ITEM_SUIT: pEntity = CBaseEntity::Create( "item_suit", pev->origin, pev->angles ); break; + case 46: // ITEM_FLASHLIGHT: + pEntity = CBaseEntity::Create( "item_flashlight", pev->origin, pev->angles ); + break; } if( !pEntity ) @@ -366,6 +369,33 @@ class CItemSecurity : public CItem LINK_ENTITY_TO_CLASS( item_security, CItemSecurity ) +class CItemFlashlight : public CItem +{ + void Spawn( void ) + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_flashlight.mdl" ); + CItem::Spawn(); + } + void Precache( void ) + { + PRECACHE_MODEL( "models/w_flashlight.mdl" ); + PRECACHE_SOUND( "items/gunpickup2.wav" ); + } + BOOL MyTouch( CBasePlayer *pPlayer ) + { + if( pPlayer->pev->weapons & ( 1 << WEAPON_FLASHLIGHT ) ) + return FALSE; + + EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); + + pPlayer->pev->weapons |= ( 1 << WEAPON_FLASHLIGHT ); + return TRUE; + } +}; + +LINK_ENTITY_TO_CLASS( item_flashlight, CItemFlashlight ) + class CItemLongJump : public CItem { void Spawn( void ) diff --git a/dlls/player.cpp b/dlls/player.cpp index f93cde01..0f6df079 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3295,7 +3295,7 @@ void CBasePlayer::FlashlightTurnOn( void ) return; } - if( (pev->weapons & ( 1 << WEAPON_SUIT ) ) ) + if( (pev->weapons & ( 1 << WEAPON_FLASHLIGHT ) ) ) { EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); SetBits( pev->effects, EF_DIMLIGHT ); diff --git a/dlls/weapons.h b/dlls/weapons.h index aa849300..f976ba2c 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -81,6 +81,7 @@ public: #define WEAPON_ALLWEAPONS (~(1<