Browse Source

Simplify glock fire events (#231)

* Refactor EV_FireGlock2.

* Moved EV_FireGlock1 implementation to static function.
hl_urbicide
Marc-Antoine Lortie 3 years ago committed by GitHub
parent
commit
f43961e4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      cl_dll/ev_hldm.cpp

49
cl_dll/ev_hldm.cpp

@ -458,7 +458,8 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
//====================== //======================
// GLOCK START // GLOCK START
//====================== //======================
void EV_FireGlock1( event_args_t *args ) // Shared Glock fire implementation for EV_FireGlock1 and EV_FireGlock2.
static void EV_FireGlock_Impl( event_args_t *args )
{ {
int idx; int idx;
vec3_t origin; vec3_t origin;
@ -503,50 +504,14 @@ void EV_FireGlock1( event_args_t *args )
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
} }
void EV_FireGlock2( event_args_t *args ) void EV_FireGlock1( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell;
vec3_t vecSrc, vecAiming;
//vec3_t vecSpread;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
int empty = args->bparam1;
AngleVectors( angles, forward, right, up );
shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell
if( EV_IsLocal( idx ) )
{ {
// Add muzzle flash to current weapon model EV_FireGlock_Impl( args );
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 );
V_PunchAxis( 0, -2.0 );
} }
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); void EV_FireGlock2( event_args_t *args )
{
EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); EV_FireGlock_Impl( args );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
} }
//====================== //======================
// GLOCK END // GLOCK END

Loading…
Cancel
Save