2009-12-02 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2008 <20>
|
|
|
|
|
// ev_common.cpp - events common code
|
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "ev_hldm.h"
|
2010-03-14 22:00:00 +01:00
|
|
|
|
#include "r_tempents.h"
|
2010-08-06 22:00:00 +02:00
|
|
|
|
#include "ref_params.h"
|
|
|
|
|
|
|
|
|
|
extern ref_params_t *gpViewParams;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
void EV_EjectBrass( event_args_t *args );
|
|
|
|
|
void EV_FireNull( event_args_t *args );
|
2010-03-07 22:00:00 +01:00
|
|
|
|
void EV_FireCrowbar( event_args_t *args );
|
|
|
|
|
void EV_PlayEmptySound( event_args_t *args );
|
|
|
|
|
void EV_FireGlock1( event_args_t *args );
|
|
|
|
|
void EV_FireMP5( event_args_t *args );
|
|
|
|
|
void EV_FirePython( event_args_t *args );
|
|
|
|
|
void EV_FireGauss( event_args_t *args );
|
|
|
|
|
void EV_SpinGauss( event_args_t *args );
|
|
|
|
|
void EV_EgonFire( event_args_t *args );
|
|
|
|
|
void EV_EgonStop( event_args_t *args );
|
|
|
|
|
void EV_FireShotGunSingle( event_args_t *args );
|
|
|
|
|
void EV_FireShotGunDouble( event_args_t *args );
|
|
|
|
|
void EV_SnarkFire( event_args_t *args );
|
|
|
|
|
void EV_TrainPitchAdjust( event_args_t *args );
|
|
|
|
|
void EV_Decals( event_args_t *args );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================
|
|
|
|
|
// Game_HookEvents
|
|
|
|
|
//======================
|
|
|
|
|
void EV_HookEvents( void )
|
|
|
|
|
{
|
2010-06-28 22:00:00 +02:00
|
|
|
|
g_engfuncs.pfnHookEvent( "evEjectBrass", EV_EjectBrass );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evNull", EV_FireNull );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evCrowbar", EV_FireCrowbar );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evEmptySound", EV_PlayEmptySound );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evGlock1", EV_FireGlock1 );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evShotgun1", EV_FireShotGunSingle );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evShotgun2", EV_FireShotGunDouble );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evMP5", EV_FireMP5 );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evPython", EV_FirePython );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evGauss", EV_FireGauss );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evGaussSpin", EV_SpinGauss );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evEgonFire", EV_EgonFire );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evEgonStop", EV_EgonStop );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evTrain", EV_TrainPitchAdjust );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evSnarkFire", EV_SnarkFire );
|
|
|
|
|
g_engfuncs.pfnHookEvent( "evDecals", EV_Decals );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_CreateTracer
|
|
|
|
|
//=================
|
|
|
|
|
void EV_CreateTracer( float *start, float *end )
|
|
|
|
|
{
|
2010-03-14 22:00:00 +01:00
|
|
|
|
g_pTempEnts->TracerEffect( start, end );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_IsPlayer
|
|
|
|
|
//=================
|
|
|
|
|
int EV_IsPlayer( int idx )
|
|
|
|
|
{
|
|
|
|
|
if ( idx >= 1 && idx <= gpGlobals->maxClients )
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_IsLocal
|
|
|
|
|
//=================
|
|
|
|
|
int EV_IsLocal( int idx )
|
|
|
|
|
{
|
|
|
|
|
return g_engfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_GetGunPosition
|
|
|
|
|
//=================
|
|
|
|
|
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
|
|
|
|
{
|
2010-02-23 22:00:00 +01:00
|
|
|
|
int idx;
|
|
|
|
|
Vector view_ofs;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
idx = args->entindex;
|
|
|
|
|
|
2010-02-23 22:00:00 +01:00
|
|
|
|
view_ofs = Vector( 0, 0, 0 );
|
|
|
|
|
view_ofs.z = DEFAULT_VIEWHEIGHT;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
2010-02-23 22:00:00 +01:00
|
|
|
|
if ( EV_IsPlayer( idx ))
|
2009-12-02 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
// in spec mode use entity viewheigh, not own
|
|
|
|
|
if ( EV_IsLocal( idx ))
|
|
|
|
|
{
|
|
|
|
|
// Grab predicted result for local player
|
|
|
|
|
g_engfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
|
|
|
|
}
|
|
|
|
|
else if ( args->ducking == 1 )
|
|
|
|
|
{
|
|
|
|
|
view_ofs[2] = VEC_DUCK_VIEW;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-23 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
pos[0] = origin[0] + view_ofs.x;
|
|
|
|
|
pos[1] = origin[1] + view_ofs.y;
|
|
|
|
|
pos[2] = origin[2] + view_ofs.z;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_EjectBrass
|
|
|
|
|
//=================
|
|
|
|
|
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
|
|
|
|
{
|
2010-02-23 22:00:00 +01:00
|
|
|
|
Vector endpos = Vector( 0.0f, rotation, 0.0f );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
2010-03-14 22:00:00 +01:00
|
|
|
|
g_pTempEnts->TempModel( origin, velocity, endpos, RANDOM_LONG( 30, 50 ), model, soundtype );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_GetDefaultShellInfo
|
|
|
|
|
//=================
|
|
|
|
|
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
|
|
|
|
|
{
|
2010-02-23 22:00:00 +01:00
|
|
|
|
int idx;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
Vector view_ofs;
|
|
|
|
|
float fR, fU;
|
|
|
|
|
|
|
|
|
|
idx = args->entindex;
|
2010-02-23 22:00:00 +01:00
|
|
|
|
view_ofs = Vector( 0, 0, 0 );
|
|
|
|
|
view_ofs.z = DEFAULT_VIEWHEIGHT;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if ( EV_IsPlayer( idx ) )
|
|
|
|
|
{
|
|
|
|
|
if ( EV_IsLocal( idx ) )
|
|
|
|
|
{
|
|
|
|
|
g_engfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
|
|
|
|
}
|
|
|
|
|
else if ( args->ducking == 1 )
|
|
|
|
|
{
|
|
|
|
|
view_ofs[2] = VEC_DUCK_VIEW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-23 22:00:00 +01:00
|
|
|
|
fR = RANDOM_FLOAT( 50, 70 );
|
|
|
|
|
fU = RANDOM_FLOAT( 100, 150 );
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
2010-02-23 22:00:00 +01:00
|
|
|
|
for ( int i = 0; i < 3; i++ )
|
2009-12-02 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
|
2010-02-26 22:00:00 +01:00
|
|
|
|
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=================
|
|
|
|
|
// EV_MuzzleFlash
|
|
|
|
|
//=================
|
|
|
|
|
void EV_MuzzleFlash( void )
|
|
|
|
|
{
|
|
|
|
|
// Add muzzle flash to current weapon model
|
2010-08-07 22:00:00 +02:00
|
|
|
|
cl_entity_t *ent = GetViewModel();
|
2010-02-23 22:00:00 +01:00
|
|
|
|
if ( !ent ) return;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// Or in the muzzle flash
|
2010-08-07 22:00:00 +02:00
|
|
|
|
ent->curstate.effects |= EF_MUZZLEFLASH;
|
2009-12-02 22:00:00 +01:00
|
|
|
|
}
|
2009-12-05 22:00:00 +01:00
|
|
|
|
|
2010-03-15 22:00:00 +01:00
|
|
|
|
//=================
|
|
|
|
|
// EV_FlashLight
|
|
|
|
|
//=================
|
2010-08-07 22:00:00 +02:00
|
|
|
|
void EV_UpadteFlashlight( cl_entity_t *pEnt )
|
2010-03-15 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
Vector vecSrc, vecEnd, vecPos, forward;
|
|
|
|
|
float rgba[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
|
|
|
TraceResult tr;
|
|
|
|
|
|
2010-08-07 22:00:00 +02:00
|
|
|
|
if ( EV_IsLocal( pEnt->index ) )
|
2010-08-06 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// get the predicted angles
|
|
|
|
|
AngleVectors( gpViewParams->cl_viewangles, forward, NULL, NULL );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-08-07 22:00:00 +02:00
|
|
|
|
Vector v_angle;
|
|
|
|
|
|
|
|
|
|
// restore viewangles from angles
|
|
|
|
|
v_angle[PITCH] = -pEnt->angles[PITCH] * 3;
|
|
|
|
|
v_angle[YAW] = pEnt->angles[YAW];
|
|
|
|
|
v_angle[ROLL] = 0; // no roll
|
|
|
|
|
|
|
|
|
|
AngleVectors( v_angle, forward, NULL, NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector view_ofs = Vector( 0, 0, 0 );
|
|
|
|
|
view_ofs.z = DEFAULT_VIEWHEIGHT;
|
|
|
|
|
|
|
|
|
|
if ( EV_IsPlayer( pEnt->index ) )
|
|
|
|
|
{
|
|
|
|
|
if ( EV_IsLocal( pEnt->index ) )
|
|
|
|
|
{
|
|
|
|
|
g_engfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
|
|
|
|
}
|
|
|
|
|
else if ( pEnt->curstate.usehull == 1 ) // NOTE: needs changes in delta.lst
|
|
|
|
|
{
|
|
|
|
|
view_ofs[2] = VEC_DUCK_VIEW;
|
|
|
|
|
}
|
2010-08-06 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-07 22:00:00 +02:00
|
|
|
|
vecSrc = pEnt->origin + view_ofs;
|
2010-06-06 22:00:00 +02:00
|
|
|
|
vecEnd = vecSrc + forward * 512;
|
2010-03-15 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEnt, &tr );
|
|
|
|
|
|
|
|
|
|
if( tr.flFraction != 1.0f )
|
|
|
|
|
vecPos = tr.vecEndPos + (tr.vecPlaneNormal * -16.0f);
|
|
|
|
|
else vecPos = tr.vecEndPos;
|
|
|
|
|
|
|
|
|
|
// update flashlight endpos
|
2010-08-07 22:00:00 +02:00
|
|
|
|
dlight_t *dl = g_engfuncs.pEfxAPI->CL_AllocDLight( pEnt->index );
|
2010-06-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
dl->origin = vecPos;
|
|
|
|
|
dl->die = gpGlobals->time + 0.001f; // die on next frame
|
|
|
|
|
dl->color[0] = 255;
|
|
|
|
|
dl->color[1] = 255;
|
|
|
|
|
dl->color[2] = 255;
|
|
|
|
|
dl->radius = 96;
|
2010-03-15 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-07 22:00:00 +02:00
|
|
|
|
void HUD_CmdStart( const cl_entity_t *player, int runfuncs )
|
2009-12-05 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-07 22:00:00 +02:00
|
|
|
|
void HUD_CmdEnd( const cl_entity_t *player, const usercmd_t *cmd, unsigned int random_seed )
|
2009-12-05 22:00:00 +01:00
|
|
|
|
{
|
2010-03-07 22:00:00 +01:00
|
|
|
|
// Offset final origin by view_offset
|
|
|
|
|
if( cl_lw->integer )
|
|
|
|
|
{
|
2010-08-07 22:00:00 +02:00
|
|
|
|
previousorigin = gpViewParams->vieworg; // FIXME: probably this is not correct
|
2010-03-07 22:00:00 +01:00
|
|
|
|
}
|
2009-12-05 22:00:00 +01:00
|
|
|
|
}
|