You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
6.7 KiB
307 lines
6.7 KiB
/*** |
|
* |
|
* 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" |
|
|
|
enum eagel_e |
|
{ |
|
EAGEL_IDLE1 = 0, |
|
EAGEL_FIDGET1, |
|
EAGEL_FIRE1, |
|
EAGEL_RELOAD, |
|
EAGEL_HOLSTER, |
|
EAGEL_DRAW, |
|
EAGEL_IDLE2, |
|
EAGEL_IDLE3 |
|
}; |
|
|
|
LINK_ENTITY_TO_CLASS( weapon_eagel, CEagel ) |
|
|
|
void CEagel::Spawn( ) |
|
{ |
|
pev->classname = MAKE_STRING("weapon_eagel"); // hack to allow for old names |
|
Precache( ); |
|
m_iId = WEAPON_EAGEL; |
|
SET_MODEL(ENT(pev), "models/w_eagel.mdl"); |
|
|
|
m_iDefaultAmmo = EAGEL_DEFAULT_GIVE; |
|
|
|
FallInit();// get ready to fall down. |
|
} |
|
|
|
|
|
void CEagel::Precache( void ) |
|
{ |
|
PRECACHE_MODEL("models/v_eagel.mdl"); |
|
PRECACHE_MODEL("models/w_eagel.mdl"); |
|
PRECACHE_MODEL("models/p_eagel.mdl"); |
|
|
|
m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell |
|
|
|
PRECACHE_SOUND("items/9mmclip1.wav"); |
|
PRECACHE_SOUND("items/9mmclip2.wav"); |
|
|
|
PRECACHE_SOUND ("weapons/eagel_fire1.wav");//silenced handgun |
|
PRECACHE_SOUND ("weapons/eagel_fire2.wav");//silenced handgun |
|
PRECACHE_SOUND ("weapons/eagel_fire3.wav");//handgun |
|
|
|
m_usFireEagel1 = PRECACHE_EVENT( 1, "events/eagel1.sc" ); |
|
m_usFireEagel2 = PRECACHE_EVENT( 1, "events/eagel2.sc" ); |
|
} |
|
|
|
int CEagel::GetItemInfo(ItemInfo *p) |
|
{ |
|
p->pszName = STRING(pev->classname); |
|
p->pszAmmo1 = "9mm"; |
|
p->iMaxAmmo1 = _9MM_MAX_CARRY; |
|
p->pszAmmo2 = NULL; |
|
p->iMaxAmmo2 = -1; |
|
p->iMaxClip = EAGEL_MAX_CLIP; |
|
p->iSlot = 1; |
|
p->iPosition = 2; |
|
p->iFlags = 0; |
|
p->iId = m_iId = WEAPON_EAGEL; |
|
p->iWeight = EAGEL_WEIGHT; |
|
p->weaponName = "Desert Eagle"; |
|
|
|
return 1; |
|
} |
|
|
|
int CEagel::AddToPlayer( CBasePlayer *pPlayer ) |
|
{ |
|
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) |
|
{ |
|
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); |
|
WRITE_BYTE( m_iId ); |
|
MESSAGE_END(); |
|
return TRUE; |
|
} |
|
return FALSE; |
|
} |
|
|
|
BOOL CEagel::Deploy( ) |
|
{ |
|
#if CLIENT_DLL |
|
if ( bIsMultiplayer() ) |
|
#else |
|
if ( g_pGameRules->IsMultiplayer() ) |
|
#endif |
|
{ |
|
// enable laser sight geometry. |
|
pev->body = 1; |
|
} |
|
else |
|
{ |
|
pev->body = 0; |
|
} |
|
|
|
return DefaultDeploy( "models/v_eagel.mdl", "models/p_eagel.mdl", EAGEL_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); |
|
|
|
} |
|
|
|
void CEagel::SecondaryAttack( void ) |
|
{ |
|
if ( m_pPlayer->pev->fov != 0 ) |
|
{ |
|
m_fInZoom = FALSE; |
|
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov |
|
} |
|
else if ( m_pPlayer->pev->fov != 40 ) |
|
{ |
|
m_fInZoom = TRUE; |
|
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40; |
|
} |
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; |
|
} |
|
|
|
void CEagel::Holster( int skiplocal /* = 0 */ ) |
|
{ |
|
m_fInReload = FALSE;// cancel any reload in progress. |
|
|
|
if ( m_fInZoom ) |
|
{ |
|
SecondaryAttack(); |
|
} |
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f; |
|
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
|
SendWeaponAnim( EAGEL_HOLSTER ); |
|
} |
|
|
|
void CEagel::PrimaryAttack( void ) |
|
{ |
|
EagelFire( 0.01, 0.4, TRUE ); |
|
} |
|
|
|
void CEagel::EagelFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) |
|
{ |
|
if (m_iClip <= 0) |
|
{ |
|
if (m_fFireOnEmpty) |
|
{ |
|
PlayEmptySound(); |
|
m_flNextPrimaryAttack = GetNextAttackDelay( 0.2f ); |
|
} |
|
|
|
return; |
|
} |
|
|
|
m_iClip--; |
|
|
|
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; |
|
|
|
int flags; |
|
|
|
#if CLIENT_WEAPONS |
|
flags = FEV_NOTHOST; |
|
#else |
|
flags = 0; |
|
#endif |
|
|
|
// player "shoot" animation |
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); |
|
|
|
// silenced |
|
if (pev->body == 1) |
|
{ |
|
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; |
|
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; |
|
} |
|
else |
|
{ |
|
// non-silenced |
|
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; |
|
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; |
|
} |
|
|
|
Vector vecSrc = m_pPlayer->GetGunPosition( ); |
|
Vector vecAiming; |
|
|
|
if ( fUseAutoAim ) |
|
{ |
|
vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); |
|
} |
|
else |
|
{ |
|
vecAiming = gpGlobals->v_forward; |
|
} |
|
|
|
Vector vecDir; |
|
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); |
|
|
|
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireEagel1 : m_usFireEagel2, 0.0, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); |
|
|
|
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay( flCycleTime ); |
|
|
|
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) |
|
// HEV suit - indicate out of ammo condition |
|
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); |
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
|
|
|
} |
|
|
|
|
|
void CEagel::Reload( void ) |
|
{ |
|
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == EAGEL_MAX_CLIP ) |
|
return; |
|
|
|
if ( m_pPlayer->pev->fov != 0 ) |
|
{ |
|
m_fInZoom = FALSE; |
|
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov |
|
} |
|
|
|
int bUseScope = FALSE; |
|
|
|
int iResult = 0; |
|
|
|
if (m_iClip == 0) |
|
iResult = DefaultReload( EAGEL_MAX_CLIP, EAGEL_RELOAD, 1.5 ); |
|
|
|
if (iResult) |
|
{ |
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
|
} |
|
} |
|
|
|
void CEagel::WeaponIdle( void ) |
|
{ |
|
ResetEmptySound( ); |
|
|
|
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); |
|
|
|
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) |
|
return; |
|
|
|
// only idle if the slid isn't back |
|
if (m_iClip != 0) |
|
{ |
|
int iAnim; |
|
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); |
|
|
|
if (flRand <= 0.3f) |
|
{ |
|
iAnim = EAGEL_IDLE3; |
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0f / 16.0f; |
|
} |
|
else if (flRand <= 0.6f) |
|
{ |
|
iAnim = EAGEL_IDLE1; |
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0f / 16.0f; |
|
} |
|
else |
|
{ |
|
iAnim = EAGEL_IDLE2; |
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0f / 16.0f; |
|
} |
|
SendWeaponAnim( iAnim, 1 ); |
|
} |
|
} |
|
|
|
class CEagelAmmo : public CBasePlayerAmmo |
|
{ |
|
void Spawn( void ) |
|
{ |
|
Precache( ); |
|
SET_MODEL(ENT(pev), "models/w_eagelclip.mdl"); |
|
CBasePlayerAmmo::Spawn( ); |
|
} |
|
void Precache( void ) |
|
{ |
|
PRECACHE_MODEL ("models/w_eagelclip.mdl"); |
|
PRECACHE_SOUND("items/9mmclip1.wav"); |
|
} |
|
BOOL AddAmmo( CBaseEntity *pOther ) |
|
{ |
|
if (pOther->GiveAmmo( AMMO_EAGELCLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1) |
|
{ |
|
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); |
|
return TRUE; |
|
} |
|
return FALSE; |
|
} |
|
}; |
|
LINK_ENTITY_TO_CLASS( ammo_eagelclip, CEagelAmmo ) |
|
|
|
|