Add weapon_vorti implementation.

This commit is contained in:
Night Owl 2017-12-10 01:11:23 +05:00
parent 9b26af3b3c
commit cb2f25eaf8
8 changed files with 859 additions and 0 deletions

View File

@ -44,6 +44,7 @@ set (CLDLL_SOURCES
../dlls/tripmine.cpp
../dlls/glock.cpp
../dlls/decay/displacer.cpp
../dlls/decay/vortihands.cpp
ev_hldm.cpp
hl/hl_baseentity.cpp
hl/hl_events.cpp

View File

@ -68,6 +68,9 @@ void EV_EgonStop( struct event_args_s *args );
void EV_HornetGunFire( struct event_args_s *args );
void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args );
void EV_VortiHands( struct event_args_s *args );
void EV_VortiSpin( struct event_args_s *args );
void EV_VortiFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args );
}
@ -1690,6 +1693,225 @@ void EV_SnarkFire( event_args_t *args )
// SQUEAK END
//======================
//======================
// VORTIHANDS START
//======================
enum vortihands_e
{
VORTIHANDS_IDLE1 = 0,
VORTIHANDS_IDLE2,
VORTIHANDS_ATTACK1HIT,
VORTIHANDS_ATTACK1MISS,
VORTIHANDS_ATTACK2MISS,
VORTIHANDS_ATTACK2HIT,
VORTIHANDS_ATTACK3MISS,
VORTIHANDS_ATTACK3HIT,
VORTIHANDS_CHARGE,
VORTIHANDS_CHARGE_LOOP,
VORTIHANDS_ZAP,
VORTIHANDS_RETURN
};
//Only predict the miss sounds, hit sounds are still played
//server side, so players don't get the wrong idea.
void EV_VortiHands( event_args_t *args )
{
int idx, iAnim;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
idx = args->entindex;
VectorCopy( args->origin, origin );
//Play Swing sound
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "zombie/claw_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM );
if( EV_IsLocal( idx ) )
{
switch( (g_iSwing++) % 3 )
{
case 0:
iAnim = VORTIHANDS_ATTACK1MISS;
break;
case 1:
iAnim = VORTIHANDS_ATTACK2MISS;
break;
case 2:
iAnim = VORTIHANDS_ATTACK3MISS;
break;
}
gEngfuncs.pEventAPI->EV_WeaponAnimation( iAnim, 1 );
}
}
void EV_VortiSpin( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
int iSoundState = 0;
int pitch;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
pitch = args->iparam1;
iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0;
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "debris/zap1.wav", 1.0, ATTN_NORM, iSoundState, pitch );
}
/*
==============================
EV_StopPreviousGauss
==============================
*/
void EV_StopPreviousVorti( int idx )
{
// Make sure we don't have a gauss spin event in the queue for this guy
gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/vortispin.sc" );
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "debris/zap1.wav" );
}
extern float g_flApplyVel;
void EV_VortiFire( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
float flDamage = args->fparam1;
//int primaryfire = args->bparam1;
//int m_fPrimaryFire = args->bparam1;
//int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
vec3_t vecSrc;
vec3_t vecDest;
//edict_t *pentIgnore;
pmtrace_t tr, beam_tr;
float flMaxFrac = 1.0;
//int nTotal = 0;
int fHasPunched = 0;
int fFirstBeam = 1;
int nMaxHits = 10;
physent_t *pEntity;
int m_iBeam, m_iGlow, m_iBalls;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
if( args->bparam2 )
{
EV_StopPreviousVorti( idx );
return;
}
//Con_Printf( "Firing gauss with %f\n", flDamage );
EV_GetGunPosition( args, vecSrc, origin );
m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/lgtning.spr" );
//m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" );
AngleVectors( angles, forward, right, up );
VectorMA( vecSrc, 8192, forward, vecDest );
if( EV_IsLocal( idx ) )
{
V_PunchAxis( 0, -2.0 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( VORTIHANDS_ZAP, 2 );
//if( m_fPrimaryFire == false )
// g_flApplyVel = flDamage;
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/electro4.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
while( flDamage > 10 && nMaxHits > 0 )
{
nMaxHits--;
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecDest, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PopPMStates();
if( tr.allsolid )
break;
if( EV_IsLocal( idx ) )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
}
//fFirstBeam = 0;
for( int i = 1; i < 3; i++ )
{
gEngfuncs.pEfxAPI->R_BeamEntPoint(
idx | ( i << 12 ),
tr.endpos,
m_iBeam,
0.3,
3.0,
0.5,
1.0,
55,
0,
0,
0.5,
1.0,
0
);
}
pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );
if( pEntity == NULL )
break;
if( pEntity->solid == SOLID_BSP )
{
// tunnel
EV_HLDM_DecalGunshot( &tr, BULLET_MONSTER_12MM );
//gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT );
// limit it to one hole punch
if( fHasPunched )
{
break;
}
fHasPunched = 1;
// try punching through wall if secondary attack (primary is incapable of breaking through)
//gEngfuncs.pEventAPI->EV_PopPMStates();
flDamage = 0;
}
else
VectorAdd( tr.endpos, forward, vecSrc );
}
}
//======================
// VORTIHANDS END
//======================
void EV_TrainPitchAdjust( event_args_t *args )
{
int idx;

View File

@ -38,6 +38,9 @@ void EV_EgonStop( struct event_args_s *args );
void EV_HornetGunFire( struct event_args_s *args );
void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args );
void EV_VortiHands( struct event_args_s *args );
void EV_VortiSpin( struct event_args_s *args );
void EV_VortiFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args );
}
@ -76,4 +79,7 @@ void Game_HookEvents( void )
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
gEngfuncs.pfnHookEvent( "events/vorti.sc", EV_VortiHands );
gEngfuncs.pfnHookEvent( "events/vortispin.sc", EV_VortiSpin );
gEngfuncs.pfnHookEvent( "events/vortifire.sc", EV_VortiFire );
}

View File

@ -68,6 +68,7 @@ CSatchel g_Satchel;
CTripmine g_Tripmine;
CSqueak g_Snark;
CDisplacer g_Displacer;
CVortiHands g_VortiHands;
/*
======================
@ -618,6 +619,7 @@ void HUD_InitClientWeapons( void )
HUD_PrepEntity( &g_Tripmine, &player );
HUD_PrepEntity( &g_Snark, &player );
HUD_PrepEntity( &g_Displacer, &player );
HUD_PrepEntity( &g_VortiHands, &player );
}
/*
@ -726,6 +728,9 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
case WEAPON_DISPLACER:
pWeapon = &g_Displacer;
break;
case WEAPON_VORTIHANDS:
pWeapon = &g_VortiHands;
break;
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it

View File

@ -132,6 +132,7 @@ set (SVDLL_SOURCES
bot/bot.cpp
bot/botcam.cpp
decay/displacer.cpp
decay/vortihands.cpp
../pm_shared/pm_debug.c
../pm_shared/pm_math.c
../pm_shared/pm_shared.c

569
dlls/decay/vortihands.cpp Normal file
View File

@ -0,0 +1,569 @@
/***
*
* 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.
*
****/
#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
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
extern int gmsgAlienState;
extern int g_irunninggausspred;
LINK_ENTITY_TO_CLASS( weapon_vorti, CVortiHands )
enum vortihands_e
{
VORTIHANDS_IDLE1 = 0,
VORTIHANDS_IDLE2,
VORTIHANDS_ATTACK1,
VORTIHANDS_ATTACK1MISS,
VORTIHANDS_ATTACK2,
VORTIHANDS_ATTACK2HIT,
VORTIHANDS_ATTACK3,
VORTIHANDS_ATTACK3HIT,
VORTIHANDS_CHARGE,
VORTIHANDS_CHARGE_LOOP,
VORTIHANDS_ZAP,
VORTIHANDS_RETURN
};
float CVortiHands::GetFullChargeTime( void )
{
return 3.0f;
}
void CVortiHands::Spawn()
{
Precache();
m_iId = WEAPON_VORTIHANDS;
SET_MODEL( ENT( pev ), "models/w_slave.mdl" );
m_iClip = -1;
FallInit();// get ready to fall down.
}
void CVortiHands::Precache( void )
{
PRECACHE_MODEL( "models/v_slave.mdl" );
PRECACHE_MODEL( "models/w_slave.mdl" );
PRECACHE_MODEL( "models/p_slave.mdl" );
PRECACHE_MODEL( "sprites/lgtning.spr" );
PRECACHE_SOUND( "debris/zap1.wav" );
PRECACHE_SOUND( "debris/zap4.wav" );
PRECACHE_SOUND( "zombie/claw_strike1.wav" );
PRECACHE_SOUND( "zombie/claw_strike2.wav" );
PRECACHE_SOUND( "zombie/claw_strike3.wav" );
PRECACHE_SOUND( "zombie/claw_miss1.wav" );
PRECACHE_SOUND( "zombie/claw_miss2.wav" );
PRECACHE_SOUND( "aslave/slv_word5.wav" );
PRECACHE_SOUND( "aslave/slv_word7.wav" );
PRECACHE_SOUND( "aslave/slv_word3.wav" );
PRECACHE_SOUND( "aslave/slv_word4.wav" );
m_usVorti = PRECACHE_EVENT( 1, "events/vorti.sc" );
m_usVortiFire = PRECACHE_EVENT( 1, "events/vortifire.sc" );
m_usVortiSpin = PRECACHE_EVENT( 1, "events/vortispin.sc" );
}
int CVortiHands::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 = 1;
p->iId = WEAPON_VORTIHANDS;
p->iWeight = VORTIHANDS_WEIGHT;
return 1;
}
int CVortiHands::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 CVortiHands::CrosshairState( int state )
{
#ifndef CLIENT_DLL
MESSAGE_BEGIN( MSG_ONE, gmsgAlienState, NULL, m_pPlayer->pev );
WRITE_BYTE( state );
MESSAGE_END();
#endif
}
BOOL CVortiHands::Deploy()
{
return DefaultDeploy( "models/v_slave.mdl", "models/p_slave.mdl", VORTIHANDS_IDLE1, "vortihands" );
}
void CVortiHands::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim( VORTIHANDS_IDLE1 );
}
extern void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity );
/*
void FindHullIntersection( 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 CVortiHands::PrimaryAttack()
{
m_fInAttack = 0;
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
CrosshairState( m_fInAttack );
if( !Swing( 1 ) )
{
#ifndef CLIENT_DLL
SetThink( &CVortiHands::SwingAgain );
pev->nextthink = gpGlobals->time + 0.1;
#endif
}
}
void CVortiHands::Smack()
{
DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR );
}
void CVortiHands::SwingAgain( void )
{
Swing( 0 );
}
int CVortiHands::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() )
FindHullIntersection( 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
if( fFirst )
{
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usVorti,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
0, 0, 0 );
}
if( tr.flFraction >= 1.0 )
{
if( fFirst )
{
// miss
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
}
else
{
switch( ( ( m_iSwing++ ) % 2 ) + 1 )
{
case 0:
SendWeaponAnim( VORTIHANDS_ATTACK1 );
break;
case 1:
SendWeaponAnim( VORTIHANDS_ATTACK2HIT );
break;
case 2:
SendWeaponAnim( VORTIHANDS_ATTACK3HIT );
break;
}
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL
// hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if( pEntity )
{
ClearMultiDamage();
// If building with the clientside weapon prediction system,
// UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making
// m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false.
#ifdef CLIENT_WEAPONS
if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
#else
if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
#endif
{
// first swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
}
else
{
// subsequent swings do half
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB );
}
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
// play thwack or smack sound
switch( RANDOM_LONG( 0, 2 ) )
{
case 0:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "zombie/claw_strike1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "zombie/claw_strike2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "zombie/claw_strike3.wav", 1, ATTN_NORM );
break;
}
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;
}
// also play crowbar strike
switch( RANDOM_LONG( 0, 1 ) )
{
case 0:
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "zombie/claw_miss1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break;
case 1:
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "zombie/claw_miss2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break;
}
// delay the decal a bit
m_trHit = tr;
}
m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME );
SetThink( &CVortiHands::Smack );
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
#endif
m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 );
}
return fDidHit;
}
void CVortiHands::SecondaryAttack()
{
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
if( m_fInAttack != 0 )
{
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) );
SendWeaponAnim( VORTIHANDS_IDLE1 );
m_fInAttack = 0;
}
else
{
PlayEmptySound();
}
m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );
return;
}
if( m_fInAttack == 0 )
{
// spin up
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
m_fInAttack = 1;
CrosshairState( m_fInAttack );
SendWeaponAnim( VORTIHANDS_CHARGE );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
m_pPlayer->m_flStartCharge = gpGlobals->time;
m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime();
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usVortiSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 );
m_iSoundState = SND_CHANGE_PITCH;
}
else if( m_fInAttack == 1 )
{
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
SendWeaponAnim( VORTIHANDS_CHARGE_LOOP );
m_fInAttack = 2;
CrosshairState( m_fInAttack );
}
}
else
{
int pitch = (int)( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100 );
if( pitch > 250 )
pitch = 250;
// ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch );
if( m_iSoundState == 0 )
ALERT( at_console, "sound state %d\n", m_iSoundState );
CrosshairState( 3 );
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usVortiSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 );
m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
// m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1;
if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 )
{
// Player charged up too long. Zap him.
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) );
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
CrosshairState( m_fInAttack );
SendWeaponAnim( VORTIHANDS_IDLE1 );
// 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 CVortiHands::StartFire( void )
{
float flDamage;
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecAiming = gpGlobals->v_forward;
Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
if( gpGlobals->time - m_pPlayer->m_flStartCharge < GetFullChargeTime() )
{
flDamage = 60;
}
else
{
flDamage = 60 * ( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) / GetFullChargeTime() );
}
if( m_fInAttack != 3 )
{
//ALERT( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage );
// 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.3, 0.8 );
Fire( vecSrc, vecAiming, flDamage );
}
void CVortiHands::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage )
{
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
TraceResult tr, beam_tr;
#ifndef CLIENT_DLL
Vector vecSrc = vecOrigSrc;
Vector vecDest = vecSrc + vecDir * 8192;
edict_t *pentIgnore;
float flMaxFrac = 1.0;
int nTotal = 0;
int fHasPunched = 0;
int fFirstBeam = 1;
int nMaxHits = 10;
pentIgnore = ENT( m_pPlayer->pev );
#else
g_irunninggausspred = true;
#endif
// The main firing event is sent unreliably so it won't be delayed.
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usVortiFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, 0, 0 );
// 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_usVortiFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );
/*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 );
#ifndef CLIENT_DLL
while( flDamage > 10 && nMaxHits > 0 )
{
nMaxHits--;
// ALERT( at_console, "." );
UTIL_TraceLine( vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr );
if( tr.fAllSolid )
break;
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
if( pEntity == NULL )
break;
if( fFirstBeam )
{
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
fFirstBeam = 0;
nTotal += 26;
}
if( pEntity->pev->takedamage )
{
ClearMultiDamage();
pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET );
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
}
vecSrc = tr.vecEndPos + vecDir;
pentIgnore = ENT( pEntity->pev );
}
#endif
// ALERT( at_console, "%d bytes\n", nTotal );
}
void CVortiHands::WeaponIdle( void )
{
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
if( m_fInAttack != 0 )
{
m_fInAttack = 0;
CrosshairState( m_fInAttack );
ALERT( at_console, "released right button!\n" );
StartFire();
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
}
}

View File

@ -1639,3 +1639,10 @@ TYPEDESCRIPTION CDisplacer::m_SaveData[] =
};
IMPLEMENT_SAVERESTORE( CDisplacer, CBasePlayerWeapon )
TYPEDESCRIPTION CVortiHands::m_SaveData[] =
{
DEFINE_FIELD( CVortiHands, m_fInAttack, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CVortiHands, CBasePlayerWeapon )

View File

@ -78,6 +78,7 @@ public:
#define WEAPON_SATCHEL 14
#define WEAPON_SNARK 15
#define WEAPON_DISPLACER 16
#define WEAPON_VORTIHANDS 17
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))
@ -103,6 +104,7 @@ public:
#define SATCHEL_WEIGHT -10
#define TRIPMINE_WEIGHT -10
#define DISPLACER_WEIGHT 20
#define VORTIHANDS_WEIGHT 0
// weapon clip/carry ammo capacities
#define URANIUM_MAX_CARRY 100
@ -1051,4 +1053,50 @@ private:
CBeam *m_pBeam[3];
int m_iFireMode;
};
class CVortiHands : public CBasePlayerWeapon
{
public:
#ifndef CLIENT_DLL
int Save( CSave &save );
int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
#endif
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void );
void EXPORT Smack( void );
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void CrosshairState( int state );
void PrimaryAttack( void );
void SecondaryAttack( void );
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
void WeaponIdle();
float GetFullChargeTime( void );
void StartFire( void );
void Fire( Vector vecOrigSrc, Vector vecDirShooting, float flDamage );
int m_iSwing;
int m_iSoundState;
TraceResult m_trHit;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usVorti;
unsigned short m_usVortiFire;
unsigned short m_usVortiSpin;
};
#endif // WEAPONS_H