diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index dd25908c..9f2ac25d 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -24,7 +24,6 @@ LOCAL_CFLAGS += -DCLIENT_DLL=1 SRCS= SRCS_C= -SRCS+=./noffice/glow.cpp SRCS+=./noffice/pain.cpp SRCS+=./noffice/cinematic.cpp SRCS+=./noffice/deathvision.cpp diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2c9884dc..ec0875e0 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -52,7 +52,6 @@ endif() set (CLDLL_SOURCES - noffice/glow.cpp noffice/pain.cpp noffice/cinematic.cpp noffice/deathvision.cpp diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index ee732b98..c0d6f39f 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -54,25 +54,13 @@ void EV_FireGlock1( struct event_args_s *args ); void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); void EV_FireShotGunDouble( struct event_args_s *args ); +void EV_FireShotGunX( struct event_args_s *args ); void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); void EV_FirePython( struct event_args_s *args ); void EV_FireGauss( struct event_args_s *args ); void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); - -void EV_Torch( struct event_args_s *args ); -void EV_FireShotGunX( struct event_args_s *args ); } #define VECTOR_CONE_1DEGREES Vector( 0.00873f, 0.00873f, 0.00873f ) @@ -493,7 +481,7 @@ void EV_FireGlock1( event_args_t *args ) V_PunchAxis( 0, -2.0 ); } - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); + EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 13, -8, 6 ); EV_EjectBrass( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); @@ -685,7 +673,7 @@ void EV_FireMP5( event_args_t *args ) V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); } - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); + EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 15, -10, 5 ); EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); @@ -712,36 +700,6 @@ void EV_FireMP5( event_args_t *args ) } } -// We only predict the animation and sound -// The grenade is still launched from the server. -void EV_FireMP52( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 ); - V_PunchAxis( 0, -10 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher2.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - } -} -//====================== -// MP5 END -//====================== - //====================== // PHYTON START // ( .357 ) @@ -1761,56 +1719,6 @@ int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) return 0; } -//====================== -// TORCH START -//====================== -#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" -#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" - -enum torch_e -{ - TORCH_IDLE_OFF = 0, - TORCH_DRAW, - TORCH_IDLE_ON, - TORCH_SWITCH, - TORCH_HOLSTER_OFF, - TORCH_HOLSTER_ON -}; - -void EV_Torch( struct event_args_s *args ) -{ - int idx; - vec3_t origin; - - int flashlightOn; - - idx = args->entindex; - - VectorCopy( args->origin, origin ); - - flashlightOn = args->bparam1; - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( TORCH_SWITCH, 1 ); - } - - if( flashlightOn ) - { - // Play flashlight on sound. - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1, ATTN_NORM, 0, 100 ); - } - else - { - // Play flashlight off sound. - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1, ATTN_NORM, 0, 100 ); - } -} -//====================== -// TORCH END -//====================== - //====================== // SHOTGUNX START //====================== diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index ea790d52..38978f6a 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -345,10 +345,5 @@ void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) { } int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } void CBasePlayerWeapon::RetireWeapon( void ) { } -void CBasePlayerWeapon::ItemPostFrame_Always( void ) { } -int CBasePlayerWeapon::DefaultAmmoBySkill( int iMaxClip, int iSkillLevel ) { return 0; } -string_t CBasePlayerWeapon::GetClipModel() const { return 0; } -void CBasePlayerWeapon::SetClipModel( const char* szModel ) { } -void CBasePlayerWeapon::DropClip( void ) { } void CSoundEnt::InsertSound( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index b0fd75b6..7b98084e 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -24,25 +24,13 @@ void EV_FireGlock1( struct event_args_s *args ); void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); void EV_FireShotGunDouble( struct event_args_s *args ); +void EV_FireShotGunX( struct event_args_s *args ); void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); void EV_FirePython( struct event_args_s *args ); void EV_FireGauss( struct event_args_s *args ); void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); - -void EV_Torch( struct event_args_s *args ); -void EV_FireShotGunX( struct event_args_s *args ); } /* @@ -64,21 +52,10 @@ void Game_HookEvents( void ) gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble ); + gEngfuncs.pfnHookEvent( "events/shotgunx.sc", EV_FireShotGunX ); gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 ); - gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 ); gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython ); gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss ); gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss ); gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); - gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar ); - gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow ); - gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 ); - gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg ); - gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire ); - gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop ); - gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire ); - gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire ); - gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire ); - gEngfuncs.pfnHookEvent( "events/torch.sc", EV_Torch ); - gEngfuncs.pfnHookEvent( "events/shotgunx.sc", EV_FireShotGunX ); } diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index babbd71e..e4334b60 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -233,7 +233,6 @@ void CHud::Init( void ) m_TextMessage.Init(); m_StatusIcons.Init(); m_Cinematic.Init(); - m_Glow.Init(); m_DeathVision.Init(); m_MOTD.Init(); m_Scoreboard.Init(); @@ -417,7 +416,6 @@ void CHud::VidInit( void ) m_TextMessage.VidInit(); m_StatusIcons.VidInit(); m_Cinematic.VidInit(); - m_Glow.VidInit(); m_DeathVision.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 6744b953..6ccc7f32 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -578,23 +578,6 @@ private: float m_flCineTime; }; -// -//----------------------------------------------------- -// -class CHudGlow : public CHudBase -{ -public: - int Init( void ); - int VidInit( void ); - int Draw( float flTime ); - int MsgFunc_Glow( const char *pszName, int iSize, void *pbuf ); - - void DrawGlow( void ); -private: - - HSPRITE m_hSprite; -}; - // //----------------------------------------------------- // @@ -690,7 +673,6 @@ public: CHudTextMessage m_TextMessage; CHudStatusIcons m_StatusIcons; CHudCinematic m_Cinematic; - CHudGlow m_Glow; CHudDeathVision m_DeathVision; CHudScoreboard m_Scoreboard; CHudMOTD m_MOTD; diff --git a/cl_dll/noffice/glow.cpp b/cl_dll/noffice/glow.cpp deleted file mode 100644 index 3aec6732..00000000 --- a/cl_dll/noffice/glow.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/*** -* -* 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. -* -****/ -// -// Geiger.cpp -// -// implementation of CHudAmmo class -// - -#include "hud.h" -#include "cl_util.h" -#include -#include -#include - -#include "event_api.h" -#include "event_args.h" -#include "triangleapi.h" - - -#include "pm_shared.h" -#include "pm_defs.h" -#include "pmtrace.h" - -#include "parsemsg.h" - -extern vec3_t v_origin; // last view origin -extern vec3_t v_angles; // last view angle -extern vec3_t v_cl_angles; // last client/mouse angle -extern vec3_t v_sim_org; // last sim origin - -DECLARE_MESSAGE(m_Glow, Glow) - -int CHudGlow::Init(void) -{ - HOOK_MESSAGE(Glow); - - m_iFlags = 0; - - gHUD.AddHudElem(this); - - srand((unsigned)time(NULL)); - - return 1; -}; - -int CHudGlow::VidInit(void) -{ - m_iFlags = 0; - - m_hSprite = SPR_Load("sprites/glow01.spr"); - - return 1; -}; - -int CHudGlow::MsgFunc_Glow(const char *pszName, int iSize, void *pbuf) -{ - BEGIN_READ(pbuf, iSize); - int fOn = READ_BYTE(); - - if (fOn) - { - m_iFlags |= HUD_ACTIVE; - } - else - { - m_iFlags &= ~HUD_ACTIVE; - } - - return 1; -} - -int CHudGlow::Draw(float flTime) -{ - return 1; -} - -#define GLOW_TRACE_DISTANCE 80.0f -#define GLOW_MAX_ALPHA 1.0f - -void CHudGlow::DrawGlow(void) -{ - if (gHUD.m_iHideHUDDisplay & HIDEHUD_ALL) - return; - - if (!(m_iFlags & HUD_ACTIVE)) - return; - - cl_entity_t* ent = gEngfuncs.GetViewModel(); - if (!ent) - return; - - float r, g, b, a; - vec3_t origin, forward, right, up, screen, point; - struct model_s *hSpriteModel; - int size = 10; - - r = 1.0f; g = b = 0.95f; - - VectorCopy(ent->attachment[0], origin); - AngleVectors(v_angles, forward, right, up); - - vec3_t tracedir; - VectorScale(forward, GLOW_TRACE_DISTANCE, tracedir); - VectorAdd(tracedir, origin, tracedir); - pmtrace_t * trace = gEngfuncs.PM_TraceLine(origin, tracedir, PM_TRACELINE_PHYSENTSONLY, 2, -1); - - if (trace->fraction != 1.0) - { - a = ((trace->fraction * GLOW_MAX_ALPHA) / GLOW_TRACE_DISTANCE) * 100; - } - else - { - a = GLOW_MAX_ALPHA; - } - - a = Q_min(a, GLOW_MAX_ALPHA); - - // gEngfuncs.Con_Printf("Glow opacity: %f.\n", a); - - gEngfuncs.pTriAPI->WorldToScreen(origin, point); - - hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer(m_hSprite); - - gEngfuncs.pTriAPI->SpriteTexture(hSpriteModel, 0); - gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); - gEngfuncs.pTriAPI->CullFace( TRI_NONE ); - gEngfuncs.pTriAPI->Color4f( r, g, b, a ); - gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - - gEngfuncs.pTriAPI->TexCoord2f(1, 0); - VectorMA(origin, size, up, point); - VectorMA(point, size, right, point); - gEngfuncs.pTriAPI->Vertex3fv(point); - - gEngfuncs.pTriAPI->TexCoord2f(0, 0); - VectorMA(origin, size, up, point); - VectorMA(point, -size, right, point); - gEngfuncs.pTriAPI->Vertex3fv(point); - - gEngfuncs.pTriAPI->TexCoord2f(0, 1); - VectorMA(origin, -size, up, point); - VectorMA(point, -size, right, point); - gEngfuncs.pTriAPI->Vertex3fv(point); - - gEngfuncs.pTriAPI->TexCoord2f(1, 1); - VectorMA(origin, -size, up, point); - VectorMA(point, size, right, point); - gEngfuncs.pTriAPI->Vertex3fv(point); - - gEngfuncs.pTriAPI->End(); - - return; -} diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index b0b6795e..68e841ee 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -112,7 +112,6 @@ Render any triangles with transparent rendermode needs here */ void DLLEXPORT HUD_DrawTransparentTriangles( void ) { - gHUD.m_Glow.DrawGlow(); #if defined( TEST_IT ) // Draw_Triangles(); #endif diff --git a/dlls/Android.mk b/dlls/Android.mk index 35820d3a..4511133c 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -123,7 +123,8 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ noffice/dave.cpp \ noffice/female.cpp \ noffice/clip.cpp \ - noffice/flashlightspot.cpp \ + noffice/lightspot.cpp \ + noffice/wallspot.cpp \ noffice/furniture_passable.cpp \ noffice/holster.cpp \ noffice/news.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bc356355..a54f1c16 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -48,7 +48,8 @@ set (SVDLL_SOURCES noffice/dave.cpp noffice/female.cpp noffice/clip.cpp - noffice/flashlightspot.cpp + noffice/lightspot.cpp + noffice/wallspot.cpp noffice/furniture_passable.cpp noffice/holster.cpp noffice/news.cpp diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 3b1d8a6b..272fa311 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -60,7 +60,7 @@ void CCrowbar::Precache( void ) PRECACHE_SOUND( "weapons/cbar_hitbod3.wav" ); PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); + // m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); } int CCrowbar::GetItemInfo( ItemInfo *p ) @@ -92,16 +92,9 @@ int CCrowbar::AddToPlayer( CBasePlayer *pPlayer ) BOOL CCrowbar::Deploy() { - m_flReleaseThrow = -1; return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); } -BOOL CCrowbar::CanHolster( void ) -{ - // can only holster crowbar when not primed! - return ( m_flStartThrow == 0 ); -} - void CCrowbar::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; @@ -154,17 +147,19 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f void CCrowbar::PrimaryAttack() { - if( !m_flStartThrow ) + if( m_fInAttack ) { - m_flStartThrow = gpGlobals->time; - m_flReleaseThrow = 0; - - SendWeaponAnim( CROWBAR_AIM ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.45f; + if( m_fInAttack == 1 && m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + { + SendWeaponAnim( CROWBAR_HOLD ); + m_fInAttack = 2; + } } - else if( m_flTimeWeaponIdle <= UTIL_WeaponTimeBase() ) + else { - SendWeaponAnim( CROWBAR_HOLD ); + SendWeaponAnim( CROWBAR_AIM ); + m_fInAttack = 1; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.4f; } } @@ -205,19 +200,18 @@ int CCrowbar::Swing( int fFirst ) } } #endif - if( fFirst ) - { - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0f, g_vecZero, g_vecZero, 0, 0, 0, - 0, 0, 0 ); - } if( tr.flFraction >= 1.0f ) { if( fFirst ) { // miss - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5 ; + SendWeaponAnim( CROWBAR_RELEASEMISS ); + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xF ) ); + + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } @@ -334,36 +328,17 @@ int CCrowbar::Swing( int fFirst ) void CCrowbar::WeaponIdle( void ) { - if( m_flReleaseThrow == 0 && m_flStartThrow ) - m_flReleaseThrow = gpGlobals->time; - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if( m_flStartThrow ) + if( m_fInAttack ) { - if( !Swing( 1 ) ) - { - SetThink( &CCrowbar::SwingAgain ); - pev->nextthink = gpGlobals->time + 0.1f; - } - - m_flReleaseThrow = 0; - m_flStartThrow = 0; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; - return; + Swing( 0 ); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; } - else if( m_flReleaseThrow > 0 ) + else { - // we've finished the throw, restart. - m_flStartThrow = 0; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); - m_flReleaseThrow = -1; - return; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; } - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 35.0 / 13.0; - SendWeaponAnim( CROWBAR_IDLE ); } diff --git a/dlls/glock.cpp b/dlls/glock.cpp index c72d3764..9def2d1c 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -45,20 +45,7 @@ void CGlock::Spawn() m_iId = WEAPON_GLOCK; SET_MODEL( ENT( pev ), "models/w_9mmhandgun.mdl" ); - SetClipModel( "models/w_9mmclip.mdl" ); - - // ========================================== - // Code changes for- Night at the Office: - // ========================================== - // - // -Randomised Ammo. Picking up a gun from a fallen terrorist - // will not give you a pre-defined amount of bullets. The exact - // number is random (depending on the gun and clip size), which - // means the player will constantly need to keep a check on the - // ammo as it will no longer be 'comfortable' for the player to - // waste ammo. - - m_iDefaultAmmo = DefaultAmmoBySkill( GLOCK_MAX_CLIP, gSkillData.iSkillLevel ); + m_iDefaultAmmo = GLOCK_MAX_CLIP; FallInit();// get ready to fall down. } @@ -69,7 +56,8 @@ void CGlock::Precache( void ) PRECACHE_MODEL( "models/w_9mmhandgun.mdl" ); PRECACHE_MODEL( "models/p_9mmhandgun.mdl" ); - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell + m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell + m_iClipModel = PRECACHE_MODEL( "models/w_9mmclip.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/9mmclip2.wav" ); @@ -223,17 +211,31 @@ void CGlock::Reload( void ) int iResult; - if( m_iClip == 0 ) - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5f ); - else - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5f ); - - if( iResult ) + if( m_iClip != GLOCK_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 ) { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - // Unblock primary attack. - m_fInAttack = 0; + Vector vecShellVelocity = m_pPlayer->pev->velocity + + gpGlobals->v_right * RANDOM_FLOAT( -10, 10 ) + + gpGlobals->v_forward * 23; + + EjectClip( pev->origin + m_pPlayer->pev->view_ofs + + gpGlobals->v_up * -22 + + gpGlobals->v_forward * 10 + + gpGlobals->v_right * 2, vecShellVelocity, pev->angles.y, m_iClipModel, TE_BOUNCE_SHELL ); + + if( m_iClip == 0 ) + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5f ); + else + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5f ); + + if( iResult ) + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + + // Unblock primary attack. + m_fInAttack = 0; + } } } diff --git a/dlls/monsters.h b/dlls/monsters.h index 659a5f79..e5cfb898 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -75,7 +75,8 @@ extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL CONSTANT float g_flMeleeRange; extern DLL_GLOBAL CONSTANT float g_flMediumRange; extern DLL_GLOBAL CONSTANT float g_flLongRange; -extern void EjectBrass(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); +extern void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); +extern void EjectClip( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ); BOOL FBoxVisible( entvars_t *pevLooker, entvars_t *pevTarget ); diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 4395a524..6b1b3186 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -40,17 +40,12 @@ LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 ) //========================================================= //========================================================= -int CMP5::SecondaryAmmoIndex( void ) -{ - return m_iSecondaryAmmoType; -} void CMP5::Spawn() { pev->classname = MAKE_STRING( "weapon_9mmAR" ); // hack to allow for old names Precache(); SET_MODEL( ENT( pev ), "models/w_AK47.mdl" ); - SetClipModel( "models/w_akclip.mdl" ); m_iId = WEAPON_MP5; @@ -65,7 +60,7 @@ void CMP5::Spawn() // ammo as it will no longer be 'comfortable' for the player to // waste ammo. - m_iDefaultAmmo = DefaultAmmoBySkill( MP5_MAX_CLIP, gSkillData.iSkillLevel ); + m_iDefaultAmmo = RANDOM_LONG( 1, 37 ); FallInit();// get ready to fall down. } @@ -76,11 +71,11 @@ void CMP5::Precache( void ) PRECACHE_MODEL( "models/w_AK47.mdl" ); PRECACHE_MODEL( "models/p_AK47.mdl" ); - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shellTE_MODEL + m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shellTE_MODEL + m_iClipModel = PRECACHE_MODEL( "models/w_akclip.mdl" ); PRECACHE_MODEL( "models/grenade.mdl" ); // grenade - PRECACHE_MODEL( "models/w_akclip.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/clipinsert1.wav" ); @@ -96,7 +91,7 @@ void CMP5::Precache( void ) PRECACHE_SOUND( "weapons/357_cock1.wav" ); m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" ); - m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" ); + // m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" ); } int CMP5::GetItemInfo( ItemInfo *p ) @@ -208,6 +203,20 @@ void CMP5::Reload( void ) return; DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5f ); + + if( m_iClip != MP5_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0) + { + UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); + + Vector vecShellVelocity = m_pPlayer->pev->velocity + + gpGlobals->v_right * RANDOM_FLOAT( -10, 10 ) + + gpGlobals->v_forward * 23; + + EjectClip( pev->origin + m_pPlayer->pev->view_ofs + + gpGlobals->v_up * -22 + + gpGlobals->v_forward * 10 + + gpGlobals->v_right * 2, vecShellVelocity, pev->angles.y, m_iClipModel, TE_BOUNCE_SHELL ); + } } void CMP5::WeaponIdle( void ) @@ -236,12 +245,6 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } -BOOL CMP5::IsUseable() -{ - //Can be used if the player has AR grenades. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; -} - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/noffice/flashlightspot.h b/dlls/noffice/flashlightspot.h deleted file mode 100644 index 36e373c3..00000000 --- a/dlls/noffice/flashlightspot.h +++ /dev/null @@ -1,30 +0,0 @@ -/*** -* -* 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. -* -****/ - -#ifndef FLASHLIGHTSPOT_H -#define FLASHLIGHTSPOT_H - -class CFlashlightSpot : public CLaserSpot -{ -public: - void Spawn(void); - void Precache(void); - - virtual int ObjectCaps(void) { return FCAP_ACROSS_TRANSITION; } - - static CFlashlightSpot *CreateSpot(void); -}; - -#endif // FLASHLIGHTSPOT_H \ No newline at end of file diff --git a/dlls/noffice/holster.cpp b/dlls/noffice/holster.cpp index 6df7e627..3ef6666d 100644 --- a/dlls/noffice/holster.cpp +++ b/dlls/noffice/holster.cpp @@ -34,15 +34,15 @@ enum holster_e { HOLSTER_ATTACK3MISS, HOLSTER_ATTACK3HIT, HOLSTER_IDLE2, - HOLSTER_IDLE3, + HOLSTER_IDLE3 }; -LINK_ENTITY_TO_CLASS(weapon_holster, CHolster); +LINK_ENTITY_TO_CLASS( weapon_holster, CHolster ) void CHolster::Spawn() { Precache(); - SET_MODEL(ENT(pev), "models/w_holster.mdl"); + SET_MODEL( ENT( pev ), "models/w_holster.mdl" ); m_iId = WEAPON_HOLSTER; m_iClip = -1; @@ -50,16 +50,16 @@ void CHolster::Spawn() } -void CHolster::Precache(void) +void CHolster::Precache() { - PRECACHE_MODEL("models/v_holster.mdl"); - PRECACHE_MODEL("models/w_holster.mdl"); - PRECACHE_MODEL("models/p_holster.mdl"); + PRECACHE_MODEL( "models/v_holster.mdl" ); + PRECACHE_MODEL( "models/w_holster.mdl" ); + PRECACHE_MODEL( "models/p_holster.mdl" ); } -int CHolster::GetItemInfo(ItemInfo *p) +int CHolster::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = NULL; p->iMaxAmmo1 = -1; p->pszAmmo2 = NULL; @@ -73,12 +73,12 @@ int CHolster::GetItemInfo(ItemInfo *p) return 1; } -int CHolster::AddToPlayer(CBasePlayer *pPlayer) +int CHolster::AddToPlayer( CBasePlayer *pPlayer ) { - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); MESSAGE_END(); return TRUE; } @@ -87,20 +87,13 @@ int CHolster::AddToPlayer(CBasePlayer *pPlayer) BOOL CHolster::Deploy() { - return DefaultDeploy("models/v_holster.mdl", "models/p_holster.mdl", HOLSTER_DRAW, "holster"); + return DefaultDeploy( "models/v_holster.mdl", "models/p_holster.mdl", HOLSTER_DRAW, "holster" ); } -void CHolster::Holster(int skiplocal /*= 0*/) +void CHolster::Holster( int skiplocal /*= 0*/ ) { + SendWeaponAnim( HOLSTER_HOLSTER ); + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; } -void CHolster::WeaponIdle(void) -{ - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - SendWeaponAnim(HOLSTER_IDLE); - - m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again. -} \ No newline at end of file diff --git a/dlls/noffice/lightspot.cpp b/dlls/noffice/lightspot.cpp new file mode 100644 index 00000000..3918bc1c --- /dev/null +++ b/dlls/noffice/lightspot.cpp @@ -0,0 +1,62 @@ +/*** +* +* 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 "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "weapons.h" +#include "nodes.h" +#include "player.h" +#include "gamerules.h" + +LINK_ENTITY_TO_CLASS( light_spot2, CLightSpot ) + +//========================================================= +//========================================================= +CLightSpot *CLightSpot::CreateSpot( void ) +{ + CLightSpot *pSpot = GetClassPtr( (CLightSpot *)NULL ); + pSpot->Spawn(); + + pSpot->pev->classname = MAKE_STRING( "light_spot2" ); + + return pSpot; +} + +//========================================================= +//========================================================= +void CLightSpot::Spawn( void ) +{ + Precache(); + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; + + pev->rendermode = kRenderTransAdd; + pev->renderfx = kRenderFxNoDissipation; + + SetBits( pev->effects, EF_DIMLIGHT ); + + pev->renderamt = 185; + + SET_MODEL( ENT( pev ), "sprites/beam.spr" ); + UTIL_SetOrigin( pev, pev->origin ); +} + +void CLightSpot::Precache( void ) +{ + PRECACHE_MODEL( "sprites/beam.spr" ); +} + diff --git a/dlls/noffice/torch.cpp b/dlls/noffice/torch.cpp index fbd28aab..8b6d8477 100644 --- a/dlls/noffice/torch.cpp +++ b/dlls/noffice/torch.cpp @@ -22,9 +22,6 @@ #include "player.h" #include "soundent.h" #include "gamerules.h" -#include "flashlightspot.h" - -extern int gmsgGlow; enum torch_e { TORCH_IDLE_OFF = 0, @@ -32,97 +29,36 @@ enum torch_e { TORCH_IDLE_ON, TORCH_SWITCH, TORCH_HOLSTER_OFF, - TORCH_HOLSTER_ON, -}; - -LINK_ENTITY_TO_CLASS(weapon_torch, CTorch); - -#ifndef CLIENT_DLL -TYPEDESCRIPTION CTorch::m_SaveData[] = -{ - DEFINE_FIELD(CTorch, m_pSpot, FIELD_CLASSPTR), - DEFINE_FIELD(CTorch, m_pGlow, FIELD_CLASSPTR), - DEFINE_FIELD(CTorch, m_fIsOn, FIELD_BOOLEAN), + TORCH_HOLSTER_ON }; -int CTorch::Save(CSave &save) -{ - if (!CBasePlayerWeapon::Save(save)) - return 0; - - return save.WriteFields("TORCH", this, m_SaveData, ARRAYSIZE(m_SaveData)); -} - - -int CTorch::Restore(CRestore &restore) -{ - if (!CBasePlayerWeapon::Restore(restore)) - return 0; - - int status = restore.ReadFields("TORCH", this, m_SaveData, ARRAYSIZE(m_SaveData)); - - if (status) - { - if (m_fIsOn) - { - m_fUpdate = TRUE; - } - } - - return status; -} -#endif +LINK_ENTITY_TO_CLASS( weapon_torch, CTorch ) void CTorch::Spawn() { Precache(); - SET_MODEL(ENT(pev), "models/w_torch.mdl"); + SET_MODEL( ENT( pev ), "models/w_torch.mdl" ); m_iId = WEAPON_TORCH; m_iClip = -1; - m_fIsOn = FALSE; - m_fUpdate = FALSE; - -#ifndef CLIENT_DLL - m_pSpot = NULL; - m_pGlow = NULL; -#endif - FallInit();// get ready to fall down. } - -void CTorch::Precache(void) +void CTorch::Precache() { - PRECACHE_MODEL("models/v_torch.mdl"); - PRECACHE_MODEL("models/w_torch.mdl"); - PRECACHE_MODEL("models/p_torch.mdl"); + PRECACHE_MODEL( "models/v_torch.mdl" ); + PRECACHE_MODEL( "models/w_torch.mdl" ); + PRECACHE_MODEL( "models/p_torch.mdl" ); - PRECACHE_SOUND( SOUND_FLASHLIGHT_ON ); + PRECACHE_SOUND( "items/flashlight1.wav" ); - PRECACHE_MODEL("sprites/glow01.spr"); - PRECACHE_MODEL("sprites/glow02.spr"); - PRECACHE_MODEL("sprites/glow03.spr"); - PRECACHE_MODEL("sprites/glow04.spr"); - PRECACHE_MODEL("sprites/glow05.spr"); - - PRECACHE_MODEL("sprites/flare1.spr"); - PRECACHE_MODEL("sprites/flare2.spr"); - PRECACHE_MODEL("sprites/flare3.spr"); - PRECACHE_MODEL("sprites/flare4.spr"); - PRECACHE_MODEL("sprites/flare5.spr"); - PRECACHE_MODEL("sprites/flare6.spr"); - - PRECACHE_MODEL("sprites/blueflare1.spr"); - - m_usTorch = PRECACHE_EVENT(1, "events/torch.sc"); - - UTIL_PrecacheOther( "flashlight_spot" ); + UTIL_PrecacheOther( "light_spot2" ); + UTIL_PrecacheOther( "wall_spot2" ); } -int CTorch::GetItemInfo(ItemInfo *p) +int CTorch::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = NULL; p->iMaxAmmo1 = -1; p->pszAmmo2 = NULL; @@ -136,12 +72,12 @@ int CTorch::GetItemInfo(ItemInfo *p) return 1; } -int CTorch::AddToPlayer(CBasePlayer *pPlayer) +int CTorch::AddToPlayer( CBasePlayer *pPlayer ) { - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); MESSAGE_END(); return TRUE; } @@ -150,180 +86,73 @@ int CTorch::AddToPlayer(CBasePlayer *pPlayer) BOOL CTorch::Deploy() { - return DefaultDeploy("models/v_torch.mdl", "models/p_torch.mdl", TORCH_DRAW, "torch"); + return DefaultDeploy( "models/v_torch.mdl", "models/p_torch.mdl", TORCH_DRAW, "torch" ); } -void CTorch::Holster(int skiplocal /*= 0*/) +void CTorch::Holster( int skiplocal /*= 0*/ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; + if( m_fIsOn ) + PrimaryAttack(); - if ( m_fIsOn ) - TurnOff(); + SendWeaponAnim( TORCH_HOLSTER_OFF ); - SendWeaponAnim(TORCH_HOLSTER_OFF); + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; } void CTorch::PrimaryAttack() { - // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) - { - m_flNextPrimaryAttack = 0.15; - return; - } - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - ToggleFlashlight(); - - PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usTorch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, m_fIsOn, 0); - - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); - - UpdateSpot(); -} - -void CTorch::WeaponIdle(void) -{ - UpdateSpot(); - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - int iAnim; - - if (m_fIsOn) - iAnim = TORCH_IDLE_ON; - else - iAnim = TORCH_IDLE_OFF; - - SendWeaponAnim(iAnim); - - m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again. -} - - -void CTorch::TurnOn(void) -{ - m_fIsOn = TRUE; - -#ifndef CLIENT_DLL - if (!m_pSpot) - { - m_pSpot = CFlashlightSpot::CreateSpot(); - } - - MESSAGE_BEGIN(MSG_ONE, gmsgGlow, NULL, m_pPlayer->pev); - WRITE_BYTE(1); - MESSAGE_END(); -#endif + SendWeaponAnim( TORCH_SWITCH ); - m_pPlayer->pev->effects |= EF_DIMLIGHT; -} + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "items/flashlight1.wav", VOL_NORM, ATTN_NORM ); -void CTorch::TurnOff(void) -{ - m_fIsOn = FALSE; + m_fIsOn = ( m_fIsOn == FALSE ); -#ifndef CLIENT_DLL - if (m_pSpot) + if( !m_fIsOn ) { - m_pSpot->Killed(NULL, GIB_NORMAL); - m_pSpot = NULL; - } + SetBits( m_pLightSpot->pev->effects, EF_NODRAW ); + ClearBits( m_pLightSpot->pev->effects, EF_DIMLIGHT ); - if (m_pGlow) - { - UTIL_Remove(m_pGlow); - m_pGlow = NULL; + SetBits( m_pWallSpot->pev->effects, EF_NODRAW ); } - MESSAGE_BEGIN(MSG_ONE, gmsgGlow, NULL, m_pPlayer->pev); - WRITE_BYTE(0); - MESSAGE_END(); -#endif - - m_pPlayer->pev->effects &= ~EF_DIMLIGHT; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.4f; } -void CTorch::ToggleFlashlight(void) +void CTorch::WeaponIdle() { - if (!m_fIsOn) - TurnOn(); - else - TurnOff(); -} - -#define TORCH_TRACE_DISTANCE 144 - -#define TORCH_SPOT_MAX_ALPHA 128 + UpdateSpot(); -#define TORCH_GLOW_MAX_ALPHA 200 + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; // how long till we do this again. +} -void CTorch::UpdateSpot(void) +void CTorch::UpdateSpot() { - -#ifndef CLIENT_DLL - if (m_fUpdate) + if( m_fIsOn ) { - TurnOn(); - m_fUpdate = FALSE; - } - - if (m_fIsOn && m_pSpot) - { - if (!m_pSpot) + if( !m_pLightSpot ) { - m_pSpot = CFlashlightSpot::CreateSpot(); + m_pLightSpot = CLightSpot::CreateSpot(); + m_pWallSpot = CWallSpot::CreateSpot(); } - - UTIL_MakeVectors(m_pPlayer->pev->v_angle); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecAiming = gpGlobals->v_forward; - - TraceResult tr; - UTIL_TraceLine(vecSrc, vecSrc + vecAiming * 8192, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr); - - UTIL_SetOrigin(m_pSpot->pev, tr.vecEndPos); - - if (!m_pGlow) + else { - m_pGlow = CSprite::SpriteCreate("sprites/flare1.spr", pev->origin, FALSE); - m_pGlow->SetTransparency(kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation); - m_pGlow->SetScale(1.0f); - } - - UTIL_SetOrigin(m_pGlow->pev, tr.vecEndPos); + ClearBits( m_pLightSpot->pev->effects, EF_NODRAW ); + SetBits( m_pLightSpot->pev->effects, EF_DIMLIGHT ); - if (UTIL_PointContents(tr.vecEndPos) == CONTENTS_SKY) - { - m_pSpot->pev->renderamt = 0; - m_pGlow->SetBrightness(0); + ClearBits( m_pWallSpot->pev->effects, EF_NODRAW ); } - else - { - m_pSpot->pev->renderamt = TORCH_SPOT_MAX_ALPHA; - float dist = (tr.vecEndPos - vecSrc).Length(); + UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - float brightness; + Vector vecSrc = m_pPlayer->GetGunPosition(); + Vector vecAiming = gpGlobals->v_forward; - if (dist < TORCH_TRACE_DISTANCE) - brightness = ((TORCH_TRACE_DISTANCE - dist) * TORCH_GLOW_MAX_ALPHA) / TORCH_TRACE_DISTANCE; - else - brightness = 0; + TraceResult tr; - m_pGlow->SetBrightness(brightness); + UTIL_SetOrigin( m_pLightSpot->pev, vecSrc + vecAiming * 10.0f ); - // ALERT(at_console, "Server: Glow brightness: %f\n", brightness); - } + UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 250.0f, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); + + UTIL_SetOrigin( m_pWallSpot->pev, tr.vecEndPos ); } -#endif } diff --git a/dlls/noffice/flashlightspot.cpp b/dlls/noffice/wallspot.cpp similarity index 57% rename from dlls/noffice/flashlightspot.cpp rename to dlls/noffice/wallspot.cpp index f567a2ff..1b7c7bc1 100644 --- a/dlls/noffice/flashlightspot.cpp +++ b/dlls/noffice/wallspot.cpp @@ -1,9 +1,9 @@ /*** * -* 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. +* 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 @@ -16,43 +16,45 @@ #include "extdll.h" #include "util.h" #include "cbase.h" +#include "monsters.h" #include "weapons.h" +#include "nodes.h" #include "player.h" #include "gamerules.h" -#include "flashlightspot.h" -LINK_ENTITY_TO_CLASS(flashlight_spot, CFlashlightSpot); +LINK_ENTITY_TO_CLASS( wall_spot, CWallSpot ) //========================================================= //========================================================= -CFlashlightSpot *CFlashlightSpot::CreateSpot(void) +CWallSpot *CWallSpot::CreateSpot( void ) { - CFlashlightSpot *pSpot = GetClassPtr((CFlashlightSpot *)NULL); + CWallSpot *pSpot = GetClassPtr( (CWallSpot *)NULL ); pSpot->Spawn(); - pSpot->pev->classname = MAKE_STRING("flashlight_spot"); + pSpot->pev->classname = MAKE_STRING( "wall_spot" ); return pSpot; } //========================================================= //========================================================= -void CFlashlightSpot::Spawn(void) +void CWallSpot::Spawn( void ) { Precache(); pev->movetype = MOVETYPE_NONE; pev->solid = SOLID_NOT; - pev->rendermode = kRenderGlow; // kRenderGlow + pev->rendermode = kRenderGlow; pev->renderfx = kRenderFxNoDissipation; - pev->renderamt = 128; - pev->scale = 4; + pev->scale = 4.0f; + pev->renderamt = 90; - SET_MODEL(ENT(pev), "sprites/beam2.spr"); - UTIL_SetOrigin(pev, pev->origin); -}; + SET_MODEL( ENT( pev ), "sprites/beam2.spr" ); + UTIL_SetOrigin( pev, pev->origin ); +} -void CFlashlightSpot::Precache(void) +void CWallSpot::Precache( void ) { - PRECACHE_MODEL("sprites/beam2.spr"); -}; \ No newline at end of file + PRECACHE_MODEL( "sprites/beam2.spr" ); +} + diff --git a/dlls/player.cpp b/dlls/player.cpp index 6da1ccc8..473290e7 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -193,7 +193,6 @@ int gmsgStatusText = 0; int gmsgStatusValue = 0; int gmsgCinematic = 0; -int gmsgGlow = 0; int gmsgDeathVision = 0; void LinkUserMessages( void ) @@ -244,7 +243,6 @@ void LinkUserMessages( void ) gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); gmsgCinematic = REG_USER_MSG( "Cinematic", 1 ); - gmsgGlow = REG_USER_MSG( "Glow", 1 ); gmsgDeathVision = REG_USER_MSG( "DeathVision", 1 ); } @@ -3223,10 +3221,34 @@ BOOL CBasePlayer::FlashlightIsOn( void ) void CBasePlayer::FlashlightTurnOn( void ) { + if( !g_pGameRules->FAllowFlashlight() ) + { + return; + } + + 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 ); + MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + WRITE_BYTE( 1 ); + WRITE_BYTE( m_iFlashBattery ); + MESSAGE_END(); + + m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; + } } 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 ); + MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( m_iFlashBattery ); + MESSAGE_END(); + + m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; } /* @@ -3299,15 +3321,6 @@ void CBasePlayer::ImpulseCommands() gmsgLogo = 0; break; case 100: - { - // If the player has the torch and is not using it, - // requested to turn on the flashlight, - // change weapon to flashlight. - if( ( pev->weapons & ( 1 << WEAPON_TORCH ) ) && m_pActiveItem && !FClassnameIs( m_pActiveItem->pev, "weapon_torch" ) ) - { - SwitchToFlashlight(); - } - } case 201: // paint decal if( gpGlobals->time < m_flNextDecalTime ) @@ -3677,16 +3690,6 @@ void CBasePlayer::ItemPostFrame() if( m_pTank != 0 ) return; - if( m_pActiveItem ) - { - CBasePlayerWeapon*pWeapon = (CBasePlayerWeapon*)m_pActiveItem; - - // This function always gets called to update the current weapon, - // regardless of next attack time. - if( pWeapon ) - pWeapon->ItemPostFrame_Always(); - } - #if defined( CLIENT_WEAPONS ) if( m_flNextAttack > 0 ) #else @@ -4593,27 +4596,6 @@ void CBasePlayer::UpdateStamina( void ) // ALERT( at_console, "Player stamina level: %d\n", m_iStaminaLevel ); } -void CBasePlayer::SwitchToFlashlight( void ) -{ - // go through all of the weapons and find the torch weapon. - for( int i = 0; i < MAX_ITEM_TYPES; i++ ) - { - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - - while( pPlayerItem ) - { - if( pPlayerItem && pPlayerItem->m_iId == WEAPON_TORCH ) - { - // Switch to torch. - SwitchWeapon( pPlayerItem ); - return; - } - - pPlayerItem = pPlayerItem->m_pNext; - } - } -} - //========================================================= // Dead HEV suit prop //========================================================= diff --git a/dlls/player.h b/dlls/player.h index 2960bc52..cba5c646 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -326,8 +326,6 @@ public: int m_iAutoWepSwitch; - void SwitchToFlashlight( void ); - void UpdateStamina( void ); int m_iStaminaLevel; float m_flStaminaStart; diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 3d87f734..d87d24cd 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -49,18 +49,7 @@ void CShotgun::Spawn() m_iId = WEAPON_SHOTGUN; SET_MODEL( ENT( pev ), "models/w_shotgun.mdl" ); - // ========================================== - // Code changes for- Night at the Office: - // ========================================== - // - // -Randomised Ammo. Picking up a gun from a fallen terrorist - // will not give you a pre-defined amount of bullets. The exact - // number is random (depending on the gun and clip size), which - // means the player will constantly need to keep a check on the - // ammo as it will no longer be 'comfortable' for the player to - // waste ammo. - - m_iDefaultAmmo = DefaultAmmoBySkill( SHOTGUN_MAX_CLIP, gSkillData.iSkillLevel ); + m_iDefaultAmmo = SHOTGUN_DEFAULT_GIVE; FallInit();// get ready to fall } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index b008b3a0..d2272cb5 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -206,6 +206,24 @@ void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotat MESSAGE_END(); } +void EjectClip( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) +{ + // FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see. + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); + WRITE_BYTE( TE_MODEL ); + WRITE_COORD( vecOrigin.x ); + WRITE_COORD( vecOrigin.y ); + WRITE_COORD( vecOrigin.z ); + WRITE_COORD( vecVelocity.x ); + WRITE_COORD( vecVelocity.y ); + WRITE_COORD( vecVelocity.z ); + WRITE_ANGLE( rotation ); + WRITE_SHORT( model ); + WRITE_BYTE( soundtype ); + WRITE_BYTE( 405 );// 40.5 seconds + MESSAGE_END(); +} + #if 0 // UNDONE: This is no longer used? void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ) @@ -391,8 +409,6 @@ TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = DEFINE_FIELD( CBasePlayerWeapon, m_iDefaultAmmo, FIELD_INTEGER ), //DEFINE_FIELD( CBasePlayerWeapon, m_iClientClip, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly //DEFINE_FIELD( CBasePlayerWeapon, m_iClientWeaponState, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly - DEFINE_FIELD( CBasePlayerWeapon, m_iszClipModel, FIELD_STRING ), - DEFINE_FIELD( CBasePlayerWeapon, m_flDropClipTime, FIELD_TIME ), }; IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem ) @@ -966,12 +982,6 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; - // Drop an instance of current weapon clip on the ground. - if( !FStringNull( GetClipModel() ) ) - { - m_flDropClipTime = gpGlobals->time + GetDropClipDelay(); - } - return TRUE; } @@ -1148,80 +1158,6 @@ void CBasePlayerWeapon::RetireWeapon( void ) } } -void CBasePlayerWeapon::ItemPostFrame_Always( void ) -{ - // Check if it is time to drop the clip. - if( m_fInReload && m_flDropClipTime != 0 && m_flDropClipTime <= gpGlobals->time ) - { - DropClip(); - m_flDropClipTime = 0; - } -} - -// ========================================== -// Code changes for- Night at the Office: -// ========================================== -// -// -Randomised Ammo. Picking up a gun from a fallen terrorist -// will not give you a pre-defined amount of bullets. The exact -// number is random (depending on the gun and clip size), which -// means the player will constantly need to keep a check on the -// ammo as it will no longer be 'comfortable' for the player to -// waste ammo. - -int CBasePlayerWeapon::DefaultAmmoBySkill(int iMaxClip, int iSkillLevel) -{ - int iDefaultAmmo = 0; - - switch( iSkillLevel ) - { - default: - case SKILL_EASY: - // Random ammunition equal or superior to 75% clip capacity. - iDefaultAmmo = RANDOM_LONG( (int)( ceilf( iMaxClip * 0.75f ) ), iMaxClip ); - break; - case SKILL_MEDIUM: - // Random ammunition equal or superior to 50% clip capacity. - iDefaultAmmo = RANDOM_LONG( (int)( ceilf( iMaxClip * 0.5f ) ), iMaxClip ); - break; - case SKILL_HARD: - // Random ammunition equal or superior to 25% clip capacity. - iDefaultAmmo = RANDOM_LONG( (int)( ceilf( iMaxClip * 0.25f ) ), iMaxClip ); - break; - } - - return iDefaultAmmo; -} - -string_t CBasePlayerWeapon::GetClipModel() const -{ - return m_iszClipModel; -} - -void CBasePlayerWeapon::SetClipModel( const char* szModel ) -{ - m_iszClipModel = ALLOC_STRING( szModel ); -} - -// ========================================== -// Code changes for- Night at the Office: -// ========================================== -// -// -Clip Dropping. An extension of the realistic reloading. -// Whenever a gun with a weapon clip is reloaded, a clip -// model is 'ejected' onto the floor. - -void CBasePlayerWeapon::DropClip( void ) -{ - UTIL_MakeVectors( m_pPlayer->pev->angles ); - CWeaponClip *pClip = GetClassPtr( (CWeaponClip *)NULL ); - pClip->pev->angles.x = pClip->pev->angles.z = 0; - pClip->pev->origin = pev->origin + gpGlobals->v_forward * -16; - pClip->Spawn( STRING( GetClipModel() ) ); - pClip->pev->owner = edict(); - pClip->pev->avelocity = Vector( RANDOM_FLOAT( 200, 400 ), RANDOM_FLOAT( 200, 400 ), 0.0f ); -} - float CBasePlayerWeapon::GetNextAttackDelay( float delay ) { if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1.0f ) @@ -1696,3 +1632,12 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = }; IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon )*/ + +TYPEDESCRIPTION CTorch::m_SaveData[] = +{ + DEFINE_FIELD( CTorch, m_pLightSpot, FIELD_CLASSPTR ), + DEFINE_FIELD( CTorch, m_pWallSpot, FIELD_CLASSPTR ), + DEFINE_FIELD( CTorch, m_fIsOn, FIELD_BOOLEAN ) +}; + +IMPLEMENT_SAVERESTORE( CTorch, CBasePlayerWeapon ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 366b5ab3..701bb915 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -296,18 +296,6 @@ public: // hle time creep vars float m_flPrevPrimaryAttack; float m_flLastFireTime; - - virtual void ItemPostFrame_Always( void ); - - virtual int DefaultAmmoBySkill( int iMaxClip, int iSkillLevel ); - - virtual string_t GetClipModel() const; - void SetClipModel( const char* szModel ); - void DropClip( void ); - virtual float GetDropClipDelay( void ) const { return 0.0f; } - - string_t m_iszClipModel; - float m_flDropClipTime; }; class CBasePlayerAmmo : public CBaseEntity @@ -440,9 +428,9 @@ public: #endif } - float GetDropClipDelay() const { return 0.72f; } private: int m_iShell; + int m_iClipModel; int m_fInAttack; unsigned short m_usFireGlock1; @@ -470,8 +458,7 @@ public: int m_iSwing; TraceResult m_trHit; - float m_flReleaseThrow; - float m_flStartThrow; + int m_fInAttack; virtual BOOL UseDecrement( void ) { #if defined( CLIENT_WEAPONS ) @@ -481,7 +468,6 @@ public: #endif } - BOOL CanHolster( void ); void WeaponIdle( void ); private: @@ -530,13 +516,12 @@ public: void PrimaryAttack( void ); void SecondaryAttack( void ); - int SecondaryAmmoIndex( void ); BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); - BOOL IsUseable(); float m_flNextAnimTime; int m_iShell; + int m_iClipModel; virtual BOOL UseDecrement( void ) { @@ -547,8 +532,6 @@ public: #endif } - float GetDropClipDelay() const { return 0.4f; } - private: unsigned short m_usMP5; unsigned short m_usMP52; @@ -641,6 +624,22 @@ public: static CLaserSpot *CreateSpot( void ); }; +class CLightSpot : public CLaserSpot +{ + void Spawn( void ); + void Precache( void ); +public: + static CLightSpot *CreateSpot( void ); +}; + +class CWallSpot : public CLaserSpot +{ + void Spawn( void ); + void Precache( void ); +public: + static CWallSpot *CreateSpot( void ); +}; + class CRpg : public CBasePlayerWeapon { public: @@ -983,7 +982,6 @@ public: BOOL Deploy( void ); void Holster( int skiplocal = 0 ); - void WeaponIdle( void ); virtual BOOL UseDecrement( void ) { @@ -1025,19 +1023,11 @@ public: #endif } - void TurnOn( void ); - void TurnOff( void ); - void ToggleFlashlight( void ); - void UpdateSpot( void ); - CLaserSpot* m_pSpot; - CSprite* m_pGlow; + CLightSpot *m_pLightSpot; + CWallSpot *m_pWallSpot; BOOL m_fIsOn; - BOOL m_fUpdate; - -private: - unsigned short m_usTorch; }; #endif // WEAPONS_H