RAINBOW2000
8 years ago
21 changed files with 346 additions and 1017 deletions
@ -1,485 +0,0 @@
@@ -1,485 +0,0 @@
|
||||
#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 1300 |
||||
#define BOLT_WATER_VELOCITY 1300 |
||||
|
||||
|
||||
class CCrowbar2 : public CBasePlayerWeapon |
||||
{ |
||||
public: |
||||
void Spawn( void ); |
||||
void Precache( void ); |
||||
int iItemSlot( ) { return 3; } |
||||
int GetItemInfo(ItemInfo *p); |
||||
|
||||
void FireBolt( void ); |
||||
void FireSniperBolt( void ); |
||||
void PrimaryAttack( void ); |
||||
int AddToPlayer( CBasePlayer *pPlayer ); |
||||
BOOL Deploy( ); |
||||
void Holster( int skiplocal = 0 ); |
||||
void WeaponIdle( void ); |
||||
|
||||
int m_fInZoom; // don't save this
|
||||
|
||||
virtual BOOL UseDecrement( void ) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
private: |
||||
unsigned short m_usCrossbow12; |
||||
unsigned short m_usCrossbow22; |
||||
}; |
||||
|
||||
|
||||
|
||||
// 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 CCrowbar2Bolt : 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 CCrowbar2Bolt *BoltCreate( void ); |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS( crowbar2_bolt, CCrowbar2Bolt ) |
||||
|
||||
CCrowbar2Bolt *CCrowbar2Bolt::BoltCreate( void ) |
||||
{ |
||||
// Create a new entity with CCrossbowBolt private data
|
||||
CCrowbar2Bolt *pBolt = GetClassPtr( (CCrowbar2Bolt *)NULL ); |
||||
pBolt->pev->classname = MAKE_STRING( "crossbow_bolt" ); // g-cont. enable save\restore
|
||||
pBolt->Spawn(); |
||||
|
||||
return pBolt; |
||||
} |
||||
|
||||
void CCrowbar2Bolt::Spawn() |
||||
{ |
||||
Precache(); |
||||
pev->movetype = MOVETYPE_FLY; |
||||
pev->solid = SOLID_BBOX; |
||||
|
||||
pev->gravity = 300; |
||||
|
||||
SET_MODEL( ENT( pev ), "models/w_hammer.mdl" ); |
||||
|
||||
UTIL_SetOrigin( pev, pev->origin ); |
||||
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); |
||||
|
||||
SetTouch( &CCrowbar2Bolt::BoltTouch ); |
||||
SetThink( &CCrowbar2Bolt::BubbleThink ); |
||||
pev->nextthink = gpGlobals->time + 0.2; |
||||
} |
||||
|
||||
void CCrowbar2Bolt::Precache() |
||||
{ |
||||
PRECACHE_MODEL( "models/w_hammer.mdl" ); |
||||
PRECACHE_SOUND( "weapons/hammer_hitbod1.wav" ); |
||||
PRECACHE_SOUND( "weapons/hammer_hitbod2.wav" ); |
||||
PRECACHE_SOUND( "weapons/g_bounce2.wav" ); |
||||
PRECACHE_SOUND( "fvox/beep.wav" ); |
||||
m_iTrail = PRECACHE_MODEL( "sprites/streak.spr" ); |
||||
} |
||||
|
||||
int CCrowbar2Bolt::Classify( void ) |
||||
{ |
||||
return CLASS_NONE; |
||||
} |
||||
|
||||
void CCrowbar2Bolt::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, 259, pev->velocity.Normalize(), &tr, DMG_ALWAYSGIB ); |
||||
} |
||||
else |
||||
{ |
||||
pOther->TraceAttack( pevOwner, 259, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_ALWAYSGIB ); |
||||
} |
||||
|
||||
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/hammer_hitbod.wav", 1, ATTN_NORM ); |
||||
break; |
||||
case 1: |
||||
EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/hammer_hitbod.wav", 1, ATTN_NORM ); |
||||
break; |
||||
} |
||||
|
||||
if( !g_pGameRules->IsMultiplayer() ) |
||||
{ |
||||
Killed( pev, GIB_ALWAYS ); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/hammer_hit.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) ); |
||||
|
||||
SetThink( &CBaseEntity::SUB_Remove ); |
||||
pev->nextthink = gpGlobals->time;// 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( pev, 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( 180,360 ); |
||||
pev->nextthink = gpGlobals->time + 10.0; |
||||
} |
||||
else if( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP ) |
||||
{ |
||||
Vector vecDir = pev->velocity.Normalize(); |
||||
UTIL_SetOrigin( pev, 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, 180 ); |
||||
pev->nextthink = gpGlobals->time + 10.0; |
||||
|
||||
} |
||||
|
||||
if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER ) |
||||
{ |
||||
UTIL_Sparks( pev->origin ); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
void CCrowbar2Bolt::BubbleThink( void ) |
||||
{ |
||||
pev->nextthink = gpGlobals->time + 0.1; |
||||
|
||||
if( pev->waterlevel == 0 ) |
||||
return; |
||||
|
||||
UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); |
||||
} |
||||
|
||||
void CCrowbar2Bolt::ExplodeThink( void ) |
||||
{ |
||||
int iContents = UTIL_PointContents( pev->origin ); |
||||
int iScale; |
||||
|
||||
pev->dmg = 40; |
||||
iScale = 10; |
||||
|
||||
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 crowbar_e |
||||
{ |
||||
CROSSBOW_IDLE = 0, |
||||
CROSSBOW_DRAW, |
||||
CROSSBOW_HOLSTER, |
||||
CROSSBOW_ATTACK1HIT |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_hammer, CCrowbar2 ) |
||||
|
||||
void CCrowbar2::Spawn() |
||||
{ |
||||
Precache(); |
||||
m_iId = WEAPON_HAMMER; |
||||
SET_MODEL( ENT( pev ), "models/w_hammer.mdl" ); |
||||
|
||||
m_iDefaultAmmo = -1; |
||||
|
||||
FallInit();// get ready to fall down.
|
||||
} |
||||
|
||||
int CCrowbar2::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 CCrowbar2::Precache( void ) |
||||
{ |
||||
PRECACHE_MODEL( "models/w_hammer.mdl" ); |
||||
PRECACHE_MODEL( "models/v_hammer.mdl" ); |
||||
PRECACHE_MODEL( "models/p_hammer.mdl" ); |
||||
|
||||
PRECACHE_SOUND( "g_bounce2.wav" ); |
||||
|
||||
UTIL_PrecacheOther( "crowbar2_bolt" ); |
||||
|
||||
m_usCrossbow12 = PRECACHE_EVENT( 1, "events/crowbar.sc" ); |
||||
m_usCrossbow22 = PRECACHE_EVENT( 1, "events/crowbar.sc" ); |
||||
} |
||||
|
||||
int CCrowbar2::GetItemInfo( ItemInfo *p ) |
||||
{ |
||||
p->pszName = STRING( pev->classname ); |
||||
p->pszAmmo1 = NULL; |
||||
p->iMaxAmmo1 = -1; |
||||
p->pszAmmo2 = NULL; |
||||
p->iMaxAmmo2 = -1; |
||||
p->iMaxClip = -1; |
||||
p->iSlot = 0; |
||||
p->iPosition = 4; |
||||
p->iId = WEAPON_HAMMER; |
||||
p->iFlags = 0; |
||||
p->iWeight = -10; |
||||
return 1; |
||||
} |
||||
|
||||
BOOL CCrowbar2::Deploy() |
||||
{ |
||||
if( m_iClip ) |
||||
return DefaultDeploy( "models/v_hammer.mdl", "models/p_hammer.mdl", CROSSBOW_DRAW, "bow" ); |
||||
return DefaultDeploy( "models/v_hammer.mdl", "models/p_hammer.mdl", CROSSBOW_DRAW, "bow" ); |
||||
} |
||||
|
||||
void CCrowbar2::Holster( int skiplocal /* = 0 */ ) |
||||
{ |
||||
m_fInReload = FALSE;// cancel any reload in progress.
|
||||
|
||||
if( m_fInZoom ) |
||||
{ |
||||
SecondaryAttack(); |
||||
} |
||||
|
||||
m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5; |
||||
if( m_iClip ) |
||||
{ |
||||
SendWeaponAnim( CROSSBOW_HOLSTER ); |
||||
} |
||||
|
||||
} |
||||
|
||||
void CCrowbar2::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 CCrowbar2::FireSniperBolt() |
||||
{ |
||||
m_flNextPrimaryAttack = gpGlobals->time + 0.35; |
||||
|
||||
|
||||
TraceResult tr; |
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; |
||||
|
||||
int flags; |
||||
#if defined( CLIENT_WEAPONS ) |
||||
flags = FEV_NOTHOST; |
||||
#else |
||||
flags = 0; |
||||
#endif |
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow22, 0.0, (float *)&g_vecZero, (float *)&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_ALWAYSGIB ); |
||||
ApplyMultiDamage( pev, m_pPlayer->pev ); |
||||
} |
||||
#endif |
||||
} |
||||
|
||||
void CCrowbar2::FireBolt() |
||||
{ |
||||
TraceResult tr; |
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; |
||||
|
||||
|
||||
int flags; |
||||
#if defined( CLIENT_WEAPONS ) |
||||
flags = FEV_NOTHOST; |
||||
#else |
||||
flags = 0; |
||||
#endif |
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow12, 0.0, (float *)&g_vecZero, (float *)&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; |
||||
Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; |
||||
Vector vecDir = gpGlobals->v_forward; |
||||
|
||||
#ifndef CLIENT_DLL |
||||
CCrowbar2Bolt *pBolt = CCrowbar2Bolt::BoltCreate(); |
||||
pBolt->pev->origin = vecSrc; |
||||
pBolt->pev->angles = anglesAim; |
||||
pBolt->pev->owner = m_pPlayer->edict(); |
||||
|
||||
if( m_pPlayer->pev->waterlevel == 3 ) |
||||
{ |
||||
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 = gpGlobals->time + 0.35; |
||||
|
||||
m_flNextSecondaryAttack = gpGlobals->time + 0.35; |
||||
|
||||
if( m_iClip != 0 ) |
||||
m_flTimeWeaponIdle = gpGlobals->time + 5.0; |
||||
else |
||||
m_flTimeWeaponIdle = gpGlobals->time + 0.75; |
||||
} |
||||
|
||||
|
||||
void CCrowbar2::WeaponIdle( void ) |
||||
{ |
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
|
||||
|
||||
ResetEmptySound(); |
||||
|
||||
if( m_flTimeWeaponIdle < gpGlobals->time ) |
||||
{ |
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); |
||||
if( flRand <= 0.75 ) |
||||
{ |
||||
if( m_iClip ) |
||||
{ |
||||
SendWeaponAnim( CROSSBOW_IDLE ); |
||||
} |
||||
else |
||||
{ |
||||
SendWeaponAnim( CROSSBOW_IDLE ); |
||||
} |
||||
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
||||
} |
||||
else |
||||
{ |
||||
if( m_iClip ) |
||||
{ |
||||
m_flTimeWeaponIdle = gpGlobals->time + 90.0 / 30.0; |
||||
} |
||||
else |
||||
{ |
||||
m_flTimeWeaponIdle = gpGlobals->time + 80.0 / 30.0; |
||||
} |
||||
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endif |
@ -1,259 +0,0 @@
@@ -1,259 +0,0 @@
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "weapons.h" |
||||
#include "nodes.h" |
||||
#include "player.h" |
||||
|
||||
enum glock_e |
||||
{ |
||||
GLOCK_IDLE1 = 0, |
||||
GLOCK_IDLE2, |
||||
GLOCK_IDLE3, |
||||
GLOCK_SHOOT, |
||||
GLOCK_SHOOT_EMPTY, |
||||
GLOCK_RELOAD, |
||||
GLOCK_RELOAD_NOT_EMPTY, |
||||
GLOCK_DRAW, |
||||
GLOCK_HOLSTER, |
||||
GLOCK_ADD_SILENCER |
||||
}; |
||||
|
||||
class CGlock2 : public CBasePlayerWeapon |
||||
{ |
||||
public: |
||||
void Spawn( void ); |
||||
void Precache( void ); |
||||
int iItemSlot( void ) { return 2; } |
||||
int GetItemInfo(ItemInfo *p); |
||||
|
||||
void PrimaryAttack( void ); |
||||
void SecondaryAttack( void ); |
||||
void GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ); |
||||
BOOL Deploy( void ); |
||||
void Reload( void ); |
||||
void WeaponIdle( void ); |
||||
|
||||
virtual BOOL UseDecrement( void ) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
private: |
||||
int m_iShell; |
||||
|
||||
unsigned short m_usFireGlock1; |
||||
unsigned short m_usFireGlock2; |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_glock2, CGlock2 ) |
||||
|
||||
void CGlock2::Spawn() |
||||
{ |
||||
pev->classname = MAKE_STRING( "weapon_glock2" ); // hack to allow for old names
|
||||
Precache(); |
||||
m_iId = WEAPON_GLOCK2; |
||||
SET_MODEL( ENT( pev ), "models/w_9mmhandgun.mdl" ); |
||||
|
||||
m_iDefaultAmmo = GLOCK_DEFAULT_GIVE; |
||||
|
||||
FallInit();// get ready to fall down.
|
||||
} |
||||
|
||||
void CGlock2::Precache( void ) |
||||
{ |
||||
PRECACHE_MODEL( "models/v_9mmhandgun.mdl" ); |
||||
PRECACHE_MODEL( "models/w_9mmhandgun.mdl" ); |
||||
PRECACHE_MODEL( "models/p_9mmhandgun.mdl" ); |
||||
|
||||
m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell
|
||||
|
||||
PRECACHE_SOUND( "items/9mmclip1.wav" ); |
||||
PRECACHE_SOUND( "items/9mmclip2.wav" ); |
||||
|
||||
PRECACHE_SOUND( "weapons/pl_gun1.wav" );//silenced handgun
|
||||
PRECACHE_SOUND( "weapons/pl_gun2.wav" );//silenced handgun
|
||||
PRECACHE_SOUND( "weapons/pl_gun3.wav" );//handgun
|
||||
|
||||
m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" ); |
||||
m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" ); |
||||
} |
||||
|
||||
int CGlock2::GetItemInfo( ItemInfo *p ) |
||||
{ |
||||
p->pszName = STRING( pev->classname ); |
||||
p->pszAmmo1 = "snipars"; |
||||
p->iMaxAmmo1 = _9MM_MAX_CARRY; |
||||
p->pszAmmo2 = NULL; |
||||
p->iMaxAmmo2 = -1; |
||||
p->iMaxClip = GLOCK_MAX_CLIP; |
||||
p->iSlot = 1; |
||||
p->iPosition = 2; |
||||
p->iFlags = 0; |
||||
p->iId = m_iId = WEAPON_GLOCK2; |
||||
p->iWeight = GLOCK_WEIGHT; |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
BOOL CGlock2::Deploy() |
||||
{ |
||||
// pev->body = 1;
|
||||
return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); |
||||
} |
||||
|
||||
void CGlock2::SecondaryAttack( void ) |
||||
{ |
||||
GlockFire( 0.1, 0.2, FALSE ); |
||||
} |
||||
|
||||
void CGlock2::PrimaryAttack( void ) |
||||
{ |
||||
GlockFire( 0.01, 0.3, TRUE ); |
||||
} |
||||
|
||||
void CGlock2::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) |
||||
{ |
||||
if( m_iClip <= 0 ) |
||||
{ |
||||
if( m_fFireOnEmpty ) |
||||
{ |
||||
PlayEmptySound(); |
||||
m_flNextPrimaryAttack = gpGlobals->time + 0.2; |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
m_iClip--; |
||||
|
||||
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; |
||||
|
||||
int flags; |
||||
#if defined( 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_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); |
||||
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 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 = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
||||
} |
||||
|
||||
void CGlock2::Reload( void ) |
||||
{ |
||||
if( m_pPlayer->ammo_snipars <= 0 ) |
||||
return; |
||||
|
||||
int iResult; |
||||
|
||||
if( m_iClip == 0 ) |
||||
iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 ); |
||||
else |
||||
iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); |
||||
|
||||
if( iResult ) |
||||
{ |
||||
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); |
||||
} |
||||
} |
||||
|
||||
void CGlock2::WeaponIdle( void ) |
||||
{ |
||||
ResetEmptySound(); |
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); |
||||
|
||||
if( m_flTimeWeaponIdle > gpGlobals->time ) |
||||
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.3 + 0 * 0.75 ) |
||||
{ |
||||
iAnim = GLOCK_IDLE3; |
||||
m_flTimeWeaponIdle = gpGlobals->time + 49.0 / 16; |
||||
} |
||||
else if( flRand <= 0.6 + 0 * 0.875 ) |
||||
{ |
||||
iAnim = GLOCK_IDLE1; |
||||
m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 16.0; |
||||
} |
||||
else |
||||
{ |
||||
iAnim = GLOCK_IDLE2; |
||||
m_flTimeWeaponIdle = gpGlobals->time + 40.0 / 16.0; |
||||
} |
||||
SendWeaponAnim( iAnim, 1 ); |
||||
} |
||||
} |
||||
|
||||
class CGlock2Ammo : public CBasePlayerAmmo |
||||
{ |
||||
void Spawn( void ) |
||||
{ |
||||
Precache(); |
||||
SET_MODEL( ENT( pev ), "models/w_9mmclip.mdl" ); |
||||
CBasePlayerAmmo::Spawn(); |
||||
} |
||||
|
||||
void Precache( void ) |
||||
{ |
||||
PRECACHE_MODEL( "models/w_9mmclip.mdl" ); |
||||
PRECACHE_SOUND( "items/9mmclip1.wav" ); |
||||
} |
||||
|
||||
BOOL AddAmmo( CBaseEntity *pOther ) |
||||
{ |
||||
if( pOther->GiveAmmo( AMMO_GLOCKCLIP_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_snipars, CGlock2Ammo ) |
@ -0,0 +1,280 @@
@@ -0,0 +1,280 @@
|
||||
/***
|
||||
Dicks |
||||
***/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "weapons.h" |
||||
#include "nodes.h" |
||||
#include "player.h" |
||||
#include "gamerules.h" |
||||
|
||||
#define CROWBAR_BODYHIT_VOLUME 128 |
||||
#define CROWBAR_WALLHIT_VOLUME 512 |
||||
|
||||
class CHammer : public CBasePlayerWeapon |
||||
{ |
||||
public: |
||||
void Spawn( void ); |
||||
void Precache( void ); |
||||
int iItemSlot( void ) { return 1; } |
||||
void EXPORT SwingAgain( void ); |
||||
void EXPORT Smack( void ); |
||||
int GetItemInfo(ItemInfo *p); |
||||
|
||||
void PrimaryAttack( void ); |
||||
int Swing( int fFirst ); |
||||
BOOL Deploy( void ); |
||||
void Holster( int skiplocal = 0 ); |
||||
int m_iSwing; |
||||
TraceResult m_trHit; |
||||
|
||||
virtual BOOL UseDecrement( void ) |
||||
{ |
||||
#if defined( CLIENT_WEAPONS ) |
||||
return TRUE; |
||||
#else |
||||
return FALSE; |
||||
#endif |
||||
} |
||||
private: |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_hammer, CHammer ) |
||||
|
||||
enum crowbar_e |
||||
{ |
||||
CROWBAR_IDLE = 0, |
||||
CROWBAR_DRAW, |
||||
CROWBAR_ATTACK |
||||
}; |
||||
|
||||
|
||||
void CHammer::Spawn( ) |
||||
{ |
||||
Precache(); |
||||
m_iId = WEAPON_HAMMER; |
||||
SET_MODEL( ENT( pev ), "models/w_hammer.mdl" ); |
||||
m_iClip = -1; |
||||
|
||||
FallInit();// get ready to fall down.
|
||||
} |
||||
|
||||
void CHammer::Precache( void ) |
||||
{ |
||||
PRECACHE_MODEL( "models/v_hammer.mdl" ); |
||||
PRECACHE_MODEL( "models/w_hammer.mdl" ); |
||||
PRECACHE_MODEL( "models/p_hammer.mdl" ); |
||||
PRECACHE_SOUND( "weapons/hammer_hit.wav" ); |
||||
PRECACHE_SOUND( "weapons/hammer_hitbod.wav" ); |
||||
} |
||||
|
||||
int CHammer::GetItemInfo( ItemInfo *p ) |
||||
{ |
||||
p->pszName = STRING( pev->classname ); |
||||
p->pszAmmo1 = NULL; |
||||
p->iMaxAmmo1 = -1; |
||||
p->pszAmmo2 = NULL; |
||||
p->iMaxAmmo2 = -1; |
||||
p->iMaxClip = WEAPON_NOCLIP; |
||||
p->iSlot = 0; |
||||
p->iPosition = 3; |
||||
p->iId = WEAPON_HAMMER; |
||||
p->iWeight = 10; |
||||
return 1; |
||||
} |
||||
|
||||
BOOL CHammer::Deploy() |
||||
{ |
||||
return DefaultDeploy( "models/v_hammer.mdl", "models/p_hammer.mdl", CROWBAR_DRAW, "hammer" ); |
||||
} |
||||
|
||||
void CHammer::Holster( int skiplocal /* = 0 */ ) |
||||
{ |
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; |
||||
} |
||||
|
||||
void FindHullIntersection69( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity ) |
||||
{ |
||||
int i, j, k; |
||||
float distance; |
||||
float *minmaxs[2] = {mins, maxs}; |
||||
TraceResult tmpTrace; |
||||
Vector vecHullEnd = tr.vecEndPos; |
||||
Vector vecEnd; |
||||
|
||||
distance = 1e6f; |
||||
|
||||
vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 ); |
||||
UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace ); |
||||
if( tmpTrace.flFraction < 1.0 ) |
||||
{ |
||||
tr = tmpTrace; |
||||
return; |
||||
} |
||||
|
||||
for( i = 0; i < 2; i++ ) |
||||
{ |
||||
for( j = 0; j < 2; j++ ) |
||||
{ |
||||
for( k = 0; k < 2; k++ ) |
||||
{ |
||||
vecEnd.x = vecHullEnd.x + minmaxs[i][0]; |
||||
vecEnd.y = vecHullEnd.y + minmaxs[j][1]; |
||||
vecEnd.z = vecHullEnd.z + minmaxs[k][2]; |
||||
|
||||
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace ); |
||||
if( tmpTrace.flFraction < 1.0 ) |
||||
{ |
||||
float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length(); |
||||
if( thisDistance < distance ) |
||||
{ |
||||
tr = tmpTrace; |
||||
distance = thisDistance; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void CHammer::PrimaryAttack() |
||||
{ |
||||
if( !Swing( 1 ) ) |
||||
{ |
||||
SetThink( &CCrowbar::SwingAgain ); |
||||
pev->nextthink = gpGlobals->time + 1; |
||||
} |
||||
} |
||||
|
||||
void CHammer::Smack() |
||||
{ |
||||
DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); |
||||
} |
||||
|
||||
void CHammer::SwingAgain( void ) |
||||
{ |
||||
Swing( 0 ); |
||||
} |
||||
|
||||
int CHammer::Swing( int fFirst ) |
||||
{ |
||||
int fDidHit = FALSE; |
||||
|
||||
TraceResult tr; |
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle ); |
||||
Vector vecSrc = m_pPlayer->GetGunPosition(); |
||||
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; |
||||
|
||||
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); |
||||
|
||||
#ifndef CLIENT_DLL |
||||
if( tr.flFraction >= 1.0 ) |
||||
{ |
||||
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr ); |
||||
if( tr.flFraction < 1.0 ) |
||||
{ |
||||
// Calculate the point of intersection of the line (or hull) and the object we hit
|
||||
// This is and approximation of the "best" intersection
|
||||
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); |
||||
if( !pHit || pHit->IsBSPModel() ) |
||||
FindHullIntersection69( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() ); |
||||
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
|
||||
} |
||||
} |
||||
#endif |
||||
// PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar,
|
||||
//0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
|
||||
// 0.0, 0, 0.0 );
|
||||
SendWeaponAnim( CROWBAR_ATTACK ); |
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; |
||||
pev->effects |= EF_MUZZLEFLASH; |
||||
if( tr.flFraction >= 1.0 ) |
||||
{ |
||||
if( fFirst ) |
||||
{ |
||||
// miss
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; |
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
SendWeaponAnim( CROWBAR_ATTACK); |
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); |
||||
|
||||
#ifndef CLIENT_DLL |
||||
// hit
|
||||
fDidHit = TRUE; |
||||
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); |
||||
|
||||
ClearMultiDamage(); |
||||
|
||||
if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) |
||||
{ |
||||
// first swing does full damage
|
||||
pEntity->TraceAttack( m_pPlayer->pev, 50, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_ALWAYSGIB ); |
||||
} |
||||
else |
||||
{ |
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack( m_pPlayer->pev, 50, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_ALWAYSGIB ); |
||||
} |
||||
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); |
||||
|
||||
// play thwack, smack, or dong sound
|
||||
float flVol = 1.0; |
||||
int fHitWorld = TRUE; |
||||
|
||||
if( pEntity ) |
||||
{ |
||||
if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) |
||||
{ |
||||
// play thwack or smack sound
|
||||
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/hammer_hitbod.wav", 1, ATTN_NORM ); |
||||
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; |
||||
if( !pEntity->IsAlive() ) |
||||
return TRUE; |
||||
else |
||||
flVol = 0.1; |
||||
|
||||
fHitWorld = FALSE; |
||||
} |
||||
} |
||||
|
||||
// play texture hit sound
|
||||
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
|
||||
|
||||
if( fHitWorld ) |
||||
{ |
||||
float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR ); |
||||
|
||||
if( g_pGameRules->IsMultiplayer() ) |
||||
{ |
||||
// override the volume here, cause we don't play texture sounds in multiplayer,
|
||||
// and fvolbar is going to be 0 from the above call.
|
||||
|
||||
fvolbar = 1; |
||||
} |
||||
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/hammer_hit.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); |
||||
|
||||
// delay the decal a bit
|
||||
m_trHit = tr; |
||||
} |
||||
|
||||
m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; |
||||
#endif |
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; |
||||
|
||||
SetThink( &CCrowbar::Smack ); |
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.3; |
||||
} |
||||
return fDidHit; |
||||
} |
Loading…
Reference in new issue