Refactor and optimize events

This commit is contained in:
a1batross 2016-07-04 00:43:53 +06:00
parent c6d49140e1
commit 1cbb305ef8
38 changed files with 620 additions and 691 deletions

View File

@ -38,9 +38,9 @@
#include <assert.h>
extern float g_flRoundTime;
#include "pm_shared.h"
extern "C" char PM_FindTextureType( char *name );
extern float g_flRoundTime;
// play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the
// original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture.
@ -83,7 +83,7 @@ void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 )
{
int iSmokeSprite = gEngfuncs.pEventAPI->EV_FindModelIndex ("sprites/smoke.spr");
TEMPENTITY *pTemp = gEngfuncs.pEfxAPI->R_TempSprite( Vector( x, y, z ),
Vector( (int)gEngfuncs.pfnRandomLong( -100, 100 ), (int)gEngfuncs.pfnRandomLong( -100, 100 ), (int)gEngfuncs.pfnRandomLong( -100, 100 ) ),
Vector( (int)Com_RandomLong( -100, 100 ), (int)Com_RandomLong( -100, 100 ), (int)Com_RandomLong( -100, 100 ) ),
5, iSmokeSprite, kRenderTransAlpha, kRenderFxNone, 1.0, 0.5, FTENT_FADEOUT | FTENT_PERSIST );
if(pTemp)
@ -91,7 +91,7 @@ void EV_HLDM_NewExplode( float x, float y, float z, float ScaleExplode1 )
pTemp->fadeSpeed = 0.6;
pTemp->entity.curstate.framerate = 1;
pTemp->entity.curstate.renderamt = 255;
int Color = gEngfuncs.pfnRandomLong( 0, 140 );
int Color = Com_RandomLong( 0, 140 );
pTemp->entity.curstate.rendercolor.r = Color;
pTemp->entity.curstate.rendercolor.g = Color;
pTemp->entity.curstate.rendercolor.b = Color;
@ -261,7 +261,7 @@ char EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *ve
}
// play material hit sound
gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[gEngfuncs.pfnRandomLong(0,cnt-1)], fvol, fattn, 0, 96 + gEngfuncs.pfnRandomLong(0,0xf) );
gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[Com_RandomLong(0,cnt-1)], fvol, fattn, 0, 96 + Com_RandomLong(0,0xf) );
return chTextureType;
}
@ -273,7 +273,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe )
if ( pe->classnumber == 1 )
{
idx = gEngfuncs.pfnRandomLong( 0, 2 );
idx = Com_RandomLong( 0, 2 );
sprintf( decalname, "{break%i", idx + 1 );
}
else if ( pe->rendermode != kRenderNormal )
@ -282,7 +282,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe )
}
else
{
idx = gEngfuncs.pfnRandomLong( 0, 4 );
idx = Com_RandomLong( 0, 4 );
sprintf( decalname, "{shot%i", idx + 1 );
}
return decalname;
@ -296,7 +296,7 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName, char chTextu
gEngfuncs.pEfxAPI->R_BulletImpactParticles( pTrace->endpos );
iRand = gEngfuncs.pfnRandomLong(0,0x7FFF);
iRand = Com_RandomLong(0,0x7FFF);
if ( iRand < (0x7fff/2) )// not every bullet makes a sound.
{
if( chTextureType == CHAR_TEX_VENT || chTextureType == CHAR_TEX_METAL )
@ -375,12 +375,12 @@ void EV_WallPuff_Wind( struct tempent_s *te, float frametime, float currenttime
else
te->entity.baseline.origin.y -= yWindMagnitude;
if ( !gEngfuncs.pfnRandomLong(0, 10) && yWindMagnitude > 3.0 )
if ( !Com_RandomLong(0, 10) && yWindMagnitude > 3.0 )
{
yWindMagnitude = 0;
yWindDirection = !yWindDirection;
}
if ( !gEngfuncs.pfnRandomLong(0, 10) && xWindMagnitude > 3.0 )
if ( !Com_RandomLong(0, 10) && xWindMagnitude > 3.0 )
{
xWindMagnitude = 0;
xWindDirection = !xWindDirection;
@ -432,7 +432,7 @@ void EV_HLDM_DecalGunshot(pmtrace_t *pTrace, int iBulletType, float scale, int r
dir.x = dir.x * dir.x * gEngfuncs.pfnRandomFloat( 4.0f, 12.0f );
dir.y = dir.y * dir.y * gEngfuncs.pfnRandomFloat( 4.0f, 12.0f );
dir.z = dir.z * dir.z * gEngfuncs.pfnRandomFloat( 4.0f, 12.0f );
gEngfuncs.pEfxAPI->R_StreakSplash( pTrace->endpos, dir, 4, gEngfuncs.pfnRandomLong( 5, 10 ), dir.z, -75.0f, 75.0f );
gEngfuncs.pEfxAPI->R_StreakSplash( pTrace->endpos, dir, 4, Com_RandomLong( 5, 10 ), dir.z, -75.0f, 75.0f );
}
if( gHUD.cl_weapon_wallpuff && gHUD.cl_weapon_wallpuff->value && bCreateWallPuff )
@ -442,7 +442,7 @@ void EV_HLDM_DecalGunshot(pmtrace_t *pTrace, int iBulletType, float scale, int r
{
char path[] = "sprites/wall_puff1.spr";
path[17] += gEngfuncs.pfnRandomLong(0, 3);
path[17] += Com_RandomLong(0, 3);
te = gEngfuncs.pEfxAPI->R_DefaultSprite( pTrace->endpos,
gEngfuncs.pEventAPI->EV_FindModelIndex(path), 30.0f );
}
@ -461,9 +461,9 @@ void EV_HLDM_DecalGunshot(pmtrace_t *pTrace, int iBulletType, float scale, int r
te->entity.curstate.rendercolor.r = r;
te->entity.curstate.rendercolor.g = g;
te->entity.curstate.rendercolor.b = b;
te->entity.curstate.renderamt = gEngfuncs.pfnRandomLong( 100, 180 );
te->entity.curstate.renderamt = Com_RandomLong( 100, 180 );
te->entity.curstate.scale = 0.5;
te->entity.baseline.origin = (25 + gEngfuncs.pfnRandomLong( 0, 4 ) ) * pTrace->plane.normal;
te->entity.baseline.origin = (25 + Com_RandomLong( 0, 4 ) ) * pTrace->plane.normal;
}
}
}
@ -473,13 +473,12 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo
{
int tracer = 0;
int i;
qboolean player = idx >= 1 && idx <= gEngfuncs.GetMaxClients() ? true : false;
if ( iTracerFreq != 0 && ( (*tracerCount)++ % iTracerFreq) == 0 )
{
vec3_t vecTracerSrc;
if ( player )
if ( EV_IsPlayer( idx ) )
{
vec3_t offset( 0, 0, -4 );
@ -720,54 +719,6 @@ void EV_HLDM_FireBullets(int idx,
}
void EV_TrainPitchAdjust( event_args_t *args )
{
int idx;
vec3_t origin;
unsigned short us_params;
int noise;
float m_flVolume;
int pitch;
int stop;
char sz[ 256 ];
idx = args->entindex;
VectorCopy( args->origin, origin );
us_params = (unsigned short)args->iparam1;
stop = args->bparam1;
m_flVolume = (float)(us_params & 0x003f)/40.0;
noise = (int)(((us_params) >> 12 ) & 0x0007);
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
switch ( noise )
{
case 1: strncpy( sz, "plats/ttrain1.wav", sizeof(sz)); break;
case 2: strncpy( sz, "plats/ttrain2.wav", sizeof(sz)); break;
case 3: strncpy( sz, "plats/ttrain3.wav", sizeof(sz)); break;
case 4: strncpy( sz, "plats/ttrain4.wav", sizeof(sz)); break;
case 5: strncpy( sz, "plats/ttrain6.wav", sizeof(sz)); break;
case 6: strncpy( sz, "plats/ttrain7.wav", sizeof(sz)); break;
default:
// no sound
strncpy( sz, "", sizeof(sz) );
return;
}
if ( stop )
{
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz );
}
else
{
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, 0, pitch );
}
}
void EV_CS16Client_KillEveryRound( TEMPENTITY *te, float frametime, float current_time )
{
if( g_flRoundTime > te->entity.curstate.fuser4 )

View File

@ -37,27 +37,31 @@ enum ak47_e
AK47_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/ak47-1.wav",
"weapons/ak47-2.wav"
};
void EV_FireAK47( event_args_t *args )
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2] );
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( args->entindex ) )
{
++g_iShotsFired;
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(AK47_SHOOT1, AK47_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(AK47_SHOOT1, AK47_SHOOT3), 2);
EV_MuzzleFlash();
if( !cl_righthand->value )
{
@ -74,21 +78,15 @@ void EV_FireAK47( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong(0, 1) ? "weapons/ak47-1.wav" : "weapons/ak47-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;
Vector vSpread( args->fparam1, args->fparam2, 0.0f );
int tracerCount;
vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
forward, right, up,
1, vecSrc, vecAiming,

View File

@ -36,30 +36,28 @@ enum aug_e
AUG_SHOOT3
};
static const char *SOUNDS_NAME = "weapons/aug-1.wav";
void EV_FireAUG( struct event_args_s *args )
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2] );
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( idx ) )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(AUG_SHOOT1, AUG_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(AUG_SHOOT1, AUG_SHOOT3), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 17.0, -8.0, -14.0, 0);
@ -74,13 +72,9 @@ void EV_FireAUG( struct event_args_s *args )
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/aug-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,22 +37,20 @@ enum awp_e
AWP_DRAW
};
static const char *SOUNDS_NAME = "weapons/awp1.wav";
void EV_FireAWP( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -60,21 +58,10 @@ void EV_FireAWP( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( gEngfuncs.pfnRandomLong(AWP_SHOOT1, AWP_SHOOT3), 2 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( Com_RandomLong(AWP_SHOOT1, AWP_SHOOT3), 2 );
}
#if defined(_CS16CLIENT_FIX_EVENT_ORIGIN)
else
{
cl_entity_t *ent = gEngfuncs.GetEntityByIndex(idx);
origin = ent->origin;
}
#endif
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/awp1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -27,6 +27,7 @@
*/
#include "events.h"
void EV_CreateExplo(event_args_s *args){
void EV_CreateExplo(event_args_s *args)
{
gEngfuncs.Con_DPrintf("^3 CREATE EXPLO EXPLO EXPLO EXPLO!!!111");
}

View File

@ -38,7 +38,7 @@ void EV_Smoke_FadeOut( struct tempent_s *te, float frametime, float currenttime
te->entity.curstate.renderamt = 255.0f - (currenttime - te->entity.curstate.fuser3) * te->entity.baseline.renderamt ;
if( te->entity.curstate.renderamt < 0 ) te->entity.curstate.renderamt = 0;
}
EV_CS16Client_KillEveryRound(te, frametime, currenttime );
EV_CS16Client_KillEveryRound( te, frametime, currenttime );
}
@ -70,21 +70,21 @@ void EV_CreateSmoke(event_args_s *args)
pTemp->entity.curstate.renderamt = 255;
pTemp->entity.curstate.rendermode = kRenderTransTexture;
pTemp->entity.curstate.rendercolor.r = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.rendercolor.g = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.rendercolor.b = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.rendercolor.r = Com_RandomLong(210, 230);
pTemp->entity.curstate.rendercolor.g = Com_RandomLong(210, 230);
pTemp->entity.curstate.rendercolor.b = Com_RandomLong(210, 230);
pTemp->entity.curstate.scale = 5.0f;
// make it move slowly
pTemp->entity.baseline.origin.x = gEngfuncs.pfnRandomLong(-5, 5);
pTemp->entity.baseline.origin.y = gEngfuncs.pfnRandomLong(-5, 5);
pTemp->entity.baseline.origin.x = Com_RandomLong(-5, 5);
pTemp->entity.baseline.origin.y = Com_RandomLong(-5, 5);
pTemp->entity.baseline.renderamt = 18;
}
}
}
else // second and other
{
pTemp = gEngfuncs.pEfxAPI->R_DefaultSprite( args->origin, gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/black_smoke4.spr" ), 6.0f );
pTemp = gEngfuncs.pEfxAPI->R_DefaultSprite( args->origin, g_iBlackSmoke, 6.0f );
if( pTemp )
{
@ -94,12 +94,12 @@ void EV_CreateSmoke(event_args_s *args)
pTemp->entity.curstate.rendermode = kRenderTransTexture;
pTemp->entity.curstate.renderfx = kRenderFxNone;
pTemp->entity.curstate.rendercolor.r = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.rendercolor.g = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.rendercolor.b = gEngfuncs.pfnRandomLong(210, 230);
pTemp->entity.curstate.renderamt = gEngfuncs.pfnRandomLong(180, 200);
pTemp->entity.curstate.rendercolor.r = Com_RandomLong(210, 230);
pTemp->entity.curstate.rendercolor.g = Com_RandomLong(210, 230);
pTemp->entity.curstate.rendercolor.b = Com_RandomLong(210, 230);
pTemp->entity.curstate.renderamt = Com_RandomLong(180, 200);
pTemp->entity.baseline.origin[0] = gEngfuncs.pfnRandomLong(10, 30);
pTemp->entity.baseline.origin[0] = Com_RandomLong(10, 30);
}
}
}

View File

@ -37,27 +37,27 @@ enum deagle_e
DEAGLE_DRAW
};
static const char *SOUNDS_NAME[] =
{
"weapons/deagle-1.wav",
"weapons/deagle-2.wav"
};
void EV_FireDEAGLE( 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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
vec3_t vecSrc;
int idx = args->entindex;
Vector origin( args->origin );
Vector velocity( args->velocity );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( idx ) )
@ -66,7 +66,7 @@ void EV_FireDEAGLE( event_args_t *args )
EV_MuzzleFlash();
if( args->bparam1 )
{
gEngfuncs.pEventAPI->EV_WeaponAnimation( gEngfuncs.pfnRandomLong(DEAGLE_SHOOT1, DEAGLE_SHOOT2), 2 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( Com_RandomLong(DEAGLE_SHOOT1, DEAGLE_SHOOT2), 2 );
}
else
{
@ -86,23 +86,16 @@ void EV_FireDEAGLE( event_args_t *args )
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong(0, 1) ? "weapons/deagle-1.wav" : "weapons/deagle-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;
Vector vSpread( args->fparam1, args->fparam2, 0.0f );
int tracerCount;
vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
forward, right, up,
1, vecSrc, vecAiming,
1, vecSrc, forward,
vSpread, 8192.0, BULLET_PLAYER_50AE, 0, &tracerCount,
2 );
}

View File

@ -47,24 +47,19 @@ enum elite_e
ELITE_DRAW
};
static const char *SOUNDS_NAME = "weapons/elite_fire.wav";
void EV_FireElite( event_args_s *args, int sequence )
{
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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles( args->angles );
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( idx ) )
@ -85,12 +80,9 @@ void EV_FireElite( event_args_s *args, int sequence )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/elite_fire.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
@ -107,10 +99,10 @@ void EV_FireElite( event_args_s *args, int sequence )
void EV_FireEliteLeft(event_args_s *args)
{
EV_FireElite( args, gEngfuncs.pfnRandomLong( ELITE_SHOOTLEFT1, ELITE_SHOOTLEFT4 ));
EV_FireElite( args, Com_RandomLong( ELITE_SHOOTLEFT1, ELITE_SHOOTLEFT4 ));
}
void EV_FireEliteRight( event_args_s *args )
{
EV_FireElite( args, gEngfuncs.pfnRandomLong( ELITE_SHOOTRIGHT1, ELITE_SHOOTRIGHT4 ));
EV_FireElite( args, Com_RandomLong( ELITE_SHOOTRIGHT1, ELITE_SHOOTRIGHT4 ));
}

View File

@ -37,25 +37,26 @@ enum famas_e
FAMAS_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/famas-1.wav", "weapons/famas-2.wav"
};
void EV_FireFAMAS( 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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = args->iparam1 / 10000000 + args->angles[0];
angles.y = args->iparam2 / 10000000 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 10000000.0f + args->angles[0],
args->iparam2 / 10000000.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -63,7 +64,7 @@ void EV_FireFAMAS( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(FAMAS_SHOOT1,FAMAS_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(FAMAS_SHOOT1,FAMAS_SHOOT3), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 17.0, -8.0, -14.0, 0);
@ -78,13 +79,9 @@ void EV_FireFAMAS( event_args_t *args )
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong( 0, 1) ? "weapons/famas-1.wav" : "weapons/famas-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,27 +37,24 @@ enum fiveseven_e
FIVESEVEN_DRAW
};
static const char *SOUNDS_NAME = "weapons/fiveseven-1.wav";
void EV_Fire57(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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -67,7 +64,7 @@ void EV_Fire57(event_args_t *args)
EV_MuzzleFlash();
if( args->bparam1 )
{
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(FIVESEVEN_SHOOT1, FIVESEVEN_SHOOT2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(FIVESEVEN_SHOOT1, FIVESEVEN_SHOOT2), 2);
}
else
{
@ -88,12 +85,10 @@ void EV_Fire57(event_args_t *args)
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/fiveseven-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -36,29 +36,28 @@ enum g3sg1_e
G3SG1_DRAW
};
static const char *SOUNDS_NAME = "weapons/g3sg1-1.wav";
void EV_FireG3SG1(event_args_s *args)
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( args->entindex ) )
{
++g_iShotsFired;
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(G3SG1_SHOOT, G3SG1_SHOOT2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(G3SG1_SHOOT, G3SG1_SHOOT2), 2);
EV_MuzzleFlash();
if( !cl_righthand->value )
{
@ -75,14 +74,9 @@ void EV_FireG3SG1(event_args_s *args)
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/g3sg1-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,27 +37,27 @@ enum galil_e
GALIL_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/galil-1.wav", "weapons/galil-2.wav"
};
void EV_FireGALIL( 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 up, right, forward;
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = args->iparam1 / 10000000 + args->angles[0];
angles.y = args->iparam2 / 10000000 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up );
@ -65,7 +65,7 @@ void EV_FireGALIL( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(GALIL_SHOOT1 + gEngfuncs.pfnRandomLong(0,2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(GALIL_SHOOT1 + Com_RandomLong(0,2), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -8.0, -10.0, 0);
@ -81,13 +81,9 @@ void EV_FireGALIL( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/galil-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong( 0, 1 )] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -59,26 +59,26 @@ enum glock18_shield_e
GLOCK18_SHIELD_DOWN
};
static const char *SOUNDS_NAME[] =
{
"weapons/glock18-1.wav", "weapons/glock18-2.wav"
};
void EV_Fireglock18( 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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -117,12 +117,10 @@ void EV_Fireglock18( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
(g_iWeaponFlags & WPNSTATE_GLOCK18_BURST_MODE) != 0 || g_bGlockBurstMode ? "weapons/glock18-1.wav": "weapons/glock18-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( (g_iWeaponFlags & WPNSTATE_GLOCK18_BURST_MODE) != 0 || g_bGlockBurstMode ? SOUNDS_NAME[0] : SOUNDS_NAME[1] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -39,24 +39,16 @@ enum knife_e
KNIFE_MIDSLASH2
};
static const char *SOUNDS_NAME = "weapons/knife_miss1.wav";
void EV_Knife( struct event_args_s *args )
{
int idx;
vec3_t origin;
idx = args->entindex;
VectorCopy( args->origin, origin );
int idx = args->entindex;
Vector origin( args->origin );
if( EV_IsLocal( idx ))
gEngfuncs.pEventAPI->EV_WeaponAnimation( args->iparam1, 2 );
#if defined(_CS16CLIENT_FIX_EVENT_ORIGIN)
else
{
cl_entity_t *ent = gEngfuncs.GetEntityByIndex(idx);
origin = ent->origin;
}
#endif
//Play Swing sound
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/knife_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM);
PLAY_EVENT_SOUND( SOUNDS_NAME );
}

View File

@ -36,29 +36,31 @@ enum m249_e
M249_DRAW
};
static const char *SOUNDS_NAME[] =
{
"weapons/m249-1.wav", "weapons/m249-2.wav"
};
void EV_FireM249(event_args_s *args)
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( args->entindex ) )
{
++g_iShotsFired;
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(M249_SHOOT1, M249_SHOOT2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(M249_SHOOT1, M249_SHOOT2), 2);
EV_MuzzleFlash();
if( !cl_righthand->value )
{
@ -75,14 +77,9 @@ void EV_FireM249(event_args_s *args)
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong(0, 1) ? "weapons/m249-1.wav" : "weapons/m249-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -38,20 +38,19 @@ enum m3_e
M3_DRAW
};
static const char *SOUNDS_NAME = "weapons/m3-1.wav";
void EV_FireM3( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -59,14 +58,10 @@ void EV_FireM3( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(M3_SHOOT1, M3_SHOOT2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(M3_SHOOT1, M3_SHOOT2), 2);
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/m3-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -45,26 +45,27 @@ enum m4a1_e
M4A1_DETACH_SILENCER
};
static const char *SOUNDS_NAME[] =
{
"weapons/m4a1-1.wav",
"weapons/m4a1_unsil-1.wav",
"weapons/m4a1_unsil-2.wav"
};
void EV_FireM4A1( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell, sequence;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
const char *szSoundName;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int sequence, idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -74,11 +75,11 @@ void EV_FireM4A1( event_args_t *args )
EV_MuzzleFlash();
if( args->bparam1 )
{
sequence = gEngfuncs.pfnRandomLong( M4A1_SHOOT1, M4A1_SHOOT3 );
sequence = Com_RandomLong( M4A1_SHOOT1, M4A1_SHOOT3 );
}
else
{
sequence = gEngfuncs.pfnRandomLong( M4A1_SHOOT1_UNSIL, M4A1_SHOOT3_UNSIL );
sequence = Com_RandomLong( M4A1_SHOOT1_UNSIL, M4A1_SHOOT3_UNSIL );
}
gEngfuncs.pEventAPI->EV_WeaponAnimation(sequence, 2);
if( !cl_righthand->value )
@ -96,21 +97,9 @@ void EV_FireM4A1( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
if( args->bparam1 )
{
szSoundName = "weapons/m4a1-1.wav";
}
else
{
szSoundName = gEngfuncs.pfnRandomLong( 0, 1) ? "weapons/m4a1_unsil-1.wav" : "weapons/m4a1_unsil-2.wav";
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
szSoundName,
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( args->bparam1 ? SOUNDS_NAME[0] : SOUNDS_NAME[Com_RandomLong( 1, 2 )]);
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,29 +37,28 @@ enum mac10_e
MAC10_SHOOT3
};
static const char *SOUNDS_NAME = "weapons/mac10-1.wav";
void EV_FireMAC10(event_args_s *args)
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( args->entindex ) )
{
++g_iShotsFired;
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(MAC10_SHOOT1, MAC10_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(MAC10_SHOOT1, MAC10_SHOOT3), 2);
EV_MuzzleFlash();
if( !cl_righthand->value )
{
@ -76,14 +75,9 @@ void EV_FireMAC10(event_args_s *args)
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/mac10-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,26 +37,26 @@ enum mp5n_e
MP5N_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/mp5-1.wav",
"weapons/mp5-2.wav"
};
void EV_FireMP5( 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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -64,7 +64,7 @@ void EV_FireMP5( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(MP5N_SHOOT1 + gEngfuncs.pfnRandomLong(0,2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(MP5N_SHOOT1 + Com_RandomLong(0,2), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 36.0, -10.0, -11.0, 0);
@ -80,13 +80,9 @@ void EV_FireMP5( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong( 0, 1 ) ? "weapons/mp5-1.wav" : "weapons/mp5-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -51,26 +51,22 @@ enum p228_shield_e
P228_SHIELD_DOWN
};
static const char *SOUNDS_NAME = "weapons/p228-1.wav";
void EV_FireP228(event_args_s *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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -82,9 +78,9 @@ void EV_FireP228(event_args_s *args)
if( args->bparam1 )
{
if( g_bHoldingShield )
seq = gEngfuncs.pfnRandomLong(P228_SHIELD_SHOOT1, P228_SHIELD_SHOOT2);
seq = Com_RandomLong(P228_SHIELD_SHOOT1, P228_SHIELD_SHOOT2);
else
seq = gEngfuncs.pfnRandomLong(P228_SHOOT1, P228_SHOOT3);
seq = Com_RandomLong(P228_SHOOT1, P228_SHOOT3);
}
else
{
@ -106,12 +102,9 @@ void EV_FireP228(event_args_s *args)
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/p228-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -36,29 +36,28 @@ enum p90_e
P90_SHOOT3
};
static const char *SOUNDS_NAME = "weapons/p90-1.wav";
void EV_FireP90(event_args_s *args)
{
vec3_t origin, angles, velocity;
vec3_t ShellVelocity, ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
int shell, idx;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
if ( EV_IsLocal( args->entindex ) )
{
++g_iShotsFired;
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(P90_SHOOT1, P90_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(P90_SHOOT1, P90_SHOOT3), 2);
EV_MuzzleFlash();
if( !cl_righthand->value )
{
@ -74,14 +73,9 @@ vec3_t origin, angles, velocity;
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/p90-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -36,21 +36,20 @@ enum scout_e
SCOUT_DRAW
};
static const char *SOUNDS_NAME = "weapons/scout_fire-1.wav";
void EV_FireScout(event_args_s *args)
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -58,21 +57,10 @@ void EV_FireScout(event_args_s *args)
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( gEngfuncs.pfnRandomLong(SCOUT_SHOOT, SCOUT_SHOOT2), 2 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( Com_RandomLong(SCOUT_SHOOT, SCOUT_SHOOT2), 2 );
}
#if defined(_CS16CLIENT_FIX_EVENT_ORIGIN)
else
{
cl_entity_t *ent = gEngfuncs.GetEntityByIndex(idx);
origin = ent->origin;
}
#endif
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/scout_fire-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -36,26 +36,22 @@ enum sg550_e
SG550_DRAW
};
static const char *SOUNDS_NAME = "weapons/sg550-1.wav";
void EV_FireSG550(event_args_s *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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -63,7 +59,7 @@ void EV_FireSG550(event_args_s *args)
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( gEngfuncs.pfnRandomLong(SG550_SHOOT, SG550_SHOOT2), 2 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( Com_RandomLong(SG550_SHOOT, SG550_SHOOT2), 2 );
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -8.0, -10.0, 0);
@ -78,13 +74,9 @@ void EV_FireSG550(event_args_s *args)
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/sg550-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );

View File

@ -37,26 +37,25 @@ enum sg552_e
SG552_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/sg552-1.wav", "weapons/sg552-2.wav"
};
void EV_FireSG552( 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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -64,7 +63,7 @@ void EV_FireSG552( event_args_t *args )
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(SG552_SHOOT1, SG552_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(SG552_SHOOT1, SG552_SHOOT3), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -8.0, -10.0, 0);
@ -79,13 +78,8 @@ void EV_FireSG552( event_args_t *args )
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/rshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong( 0, 1 ) ? "weapons/sg552-1.wav" : "weapons/sg552-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iRShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -37,26 +37,25 @@ enum tmp_e
TMP_SHOOT3
};
static const char *SOUNDS_NAME[] =
{
"weapons/tmp-1.wav", "weapons/tmp-2.wav"
};
void EV_FireTMP(event_args_s *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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -64,7 +63,7 @@ void EV_FireTMP(event_args_s *args)
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(TMP_SHOOT1, TMP_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(TMP_SHOOT1, TMP_SHOOT3), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 32.0, -6.0, -11.0, 0);
@ -79,12 +78,8 @@ void EV_FireTMP(event_args_s *args)
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
gEngfuncs.pfnRandomLong( 0, 1 ) ? "weapons/tmp-1.wav" : "weapons/tmp-2.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME[Com_RandomLong( 0, 1 )] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -37,26 +37,22 @@ enum ump45_e
UMP45_SHOOT3
};
static const char *SOUNDS_NAME = "weapons/ump45-1.wav";
void EV_FireUMP45(event_args_s *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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -64,7 +60,7 @@ void EV_FireUMP45(event_args_s *args)
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(UMP45_SHOOT1, UMP45_SHOOT3), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(UMP45_SHOOT1, UMP45_SHOOT3), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 34.0, -10.0, -11.0, 0);
@ -79,12 +75,8 @@ void EV_FireUMP45(event_args_s *args)
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/ump45-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -60,29 +60,29 @@ enum usp_shield_e
USP_SHIELD_DOWN
};
static const char *SOUNDS_NAME[] =
{
"weapons/usp1.wav",
"weapons/usp2.wav",
"weapons/usp_unsil-1.wav",
};
void EV_FireUSP( 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 up, right, forward;
const char *szSoundName;
idx = args->entindex;
bool silencer_on = !args->bparam2;
bool empty = !args->bparam1;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -93,20 +93,20 @@ void EV_FireUSP( event_args_t *args )
if( g_bHoldingShield )
{
if( !empty )
seq = gEngfuncs.pfnRandomLong(USP_SHIELD_SHOOT1, USP_SHIELD_SHOOT2);
seq = Com_RandomLong(USP_SHIELD_SHOOT1, USP_SHIELD_SHOOT2);
else seq = USP_SHIELD_SHOOT_EMPTY;
}
else if ( silencer_on )
{
if( !empty )
seq = gEngfuncs.pfnRandomLong(USP_UNSIL_SHOOT1, USP_UNSIL_SHOOT3);
seq = Com_RandomLong(USP_UNSIL_SHOOT1, USP_UNSIL_SHOOT3);
else seq = USP_UNSIL_SHOOT_EMPTY;
}
else
{
EV_MuzzleFlash();
if( !empty )
seq = gEngfuncs.pfnRandomLong(USP_SHOOT1, USP_SHOOT3);
seq = Com_RandomLong(USP_SHOOT1, USP_SHOOT3);
else seq = USP_SHOOT_EMPTY;
}
@ -128,22 +128,9 @@ void EV_FireUSP( event_args_t *args )
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/pshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
if( !silencer_on )
{
szSoundName = gEngfuncs.pfnRandomLong( 0, 1 ) ? "weapons/usp1.wav" : "weapons/usp2.wav";
}
else
{
szSoundName = "weapons/usp_unsil-1.wav";
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
szSoundName,
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
PLAY_EVENT_SOUND( silencer_on? SOUNDS_NAME[2] : SOUNDS_NAME[Com_RandomLong(0, 1)] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -29,50 +29,71 @@
#include <string.h>
static const char *SOUNDS_NAME[] =
{
"plats/vehicle1.wav",
"plats/vehicle2.wav",
"plats/vehicle3.wav",
"plats/vehicle4.wav",
"plats/vehicle6.wav",
"plats/vehicle7.wav"
};
static const char *SOUNDS_NAME_TRAIN[] =
{
"plats/ttrain1.wav",
"plats/ttrain2.wav",
"plats/ttrain3.wav",
"plats/ttrain4.wav",
"plats/ttrain6.wav",
"plats/ttrain7.wav"
};
void EV_Vehicle(event_args_s *args)
{
int idx;
vec3_t origin;
Vector origin(args->origin);
int idx = args->entindex;
unsigned short us_params = (unsigned short)args->iparam1;
int stop = args->bparam1;
float m_flVolume = (float)(us_params & 0x003f)/40.0;
int noise = (int)(((us_params) >> 12 ) & 0x0007);
int pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
unsigned short us_params;
int noise;
float m_flVolume;
int pitch;
int stop;
char sz[ 256 ];
idx = args->entindex;
VectorCopy( args->origin, origin );
us_params = (unsigned short)args->iparam1;
stop = args->bparam1;
m_flVolume = (float)(us_params & 0x003f)/40.0;
noise = (int)(((us_params) >> 12 ) & 0x0007);
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
switch ( noise )
{
case 1: strncpy( sz, "plats/vehicle1.wav", sizeof(sz)); break;
case 2: strncpy( sz, "plats/vehicle2.wav", sizeof(sz)); break;
case 3: strncpy( sz, "plats/vehicle3.wav", sizeof(sz)); break;
case 4: strncpy( sz, "plats/vehicle4.wav", sizeof(sz)); break;
case 5: strncpy( sz, "plats/vehicle6.wav", sizeof(sz)); break;
case 6: strncpy( sz, "plats/vehicle7.wav", sizeof(sz)); break;
default:
// no sound
strncpy( sz, "", sizeof(sz) );
if( noise < 0 || noise > 5 )
return;
}
if ( stop )
{
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz );
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, SOUNDS_NAME[noise] );
}
else
{
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, 0, pitch );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, SOUNDS_NAME[noise], m_flVolume, ATTN_NORM, 0, pitch );
}
}
void EV_TrainPitchAdjust( event_args_t *args )
{
Vector origin(args->origin);
int idx = args->entindex;
unsigned short us_params = (unsigned short)args->iparam1;
int stop = args->bparam1;
float m_flVolume = (float)(us_params & 0x003f)/40.0;
int noise = (int)(((us_params) >> 12 ) & 0x0007);
int pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
if( noise < 0 || noise > 5 )
return;
if ( stop )
{
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, SOUNDS_NAME_TRAIN[noise] );
}
else
{
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, SOUNDS_NAME_TRAIN[noise], m_flVolume, ATTN_NORM, 0, pitch );
}
}

View File

@ -38,26 +38,22 @@ enum xm1014_e
XM1014_DRAW
};
static const char *SOUNDS_NAME = "weapons/xm1014-1.wav";
void EV_FireXM1014(event_args_s *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 up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
angles.x = (long double)args->iparam1 / 100 + args->angles[0];
angles.y = (long double)args->iparam2 / 100 + args->angles[1];
angles.z = args->angles[2];
VectorCopy( args->velocity, velocity );
int idx = args->entindex;
Vector origin( args->origin );
Vector angles(
args->iparam1 / 100.0f + args->angles[0],
args->iparam2 / 100.0f + args->angles[1],
args->angles[2]
);
Vector velocity( args->velocity );
Vector forward, right, up;
AngleVectors( angles, forward, right, up );
@ -65,7 +61,7 @@ void EV_FireXM1014(event_args_s *args)
{
++g_iShotsFired;
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation(gEngfuncs.pfnRandomLong(XM1014_FIRE1, XM1014_FIRE2), 2);
gEngfuncs.pEventAPI->EV_WeaponAnimation(Com_RandomLong(XM1014_FIRE1, XM1014_FIRE2), 2);
if( !cl_righthand->value )
{
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 22.0, -9.0, -11.0, 0);
@ -80,12 +76,10 @@ void EV_FireXM1014(event_args_s *args)
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20.0, -12.0, 4.0, 0);
}
shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shotgunshell.mdl");
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL);
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON,
"weapons/xm1014-1.wav",
1, ATTN_NORM, 0,
94 + gEngfuncs.pfnRandomLong( 0, 0xf ) );
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iShotgunShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( SOUNDS_NAME );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

View File

@ -14,6 +14,8 @@
****/
#include "events.h"
int g_iRShell, g_iPShell, g_iBlackSmoke, g_iShotgunShell;
/*
======================
Game_HookEvents

View File

@ -89,6 +89,9 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
#define ClientCmd (*gEngfuncs.pfnClientCmd)
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
#define Com_RandomLong (*gEngfuncs.pfnRandomLong)
#define Com_RandomFloat (*gEngfuncs.pfnRandomFloat)
extern float color[3]; // hud.cpp
// Gets the height & width of a sprite, at the specified frame

View File

@ -70,7 +70,6 @@ extern int g_iFreezeTimeOver;
extern bool g_bHoldingShield;
extern bool g_bHoldingKnife;
extern int g_iPlayerFlags;
extern vec3_t g_vPlayerVelocity;
extern float g_flPlayerSpeed;
extern struct local_state_s *g_curstate;
extern struct local_state_s *g_finalstate;

View File

@ -53,18 +53,20 @@
#define ROLL 2
#endif
extern "C" char PM_FindTextureType( char *name );
void V_PunchAxis( int axis, float punch );
void VectorAngles( const float *forward, float *angles );
#define DECLARE_EVENT( x ) void EV_##x( struct event_args_s *args )
#define HOOK_EVENT( x, y ) gEngfuncs.pfnHookEvent( "events/" #x ".sc", EV_##y )
#define PLAY_EVENT_SOUND( x ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, (x), VOL_NORM, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 15 ) )
// enable it until fix isn't applied in Xash3D
//#define _CS16CLIENT_FIX_EVENT_ORIGIN
extern int g_iPShell;
extern int g_iRShell;
extern int g_iShotgunShell;
extern int g_iBlackSmoke;
extern "C"
{
DECLARE_EVENT(FireAK47);

View File

@ -9,6 +9,11 @@
#if !defined ( EVENTSCRIPTSH )
#define EVENTSCRIPTSH
#include "pmtrace.h"
#include "pm_shared.h"
#include "event_api.h"
#include "r_efx.h"
// defaults for clientinfo messages
#define DEFAULT_VIEWHEIGHT 28
#define VEC_DUCK_VIEW 12
@ -58,18 +63,90 @@
#define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31)
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) )
// Some of these are HL/TFC specific?
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype, int life = 2.5 );
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale, bool bReverseDirection = false );
qboolean EV_IsLocal( int idx );
qboolean EV_IsPlayer( int idx );
void EV_CreateTracer( float *start, float *end );
void CreateCorpse(Vector *p_vOrigin, Vector *p_vAngles, const char *pModel, float flAnimTime, int iSequence, int iBody);
struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void );
void EV_MuzzleFlash( void );
// Very simple and little functions that can be inlined
#endif // EVENTSCRIPTSH
/*
=================
EV_MuzzleFlash
Flag weapon/view model for muzzle flash
=================
*/
inline void EV_MuzzleFlash( void )
{
// Add muzzle flash to current weapon model
cl_entity_t *ent = gEngfuncs.GetViewModel();
if ( !ent )
return;
// Or in the muzzle flash
ent->curstate.effects |= EF_MUZZLEFLASH;
}
/*
=================
EV_CreateTracer
Creates a tracer effect
=================
*/
inline void EV_CreateTracer( float *start, float *end )
{
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
}
/*
=================
EV_IsPlayer
Is the entity's index in the player range?
=================
*/
inline bool EV_IsPlayer( int idx )
{
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
return true;
return false;
}
/*
=================
EV_IsLocal
Is the entity == the local player
=================
*/
inline bool EV_IsLocal( int idx )
{
// check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC )
return (g_iUser2 == idx);
else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
}
/*
=================
EV_EjectBrass
Bullet shell casings
=================
*/
inline void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype, float life = 2.5f )
{
Vector angles(0.0f, 0.0f, rotation);
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, angles, life, model, soundtype );
}
#endif // EVENTSCRIPTS_H

View File

@ -87,13 +87,12 @@
#define DMG_CONCUSS DMG_SONIC
typedef struct
struct DAMAGE_IMAGE
{
float fExpire;
float fBaseline;
int x, y;
} DAMAGE_IMAGE;
};
//
//-----------------------------------------------------
@ -115,19 +114,23 @@ public:
int m_iHealth;
int m_HUD_dmg_bio;
int m_HUD_cross;
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
//float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
float m_fAttack[4];
void GetPainColor( int &r, int &g, int &b );
float m_fFade;
private:
HSPRITE m_hSprite;
HSPRITE m_hDamage;
Vector2D m_vAttackPos[4];
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
float m_flTimeFlash;
int m_bitsDamage;
int DrawPain(float fTime);
int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits);
void DrawPain( float fTime );
void DrawDamage( float fTime );
void DrawHealthBar( float flTime );
void CalcDamageDirection( Vector vecFrom );
void UpdateTiles( float fTime, long bits );
void DrawPlayerLocation( void );
};

View File

@ -26,6 +26,9 @@
#define RGB_GREENISH 0x0000A000 //0,160,0
#define RGB_WHITE 0x00FFFFFF
#include <assert.h>
#include <string.h>
#include "wrect.h"
#include "cl_dll.h"
#include "ammo.h"
@ -33,6 +36,7 @@
#include "csprite.h"
#include "draw_util.h"
#define MIN_ALPHA 100
#define HUDELEM_ACTIVE 1
@ -55,6 +59,7 @@ extern cvar_t *cl_minmodels;
extern cvar_t *cl_min_t;
extern cvar_t *cl_min_ct;
extern const char *sPlayerModelFiles[];
extern wrect_t nullrc;
class CClientSprite;
@ -79,8 +84,10 @@ inline bool BIsValidCTModelIndex( int i )
return false;
}
#define HUD_ACTIVE 1
#define HUD_INTERMISSION 2
#define HUD_DRAW (1 << 0)
#define HUD_THINK (1 << 1)
#define HUD_ACTIVE (HUD_DRAW | HUD_THINK)
#define HUD_INTERMISSION (1 << 2)
#define MAX_PLAYER_NAME_LENGTH 32
@ -92,7 +99,6 @@ inline bool BIsValidCTModelIndex( int i )
class CHudBase
{
public:
int m_type;
int m_iFlags; // active, moving,
virtual ~CHudBase() {}
virtual int Init( void ) {return 0;}
@ -852,10 +858,36 @@ public:
int UpdateClientData( client_data_t *cdata, float time );
void AddHudElem(CHudBase *p);
float GetSensitivity();
HSPRITE GetSprite( int index );
wrect_t& GetSpriteRect( int index );
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
inline float GetSensitivity() { return m_flMouseSensitivity; }
inline HSPRITE GetSprite( int index )
{
assert( index >= -1 && index <= m_iSpriteCount );
return (index >= 0) ? m_rghSprites[index] : 0;
}
inline wrect_t& GetSpriteRect( int index )
{
assert( index >= -1 && index <= m_iSpriteCount );
return (index >= 0) ? m_rgrcRects[index]: nullrc;
}
// GetSpriteIndex()
// searches through the sprite list loaded from hud.txt for a name matching SpriteName
// returns an index into the gHUD.m_rghSprites[] array
// returns -1 if sprite not found
inline int GetSpriteIndex( const char *SpriteName )
{
// look through the loaded sprite name list for SpriteName
for ( int i = 0; i < m_iSpriteCount; i++ )
{
if ( strncmp( SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 )
return i;
}
return -1; // invalid sprite
}
inline short GetCharWidth ( unsigned char ch )
{
@ -883,6 +915,7 @@ public:
cvar_t *cl_predict;
cvar_t *cl_weapon_wallpuff;
cvar_t *cl_weapon_sparks;
cvar_t *zoom_sens_ratio;
HSPRITE m_hGasPuff;

View File

@ -31,7 +31,7 @@ enum BoneIndex
BONE_MAX,
};
typedef struct
struct client_anim_state_t
{
vec3_t origin;
vec3_t angles;
@ -51,7 +51,7 @@ typedef struct
byte blending[2];
latchedvars_t lv;
}client_anim_state_t;
};
class CGameStudioModelRenderer : public CStudioModelRenderer
{

View File

@ -106,6 +106,7 @@ public:
return Vec2;
}
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
inline bool IsNull(void) const { return !x && !y && !z; }
// Members
vec_t x, y, z;