Skip to content

Commit

Permalink
Fix hit accuracy stats for lightning gun and shotgun kills
Browse files Browse the repository at this point in the history
If a lightning bolt killed a player or the first shotgun pellet that
hit a player killed them, the shot was not counted as accurate.

Check if shot player is alive for hit accuracy before dealing damage.
  • Loading branch information
zturtleman committed Sep 29, 2017
1 parent eeaade7 commit 51e9aa2
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions code/game/g_weapon.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ qboolean ShotgunPellet( vec3_t start, vec3_t end, gentity_t *ent ) {
vec3_t impactpoint, bouncedir;
#endif
vec3_t tr_start, tr_end;
qboolean hitClient = qfalse;

passent = ent->s.number;
VectorCopy( start, tr_start );
Expand Down Expand Up @@ -304,19 +305,12 @@ qboolean ShotgunPellet( vec3_t start, vec3_t end, gentity_t *ent ) {
}
continue;
}
else {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_SHOTGUN);
if( LogAccuracyHit( traceEnt, ent ) ) {
return qtrue;
}
}
#else
G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, 0, MOD_SHOTGUN);
if( LogAccuracyHit( traceEnt, ent ) ) {
return qtrue;
}
#endif
if( LogAccuracyHit( traceEnt, ent ) ) {
hitClient = qtrue;
}
G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, 0, MOD_SHOTGUN);
return hitClient;
}
return qfalse;
}
Expand Down Expand Up @@ -663,24 +657,18 @@ void Weapon_LightningFire( gentity_t *ent ) {
}
continue;
}
else {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_LIGHTNING);
}
#else
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_LIGHTNING);
#endif
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, 0, MOD_LIGHTNING);
}

if ( traceEnt->takedamage && traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
Expand Down

0 comments on commit 51e9aa2

Please sign in to comment.