@@ -19,6 +19,7 @@ GNU General Public License for more details.
1919#include " r_efx.h"
2020#include " event_api.h"
2121#include " event_args.h"
22+ #include " pm_defs.h"
2223
2324void GameEventUtils::EjectBrass (const Vector &origin, const Vector &angles, const Vector &velocity, int modelIndex, int soundType)
2425{
@@ -29,6 +30,32 @@ void GameEventUtils::EjectBrass(const Vector &origin, const Vector &angles, cons
2930 2.5 , modelIndex, soundType);
3031}
3132
33+ void GameEventUtils::FireBullet (int entIndex, const matrix3x3 &camera, const Vector &origin, const Vector &direction, int tracerFreq)
34+ {
35+ pmtrace_t tr;
36+ Vector endPos = origin + direction * 8196 .f ;
37+
38+ gEngfuncs .pEventAPI ->EV_SetUpPlayerPrediction (false , true );
39+ gEngfuncs .pEventAPI ->EV_PushPMStates ();
40+ gEngfuncs .pEventAPI ->EV_SetSolidPlayers (entIndex - 1 );
41+ gEngfuncs .pEventAPI ->EV_SetTraceHull (2 ); // 2 is a point hull
42+ gEngfuncs .pEventAPI ->EV_PlayerTrace (const_cast <float *>(&origin.x ), endPos, PM_NORMAL, -1 , &tr);
43+ CreateTracer (camera, origin, tr.endpos , tracerFreq);
44+ gEngfuncs .pEventAPI ->EV_PopPMStates ();
45+ }
46+
47+ void GameEventUtils::CreateTracer (const matrix3x3 &camera, const Vector &origin, const Vector &end, int frequency)
48+ {
49+ static int32_t count = 0 ;
50+ if (count % frequency == 0 )
51+ {
52+ const Vector offset = Vector (0 .f , 0 .f , -4 .f );
53+ Vector startPos = origin + offset + camera.GetRight () * -6 .f + camera.GetForward () * 10 .f ;
54+ gEngfuncs .pEfxAPI ->R_TracerEffect (startPos, const_cast <float *>(&end.x ));
55+ }
56+ count++;
57+ }
58+
3259void GameEventUtils::SpawnMuzzleflash ()
3360{
3461 cl_entity_t *ent = gEngfuncs .GetViewModel ();
0 commit comments