This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/client/global/ev_common.cpp

152 lines
3.5 KiB
C++
Raw Normal View History

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"
#include "effects_api.h"
extern "C"
{
void EV_EjectBrass( event_args_t *args );
void EV_FireNull( event_args_t *args );
}
//======================
// Game_HookEvents
//======================
void EV_HookEvents( void )
{
2009-12-05 22:00:00 +01:00
g_engfuncs.pEventAPI->EV_HookEvent( "evEjectBrass", EV_EjectBrass );
2009-12-02 22:00:00 +01:00
}
//=================
// EV_CreateTracer
//=================
void EV_CreateTracer( float *start, float *end )
{
2010-02-24 22:00:00 +01:00
g_engfuncs.pEfxAPI->R_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-02-23 22:00:00 +01:00
g_engfuncs.pEfxAPI->R_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;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
}
}
//=================
// EV_MuzzleFlash
//=================
void EV_MuzzleFlash( void )
{
// Add muzzle flash to current weapon model
2010-02-23 22:00:00 +01:00
edict_t *ent = GetViewModel();
if ( !ent ) return;
2009-12-02 22:00:00 +01:00
// Or in the muzzle flash
2010-02-23 22:00:00 +01:00
ent->v.effects |= EF_MUZZLEFLASH;
2009-12-02 22:00:00 +01:00
}
2009-12-05 22:00:00 +01:00
void HUD_CmdStart( const edict_t *player, int runfuncs )
{
}
void HUD_CmdEnd( const edict_t *player, const usercmd_t *cmd, unsigned int random_seed )
{
}