Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
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.

642 lines
17 KiB

9 years ago
/***
*
* 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.
*
****/
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "soundent.h"
#include "shake.h"
#include "gamerules.h"
#include "game.h"
9 years ago
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
9 years ago
enum gauss_e
{
9 years ago
GAUSS_IDLE = 0,
GAUSS_IDLE2,
GAUSS_FIDGET,
GAUSS_SPINUP,
GAUSS_SPIN,
GAUSS_FIRE,
GAUSS_FIRE2,
GAUSS_HOLSTER,
GAUSS_DRAW
};
LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss )
9 years ago
float CGauss::GetFullChargeTime( void )
{
#ifdef CLIENT_DLL
9 years ago
if( bIsMultiplayer() )
9 years ago
#else
9 years ago
if( g_pGameRules->IsMultiplayer() )
9 years ago
#endif
{
return 1.5f;
9 years ago
}
return 4.0f;
9 years ago
}
#ifdef CLIENT_DLL
extern int g_irunninggausspred;
#endif
9 years ago
void CGauss::Spawn()
9 years ago
{
9 years ago
Precache();
9 years ago
m_iId = WEAPON_GAUSS;
9 years ago
SET_MODEL( ENT( pev ), "models/w_gauss.mdl" );
9 years ago
m_iDefaultAmmo = GAUSS_DEFAULT_GIVE;
FallInit();// get ready to fall down.
}
void CGauss::Precache( void )
{
9 years ago
PRECACHE_MODEL( "models/w_gauss.mdl" );
PRECACHE_MODEL( "models/v_gauss.mdl" );
PRECACHE_MODEL( "models/p_gauss.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/gauss2.wav" );
PRECACHE_SOUND( "weapons/electro4.wav" );
PRECACHE_SOUND( "weapons/electro5.wav" );
PRECACHE_SOUND( "weapons/electro6.wav" );
PRECACHE_SOUND( "ambience/pulsemachine.wav" );
9 years ago
m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" );
m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" );
m_iBeam = PRECACHE_MODEL( "sprites/smoke.spr" );
m_usGaussFire = PRECACHE_EVENT( 1, "events/gauss.sc" );
m_usGaussSpin = PRECACHE_EVENT( 1, "events/gaussspin.sc" );
}
int CGauss::AddToPlayer( CBasePlayer *pPlayer )
{
9 years ago
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
9 years ago
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
9 years ago
int CGauss::GetItemInfo( ItemInfo *p )
9 years ago
{
9 years ago
p->pszName = STRING( pev->classname );
9 years ago
p->pszAmmo1 = "uranium";
p->iMaxAmmo1 = URANIUM_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 3;
p->iPosition = 1;
p->iId = m_iId = WEAPON_GAUSS;
p->iFlags = 0;
p->iWeight = GAUSS_WEIGHT;
return 1;
}
BOOL CGauss::IsUseable()
{
// Currently charging, allow the player to fire it first. - Solokiller
8 years ago
return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0;
}
9 years ago
BOOL CGauss::Deploy()
9 years ago
{
m_pPlayer->m_flPlayAftershock = 0.0;
return DefaultDeploy( "models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss" );
}
void CGauss::Holster( int skiplocal /* = 0 */ )
{
PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );
9 years ago
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
9 years ago
9 years ago
SendWeaponAnim( GAUSS_HOLSTER );
m_fInAttack = 0;
}
void CGauss::PrimaryAttack()
{
// don't fire underwater
9 years ago
if( m_pPlayer->pev->waterlevel == 3 )
9 years ago
{
9 years ago
PlayEmptySound();
m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15f );
9 years ago
return;
}
9 years ago
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < 2 )
9 years ago
{
9 years ago
PlayEmptySound();
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
9 years ago
return;
}
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
m_fPrimaryFire = TRUE;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 2;
StartFire();
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2f;
9 years ago
}
void CGauss::SecondaryAttack()
{
// don't fire underwater
9 years ago
if( m_pPlayer->pev->waterlevel == 3 )
9 years ago
{
9 years ago
if( m_fInAttack != 0 )
9 years ago
{
9 years ago
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) );
9 years ago
SendWeaponAnim( GAUSS_IDLE );
m_fInAttack = 0;
}
else
{
9 years ago
PlayEmptySound();
9 years ago
}
m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f );
9 years ago
return;
}
9 years ago
if( m_fInAttack == 0 )
9 years ago
{
9 years ago
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
9 years ago
{
9 years ago
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM );
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
9 years ago
return;
}
m_fPrimaryFire = FALSE;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase();
// spin up
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
9 years ago
9 years ago
SendWeaponAnim( GAUSS_SPINUP );
m_fInAttack = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f;
9 years ago
m_pPlayer->m_flStartCharge = gpGlobals->time;
m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime();
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 110, 0, 0, 0 );
9 years ago
m_iSoundState = SND_CHANGE_PITCH;
}
9 years ago
else if( m_fInAttack == 1 )
9 years ago
{
9 years ago
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
9 years ago
{
SendWeaponAnim( GAUSS_SPIN );
m_fInAttack = 2;
}
}
else
{
// Moved to before the ammo burn.
// Because we drained 1 when m_InAttack == 0, then 1 again now before checking if we're out of ammo,
// this resuled in the player having -1 ammo, which in turn caused CanDeploy to think it could be deployed.
// This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?),
// But this check will prevent the problem for now. - Solokiller
// TODO: investigate further.
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
{
// out of ammo! force the gun to fire
StartFire();
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
return;
}
9 years ago
// during the charging process, eat one bit of ammo every once in a while
9 years ago
if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 )
9 years ago
{
#ifdef CLIENT_DLL
9 years ago
if( bIsMultiplayer() )
9 years ago
#else
9 years ago
if( g_pGameRules->IsMultiplayer() )
9 years ago
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1f;
9 years ago
}
else
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3f;
9 years ago
}
}
9 years ago
if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge )
9 years ago
{
// don't eat any more ammo after gun is fully charged.
m_pPlayer->m_flNextAmmoBurn = 1000;
}
int pitch = (int)( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100 );
9 years ago
if( pitch > 250 )
9 years ago
pitch = 250;
// ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch );
const bool overcharge = m_pPlayer->m_flStartCharge < gpGlobals->time - 10.0f;
9 years ago
if( m_iSoundState == 0 )
9 years ago
ALERT( at_console, "sound state %d\n", m_iSoundState );
#ifdef GAUSS_OVERCHARGE_FIX
if (!overcharge)
#endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 );
9 years ago
m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
9 years ago
// m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f;
if( overcharge )
9 years ago
{
// Player charged up too long. Zap him.
#ifdef GAUSS_OVERCHARGE_FIX
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, pitch, 0, 0, 1 );
#endif
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0f, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0f, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) );
9 years ago
9 years ago
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f;
9 years ago
#ifndef CLIENT_DLL
9 years ago
m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_SHOCK );
UTIL_ScreenFade( m_pPlayer, Vector( 255, 128, 0 ), 2, 0.5f, 128, FFADE_IN );
9 years ago
#endif
SendWeaponAnim( GAUSS_IDLE );
9 years ago
9 years ago
// Player may have been killed and this weapon dropped, don't execute any more code after this!
return;
}
}
}
//=========================================================
// StartFire- since all of this code has to run and then
// call Fire(), it was easier at this point to rip it out
// of weaponidle() and make its own function then to try to
// merge this into Fire(), which has some identical variable names
//=========================================================
void CGauss::StartFire( void )
{
float flDamage;
9 years ago
9 years ago
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecAiming = gpGlobals->v_forward;
9 years ago
Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() )
9 years ago
{
flDamage = 200.0f;
9 years ago
}
else
{
flDamage = 200.0f * ( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) / GetFullChargeTime() );
9 years ago
}
9 years ago
if( m_fPrimaryFire )
9 years ago
{
// fixed damage on primary attack
#ifdef CLIENT_DLL
flDamage = 20.0f;
9 years ago
#else
flDamage = gSkillData.plrDmgGauss;
#endif
}
9 years ago
if( m_fInAttack != 3 )
9 years ago
{
9 years ago
//ALERT( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage );
9 years ago
#ifndef CLIENT_DLL
float flZVel = m_pPlayer->pev->velocity.z;
9 years ago
if( !m_fPrimaryFire )
9 years ago
{
m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5.0f;
9 years ago
}
9 years ago
if( !g_pGameRules->IsMultiplayer() )
9 years ago
{
// in deathmatch, gauss can pop you up into the air. Not in single play.
m_pPlayer->pev->velocity.z = flZVel;
}
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
// time until aftershock 'static discharge' sound
m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3f, 0.8f );
9 years ago
Fire( vecSrc, vecAiming, flDamage );
}
void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage )
{
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
TraceResult tr, beam_tr;
#ifndef CLIENT_DLL
9 years ago
Vector vecSrc = vecOrigSrc;
Vector vecDest = vecSrc + vecDir * 8192.0f;
9 years ago
edict_t *pentIgnore;
float flMaxFrac = 1.0f;
9 years ago
int nTotal = 0;
9 years ago
int fHasPunched = 0;
int fFirstBeam = 1;
9 years ago
int nMaxHits = 10;
9 years ago
pentIgnore = ENT( m_pPlayer->pev );
#else
9 years ago
if( m_fPrimaryFire == false )
9 years ago
g_irunninggausspred = true;
#endif
9 years ago
// The main firing event is sent unreliably so it won't be delayed.
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 );
9 years ago
// This reliable event is used to stop the spinning sound
// It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client
// It's sent reliably anyway, which could lead to other delays
PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );
9 years ago
/*ALERT( at_console, "%f %f %f\n%f %f %f\n",
vecSrc.x, vecSrc.y, vecSrc.z,
vecDest.x, vecDest.y, vecDest.z );*/
//ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac );
9 years ago
#ifndef CLIENT_DLL
9 years ago
while( flDamage > 10 && nMaxHits > 0 )
9 years ago
{
nMaxHits--;
// ALERT( at_console, "." );
9 years ago
UTIL_TraceLine( vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr );
9 years ago
9 years ago
if( tr.fAllSolid )
9 years ago
break;
9 years ago
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
9 years ago
9 years ago
if( pEntity == NULL )
9 years ago
break;
9 years ago
if( fFirstBeam )
9 years ago
{
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
fFirstBeam = 0;
9 years ago
9 years ago
nTotal += 26;
}
9 years ago
if( pEntity->pev->takedamage )
9 years ago
{
ClearMultiDamage();
pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET );
9 years ago
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
9 years ago
}
9 years ago
if( pEntity->ReflectGauss() )
9 years ago
{
float n;
pentIgnore = NULL;
9 years ago
n = -DotProduct( tr.vecPlaneNormal, vecDir );
9 years ago
if( n < 0.5f ) // 60 degrees
9 years ago
{
// ALERT( at_console, "reflect %f\n", n );
// reflect
Vector r;
9 years ago
9 years ago
r = 2.0 * tr.vecPlaneNormal * n + vecDir;
flMaxFrac = flMaxFrac - tr.flFraction;
vecDir = r;
vecSrc = tr.vecEndPos + vecDir * 8.0f;
vecDest = vecSrc + vecDir * 8192.0f;
9 years ago
// explode a bit
m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST );
nTotal += 34;
9 years ago
9 years ago
// lose energy
if( n == 0.0f ) n = 0.1f;
flDamage = flDamage * ( 1.0f - n );
9 years ago
}
else
{
nTotal += 13;
// limit it to one hole punch
9 years ago
if( fHasPunched )
9 years ago
break;
fHasPunched = 1;
// try punching through wall if secondary attack (primary is incapable of breaking through)
9 years ago
if( !m_fPrimaryFire )
9 years ago
{
9 years ago
UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr );
if( !beam_tr.fAllSolid )
9 years ago
{
// trace backwards to find exit point
9 years ago
UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr );
9 years ago
8 years ago
n = ( beam_tr.vecEndPos - tr.vecEndPos ).Length();
9 years ago
9 years ago
if( n < flDamage )
9 years ago
{
if( n == 0.0f )
n = 1.0f;
9 years ago
flDamage -= n;
// ALERT( at_console, "punch %f\n", n );
nTotal += 21;
// exit blast damage
//m_pPlayer->RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, CLASS_NONE, DMG_BLAST );
float damage_radius;
9 years ago
if( g_pGameRules->IsMultiplayer() )
9 years ago
{
damage_radius = flDamage * 1.75f; // Old code == 2.5
9 years ago
}
else
{
damage_radius = flDamage * 2.5f;
9 years ago
}
::RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, damage_radius, CLASS_NONE, DMG_BLAST );
CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0f );
9 years ago
nTotal += 53;
vecSrc = beam_tr.vecEndPos + vecDir;
}
else if( !selfgauss.value )
{
flDamage = 0;
}
9 years ago
}
else
{
//ALERT( at_console, "blocked %f\n", n );
flDamage = 0;
}
}
else
{
//ALERT( at_console, "blocked solid\n" );
9 years ago
9 years ago
flDamage = 0;
}
}
}
else
{
vecSrc = tr.vecEndPos + vecDir;
pentIgnore = ENT( pEntity->pev );
}
}
#endif
// ALERT( at_console, "%d bytes\n", nTotal );
}
void CGauss::WeaponIdle( void )
{
9 years ago
ResetEmptySound();
9 years ago
// play aftershock static discharge
9 years ago
if( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time )
9 years ago
{
9 years ago
switch( RANDOM_LONG( 0, 3 ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM );
9 years ago
break;
case 1:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM );
9 years ago
break;
case 2:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM );
9 years ago
break;
case 3:
break; // no sound
9 years ago
}
m_pPlayer->m_flPlayAftershock = 0.0f;
9 years ago
}
9 years ago
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
9 years ago
return;
9 years ago
if( m_fInAttack != 0 )
9 years ago
{
StartFire();
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f;
// Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f;
9 years ago
}
else
{
int iAnim;
float flRand = RANDOM_FLOAT( 0.0f, 1.0f );
if( flRand <= 0.5f )
9 years ago
{
iAnim = GAUSS_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );
9 years ago
}
else if( flRand <= 0.75f )
9 years ago
{
iAnim = GAUSS_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );
9 years ago
}
else
{
iAnim = GAUSS_FIDGET;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f;
9 years ago
}
#ifndef CLIENT_DLL
9 years ago
SendWeaponAnim( iAnim );
#endif
9 years ago
}
}
class CGaussAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
9 years ago
Precache();
SET_MODEL( ENT( pev ), "models/w_gaussammo.mdl" );
CBasePlayerAmmo::Spawn();
9 years ago
}
void Precache( void )
{
9 years ago
PRECACHE_MODEL( "models/w_gaussammo.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
9 years ago
}
BOOL AddAmmo( CBaseEntity *pOther )
{
9 years ago
if( pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1 )
9 years ago
{
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
9 years ago
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo )
9 years ago
#endif