Browse Source

Merge @malortie's patches for Black Ops.

blackops
Night Owl 8 years ago
parent
commit
16d195e426
  1. 77
      cl_dll/blackops/nightvision.cpp
  2. 2
      cl_dll/health.cpp
  3. 2
      cl_dll/hud.cpp
  4. 15
      cl_dll/hud.h
  5. 2
      cl_dll/message.cpp
  6. 89
      dlls/blackops/hudtoggle.cpp
  7. 11
      dlls/client.cpp
  8. 6
      dlls/items.cpp
  9. 18
      dlls/player.cpp
  10. 4
      dlls/player.h
  11. 11
      dlls/python.cpp
  12. 62
      dlls/triggers.cpp
  13. 6
      dlls/weapons.cpp
  14. 6
      dlls/weapons.h

77
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 <string.h>
#include <stdio.h>
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;
}

2
cl_dll/health.cpp

@ -231,7 +231,7 @@ int CHudHealth::Draw( float flTime )
int iHeight = gHUD.m_iFontHeight; int iHeight = gHUD.m_iFontHeight;
int iWidth = HealthWidth / 10; int iWidth = HealthWidth / 10;
FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a ); FillRGBA( x, y, iWidth, iHeight, r, g, b, a );
} }
DrawDamage( flTime ); DrawDamage( flTime );

2
cl_dll/hud.cpp

@ -227,6 +227,7 @@ void CHud::Init( void )
m_AmmoSecondary.Init(); m_AmmoSecondary.Init();
m_TextMessage.Init(); m_TextMessage.Init();
m_StatusIcons.Init(); m_StatusIcons.Init();
m_Nightvision.Init();
m_MOTD.Init(); m_MOTD.Init();
m_Scoreboard.Init(); m_Scoreboard.Init();
@ -396,6 +397,7 @@ void CHud::VidInit( void )
m_AmmoSecondary.VidInit(); m_AmmoSecondary.VidInit();
m_TextMessage.VidInit(); m_TextMessage.VidInit();
m_StatusIcons.VidInit(); m_StatusIcons.VidInit();
m_Nightvision.VidInit();
m_Scoreboard.VidInit(); m_Scoreboard.VidInit();
m_MOTD.VidInit(); m_MOTD.VidInit();
} }

15
cl_dll/hud.h

@ -20,7 +20,7 @@
// CHud handles the message, calculation, and drawing the HUD // 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_REDISH 0x00FF1010 //255,160,0
#define RGB_GREENISH 0x0000A000 //0,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0
@ -556,6 +556,18 @@ private:
icon_sprite_t m_IconList[MAX_ICONSPRITES]; 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; CHudAmmoSecondary m_AmmoSecondary;
CHudTextMessage m_TextMessage; CHudTextMessage m_TextMessage;
CHudStatusIcons m_StatusIcons; CHudStatusIcons m_StatusIcons;
CHudNightvision m_Nightvision;
CHudScoreboard m_Scoreboard; CHudScoreboard m_Scoreboard;
CHudMOTD m_MOTD; CHudMOTD m_MOTD;

2
cl_dll/message.cpp

@ -240,7 +240,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
{ {
int i, j, length, width; int i, j, length, width;
const char *pText; const char *pText;
unsigned char line[80]; unsigned char line[512];
pText = pMessage->pMessage; pText = pMessage->pMessage;
// Count lines // Count lines

89
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;
}
}

11
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 // 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" ) ) else if( FStrEq( pcmd, "VModEnable" ) )
{ {
// clear 'Unknown command: VModEnable' in singleplayer // clear 'Unknown command: VModEnable' in singleplayer

6
dlls/items.cpp

@ -181,16 +181,14 @@ class CItemSuit : public CItem
void Precache( void ) void Precache( void )
{ {
PRECACHE_MODEL( "models/w_suit.mdl" ); PRECACHE_MODEL( "models/w_suit.mdl" );
PRECACHE_SOUND( "items/vest_pickup.wav" );
} }
BOOL MyTouch( CBasePlayer *pPlayer ) BOOL MyTouch( CBasePlayer *pPlayer )
{ {
if( pPlayer->pev->weapons & ( 1<<WEAPON_SUIT ) ) if( pPlayer->pev->weapons & ( 1<<WEAPON_SUIT ) )
return FALSE; return FALSE;
if( pev->spawnflags & SF_SUIT_SHORTLOGON ) EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/vest_pickup.wav", 1, ATTN_NORM );
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
pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT ); pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT );
return TRUE; return TRUE;

18
dlls/player.cpp

@ -184,6 +184,8 @@ int gmsgTeamNames = 0;
int gmsgStatusText = 0; int gmsgStatusText = 0;
int gmsgStatusValue = 0; int gmsgStatusValue = 0;
int gmsgNightvision = 0;
void LinkUserMessages( void ) void LinkUserMessages( void )
{ {
// Already taken care of? // Already taken care of?
@ -228,6 +230,8 @@ void LinkUserMessages( void )
gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 );
gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 );
gmsgNightvision = REG_USER_MSG( "Nightvision", 1 );
} }
LINK_ENTITY_TO_CLASS( player, CBasePlayer ) LINK_ENTITY_TO_CLASS( player, CBasePlayer )
@ -3180,7 +3184,7 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe )
BOOL CBasePlayer::FlashlightIsOn( void ) BOOL CBasePlayer::FlashlightIsOn( void )
{ {
return FBitSet( pev->effects, EF_DIMLIGHT ); return FBitSet( pev->effects, EF_BRIGHTLIGHT );
} }
void CBasePlayer::FlashlightTurnOn( void ) void CBasePlayer::FlashlightTurnOn( void )
@ -3193,26 +3197,34 @@ void CBasePlayer::FlashlightTurnOn( void )
if( (pev->weapons & ( 1 << WEAPON_SUIT ) ) ) if( (pev->weapons & ( 1 << WEAPON_SUIT ) ) )
{ {
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); 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 ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev );
WRITE_BYTE( 1 ); WRITE_BYTE( 1 );
WRITE_BYTE( m_iFlashBattery ); WRITE_BYTE( m_iFlashBattery );
MESSAGE_END(); MESSAGE_END();
m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time;
MESSAGE_BEGIN( MSG_ONE, gmsgNightvision, NULL, pev );
WRITE_BYTE( 1 );
MESSAGE_END();
} }
} }
void CBasePlayer::FlashlightTurnOff( void ) void CBasePlayer::FlashlightTurnOff( void )
{ {
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1.0, ATTN_NORM, 0, PITCH_NORM ); 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 ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev );
WRITE_BYTE( 0 ); WRITE_BYTE( 0 );
WRITE_BYTE( m_iFlashBattery ); WRITE_BYTE( m_iFlashBattery );
MESSAGE_END(); MESSAGE_END();
m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time;
MESSAGE_BEGIN( MSG_ONE, gmsgNightvision, NULL, pev );
WRITE_BYTE( 0 );
MESSAGE_END();
} }
/* /*

4
dlls/player.h

@ -55,8 +55,8 @@
#define CSUITNOREPEAT 32 #define CSUITNOREPEAT 32
#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" #define SOUND_FLASHLIGHT_ON "items/nvg_turnon.wav"
#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" #define SOUND_FLASHLIGHT_OFF "items/nvg_turnoff.wav"
#define TEAM_NAME_LENGTH 16 #define TEAM_NAME_LENGTH 16

11
dlls/python.cpp

@ -111,6 +111,8 @@ BOOL CPython::Deploy()
pev->body = 0; pev->body = 0;
} }
m_flSoundDelay = 0;
return DefaultDeploy( "models/v_357.mdl", "models/p_357.mdl", PYTHON_DRAW, "python", UseDecrement(), pev->body ); 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_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
SendWeaponAnim( PYTHON_HOLSTER ); SendWeaponAnim( PYTHON_HOLSTER );
m_flSoundDelay = 0;
} }
void CPython::SecondaryAttack( void ) void CPython::SecondaryAttack( void )
@ -227,9 +231,10 @@ void CPython::Reload( void )
#else #else
bUseScope = g_pGameRules->IsMultiplayer(); bUseScope = g_pGameRules->IsMultiplayer();
#endif #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 ); m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
// ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); // 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 ); EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM );
m_flSoundDelay = 0; m_flSoundDelay = 0;

62
dlls/triggers.cpp

@ -2381,3 +2381,65 @@ void CTriggerCamera::Move()
float fraction = 2 * gpGlobals->frametime; float fraction = 2 * gpGlobals->frametime;
pev->velocity = ( ( pev->movedir * pev->speed ) * fraction ) + ( pev->velocity * ( 1 - fraction ) ); 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" );
}
}

6
dlls/weapons.cpp

@ -1527,3 +1527,9 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] =
}; };
IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon )
TYPEDESCRIPTION CPython::m_SaveData[] =
{
DEFINE_FIELD( CPython, m_flSoundDelay, FIELD_TIME ),
};

6
dlls/weapons.h

@ -538,6 +538,12 @@ public:
#endif #endif
} }
#ifndef CLIENT_DLL
int Save( CSave &save );
int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
#endif
private: private:
unsigned short m_usFirePython; unsigned short m_usFirePython;
}; };

Loading…
Cancel
Save