Skip to content

Commit e76cdfe

Browse files
committed
Consider having your vehicle shot as being shot yourself
Part of #792
1 parent 751c256 commit e76cdfe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

javascript/features/limits/limits_decider.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,19 @@ export class LimitsDecider extends PlayerEventObserver {
214214
this.deathmatchDamageIssuedTime_.set(issuer, currentTime);
215215
}
216216

217-
// Called when the |player| has taken a shot, irrespective of whether it hit anything.
218-
onPlayerWeaponShot(player) {
219-
this.deathmatchWeaponShotTime_.set(player, server.clock.monotonicallyIncreasingTime());
217+
// Called when the |player| has taken a shot, irrespective of whether it hit anything. When the
218+
// shot has hit a vehicle rather than a player, and the vehicle is occupied by a driver, then
219+
// the driver will be tagged as having just taken damage instead.
220+
onPlayerWeaponShot(player, weaponId, hitType, hitId, hitPosition) {
221+
const currentTime = server.clock.monotonicallyIncreasingTime();
222+
223+
this.deathmatchWeaponShotTime_.set(player, currentTime);
224+
225+
if (hitType === 2 /* BULLET_HIT_TYPE_VEHICLE */) {
226+
const vehicleId = server.vehicleManager.getById(hitId);
227+
if (vehicleId && vehicleId.driver)
228+
this.deathmatchDamageTakenTime_.set(vehicleId.driver, currentTime);
229+
}
220230
}
221231

222232
// ---------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)