Browse Source

Add item_flashlight.

induction_1.2
Andrey Akhmichin 5 years ago
parent
commit
b6f33c964a
  1. 2
      cl_dll/flashlight.cpp
  2. 30
      dlls/items.cpp
  3. 2
      dlls/player.cpp
  4. 1
      dlls/weapons.h

2
cl_dll/flashlight.cpp

@ -111,7 +111,7 @@ int CHudFlashlight::Draw( float flTime ) @@ -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 )

30
dlls/items.cpp

@ -70,6 +70,9 @@ void CWorldItem::Spawn( void ) @@ -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 )
@ -298,6 +301,33 @@ class CItemSecurity : public CItem @@ -298,6 +301,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 )

2
dlls/player.cpp

@ -3295,7 +3295,7 @@ void CBasePlayer::FlashlightTurnOn( void ) @@ -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 );

1
dlls/weapons.h

@ -81,6 +81,7 @@ public: @@ -81,6 +81,7 @@ public:
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))
#define WEAPON_FLASHLIGHT 30
#define WEAPON_SUIT 31 // ?????
#define MAX_WEAPONS 32

Loading…
Cancel
Save