Fix hit accuracy stats for lightning gun and shotgun kills

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.
This commit is contained in:
Zack Middleton 2017-09-29 18:28:34 -05:00
parent eeaade70bd
commit 51e9aa2df0

View file

@ -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 );
@ -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;
}
@ -663,14 +657,11 @@ 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 ) {
@ -678,9 +669,6 @@ void Weapon_LightningFire( gentity_t *ent ) {
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 );