mirror of
https://github.com/FWGS/hlsdk-xash3d
synced 2024-11-12 05:10:52 +01:00
623 lines
15 KiB
C++
623 lines
15 KiB
C++
/***
|
|
*
|
|
* 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 "gamerules.h"
|
|
|
|
#ifndef CLIENT_DLL
|
|
#define BOLT_AIR_VELOCITY 2000
|
|
#define BOLT_WATER_VELOCITY 1000
|
|
|
|
extern BOOL gPhysicsInterfaceInitialized;
|
|
|
|
// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS()
|
|
//
|
|
// OVERLOADS SOME ENTVARS:
|
|
//
|
|
// speed - the ideal magnitude of my velocity
|
|
class CCrossbowBolt : public CBaseEntity
|
|
{
|
|
void Spawn( void );
|
|
void Precache( void );
|
|
int Classify( void );
|
|
void EXPORT BubbleThink( void );
|
|
void EXPORT BoltTouch( CBaseEntity *pOther );
|
|
void EXPORT ExplodeThink( void );
|
|
|
|
int m_iTrail;
|
|
|
|
public:
|
|
static CCrossbowBolt *BoltCreate( void );
|
|
};
|
|
|
|
LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt )
|
|
|
|
CCrossbowBolt *CCrossbowBolt::BoltCreate( void )
|
|
{
|
|
// Create a new entity with CCrossbowBolt private data
|
|
CCrossbowBolt *pBolt = GetClassPtr( (CCrossbowBolt *)NULL );
|
|
pBolt->pev->classname = MAKE_STRING( "crossbow_bolt" ); // g-cont. enable save\restore
|
|
pBolt->Spawn();
|
|
|
|
return pBolt;
|
|
}
|
|
|
|
void CCrossbowBolt::Spawn()
|
|
{
|
|
Precache();
|
|
pev->movetype = MOVETYPE_FLY;
|
|
pev->solid = SOLID_BBOX;
|
|
|
|
pev->gravity = 0.5;
|
|
|
|
SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" );
|
|
|
|
// UTIL_SetOrigin( this, pev->origin );
|
|
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
|
|
|
|
SetTouch( &CCrossbowBolt::BoltTouch );
|
|
SetThink( &CCrossbowBolt::BubbleThink );
|
|
SetNextThink( 0.2 );
|
|
}
|
|
|
|
void CCrossbowBolt::Precache()
|
|
{
|
|
PRECACHE_MODEL( "models/crossbow_bolt.mdl" );
|
|
PRECACHE_SOUND( "weapons/xbow_hitbod1.wav" );
|
|
PRECACHE_SOUND( "weapons/xbow_hitbod2.wav" );
|
|
PRECACHE_SOUND( "weapons/xbow_fly1.wav" );
|
|
PRECACHE_SOUND( "weapons/xbow_hit1.wav" );
|
|
PRECACHE_SOUND( "fvox/beep.wav" );
|
|
m_iTrail = PRECACHE_MODEL( "sprites/streak.spr" );
|
|
}
|
|
|
|
int CCrossbowBolt::Classify( void )
|
|
{
|
|
return CLASS_NONE;
|
|
}
|
|
|
|
void CCrossbowBolt::BoltTouch( CBaseEntity *pOther )
|
|
{
|
|
SetTouch( NULL );
|
|
SetThink( NULL );
|
|
|
|
if( pOther->pev->takedamage )
|
|
{
|
|
TraceResult tr = UTIL_GetGlobalTrace();
|
|
entvars_t *pevOwner;
|
|
|
|
pevOwner = VARS( pev->owner );
|
|
|
|
// UNDONE: this needs to call TraceAttack instead
|
|
ClearMultiDamage();
|
|
|
|
if( pOther->IsPlayer() )
|
|
{
|
|
pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB );
|
|
}
|
|
else
|
|
{
|
|
pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB );
|
|
}
|
|
|
|
ApplyMultiDamage( pev, pevOwner );
|
|
|
|
pev->velocity = Vector( 0, 0, 0 );
|
|
// play body "thwack" sound
|
|
switch( RANDOM_LONG( 0, 1 ) )
|
|
{
|
|
case 0:
|
|
EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM );
|
|
break;
|
|
case 1:
|
|
EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM );
|
|
break;
|
|
}
|
|
|
|
if( !g_pGameRules->IsMultiplayer() )
|
|
{
|
|
Killed( pev, GIB_NEVER );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) );
|
|
|
|
SetThink(&CCrossbowBolt:: SUB_Remove );
|
|
SetNextThink( 0 );// this will get changed below if the bolt is allowed to stick in what it hit.
|
|
|
|
if( FClassnameIs( pOther->pev, "worldspawn" ) )
|
|
{
|
|
// if what we hit is static architecture, can stay around for a while.
|
|
Vector vecDir = pev->velocity.Normalize();
|
|
// UTIL_SetOrigin( this, pev->origin - vecDir * 12 );
|
|
pev->angles = UTIL_VecToAngles( vecDir );
|
|
pev->solid = SOLID_NOT;
|
|
pev->movetype = MOVETYPE_FLY;
|
|
pev->velocity = Vector( 0, 0, 0 );
|
|
pev->avelocity.z = 0;
|
|
pev->angles.z = RANDOM_LONG( 0, 360 );
|
|
SetNextThink( 10.0 );
|
|
}
|
|
else if( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP )
|
|
{
|
|
Vector vecDir = pev->velocity.Normalize();
|
|
// UTIL_SetOrigin( this, pev->origin - vecDir * 12 );
|
|
pev->angles = UTIL_VecToAngles( vecDir );
|
|
pev->solid = SOLID_NOT;
|
|
pev->velocity = Vector( 0, 0, 0 );
|
|
pev->avelocity.z = 0;
|
|
pev->angles.z = RANDOM_LONG( 0, 360 );
|
|
SetNextThink( 10.0 );
|
|
|
|
if (gPhysicsInterfaceInitialized) {
|
|
// g-cont. Setup movewith feature
|
|
pev->movetype = MOVETYPE_COMPOUND; // set movewith type
|
|
pev->aiment = ENT( pOther->pev ); // set parent
|
|
}
|
|
}
|
|
|
|
if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER )
|
|
{
|
|
UTIL_Sparks( pev->origin );
|
|
}
|
|
}
|
|
|
|
if( g_pGameRules->IsMultiplayer() )
|
|
{
|
|
SetThink( &CCrossbowBolt::ExplodeThink );
|
|
SetNextThink( 0.1 );
|
|
}
|
|
}
|
|
|
|
void CCrossbowBolt::BubbleThink( void )
|
|
{
|
|
SetNextThink( 0.1 );
|
|
|
|
if (pev->waterlevel == 0 || pev->watertype <= CONTENT_FLYFIELD)
|
|
return;
|
|
|
|
UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 );
|
|
}
|
|
|
|
void CCrossbowBolt::ExplodeThink( void )
|
|
{
|
|
int iContents = UTIL_PointContents( pev->origin );
|
|
int iScale;
|
|
|
|
pev->dmg = 200;
|
|
iScale = 50;
|
|
|
|
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
|
|
WRITE_BYTE( TE_EXPLOSION );
|
|
WRITE_COORD( pev->origin.x );
|
|
WRITE_COORD( pev->origin.y );
|
|
WRITE_COORD( pev->origin.z );
|
|
if( iContents != CONTENTS_WATER )
|
|
{
|
|
WRITE_SHORT( g_sModelIndexFireball );
|
|
}
|
|
else
|
|
{
|
|
WRITE_SHORT( g_sModelIndexWExplosion );
|
|
}
|
|
WRITE_BYTE( iScale ); // scale * 10
|
|
WRITE_BYTE( 15 ); // framerate
|
|
WRITE_BYTE( TE_EXPLFLAG_NONE );
|
|
MESSAGE_END();
|
|
|
|
entvars_t *pevOwner;
|
|
|
|
if( pev->owner )
|
|
pevOwner = VARS( pev->owner );
|
|
else
|
|
pevOwner = NULL;
|
|
|
|
pev->owner = NULL; // can't traceline attack owner if this is set
|
|
|
|
::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB );
|
|
|
|
UTIL_Remove( this );
|
|
}
|
|
#endif
|
|
|
|
enum crossbow_e
|
|
{
|
|
CROSSBOW_IDLE,
|
|
CROSSBOW_FIDGET,
|
|
CROSSBOW_FIRE,
|
|
CROSSBOW_FIRE2,
|
|
CROSSBOW_FIRE3,
|
|
CROSSBOW_RELOAD,
|
|
CROSSBOW_DRAW,
|
|
CROSSBOW_HOLSTER,
|
|
};
|
|
|
|
LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow )
|
|
|
|
void CCrossbow::Spawn()
|
|
{
|
|
Precache();
|
|
m_iId = WEAPON_CROSSBOW;
|
|
SET_MODEL( ENT( pev ), "models/w_crossbow.mdl" );
|
|
|
|
NowZooming = FALSE;
|
|
ZoomStopped = TRUE;
|
|
|
|
m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE;
|
|
|
|
FallInit();// get ready to fall down.
|
|
}
|
|
|
|
int CCrossbow::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;
|
|
}
|
|
|
|
void CCrossbow::Precache( void )
|
|
{
|
|
PRECACHE_MODEL( "models/w_crossbow.mdl" );
|
|
PRECACHE_MODEL( "models/v_crossbow.mdl" );
|
|
PRECACHE_MODEL( "models/p_crossbow.mdl" );
|
|
|
|
PRECACHE_SOUND( "weapons/arrow6_fire.wav" );
|
|
PRECACHE_SOUND( "weapons/arrow6_reload.wav" );
|
|
PRECACHE_SOUND( "weapons/arrow6_drawback.wav" );
|
|
PRECACHE_SOUND( "weapons/xbow_reload1.wav" );
|
|
|
|
UTIL_PrecacheOther( "crossbow_bolt" );
|
|
|
|
m_usCrossbow = PRECACHE_EVENT( 1, "events/crossbow1.sc" );
|
|
m_usCrossbow2 = PRECACHE_EVENT( 1, "events/crossbow2.sc" );
|
|
}
|
|
|
|
int CCrossbow::GetItemInfo( ItemInfo *p )
|
|
{
|
|
p->pszName = STRING( pev->classname );
|
|
p->pszAmmo1 = "bolts";
|
|
p->iMaxAmmo1 = BOLT_MAX_CARRY;
|
|
p->pszAmmo2 = NULL;
|
|
p->iMaxAmmo2 = -1;
|
|
p->iMaxClip = CROSSBOW_MAX_CLIP;
|
|
p->iSlot = 3;
|
|
p->iPosition = 1;
|
|
p->iId = WEAPON_CROSSBOW;
|
|
p->iFlags = 0;
|
|
p->iWeight = CROSSBOW_WEIGHT;
|
|
p->weaponName = "Crossbow";
|
|
return 1;
|
|
}
|
|
|
|
BOOL CCrossbow::Deploy()
|
|
{
|
|
return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW, "bow" );
|
|
|
|
SetThink(&CCrossbow::ZoomThink);
|
|
pev->nextthink = gpGlobals->time + 0.1;
|
|
}
|
|
|
|
void CCrossbow::Holster( int skiplocal /* = 0 */ )
|
|
{
|
|
m_fInReload = FALSE;// cancel any reload in progress.
|
|
|
|
if( m_fInZoom )
|
|
{
|
|
SecondaryAttack();
|
|
}
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
|
|
|
SendWeaponAnim( CROSSBOW_HOLSTER );
|
|
}
|
|
|
|
void CCrossbow::PrimaryAttack( void )
|
|
{
|
|
#ifdef CLIENT_DLL
|
|
if( m_fInZoom && bIsMultiplayer() )
|
|
#else
|
|
if( m_fInZoom && g_pGameRules->IsMultiplayer() )
|
|
#endif
|
|
{
|
|
FireSniperBolt();
|
|
return;
|
|
}
|
|
|
|
FireBolt();
|
|
}
|
|
|
|
// this function only gets called in multiplayer
|
|
void CCrossbow::FireSniperBolt()
|
|
{
|
|
m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 );
|
|
|
|
if( m_iClip == 0 )
|
|
{
|
|
PlayEmptySound();
|
|
return;
|
|
}
|
|
|
|
TraceResult tr;
|
|
|
|
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
|
m_iClip--;
|
|
|
|
int flags;
|
|
#if defined( CLIENT_WEAPONS )
|
|
flags = FEV_NOTHOST;
|
|
#else
|
|
flags = 0;
|
|
#endif
|
|
|
|
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow2, 0.0, g_vecZero, g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 );
|
|
|
|
// player "shoot" animation
|
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
|
|
|
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
|
UTIL_MakeVectors( anglesAim );
|
|
Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
|
|
Vector vecDir = gpGlobals->v_forward;
|
|
|
|
UTIL_TraceLine( vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr );
|
|
|
|
#ifndef CLIENT_DLL
|
|
if( tr.pHit->v.takedamage )
|
|
{
|
|
ClearMultiDamage();
|
|
CBaseEntity::Instance( tr.pHit )->TraceAttack( m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB );
|
|
ApplyMultiDamage( pev, m_pPlayer->pev );
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void CCrossbow::FireBolt()
|
|
{
|
|
TraceResult tr;
|
|
|
|
if( m_iClip == 0 )
|
|
{
|
|
PlayEmptySound();
|
|
return;
|
|
}
|
|
|
|
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
|
|
|
m_iClip--;
|
|
|
|
int flags;
|
|
#if defined( CLIENT_WEAPONS )
|
|
flags = FEV_NOTHOST;
|
|
#else
|
|
flags = 0;
|
|
#endif
|
|
|
|
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow, 0.0, g_vecZero, g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 );
|
|
|
|
// player "shoot" animation
|
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
|
|
|
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
|
UTIL_MakeVectors( anglesAim );
|
|
|
|
anglesAim.x = -anglesAim.x;
|
|
|
|
#ifndef CLIENT_DLL
|
|
Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
|
|
Vector vecDir = gpGlobals->v_forward;
|
|
|
|
CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate();
|
|
pBolt->pev->origin = vecSrc;
|
|
pBolt->pev->angles = anglesAim;
|
|
pBolt->pev->owner = m_pPlayer->edict();
|
|
|
|
if (m_pPlayer->pev->waterlevel == 3 && m_pPlayer->pev->watertype > CONTENT_FLYFIELD)
|
|
{
|
|
pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY;
|
|
pBolt->pev->speed = BOLT_WATER_VELOCITY;
|
|
}
|
|
else
|
|
{
|
|
pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY;
|
|
pBolt->pev->speed = BOLT_AIR_VELOCITY;
|
|
}
|
|
pBolt->pev->avelocity.z = 10;
|
|
#endif
|
|
|
|
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_flNextPrimaryAttack = GetNextAttackDelay( 2.0 );
|
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.0;
|
|
|
|
if( m_iClip != 0 )
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
|
|
else
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
|
|
}
|
|
|
|
void CCrossbow::SecondaryAttack()
|
|
{
|
|
if( m_pPlayer->pev->fov != 0 )
|
|
{
|
|
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
|
m_fInZoom = 0;
|
|
}
|
|
else if( m_pPlayer->pev->fov != 20 )
|
|
{
|
|
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20;
|
|
m_fInZoom = 1;
|
|
}
|
|
|
|
SetNextThink( 0.1 );
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
|
}
|
|
|
|
void CCrossbow::Reload( void )
|
|
{
|
|
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP )
|
|
return;
|
|
|
|
if( m_pPlayer->pev->fov != 0 )
|
|
{
|
|
SecondaryAttack();
|
|
}
|
|
|
|
if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) )
|
|
{
|
|
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) );
|
|
}
|
|
}
|
|
|
|
void CCrossbow::ZoomThink()
|
|
{
|
|
// DrM-|ckt der Spieler den zweiten Feuerknopf?
|
|
if (m_pPlayer->m_afButtonPressed & IN_ATTACK2)
|
|
{
|
|
// DrM-|ckt er auch den ersten Feuerknopf?
|
|
if( m_pPlayer->m_afButtonPressed & IN_ATTACK )
|
|
{
|
|
// Wenn ja, FEUER!
|
|
PrimaryAttack();
|
|
}
|
|
|
|
// Wenn wir gerade nicht zoomen, und das zoomen nicht
|
|
// von einem frM-|heren zoomen gestoppt wurde, dann zoom
|
|
if( ( NowZooming == false ) && ( ZoomStopped == false ) )
|
|
{
|
|
NowZooming = true;
|
|
}
|
|
|
|
// dere das FOV, wenn wir gerade zoomen
|
|
if( ( NowZooming == true ) && ( ZoomStopped == false ) )
|
|
{
|
|
// Wenn das FOV grM-_er als 10 ist, dann dezimiere es
|
|
if( m_pPlayer->m_iFOV > 10 )
|
|
{
|
|
// Das hier kannst du ver dern, um die Zoomgeschwindigkeit
|
|
// deinem Geschmack anzupassen
|
|
m_pPlayer->m_iFOV--;
|
|
m_pPlayer->m_iFOV--;
|
|
}
|
|
else
|
|
{
|
|
// Wenn das FOV schon 10 ist, dann h auf mit zoomen
|
|
ZoomStopped = true;
|
|
}
|
|
}
|
|
// Wenn wir nicht im Zoom sind, aber ZoomStopped ist wahr, dann setz das FOV zurM-|ck
|
|
if( ( NowZooming == false ) && ( ZoomStopped == true ) )
|
|
{
|
|
m_pPlayer->m_iFOV = 90;
|
|
NowZooming = false;
|
|
ZoomStopped = false;
|
|
pev->nextthink = gpGlobals->time + 0.25;
|
|
return;
|
|
}
|
|
}
|
|
// Falls der 2. Feuerknopf nicht gedrM-|ckt ist
|
|
else
|
|
{
|
|
// Der Spieler hat den Knopf losgelassen
|
|
// Stopp zoomen und setzt ZoomStopped
|
|
if( ( NowZooming == true ) && ( ZoomStopped == false ) )
|
|
{
|
|
NowZooming = false;
|
|
ZoomStopped = true;
|
|
}
|
|
|
|
// Falls der Zoom das Ende erreicht hat
|
|
// und automatisch gestoppt wird
|
|
if( ( NowZooming == true ) && ( ZoomStopped == true ) )
|
|
{
|
|
NowZooming = false;
|
|
ZoomStopped = true;
|
|
}
|
|
}
|
|
|
|
// Stell den n hsten Durchlauf ein
|
|
pev->nextthink = gpGlobals->time + 0.05;
|
|
}
|
|
|
|
void CCrossbow::WeaponIdle( void )
|
|
{
|
|
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
|
|
|
|
ResetEmptySound();
|
|
|
|
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
|
|
{
|
|
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
|
if( flRand <= 0.75 )
|
|
{
|
|
if( m_iClip )
|
|
SendWeaponAnim( CROSSBOW_IDLE );
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
|
}
|
|
else
|
|
{
|
|
if( m_iClip )
|
|
{
|
|
SendWeaponAnim( CROSSBOW_FIDGET );
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0;
|
|
}
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
|
}
|
|
}
|
|
}
|
|
|
|
class CCrossbowAmmo : public CBasePlayerAmmo
|
|
{
|
|
void Spawn( void )
|
|
{
|
|
Precache();
|
|
SET_MODEL( ENT( pev ), "models/w_crossbow_clip.mdl" );
|
|
CBasePlayerAmmo::Spawn();
|
|
}
|
|
void Precache( void )
|
|
{
|
|
PRECACHE_MODEL( "models/w_crossbow_clip.mdl" );
|
|
PRECACHE_SOUND( "items/9mmclip1.wav" );
|
|
}
|
|
BOOL AddAmmo( CBaseEntity *pOther )
|
|
{
|
|
if( pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1 )
|
|
{
|
|
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
};
|
|
|
|
LINK_ENTITY_TO_CLASS( ammo_crossbow, CCrossbowAmmo )
|
|
#endif
|