@@ -84,6 +84,7 @@ import {
8484 nativeInspectDuration ,
8585 nativeSoundCues ,
8686 nativeReloadPhases ,
87+ nativeMagazineInsert ,
8788} from "./weapon-motion" ;
8889import { knifeInspectDuration } from "./knife-motion" ;
8990import { dustRadarProjection , loadCalloutRadar , radarCrop } from "./radar" ;
@@ -116,6 +117,7 @@ import { gradeMapColors } from "./map-color";
116117import { setupUiAudio } from "./ui-audio" ;
117118import { MatchNotices } from "./match-notices" ;
118119import { roundMvp } from "./round-mvp" ;
120+ import { roundFact , type RoundActor } from "./round-facts" ;
119121import { renderScoreboard } from "./scoreboard" ;
120122import { hideRoundBanner , showRoundBanner } from "./round-banner" ;
121123import type { LoadProgress } from "./intro" ;
@@ -303,6 +305,9 @@ export class Game {
303305 roundHistory : { winner : AgentTeam ; reason : string } [ ] = [ ] ;
304306 scoreboardSignature = "" ;
305307 roundStartKills = new Map < number | "player" , number > ( ) ;
308+ roundElapsed = 0 ;
309+ roundHighlights = new Map < RoundActor , { headshots : number ; knives : number ; grenades : number } > ( ) ;
310+ roundFirstKill ?: { name : string ; seconds : number } ;
306311 mvpCounts = new Map < number | "player" , number > ( ) ;
307312 notices = new MatchNotices ( ) ;
308313 roundPause = 0 ;
@@ -394,6 +399,7 @@ export class Game {
394399 boltTime = 0 ;
395400 rescope = 0 ;
396401 weaponCooldowns = weapons . map ( ( ) => 0 ) ;
402+ reloadLockouts = weapons . map ( ( ) => 0 ) ;
397403 selected = 2 ;
398404 primary : number | null = null ;
399405 secondary = 2 ;
@@ -469,6 +475,7 @@ export class Game {
469475 burstRemaining = 0 ;
470476 shellPhase : "intro" | "loop" | "outro" = "intro" ;
471477 shellInserted = false ;
478+ magazineInserted = false ;
472479 knife = 4 ;
473480 inspectVariant = 2 ;
474481 knifeTime = 0 ;
@@ -1267,6 +1274,7 @@ export class Game {
12671274 this . setScope ( 0 ) ;
12681275 this . rescope = this . boltTime = 0 ;
12691276 this . weaponCooldowns = weapons . map ( ( ) => 0 ) ;
1277+ this . reloadLockouts . fill ( 0 ) ;
12701278 this . position . set ( - 17 , 0 , 17 ) ;
12711279 if ( this . teamMode && this . dust ) {
12721280 this . position . fromArray ( this . dust . navigation . data . spawns [ this . team ] [ 0 ] ) ;
@@ -1552,9 +1560,14 @@ export class Game {
15521560 this . ammo = this . magazines [ index ] . ammo ;
15531561 this . reserve = this . magazines [ index ] . reserve ;
15541562 this . reload = 0 ;
1563+ this . magazineInserted = false ;
15551564 this . shots = 0 ;
15561565 this . drawTime = weaponDrawDuration ( this . selected ) ;
1557- this . cooldown = Math . max ( weapons [ index ] . deploy , this . weaponCooldowns [ index ] ) ;
1566+ this . cooldown = Math . max (
1567+ weapons [ index ] . deploy ,
1568+ this . weaponCooldowns [ index ] ,
1569+ this . reloadLockouts [ index ] ,
1570+ ) ;
15581571 if ( weapons [ index ] . unzoomsAfterShot && this . weaponCooldowns [ index ] > 0 )
15591572 this . boltTime = this . weaponCooldowns [ index ] ;
15601573 // View models are cached per team and weapon; animateGun fully re-poses them.
@@ -1795,6 +1808,7 @@ export class Game {
17951808 this . burstRemaining = 0 ;
17961809 this . shellPhase = "intro" ;
17971810 this . shellInserted = false ;
1811+ this . magazineInserted = false ;
17981812 this . revolverCharge = 0 ;
17991813 this . reload = w . reloadStyle === "shell" ? this . shellDuration ( ) : w . reload ;
18001814 this . boltTime = 0 ;
@@ -2309,6 +2323,24 @@ export class Game {
23092323 wallbang = false ,
23102324 label ?: string ,
23112325 ) {
2326+ if ( this . teamMode && ! this . roundPause && ! this . freezeTime ) {
2327+ const id : RoundActor =
2328+ killer === "YOU" ? "player" : this . bots . findIndex ( ( bot ) => bot . name === killer ) ;
2329+ const killerTeam = id === "player" ? this . team : this . bots [ id ] ?. team ;
2330+ const victimTeam =
2331+ victim === "YOU" ? this . team : this . bots . find ( ( bot ) => bot . name === victim ) ?. team ;
2332+ if ( killerTeam && victimTeam && killerTeam !== victimTeam ) {
2333+ const stats = this . roundHighlights . get ( id ) ?? { headshots : 0 , knives : 0 , grenades : 0 } ;
2334+ if ( head ) stats . headshots ++ ;
2335+ if ( weapon >= 0 && isKnife ( weapon ) ) stats . knives ++ ;
2336+ if ( label ) stats . grenades ++ ;
2337+ this . roundHighlights . set ( id , stats ) ;
2338+ this . roundFirstKill ??= {
2339+ name : killer === "YOU" ? playerName ( ) : killer ,
2340+ seconds : this . roundElapsed ,
2341+ } ;
2342+ }
2343+ }
23122344 const utilityKind = grenadeTypes . find ( ( kind ) => grenadeData [ kind ] . name === label ) ;
23132345 const killerInstance =
23142346 killer === "YOU"
@@ -2573,8 +2605,10 @@ export class Game {
25732605 const after = 1 - this . drawTime / weaponDrawDuration ( this . selected ) ;
25742606 if ( ! this . reload ) this . animationSounds ( "draw" , before , after ) ;
25752607 }
2576- for ( let i = 0 ; i < this . weaponCooldowns . length ; i ++ )
2608+ for ( let i = 0 ; i < this . weaponCooldowns . length ; i ++ ) {
25772609 this . weaponCooldowns [ i ] = Math . max ( 0 , this . weaponCooldowns [ i ] - dt ) ;
2610+ this . reloadLockouts [ i ] = Math . max ( 0 , this . reloadLockouts [ i ] - dt ) ;
2611+ }
25782612 if ( this . scopeTransition > 0 ) {
25792613 this . scopeTransition = Math . max ( 0 , this . scopeTransition - dt ) ;
25802614 this . camera . fov =
@@ -2748,15 +2782,26 @@ export class Game {
27482782 }
27492783 } else {
27502784 this . animationSounds ( "reload" , 1 - previous / w . reload , 1 - this . reload / w . reload ) ;
2751- if ( ! this . reload ) {
2785+ if (
2786+ ! this . magazineInserted &&
2787+ this . reloadProgress ( ) >= nativeMagazineInsert ( this . selected , this . emptyReload )
2788+ ) {
2789+ // The new magazine survives holstering. The remaining reload deadline
2790+ // still gates attacks after drawing, so quick-switching only cancels
2791+ // the visual tail, not the weapon's readiness time.
2792+ this . magazineInserted = true ;
2793+ this . reloadLockouts [ this . selected ] = Math . max (
2794+ this . reloadLockouts [ this . selected ] ,
2795+ this . reload ,
2796+ ) ;
27522797 const loaded = reloadMagazine ( this . selected , this . ammo , this . reserve ) ;
27532798 this . ammo = loaded . ammo ;
27542799 this . reserve = loaded . reserve ;
27552800 this . updateUI ( ) ;
27562801 }
27572802 }
27582803 }
2759- if ( ! this . reload ) this . emptyReload = false ;
2804+ if ( ! this . reload ) this . emptyReload = this . magazineInserted = false ;
27602805 const crouch = this . updateDuckInput ( dt ) ,
27612806 walk = this . keys . has ( "ShiftLeft" ) || this . keys . has ( "ShiftRight" ) ,
27622807 maxSpeed =
@@ -3164,6 +3209,9 @@ export class Game {
31643209 beepPulse : 0 ,
31653210 } ;
31663211 this . bombMesh . visible = false ;
3212+ this . roundElapsed = 0 ;
3213+ this . roundHighlights . clear ( ) ;
3214+ this . roundFirstKill = undefined ;
31673215 this . roundStartKills = new Map < number | "player" , number > ( [
31683216 [ "player" , this . kills ] ,
31693217 ...this . bots . map ( ( bot , id ) => [ id , bot . kills ] as [ number , number ] ) ,
@@ -3222,7 +3270,23 @@ export class Game {
32223270 this . bomb . defuser = null ;
32233271 this . bomb . plantProgress = this . bomb . progress = 0 ;
32243272 }
3225- showRoundBanner ( winner , this . team , reason , mvp ) ;
3273+ const winners = players . filter ( ( player ) => player . team === winner ) ;
3274+ const fact = roundFact ( {
3275+ winner,
3276+ reason,
3277+ seconds : this . roundElapsed ,
3278+ enemyCount : players . length - winners . length ,
3279+ winningDeaths : winners . filter ( ( player ) =>
3280+ player . id === "player" ? this . dead > 0 : this . bots [ player . id ] . health <= 0 ,
3281+ ) . length ,
3282+ players : winners . map ( ( player ) => ( {
3283+ name : player . name ,
3284+ kills : Math . max ( 0 , player . kills - ( this . roundStartKills . get ( player . id ) ?? player . kills ) ) ,
3285+ ...( this . roundHighlights . get ( player . id ) ?? { headshots : 0 , knives : 0 , grenades : 0 } ) ,
3286+ } ) ) ,
3287+ firstKill : this . roundFirstKill ,
3288+ } ) ;
3289+ showRoundBanner ( winner , this . team , reason , mvp , fact ) ;
32263290 this . updateUI ( ) ;
32273291 if ( this . teamScores [ winner ] >= this . winTarget || ( this . competitive && this . round >= 24 ) )
32283292 this . finish ( ) ;
@@ -3327,6 +3391,7 @@ export class Game {
33273391 this . updateBotPurchases ( dt * 8 , this . tick ++ % 8 ) ;
33283392 return ;
33293393 }
3394+ this . roundElapsed += dt ;
33303395 this . time = Math . max ( 0 , this . time - dt ) ;
33313396 const bomb = this . bomb ! ;
33323397 const stationary = ! [ "KeyW" , "KeyA" , "KeyS" , "KeyD" , "Space" ] . some ( ( key ) => this . keys . has ( key ) ) ;
@@ -3541,6 +3606,7 @@ export class Game {
35413606 this . kick = this . damage = this . hit = 0 ;
35423607 this . weaponAudio . stop ( ) ;
35433608 this . weaponCooldowns . fill ( 0 ) ;
3609+ this . reloadLockouts . fill ( 0 ) ;
35443610 this . weaponCooldowns [ weapon ] = Math . max ( 0 , bot . shot ) ;
35453611 this . primary = weaponSlot ( weapon ) === 1 ? weapon : null ;
35463612 this . secondary = weaponSlot ( weapon ) === 2 ? weapon : this . team === "t" ? 7 : 2 ;
0 commit comments