@@ -121,6 +121,8 @@ void EV_FireM249(struct event_args_s* args);
121121void EV_SniperRifle (struct event_args_s * args);
122122void EV_Knife (struct event_args_s * args);
123123void EV_PenguinFire (event_args_t * args);
124+ void EV_RayTouch (particle_s* particle);
125+ void EV_FireRailgun (event_args_t * args);
124126
125127#ifdef _HALO
126128void EV_FireSMG (event_args_t * args);
@@ -1093,6 +1095,86 @@ void EV_FireBattleRifle(event_args_t* args)
10931095// BATTLERIFLE END
10941096// ======================
10951097
1098+ // ======================
1099+ // RAILGUN START
1100+ // ======================
1101+ void EV_RayTouch (particle_s* particle)
1102+ {
1103+ vec3_t start = particle->org - particle->vel .Normalize () * 32 ;
1104+ vec3_t end = particle->org + particle->vel .Normalize () * 32 ;
1105+
1106+ pmtrace_t tr;
1107+ gEngfuncs .pEventAPI ->EV_SetUpPlayerPrediction (false , true );
1108+ gEngfuncs .pEventAPI ->EV_PushPMStates ();
1109+ gEngfuncs .pEventAPI ->EV_SetSolidPlayers (-1 );
1110+ gEngfuncs .pEventAPI ->EV_SetTraceHull (2 );
1111+ gEngfuncs .pEventAPI ->EV_PlayerTrace (start, end, PM_STUDIO_BOX, -1 , &tr);
1112+
1113+ int idx;
1114+ char decalname[32 ];
1115+ physent_t * pe;
1116+
1117+ pe = gEngfuncs .pEventAPI ->EV_GetPhysent (tr.ent );
1118+ if (pe && (/* pev->solid == SOLID_BSP || */ pe->movetype == MOVETYPE_PUSHSTEP))
1119+ {
1120+ decalname[0 ] = ' \0 ' ;
1121+ idx = gEngfuncs .pfnRandomLong (0 , 4 );
1122+ sprintf (decalname, " {shot%i" , idx + 1 );
1123+ EV_HLDM_GunshotDecalTrace (&tr, decalname);
1124+
1125+ if (gEngfuncs .PM_PointContents (tr.endpos , NULL ) != CONTENTS_WATER)
1126+ gEngfuncs .pEfxAPI ->R_SparkShower (tr.endpos );
1127+ }
1128+
1129+ gEngfuncs .pEventAPI ->EV_PopPMStates ();
1130+ }
1131+
1132+ void EV_FireRailgun (event_args_t * args)
1133+ {
1134+ int idx;
1135+ vec3_t origin, forward, right, up;
1136+
1137+ idx = args->entindex ;
1138+ EV_GetGunPosition (args, origin, args->origin );
1139+ AngleVectors (args->angles , forward, right, up);
1140+
1141+ origin = origin - up * 4 + right * 4 + forward * 2 ;
1142+
1143+ vec3_t dest;
1144+ VectorMA (origin, 8192 , forward, dest);
1145+
1146+ pmtrace_t tr;
1147+ gEngfuncs .pEventAPI ->EV_SetUpPlayerPrediction (false , true );
1148+ gEngfuncs .pEventAPI ->EV_PushPMStates ();
1149+ gEngfuncs .pEventAPI ->EV_SetSolidPlayers (idx - 1 );
1150+ gEngfuncs .pEventAPI ->EV_SetTraceHull (2 );
1151+ gEngfuncs .pEventAPI ->EV_PlayerTrace (origin, dest, PM_STUDIO_BOX, -1 , &tr);
1152+ gEngfuncs .pEventAPI ->EV_PopPMStates ();
1153+
1154+ vec3_t vel, dir, end;
1155+ VectorCopy (tr.endpos , end);
1156+ VectorSubtract (end, origin, dir);
1157+
1158+ float len = dir.Length ();
1159+ float speed = 2000 ;
1160+
1161+ VectorNormalize (dir);
1162+ VectorScale (dir, speed, vel);
1163+
1164+ gEngfuncs .pEfxAPI ->R_UserTracerParticle (origin, vel, len / speed, 2 , 0.2 , 0 , EV_RayTouch);
1165+
1166+ gEngfuncs .pEventAPI ->EV_PlaySound (idx, origin, CHAN_WEAPON, " weapons/railgun.wav" , 1.0 , ATTN_NORM, 0 , PITCH_NORM);
1167+
1168+ if (EV_IsLocal (idx))
1169+ {
1170+ gEngfuncs .pEventAPI ->EV_WeaponAnimation (1 , 0 ); // 1 == RAILGUN_FIRE. cba to put the enum in the header tbh.
1171+ Punch (-3 , 0 , 0 );
1172+ }
1173+ }
1174+ // ======================
1175+ // RAILGUN END
1176+ // ======================
1177+
10961178// ======================
10971179// PHYTON START
10981180// ( .357 )
0 commit comments