Browse Source

Fix desert eagle.

opforfixed
Night Owl 7 years ago
parent
commit
3f0dbba90c
  1. 2
      cl_dll/ev_hldm.cpp
  2. 253
      dlls/gearbox/eagle.cpp
  3. 4
      dlls/weapons.cpp
  4. 12
      dlls/weapons.h

2
cl_dll/ev_hldm.cpp

@ -1951,7 +1951,7 @@ void EV_FireEagle( event_args_t *args )
EV_MuzzleFlash(); EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( EAGLE_SHOOT, 1 ); gEngfuncs.pEventAPI->EV_WeaponAnimation( EAGLE_SHOOT, 1 );
V_PunchAxis( 0, -10.0 ); V_PunchAxis( 0, -4.0 );
} }
// Play fire sound. // Play fire sound.

253
dlls/gearbox/eagle.cpp

@ -1,17 +1,10 @@
/*** //========= Copyright © 2004-2008, Raven City Team, All rights reserved. ============//
* // //
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. // Purpose: //
* // //
* This product contains software technology licensed from Id // $NoKeywords: $ //
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. //===================================================================================//
* All Rights Reserved. //Modifided by Lost_Gamer_
*
* 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 "extdll.h"
#include "util.h" #include "util.h"
@ -21,25 +14,29 @@
#include "nodes.h" #include "nodes.h"
#include "player.h" #include "player.h"
enum eagle_e { enum deagle_e {
EAGLE_IDLE1 = 0, DEAGLE_IDLE1 = 0,
EAGLE_IDLE2, DEAGLE_IDLE2,
EAGLE_IDLE3, DEAGLE_IDLE3,
EAGLE_IDLE4, DEAGLE_IDLE4,
EAGLE_IDLE5, DEAGLE_IDLE5,
EAGLE_SHOOT, DEAGLE_SHOOT,
EAGLE_SHOOT_EMPTY, DEAGLE_SHOOT_EMPTY,
EAGLE_RELOAD, DEAGLE_RELOAD,
EAGLE_RELOAD_NOT_EMPTY, DEAGLE_RELOAD_NOT_EMPTY,
EAGLE_DRAW, DEAGLE_DRAW,
EAGLE_HOLSTER, DEAGLE_HOLSTER
}; };
LINK_ENTITY_TO_CLASS( weapon_eagle, CEagle )
LINK_ENTITY_TO_CLASS(weapon_eagle, CEagle); #ifndef CLIENT_DLL
LINK_ENTITY_TO_CLASS( eagle_laser, CLaserSpot )
#endif
void CEagle::Spawn() void CEagle::Spawn( void )
{ {
pev->classname = MAKE_STRING("weapon_eagle"); // hack to allow for old names
Precache( ); Precache( );
m_iId = WEAPON_EAGLE; m_iId = WEAPON_EAGLE;
SET_MODEL(ENT(pev), "models/w_desert_eagle.mdl"); SET_MODEL(ENT(pev), "models/w_desert_eagle.mdl");
@ -52,18 +49,18 @@ void CEagle::Spawn()
void CEagle::Precache( void ) void CEagle::Precache( void )
{ {
UTIL_PrecacheOther( "eagle_laser" );
PRECACHE_MODEL("models/v_desert_eagle.mdl"); PRECACHE_MODEL("models/v_desert_eagle.mdl");
PRECACHE_MODEL("models/w_desert_eagle.mdl"); PRECACHE_MODEL("models/w_desert_eagle.mdl");
PRECACHE_MODEL("models/p_desert_eagle.mdl"); PRECACHE_MODEL("models/p_desert_eagle.mdl");
m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell
PRECACHE_SOUND("weapons/desert_eagle_fire.wav");
PRECACHE_SOUND ("weapons/desert_eagle_reload.wav"); PRECACHE_SOUND ("weapons/desert_eagle_reload.wav");
PRECACHE_SOUND ("weapons/desert_eagle_fire.wav");
PRECACHE_SOUND ("weapons/desert_eagle_sight.wav"); PRECACHE_SOUND ("weapons/desert_eagle_sight.wav");
PRECACHE_SOUND ("weapons/desert_eagle_sight2.wav"); PRECACHE_SOUND ("weapons/desert_eagle_sight2.wav");
m_usFireEagle = PRECACHE_EVENT(1, "events/eagle.sc"); m_usEagle = PRECACHE_EVENT( 1, "events/eagle.sc" );
} }
int CEagle::GetItemInfo(ItemInfo *p) int CEagle::GetItemInfo(ItemInfo *p)
@ -85,66 +82,69 @@ int CEagle::GetItemInfo(ItemInfo *p)
BOOL CEagle::Deploy( ) BOOL CEagle::Deploy( )
{ {
return DefaultDeploy("models/v_desert_eagle.mdl", "models/p_desert_eagle.mdl", EAGLE_DRAW, "eagle", UseDecrement()); return DefaultDeploy( "models/v_desert_eagle.mdl", "models/p_desert_eagle.mdl", DEAGLE_DRAW, "onehanded", 0 );
} }
void CEagle::Holster( int skiplocal /* = 0 */ ) void CEagle::Holster( int skiplocal /* = 0 */ )
{ {
m_fInReload = FALSE;// cancel any reload in progress. m_fInReload = FALSE;// cancel any reload in progress.
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim( DEAGLE_HOLSTER );
SendWeaponAnim(EAGLE_HOLSTER); if (m_pEagleLaser)
#ifndef CLIENT_DLL
if (m_pSpot)
{ {
m_pSpot->Killed(NULL, GIB_NEVER); m_pEagleLaser->Killed( NULL, GIB_NEVER );
m_pSpot = NULL; m_pEagleLaser = NULL;
} }
#endif
} }
void CEagle::SecondaryAttack(void) void CEagle::SecondaryAttack()
{ {
m_fSpotActive = !m_fSpotActive; m_fEagleLaserActive = ! m_fEagleLaserActive;
if (!m_fEagleLaserActive && m_pEagleLaser)
#ifndef CLIENT_DLL
if (!m_fSpotActive && m_pSpot)
{ {
m_pSpot->Killed(NULL, GIB_NORMAL); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/desert_eagle_sight2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
m_pSpot = NULL; m_pEagleLaser->Killed( NULL, GIB_NORMAL );
m_pEagleLaser = NULL;
} }
#endif
if (m_fSpotActive)
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/desert_eagle_sight.wav", 1, ATTN_NORM);
else else
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/desert_eagle_sight2.wav", 1, ATTN_NORM); {
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/desert_eagle_sight.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2; }
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
} }
void CEagle::PrimaryAttack(void) void CEagle::PrimaryAttack()
{ {
if (m_iClip <= 0) if (m_iClip <= 0)
{ {
if (m_fFireOnEmpty) if (m_fFireOnEmpty)
{ {
PlayEmptySound(); PlayEmptySound();
m_flNextPrimaryAttack = GetNextAttackDelay(0.2); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
}
return;
} }
// don't fire underwater
if (m_pPlayer->pev->waterlevel == 3)
{
UpdateSpot( );
PlayEmptySound( );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.15;
return; return;
} }
UpdateSpot( );
float flSpread = 0.01;
m_iClip--; m_iClip--;
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
int flags; int flags;
BOOL m_fLaserOn;
#if defined( CLIENT_WEAPONS ) #if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST; flags = FEV_NOTHOST;
@ -154,59 +154,60 @@ void CEagle::PrimaryAttack(void)
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
Vector vecSrc = m_pPlayer->GetGunPosition( ); Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming; Vector vecAiming;
const Vector& vecSpread = VECTOR_CONE_2DEGREES; vecAiming = gpGlobals->v_forward;
float flCycleTime;
if (!m_fSpotActive) Vector vecDir;
if (m_pEagleLaser)
{ {
vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
flCycleTime = 0.25f; m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.5;
#ifndef CLIENT_DLL
m_pEagleLaser->Suspend( 0.6 );
#endif
m_fLaserOn = TRUE;
} }
else else
{ {
vecAiming = gpGlobals->v_forward; flSpread = 0.1;
flCycleTime = 0.5f; vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.22;
m_fLaserOn = FALSE;
} }
Vector vecDir; PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEagle, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, flSpread, flSpread, ( m_iClip == 0 ) ? 1 : 0, 0 );
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, (m_fSpotActive) ? VECTOR_CONE_1DEGREES : VECTOR_CONE_10DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed);
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireEagle, 0.0, (float *)&g_vecZero, (float *)&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) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
// HEV suit - indicate out of ammo condition // HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 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 );
UpdateSpot();
} }
void CEagle::Reload( void ) void CEagle::Reload( void )
{ {
if (m_pPlayer->ammo_357 <= 0) if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == EAGLE_MAX_CLIP)
return; return;
if (m_fSpotActive) if ( m_pEagleLaser && m_fEagleLaserActive )
{ {
SecondaryAttack(); #ifndef CLIENT_DLL
m_pEagleLaser->Suspend( 1.6 );
#endif
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5;
} }
int iResult; int iResult;
if (m_iClip == 0) if (m_iClip == 0)
iResult = DefaultReload(EAGLE_MAX_CLIP, EAGLE_RELOAD, 1.5); iResult = DefaultReload( EAGLE_MAX_CLIP, DEAGLE_RELOAD, 1.5 );
else else
iResult = DefaultReload(EAGLE_MAX_CLIP, EAGLE_RELOAD_NOT_EMPTY, 1.5); iResult = DefaultReload( EAGLE_MAX_CLIP, DEAGLE_RELOAD_NOT_EMPTY, 1.5 );
if (iResult) if (iResult)
{ {
@ -214,75 +215,85 @@ void CEagle::Reload(void)
} }
} }
void CEagle::UpdateSpot( void )
{
#ifndef CLIENT_DLL
if (m_fEagleLaserActive)
{
if (!m_pEagleLaser)
{
m_pEagleLaser = CLaserSpot::CreateSpot();
m_pEagleLaser->pev->classname = MAKE_STRING("eagle_laser");
m_pEagleLaser->pev->scale = 0.5;
}
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_pEagleLaser->pev, tr.vecEndPos );
if ( UTIL_PointContents(tr.vecEndPos) == CONTENT_SKY )
{
UTIL_Remove( m_pEagleLaser );
m_pEagleLaser = FALSE;
}
}
#endif
}
void CEagle::WeaponIdle( void ) void CEagle::WeaponIdle( void )
{ {
UpdateSpot( ); UpdateSpot( );
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
ResetEmptySound( ); ResetEmptySound( );
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
return;
// only idle if the slid isn't back // only idle if the slid isn't back
if (m_iClip != 0) if (m_iClip != 0)
{ {
int iAnim; int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );
if (flRand <= 0.2) if (m_pEagleLaser)
{ {
iAnim = EAGLE_IDLE1; if (flRand > 0.5 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f; {
iAnim = DEAGLE_IDLE5;//Done
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f;
} }
else if (flRand <= 0.4) else
{ {
iAnim = EAGLE_IDLE2; iAnim = DEAGLE_IDLE4;//Done
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f;
} }
else if (flRand <= 0.6) }
else
{
if (flRand <= 0.3 )
{ {
iAnim = EAGLE_IDLE3; iAnim = DEAGLE_IDLE1;//Done
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.6f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f;
} }
else if (flRand <= 0.8) else if (flRand <= 0.6 )
{ {
iAnim = EAGLE_IDLE4; iAnim = DEAGLE_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f;
} }
else else
{ {
iAnim = EAGLE_IDLE5; iAnim = DEAGLE_IDLE3;//Done
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.63f;
} }
SendWeaponAnim(iAnim, 1);
} }
SendWeaponAnim( iAnim, UseDecrement() ? 1 : 0 );
} }
void CEagle::UpdateSpot(void)
{
#ifndef CLIENT_DLL
if (m_fSpotActive)
{
if (!m_pSpot)
{
m_pSpot = CLaserSpot::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);
}
#endif
} }

4
dlls/weapons.cpp

@ -1619,8 +1619,9 @@ IMPLEMENT_SAVERESTORE( CDisplacer, CBasePlayerWeapon )
TYPEDESCRIPTION CEagle::m_SaveData[] = TYPEDESCRIPTION CEagle::m_SaveData[] =
{ {
DEFINE_FIELD( CEagle, m_fSpotActive, FIELD_INTEGER ), DEFINE_FIELD( CEagle, m_fEagleLaserActive, FIELD_INTEGER ),
}; };
IMPLEMENT_SAVERESTORE( CEagle, CBasePlayerWeapon ) IMPLEMENT_SAVERESTORE( CEagle, CBasePlayerWeapon )
TYPEDESCRIPTION CGrapple::m_SaveData[] = TYPEDESCRIPTION CGrapple::m_SaveData[] =
@ -1641,7 +1642,6 @@ TYPEDESCRIPTION CM249::m_SaveData[] =
}; };
IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon ) IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon )
TYPEDESCRIPTION CPipeWrench::m_SaveData[] = TYPEDESCRIPTION CPipeWrench::m_SaveData[] =
{ {
DEFINE_FIELD( CPipeWrench, m_iFirestate, FIELD_INTEGER ), DEFINE_FIELD( CPipeWrench, m_iFirestate, FIELD_INTEGER ),

12
dlls/weapons.h

@ -1107,13 +1107,11 @@ private:
class CEagle : public CBasePlayerWeapon class CEagle : public CBasePlayerWeapon
{ {
public: public:
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
int Save( CSave &save ); int Save( CSave &save );
int Restore( CRestore &restore ); int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
#endif #endif
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int iItemSlot( void ) { return 2; } int iItemSlot( void ) { return 2; }
@ -1123,13 +1121,12 @@ public:
void SecondaryAttack( void ); void SecondaryAttack( void );
BOOL Deploy( void ); BOOL Deploy( void );
void Holster( int skiplocal = 0 ); void Holster( int skiplocal = 0 );
void Reload( void ); void Reload( void );
void WeaponIdle( void ); void WeaponIdle( void );
void UpdateSpot( void ); void UpdateSpot( void );
BOOL ShouldWeaponIdle(void) { return TRUE; }; CLaserSpot *m_pEagleLaser;
int m_fEagleLaserActive;
virtual BOOL UseDecrement( void ) virtual BOOL UseDecrement( void )
{ {
#if defined( CLIENT_WEAPONS ) #if defined( CLIENT_WEAPONS )
@ -1139,13 +1136,10 @@ public:
#endif #endif
} }
CLaserSpot *m_pSpot;
int m_fSpotActive;
private: private:
int m_iShell; int m_iShell;
unsigned short m_usFireEagle; unsigned short m_usEagle;
}; };
class CGrappleTonguetip; class CGrappleTonguetip;

Loading…
Cancel
Save