From b6f33c964a9f1b74e08bc6e2f02364e4354af2c5 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 24 Nov 2019 23:15:26 +0500 Subject: [PATCH 1/3] Add item_flashlight. --- cl_dll/flashlight.cpp | 2 +- dlls/items.cpp | 30 ++++++++++++++++++++++++++++++ dlls/player.cpp | 2 +- dlls/weapons.h | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) 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/items.cpp b/dlls/items.cpp index 08a13711..38d8a270 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 ) @@ -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 ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 6b741778..8d20e865 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 312f5531..03d07b6a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -81,6 +81,7 @@ public: #define WEAPON_ALLWEAPONS (~(1< Date: Sun, 24 Nov 2019 23:32:48 +0500 Subject: [PATCH 2/3] Add trigger_playerfreeze. --- dlls/triggers.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 2c0888c9..01dddb85 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -2039,6 +2039,26 @@ void CTriggerGravity::GravityTouch( CBaseEntity *pOther ) pOther->pev->gravity = pev->gravity; } +class CTriggerPlayerFreeze : public CBaseDelay +{ +public: + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } +}; + +LINK_ENTITY_TO_CLASS( trigger_playerfreeze, CTriggerPlayerFreeze ) + +void CTriggerPlayerFreeze::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + if( !pActivator || !pActivator->IsPlayer() ) + pActivator = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); + + if( pActivator->pev->flags & FL_FROZEN ) + ( (CBasePlayer*)( pActivator ) )->EnableControl( TRUE ); + else + ( (CBasePlayer*)( pActivator ) )->EnableControl( FALSE ); +}; + // this is a really bad idea. class CTriggerChangeTarget : public CBaseDelay { From 3c5617571742962b5b982a4a415b8e3ebbcb83d3 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Mon, 25 Nov 2019 01:03:13 +0500 Subject: [PATCH 3/3] Fix compilation. --- dlls/cdll_dll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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