diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 08127aa1..0f0369b5 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -59,7 +59,6 @@ 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 ); @@ -1125,65 +1124,6 @@ void EV_FireGauss( event_args_t *args ) // GAUSS END //====================== -//====================== -// CROWBAR START -//====================== -enum crowbar_e -{ - CROWBAR_IDLE = 0, - CROWBAR_DRAW, - CROWBAR_HOLSTER, - CROWBAR_ATTACK1HIT, - CROWBAR_ATTACK1MISS, - CROWBAR_ATTACK2MISS, - CROWBAR_ATTACK2HIT, - CROWBAR_ATTACK3MISS, -#ifndef CROWBAR_IDLE_ANIM - CROWBAR_ATTACK3HIT -#else - CROWBAR_ATTACK3HIT, - CROWBAR_IDLE2, - CROWBAR_IDLE3 -#endif -}; - -int g_iSwing; - -//Only predict the miss sounds, hit sounds are still played -//server side, so players don't get the wrong idea. -void EV_Crowbar( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - - if( EV_IsLocal( idx ) ) - { - switch( (g_iSwing++) % 3 ) - { - case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 ); - break; - } - } -} -//====================== -// CROWBAR END -//====================== - //====================== // CROSSBOW START //====================== diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index c79279dd..fd6c5579 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -29,7 +29,6 @@ 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 ); @@ -67,7 +66,6 @@ void Game_HookEvents( void ) 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 ); diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 887811df..f4af3a41 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1429,6 +1429,8 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; + UTIL_MuzzleLight( vecSrc, 160, 255, 255, 128, 0, 0 ); + if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves @@ -1569,6 +1571,8 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi float x = 0.0f, y = 0.0f; float z; + UTIL_MuzzleLight( vecSrc, 160, 255, 255, 128, 0, 0 ); + if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index a397939b..95ab1147 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -67,8 +67,6 @@ void CCrowbar::Precache( void ) PRECACHE_SOUND( "weapons/cbar_hitbod2.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod3.wav" ); PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - - m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); } int CCrowbar::GetItemInfo( ItemInfo *p ) @@ -201,12 +199,6 @@ int CCrowbar::Swing( int fFirst ) } } #endif - if( fFirst ) - { - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0, 0, 0 ); - } if( tr.flFraction >= 1.0 ) { @@ -217,6 +209,21 @@ int CCrowbar::Swing( int fFirst ) #ifdef CROWBAR_IDLE_ANIM m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); #endif + switch( ( m_iSwing++ ) % 3 ) + { + case 0: + SendWeaponAnim( CROWBAR_ATTACK1MISS ); + break; + case 1: + SendWeaponAnim( CROWBAR_ATTACK2MISS ); + break; + case 2: + SendWeaponAnim( CROWBAR_ATTACK3MISS ); + break; + } + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xF ) ); + // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 1150d8b9..ce95f43f 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -50,6 +50,12 @@ void CGlock::Spawn() FallInit();// get ready to fall down. } +void CGlock::Holster( int skiplocal ) +{ + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( GLOCK_HOLSTER ); +} + void CGlock::Precache( void ) { PRECACHE_MODEL( "models/v_9mmhandgun.mdl" ); diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 35d586a0..23e0b480 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -540,6 +540,7 @@ BOOL CHGrunt::CheckRangeAttack2( float flDot, float flDist ) // crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while. m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. m_fThrowGrenade = FALSE; + return m_fThrowGrenade; //AJH need this or it is overridden later. } } diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index e0bc8fe0..67cc10d9 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -32,7 +32,8 @@ enum mp5_e MP5_DEPLOY, MP5_FIRE1, MP5_FIRE2, - MP5_FIRE3 + MP5_FIRE3, + MP5_HOLSTER }; LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 ) @@ -120,20 +121,26 @@ BOOL CMP5::Deploy() return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" ); } +void CMP5::Holster( int skiplocal /* = 0 */) +{ + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( MP5_HOLSTER ); +} + void CMP5::PrimaryAttack() { // don't fire underwater if (m_pPlayer->pev->waterlevel == 3 && m_pPlayer->pev->watertype > CONTENT_FLYFIELD) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } if( m_iClip <= 0 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } @@ -171,7 +178,7 @@ void CMP5::PrimaryAttack() #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, RANDOM_LONG( MP5_FIRE1, MP5_FIRE3 ), m_iShell, 0, 0 ); if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition @@ -180,7 +187,7 @@ void CMP5::PrimaryAttack() m_flNextPrimaryAttack = GetNextAttackDelay( 0.1 ); if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } @@ -191,7 +198,7 @@ void CMP5::SecondaryAttack( void ) if (m_pPlayer->pev->waterlevel == 3 && m_pPlayer->pev->watertype > CONTENT_FLYFIELD) { PlayEmptySound( ); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } @@ -234,6 +241,8 @@ void CMP5::SecondaryAttack( void ) if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + + m_pPlayer->pev->punchangle.x -= 10; } void CMP5::Reload( void ) diff --git a/dlls/python.cpp b/dlls/python.cpp index bfc989ab..a632999b 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -123,7 +123,7 @@ void CPython::Holster( int skiplocal /* = 0 */ ) SecondaryAttack(); } - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); SendWeaponAnim( PYTHON_HOLSTER ); } diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 1e1ed68a..4c771e0a 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -436,8 +436,10 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim( RPG_HOLSTER1 ); - + if( m_iClip ) + SendWeaponAnim( RPG_HOLSTER1 ); + else + SendWeaponAnim( RPG_HOLSTER2 ); #ifndef CLIENT_DLL if( m_pSpot ) { diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 229956f1..7e111628 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -113,6 +113,12 @@ BOOL CShotgun::Deploy() return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" ); } +void CShotgun::Holster( int skiplocal ) +{ + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( SHOTGUN_HOLSTER ); +} + void CShotgun::PrimaryAttack() { // don't fire underwater diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 5ad051d4..254ae6cb 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -475,6 +475,9 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( SQUEAK_DOWN ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SNARK ); @@ -482,9 +485,6 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) SetNextThink( 0.1 ); return; } - - SendWeaponAnim( SQUEAK_DOWN ); - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } void CSqueak::PrimaryAttack() diff --git a/dlls/util.cpp b/dlls/util.cpp index 3d45d173..ce0e4851 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -33,6 +33,22 @@ #include "movewith.h" #include "locus.h" +void UTIL_MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ) +{ + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecSrc.x ); // X + WRITE_COORD( vecSrc.y ); // Y + WRITE_COORD( vecSrc.z ); // Z + WRITE_BYTE( flRadius * 0.1f ); // radius * 0.1 + WRITE_BYTE( r ); // r + WRITE_BYTE( g ); // g + WRITE_BYTE( b ); // b + WRITE_BYTE( flTime * 10.0f ); // time * 10 + WRITE_BYTE( flDecay * 0.1f ); // decay * 0.1 + MESSAGE_END(); +} + float UTIL_WeaponTimeBase( void ) { #if defined( CLIENT_WEAPONS ) diff --git a/dlls/util.h b/dlls/util.h index fdcf2417..579d3d32 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -614,4 +614,5 @@ int GetStdLightStyle (int iStyle); //LRC- declared here so it can be used by eve // needs to deal with the standard lightstyles. // LRC- for aliases and groups CBaseEntity* UTIL_FollowReference( CBaseEntity* pStartEntity, const char* szName ); +void UTIL_MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ); #endif // UTIL_H diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 15c1df6c..6acdd68e 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -300,6 +300,7 @@ void W_Precache( void ) UTIL_PrecacheOther( "item_antidote" ); UTIL_PrecacheOther( "item_security" ); UTIL_PrecacheOther( "item_longjump" ); + //UTIL_PrecacheOtherWeapon( "weapon_debug" ); // shotgun UTIL_PrecacheOtherWeapon( "weapon_shotgun" ); @@ -386,6 +387,17 @@ void W_Precache( void ) PRECACHE_SOUND( "items/weapondrop1.wav" );// weapon falls to the ground } +void CBasePlayerItem::KeyValue( KeyValueData *pkvd ) //AJH +{ + if (FStrEq(pkvd->szKeyName, "master")) + { + m_sMaster = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseDelay::KeyValue( pkvd ); +} + TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = { DEFINE_FIELD( CBasePlayerItem, m_pPlayer, FIELD_CLASSPTR ), @@ -415,6 +427,7 @@ 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_sMaster, FIELD_STRING ), // AJH master entity for Lockable weapons }; IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem ) @@ -577,11 +590,35 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { AttachToPlayer( pPlayer ); EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); + + if( !gEvilImpulse101 ) + { + int i; + char sample[32]; + char weapon_name[32]; + strcpy(weapon_name, STRING(pev->classname)); + + if(strncmp(weapon_name, "weapon_", 7) == 0) + i = 7; + else if (strncmp(weapon_name, "item_", 5) == 0) + i = 5; + else + i = 0; + + sprintf( sample, "!%s", weapon_name + i ); + pPlayer->SetSuitUpdate( sample, FALSE, SUIT_NEXT_IN_30SEC ); + } } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? } +void CBasePlayerItem::Spawn() +{ + pev->animtime = gpGlobals->time + 0.1; + CBaseAnimating::Spawn(); +} + BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) { #if defined( CLIENT_WEAPONS ) @@ -745,6 +782,9 @@ void CBasePlayerWeapon :: SetNextThink( float delay ) // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { + if( !UTIL_IsMasterTriggered( m_sMaster, m_pPlayer ) ) + return FALSE; // AJH allows for locked weapons + if( m_iDefaultAmmo ) { return ExtractAmmo( (CBasePlayerWeapon *)pOriginal ); @@ -758,6 +798,9 @@ int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { + if( !UTIL_IsMasterTriggered( m_sMaster, m_pPlayer ) ) + return FALSE; // AJH allows for locked weapons + int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); pPlayer->pev->weapons |= ( 1 << m_iId ); @@ -905,16 +948,7 @@ BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) //========================================================= BOOL CBasePlayerWeapon::IsUseable( void ) { - if( m_iClip <= 0 ) - { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] <= 0 && iMaxAmmo1() != -1 ) - { - // clip is empty (or nonexistant) and the player has no more ammo of this type. - return FALSE; - } - } - - return TRUE; + return CanDeploy(); } BOOL CBasePlayerWeapon::CanDeploy( void ) @@ -1067,6 +1101,9 @@ void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) return; } + if( !UTIL_IsMasterTriggered( m_sMaster, m_pPlayer ) ) + return; // AJH allows for locked weapons + if( AddAmmo( pOther ) ) { if( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES ) diff --git a/dlls/weapons.h b/dlls/weapons.h index d16d5a4d..57e9f677 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -66,18 +66,19 @@ public: #define WEAPON_CROWBAR 1 #define WEAPON_GLOCK 2 #define WEAPON_PYTHON 3 -#define WEAPON_MP5 4 -#define WEAPON_CHAINGUN 5 -#define WEAPON_CROSSBOW 6 -#define WEAPON_SHOTGUN 7 -#define WEAPON_RPG 8 -#define WEAPON_GAUSS 9 -#define WEAPON_EGON 10 -#define WEAPON_HORNETGUN 11 -#define WEAPON_HANDGRENADE 12 -#define WEAPON_TRIPMINE 13 -#define WEAPON_SATCHEL 14 -#define WEAPON_SNARK 15 +#define WEAPON_GENERIC 4 +#define WEAPON_MP5 5 +#define WEAPON_DEBUG 6 +#define WEAPON_CROSSBOW 7 +#define WEAPON_SHOTGUN 8 +#define WEAPON_RPG 9 +#define WEAPON_GAUSS 10 +#define WEAPON_EGON 11 +#define WEAPON_HORNETGUN 12 +#define WEAPON_HANDGRENADE 13 +#define WEAPON_TRIPMINE 14 +#define WEAPON_SATCHEL 15 +#define WEAPON_SNARK 16 #define WEAPON_ALLWEAPONS (~(1<