Browse Source

...

clcampaign
RAINBOW2000 8 years ago
parent
commit
3ecfd6c85a
  1. 18
      dlls/crowbar.cpp
  2. 642
      dlls/needle.cpp

18
dlls/crowbar.cpp

@ -156,19 +156,19 @@ void CCrowbar::SecondaryAttack( void )
switch( RANDOM_LONG( 0, 3 ) ) switch( RANDOM_LONG( 0, 3 ) )
{ {
case 0: case 0:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt1.wav", 1, ATTN_NORM ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
break; break;
case 1: case 1:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt2.wav", 1, ATTN_NORM ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt2.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
break; break;
case 2: case 2:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt3.wav", 1, ATTN_NORM ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
break; break;
case 3: case 3:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt4.wav", 1, ATTN_NORM ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
break; break;
}; };
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2;
} }
void CCrowbar::Smack() void CCrowbar::Smack()

642
dlls/needle.cpp

@ -1,321 +1,321 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "nodes.h" #include "nodes.h"
#include "player.h" #include "player.h"
#include "gamerules.h" #include "gamerules.h"
#define NEEDLE_BODYHIT_VOLUME 128 #define NEEDLE_BODYHIT_VOLUME 128
#define NEEDLE_WALLHIT_VOLUME 512 #define NEEDLE_WALLHIT_VOLUME 512
class CNeedle : public CBasePlayerWeapon class CNeedle : public CBasePlayerWeapon
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int iItemSlot( void ) { return 1; } int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void ); void EXPORT SwingAgain( void );
void EXPORT Smack( void ); void EXPORT Smack( void );
int GetItemInfo(ItemInfo *p); int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void ); void PrimaryAttack( void );
int Swing( int fFirst ); int Swing( int fFirst );
BOOL Deploy( void ); BOOL Deploy( void );
void Holster( int skiplocal = 0 ); void Holster( int skiplocal = 0 );
int m_iSwing; int m_iSwing;
TraceResult m_trHit; TraceResult m_trHit;
virtual BOOL UseDecrement( void ) virtual BOOL UseDecrement( void )
{ {
return FALSE; return FALSE;
} }
private: private:
unsigned short m_usNeedle; unsigned short m_usNeedle;
}; };
LINK_ENTITY_TO_CLASS( weapon_needle, CNeedle ) LINK_ENTITY_TO_CLASS( weapon_needle, CNeedle )
enum needle_e enum needle_e
{ {
NEEDLE_IDLE1, NEEDLE_IDLE1,
NEEDLE_GIVESHOT, NEEDLE_GIVESHOT,
NEEDLE_DRAW NEEDLE_DRAW
}; };
void CNeedle::Spawn( ) void CNeedle::Spawn( )
{ {
Precache(); Precache();
m_iId = WEAPON_NEEDLE; m_iId = WEAPON_NEEDLE;
SET_MODEL( ENT( pev ), "models/w_needle.mdl" ); SET_MODEL( ENT( pev ), "models/w_needle.mdl" );
m_iClip = -1; m_iClip = -1;
FallInit();// get ready to fall down. FallInit();// get ready to fall down.
} }
void CNeedle::Precache( void ) void CNeedle::Precache( void )
{ {
PRECACHE_MODEL( "models/v_needle.mdl" ); PRECACHE_MODEL( "models/v_needle.mdl" );
PRECACHE_MODEL( "models/w_needle.mdl" ); PRECACHE_MODEL( "models/w_needle.mdl" );
PRECACHE_MODEL( "models/p_needle.mdl" ); PRECACHE_MODEL( "models/p_needle.mdl" );
PRECACHE_SOUND( "weapons/needleshot.wav" ); PRECACHE_SOUND( "weapons/needleshot.wav" );
m_usNeedle = PRECACHE_EVENT( 1, "events/crowbar.sc" ); m_usNeedle = PRECACHE_EVENT( 1, "events/crowbar.sc" );
} }
int CNeedle::GetItemInfo( ItemInfo *p ) int CNeedle::GetItemInfo( ItemInfo *p )
{ {
p->pszName = STRING( pev->classname ); p->pszName = STRING( pev->classname );
p->pszAmmo1 = NULL; p->pszAmmo1 = NULL;
p->iMaxAmmo1 = -1; p->iMaxAmmo1 = -1;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP; p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 0; p->iSlot = 0;
p->iPosition = 2; p->iPosition = 2;
p->iId = WEAPON_NEEDLE; p->iId = WEAPON_NEEDLE;
p->iWeight = CROWBAR_WEIGHT; p->iWeight = CROWBAR_WEIGHT;
return 1; return 1;
} }
BOOL CNeedle::Deploy() BOOL CNeedle::Deploy()
{ {
return DefaultDeploy( "models/v_needle.mdl", "models/p_needle.mdl", NEEDLE_DRAW, "needle" ); return DefaultDeploy( "models/v_needle.mdl", "models/p_needle.mdl", NEEDLE_DRAW, "needle" );
} }
void CNeedle::Holster( int skiplocal /* = 0 */ ) void CNeedle::Holster( int skiplocal /* = 0 */ )
{ {
m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5; m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5;
SendWeaponAnim( NEEDLE_IDLE1 ); SendWeaponAnim( NEEDLE_IDLE1 );
} }
void CNeedle::PrimaryAttack() void CNeedle::PrimaryAttack()
{ {
SendWeaponAnim( NEEDLE_GIVESHOT ); SendWeaponAnim( NEEDLE_GIVESHOT );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/needleshot.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/needleshot.wav", 1, ATTN_NORM ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 3;
} }
void CNeedle::Smack() void CNeedle::Smack()
{ {
DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR );
} }
void CNeedle::SwingAgain( void ) void CNeedle::SwingAgain( void )
{ {
Swing( 0 ); Swing( 0 );
} }
void FindHullIntersection2( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity ) void FindHullIntersection2( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
{ {
int i, j, k; int i, j, k;
float distance; float distance;
float *minmaxs[2] = {mins, maxs}; float *minmaxs[2] = {mins, maxs};
TraceResult tmpTrace; TraceResult tmpTrace;
Vector vecHullEnd = tr.vecEndPos; Vector vecHullEnd = tr.vecEndPos;
Vector vecEnd; Vector vecEnd;
distance = 1e6f; distance = 1e6f;
vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 ); vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 );
UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace ); UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if( tmpTrace.flFraction < 1.0 ) if( tmpTrace.flFraction < 1.0 )
{ {
tr = tmpTrace; tr = tmpTrace;
return; return;
} }
for( i = 0; i < 2; i++ ) for( i = 0; i < 2; i++ )
{ {
for( j = 0; j < 2; j++ ) for( j = 0; j < 2; j++ )
{ {
for( k = 0; k < 2; k++ ) for( k = 0; k < 2; k++ )
{ {
vecEnd.x = vecHullEnd.x + minmaxs[i][0]; vecEnd.x = vecHullEnd.x + minmaxs[i][0];
vecEnd.y = vecHullEnd.y + minmaxs[j][1]; vecEnd.y = vecHullEnd.y + minmaxs[j][1];
vecEnd.z = vecHullEnd.z + minmaxs[k][2]; vecEnd.z = vecHullEnd.z + minmaxs[k][2];
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace ); UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if( tmpTrace.flFraction < 1.0 ) if( tmpTrace.flFraction < 1.0 )
{ {
float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length(); float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length();
if( thisDistance < distance ) if( thisDistance < distance )
{ {
tr = tmpTrace; tr = tmpTrace;
distance = thisDistance; distance = thisDistance;
} }
} }
} }
} }
} }
} }
int CNeedle::Swing( int fFirst ) int CNeedle::Swing( int fFirst )
{ {
int fDidHit = FALSE; int fDidHit = FALSE;
TraceResult tr; TraceResult tr;
UTIL_MakeVectors( m_pPlayer->pev->v_angle ); UTIL_MakeVectors( m_pPlayer->pev->v_angle );
Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
if( tr.flFraction >= 1.0 ) if( tr.flFraction >= 1.0 )
{ {
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr ); UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if( tr.flFraction < 1.0 ) if( tr.flFraction < 1.0 )
{ {
// Calculate the point of intersection of the line (or hull) and the object we hit // Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection // This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
if( !pHit || pHit->IsBSPModel() ) if( !pHit || pHit->IsBSPModel() )
FindHullIntersection2( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() ); FindHullIntersection2( 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) vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
} }
} }
#endif #endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usNeedle, PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usNeedle,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
0.0, 0, 0.0 ); 0.0, 0, 0.0 );
if( tr.flFraction >= 1.0 ) if( tr.flFraction >= 1.0 )
{ {
if( fFirst ) if( fFirst )
{ {
// miss // miss
m_flNextPrimaryAttack = gpGlobals->time + 0.5; m_flNextPrimaryAttack = gpGlobals->time + 0.5;
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
} }
} }
else else
{ {
switch( ( ( m_iSwing++ ) % 2 ) + 1 ) switch( ( ( m_iSwing++ ) % 2 ) + 1 )
{ {
case 0: case 0:
SendWeaponAnim( NEEDLE_IDLE1 ); SendWeaponAnim( NEEDLE_IDLE1 );
break; break;
case 1: case 1:
SendWeaponAnim( NEEDLE_IDLE1 ); SendWeaponAnim( NEEDLE_IDLE1 );
break; break;
case 2: case 2:
SendWeaponAnim( NEEDLE_IDLE1 ); SendWeaponAnim( NEEDLE_IDLE1 );
break; break;
} }
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
// hit // hit
fDidHit = TRUE; fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
ClearMultiDamage(); ClearMultiDamage();
if( ( m_flNextPrimaryAttack + 1 < gpGlobals->time ) || g_pGameRules->IsMultiplayer() ) if( ( m_flNextPrimaryAttack + 1 < gpGlobals->time ) || g_pGameRules->IsMultiplayer() )
{ {
// first swing does full damage // first swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
} }
else else
{ {
// subsequent swings do half // subsequent swings do half
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB );
} }
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
// play thwack, smack, or dong sound // play thwack, smack, or dong sound
float flVol = 1.0; float flVol = 1.0;
int fHitWorld = TRUE; int fHitWorld = TRUE;
if( pEntity ) if( pEntity )
{ {
if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{ {
// play thwack or smack sound // play thwack or smack sound
switch( RANDOM_LONG( 0, 2 ) ) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: case 0:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM );
break; break;
case 1: case 1:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM );
break; break;
case 2: case 2:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM );
break; break;
} }
m_pPlayer->m_iWeaponVolume = NEEDLE_BODYHIT_VOLUME; m_pPlayer->m_iWeaponVolume = NEEDLE_BODYHIT_VOLUME;
if( !pEntity->IsAlive() ) if( !pEntity->IsAlive() )
return TRUE; return TRUE;
else else
flVol = 0.1; flVol = 0.1;
fHitWorld = FALSE; fHitWorld = FALSE;
} }
} }
// play texture hit sound // play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if( fHitWorld ) if( fHitWorld )
{ {
float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR ); float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR );
if( g_pGameRules->IsMultiplayer() ) if( g_pGameRules->IsMultiplayer() )
{ {
// override the volume here, cause we don't play texture sounds in multiplayer, // override the volume here, cause we don't play texture sounds in multiplayer,
// and fvolbar is going to be 0 from the above call. // and fvolbar is going to be 0 from the above call.
fvolbar = 1; fvolbar = 1;
} }
// also play crowbar strike // also play crowbar strike
switch( RANDOM_LONG( 0, 1 ) ) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break; break;
case 1: case 1:
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break; break;
} }
// delay the decal a bit // delay the decal a bit
m_trHit = tr; m_trHit = tr;
} }
m_pPlayer->m_iWeaponVolume = flVol * NEEDLE_WALLHIT_VOLUME; m_pPlayer->m_iWeaponVolume = flVol * NEEDLE_WALLHIT_VOLUME;
#endif #endif
m_flNextPrimaryAttack = gpGlobals->time + 0.25; m_flNextPrimaryAttack = gpGlobals->time + 0.25;
SetThink( &CNeedle::Smack ); SetThink( &CNeedle::Smack );
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
} }
return fDidHit; return fDidHit;
} }

Loading…
Cancel
Save