diff --git a/cl_dll/blackops/nightvision.cpp b/cl_dll/blackops/nightvision.cpp new file mode 100644 index 00000000..a40dabce --- /dev/null +++ b/cl_dll/blackops/nightvision.cpp @@ -0,0 +1,77 @@ +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#include "hud.h" +#include "cl_util.h" +#include "parsemsg.h" + +#include +#include + +DECLARE_MESSAGE(m_Nightvision, Nightvision) + +int CHudNightvision::Init(void) +{ + m_iFlags = 0; + + HOOK_MESSAGE(Nightvision); + + gHUD.AddHudElem(this); + + return 1; +}; + + +int CHudNightvision::VidInit(void) +{ + return 1; +}; + +int CHudNightvision::MsgFunc_Nightvision(const char *pszName, int iSize, void *pbuf) +{ + BEGIN_READ(pbuf, iSize); + int fActive = READ_BYTE(); + + if (fActive) + m_iFlags |= HUD_ACTIVE; + else + m_iFlags &= ~HUD_ACTIVE; + + return 1; +} + + +int CHudNightvision::Draw(float flTime) +{ + if (!(gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT)))) + return 1; + + int r, g, b, a; + int x, y, w, h; + + a = 128; + + UnpackRGB(r, g, b, RGB_YELLOWISH); + + ScaleColors(r, g, b, a); + + x = y = 0; + w = ScreenWidth; + h = ScreenHeight; + + FillRGBA( x, y, w, h, r, g, b, a ); + + return 1; +} \ No newline at end of file diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index d4979c35..93775b58 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -231,7 +231,7 @@ int CHudHealth::Draw( float flTime ) int iHeight = gHUD.m_iFontHeight; int iWidth = HealthWidth / 10; - FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a ); + FillRGBA( x, y, iWidth, iHeight, r, g, b, a ); } DrawDamage( flTime ); diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 0f3b45bc..0d583e34 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -227,6 +227,7 @@ void CHud::Init( void ) m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); + m_Nightvision.Init(); m_MOTD.Init(); m_Scoreboard.Init(); @@ -396,6 +397,7 @@ void CHud::VidInit( void ) m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); + m_Nightvision.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); } diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ec236003..51b12cc9 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -20,7 +20,7 @@ // CHud handles the message, calculation, and drawing the HUD // -#define RGB_YELLOWISH 0x00FFA000 //255,160,0 +#define RGB_YELLOWISH 0x00FF0000 //255,0,0 #define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 @@ -556,6 +556,18 @@ private: icon_sprite_t m_IconList[MAX_ICONSPRITES]; }; +// +//----------------------------------------------------- +// +class CHudNightvision : public CHudBase +{ +public: + int Init( void ); + int VidInit( void ); + int Draw( float flTime ); + int MsgFunc_Nightvision( const char *pszName, int iSize, void *pbuf ); +}; + // //----------------------------------------------------- // @@ -631,6 +643,7 @@ public: CHudAmmoSecondary m_AmmoSecondary; CHudTextMessage m_TextMessage; CHudStatusIcons m_StatusIcons; + CHudNightvision m_Nightvision; CHudScoreboard m_Scoreboard; CHudMOTD m_MOTD; diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index a9c706ec..af87624d 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -240,7 +240,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) { int i, j, length, width; const char *pText; - unsigned char line[80]; + unsigned char line[512]; pText = pMessage->pMessage; // Count lines diff --git a/dlls/blackops/hudtoggle.cpp b/dlls/blackops/hudtoggle.cpp new file mode 100644 index 00000000..0347d199 --- /dev/null +++ b/dlls/blackops/hudtoggle.cpp @@ -0,0 +1,89 @@ +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "customentity.h" +#include "effects.h" +#include "weapons.h" +#include "decals.h" +#include "func_break.h" +#include "shake.h" +#include "player.h" + +class CHudToggle : public CPointEntity +{ +public: + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + static TYPEDESCRIPTION m_SaveData[]; + + void Spawn(void); + void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + +protected: + BOOL m_fIsActive; +}; + +LINK_ENTITY_TO_CLASS(env_hudtoggle, CHudToggle); + +TYPEDESCRIPTION CHudToggle::m_SaveData[] = +{ + DEFINE_FIELD(CHudToggle, m_fIsActive, FIELD_BOOLEAN), +}; + +IMPLEMENT_SAVERESTORE(CHudToggle, CPointEntity); + +void CHudToggle::Spawn(void) +{ + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + + m_fIsActive = TRUE; +} + +void CHudToggle::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + CBasePlayer* pPlayer = (CBasePlayer*)pActivator; + if (!pPlayer) + return; + + switch (useType) + { + case USE_ON: + case USE_TOGGLE: + m_fIsActive = !m_fIsActive; + break; + + case USE_OFF: + m_fIsActive = FALSE; + break; + + case USE_SET: + m_fIsActive = value; + break; + } + + if (m_fIsActive) + { + pPlayer->m_iHideHUD &= ~HIDEHUD_ALL; + } + else + { + pPlayer->m_iHideHUD |= HIDEHUD_ALL; + } +} \ No newline at end of file diff --git a/dlls/client.cpp b/dlls/client.cpp index 21e5d810..0395542d 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -470,6 +470,17 @@ void ClientCommand( edict_t *pEntity ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning }*/ + else if( FStrEq( pcmd, "nightvision" ) ) + { + CBasePlayer * pPlayer = GetClassPtr( (CBasePlayer *)pev ); + if( pPlayer ) + { + if( !pPlayer->FlashlightIsOn() ) + pPlayer->FlashlightTurnOn(); + else + pPlayer->FlashlightTurnOff(); + } + } else if( FStrEq( pcmd, "VModEnable" ) ) { // clear 'Unknown command: VModEnable' in singleplayer diff --git a/dlls/items.cpp b/dlls/items.cpp index d9cc7871..26e0e6d5 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -181,16 +181,14 @@ class CItemSuit : public CItem void Precache( void ) { PRECACHE_MODEL( "models/w_suit.mdl" ); + PRECACHE_SOUND( "items/vest_pickup.wav" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { if( pPlayer->pev->weapons & ( 1<spawnflags & SF_SUIT_SHORTLOGON ) - EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon, - else - EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon + EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/vest_pickup.wav", 1, ATTN_NORM ); pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT ); return TRUE; diff --git a/dlls/player.cpp b/dlls/player.cpp index 2f097072..d2cc3baa 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -184,6 +184,8 @@ int gmsgTeamNames = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; +int gmsgNightvision = 0; + void LinkUserMessages( void ) { // Already taken care of? @@ -228,6 +230,8 @@ void LinkUserMessages( void ) gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); + + gmsgNightvision = REG_USER_MSG( "Nightvision", 1 ); } LINK_ENTITY_TO_CLASS( player, CBasePlayer ) @@ -3180,7 +3184,7 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe ) BOOL CBasePlayer::FlashlightIsOn( void ) { - return FBitSet( pev->effects, EF_DIMLIGHT ); + return FBitSet( pev->effects, EF_BRIGHTLIGHT ); } void CBasePlayer::FlashlightTurnOn( void ) @@ -3193,26 +3197,34 @@ void CBasePlayer::FlashlightTurnOn( void ) if( (pev->weapons & ( 1 << WEAPON_SUIT ) ) ) { EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); - SetBits( pev->effects, EF_DIMLIGHT ); + SetBits( pev->effects, EF_BRIGHTLIGHT ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); WRITE_BYTE( 1 ); WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; + + MESSAGE_BEGIN( MSG_ONE, gmsgNightvision, NULL, pev ); + WRITE_BYTE( 1 ); + MESSAGE_END(); } } void CBasePlayer::FlashlightTurnOff( void ) { EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1.0, ATTN_NORM, 0, PITCH_NORM ); - ClearBits( pev->effects, EF_DIMLIGHT ); + ClearBits( pev->effects, EF_BRIGHTLIGHT ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); WRITE_BYTE( 0 ); WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; + + MESSAGE_BEGIN( MSG_ONE, gmsgNightvision, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); } /* diff --git a/dlls/player.h b/dlls/player.h index e75787ee..2256f216 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -55,8 +55,8 @@ #define CSUITNOREPEAT 32 -#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" -#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" +#define SOUND_FLASHLIGHT_ON "items/nvg_turnon.wav" +#define SOUND_FLASHLIGHT_OFF "items/nvg_turnoff.wav" #define TEAM_NAME_LENGTH 16 diff --git a/dlls/python.cpp b/dlls/python.cpp index 7bb71325..96f9baa3 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -111,6 +111,8 @@ BOOL CPython::Deploy() pev->body = 0; } + m_flSoundDelay = 0; + return DefaultDeploy( "models/v_357.mdl", "models/p_357.mdl", PYTHON_DRAW, "python", UseDecrement(), pev->body ); } @@ -126,6 +128,8 @@ void CPython::Holster( int skiplocal /* = 0 */ ) m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); SendWeaponAnim( PYTHON_HOLSTER ); + + m_flSoundDelay = 0; } void CPython::SecondaryAttack( void ) @@ -227,9 +231,10 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) + int iResult = DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ); + if( iResult ) { - m_flSoundDelay = 1.5; + m_flSoundDelay = gpGlobals->time + 1.5; } } @@ -240,7 +245,7 @@ void CPython::WeaponIdle( void ) m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); - if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) + if( m_flSoundDelay != 0 && ( m_flSoundDelay <= UTIL_WeaponTimeBase() || m_flSoundDelay <= gpGlobals->time ) ) { EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM ); m_flSoundDelay = 0; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index d7f9483c..7513beea 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -2381,3 +2381,65 @@ void CTriggerCamera::Move() float fraction = 2 * gpGlobals->frametime; pev->velocity = ( ( pev->movedir * pev->speed ) * fraction ) + ( pev->velocity * ( 1 - fraction ) ); } + +// +// Adapted from TWHL - Using mp3s in Steam +// +class CTargetMP3Audio : public CBaseTrigger +{ +public: + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + + void Touch( CBaseEntity *pOther ); + + int m_iszTrack; + BOOL m_bTriggered; +}; + +LINK_ENTITY_TO_CLASS( trigger_mp3audio, CTargetMP3Audio ); + +TYPEDESCRIPTION CTargetMP3Audio::m_SaveData[] = +{ + DEFINE_FIELD( CTargetMP3Audio, m_bTriggered, FIELD_BOOLEAN ), +}; + +IMPLEMENT_SAVERESTORE( CTargetMP3Audio, CBaseTrigger ); + +void CTargetMP3Audio::KeyValue( KeyValueData *pkvd ) +{ + if( FStrEq( pkvd->szKeyName, "track" ) ) + { + m_iszTrack = ALLOC_STRING( pkvd->szValue ); + pkvd->fHandled = TRUE; + } + else + CBaseTrigger::KeyValue( pkvd ); +} + +void CTargetMP3Audio::Spawn( void ) +{ + InitTrigger(); + + m_bTriggered = FALSE; +} + +void CTargetMP3Audio::Touch( CBaseEntity *pOther ) +{ + if( m_bTriggered ) + return; + + if( !pOther || !pOther->IsPlayer() ) + return; + + m_bTriggered = TRUE; + + if( FStrEq( STRING( gpGlobals->mapname ), "ops_17th" ) ) + { + CLIENT_COMMAND( pOther->edict(), "play media/Suspense07.mp3\n" ); + } +} diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 3e2ef386..552e0a6d 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1527,3 +1527,9 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = }; IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) + +TYPEDESCRIPTION CPython::m_SaveData[] = +{ + DEFINE_FIELD( CPython, m_flSoundDelay, FIELD_TIME ), +}; + diff --git a/dlls/weapons.h b/dlls/weapons.h index 5112254a..5ce354da 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -538,6 +538,12 @@ public: #endif } +#ifndef CLIENT_DLL + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +#endif + private: unsigned short m_usFirePython; };