@@ -3,12 +3,12 @@ package main
3
3
import (
4
4
//"bufio"
5
5
"fmt"
6
+ "io/ioutil"
6
7
"math"
7
8
"os"
9
+ "path/filepath"
8
10
"strconv"
9
11
"strings"
10
- "io/ioutil"
11
- "path/filepath"
12
12
13
13
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
14
14
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
@@ -82,6 +82,7 @@ type flag struct {
82
82
hasGameStarted bool
83
83
isGameLive bool
84
84
isGameOver bool
85
+ inRound bool
85
86
prePlant bool
86
87
postPlant bool
87
88
postWinCon bool
@@ -90,14 +91,16 @@ type flag struct {
90
91
roundIntegrityEndOfficial int
91
92
92
93
//for the round (gets reset on a new round) maybe should be in a new struct
93
- tAlive int
94
- ctAlive int
95
- tMoney bool
96
- tClutchVal int
97
- ctClutchVal int
98
- tClutchSteam uint64
99
- ctClutchSteam uint64
100
- openingKill bool
94
+ tAlive int
95
+ ctAlive int
96
+ tMoney bool
97
+ tClutchVal int
98
+ ctClutchVal int
99
+ tClutchSteam uint64
100
+ ctClutchSteam uint64
101
+ openingKill bool
102
+ lastTickProcessed int
103
+ ticksProcessed int
101
104
}
102
105
103
106
type team struct {
@@ -165,50 +168,56 @@ type playerStats struct {
165
168
rounds int
166
169
//playerPoints float32
167
170
//teamPoints float32
168
- damage int
169
- kills uint8
170
- assists uint8
171
- deaths uint8
172
- deathTick int
173
- deathPlacement float64
174
- ticksAlive int
175
- trades int
176
- traded int
177
- ok int
178
- ol int
179
- cl_1 int
180
- cl_2 int
181
- cl_3 int
182
- cl_4 int
183
- cl_5 int
184
- _2k int
185
- _3k int
186
- _4k int
187
- _5k int
188
- nadeDmg int
189
- infernoDmg int
190
- utilDmg int
191
- ef int
192
- fAss int
193
- enemyFlashTime float64
194
- hs int
195
- kastRounds float64
196
- saves int
197
- entries int
198
- killPoints float64
199
- impactPoints float64
200
- winPoints float64
201
- awpKills int
202
- RF int
203
- RA int
204
- nadesThrown int
205
- firesThrown int
206
- flashThrown int
207
- smokeThrown int
208
- damageTaken int
209
- suppRounds int
210
- suppDamage int
211
- rwk int
171
+ damage int
172
+ kills uint8
173
+ assists uint8
174
+ deaths uint8
175
+ deathTick int
176
+ deathPlacement float64
177
+ ticksAlive int
178
+ trades int
179
+ traded int
180
+ ok int
181
+ ol int
182
+ cl_1 int
183
+ cl_2 int
184
+ cl_3 int
185
+ cl_4 int
186
+ cl_5 int
187
+ _2k int
188
+ _3k int
189
+ _4k int
190
+ _5k int
191
+ nadeDmg int
192
+ infernoDmg int
193
+ utilDmg int
194
+ ef int
195
+ fAss int
196
+ enemyFlashTime float64
197
+ hs int
198
+ kastRounds float64
199
+ saves int
200
+ entries int
201
+ killPoints float64
202
+ impactPoints float64
203
+ winPoints float64
204
+ awpKills int
205
+ RF int
206
+ RA int
207
+ nadesThrown int
208
+ firesThrown int
209
+ flashThrown int
210
+ smokeThrown int
211
+ damageTaken int
212
+ suppRounds int
213
+ suppDamage int
214
+ lurkerBlips int
215
+ distanceToTeammates int
216
+ lurkRounds int
217
+ wlp float64
218
+ mip float64
219
+
220
+ rwk int
212
221
213
222
//derived
214
223
utilThrown int
@@ -271,18 +280,18 @@ type playerStats struct {
271
280
}
272
281
273
282
func main () {
274
- input_dir := "in"
275
- files , _ := ioutil .ReadDir (input_dir )
276
-
277
- for _ , file := range files {
278
- filename := file .Name ()
279
- if strings .HasSuffix (filename , ".dem" ) {
280
- fmt .Println ("processing" , file .Name ())
281
- processDemo (filepath .Join (input_dir , filename ))
282
- }
283
- }
284
-
285
- var input string
283
+ input_dir := "in"
284
+ files , _ := ioutil .ReadDir (input_dir )
285
+
286
+ for _ , file := range files {
287
+ filename := file .Name ()
288
+ if strings .HasSuffix (filename , ".dem" ) {
289
+ fmt .Println ("processing" , file .Name ())
290
+ go processDemo (filepath .Join (input_dir , filename ))
291
+ }
292
+ }
293
+
294
+ var input string
286
295
fmt .Scanln (& input )
287
296
}
288
297
@@ -294,6 +303,7 @@ func initGameObject() *game {
294
303
g .flags .hasGameStarted = false
295
304
g .flags .isGameLive = false
296
305
g .flags .isGameOver = false
306
+ g .flags .inRound = false
297
307
g .flags .prePlant = true
298
308
g .flags .postPlant = false
299
309
g .flags .postWinCon = false
@@ -387,6 +397,7 @@ func processDemo(demoName string) {
387
397
388
398
//reset various flags
389
399
resetRoundFlags := func () {
400
+ game .flags .inRound = true
390
401
game .flags .prePlant = true
391
402
game .flags .postPlant = false
392
403
game .flags .postWinCon = false
@@ -396,6 +407,8 @@ func processDemo(demoName string) {
396
407
game .flags .ctClutchSteam = 0
397
408
game .flags .tMoney = false
398
409
game .flags .openingKill = true
410
+ game .flags .lastTickProcessed = 0
411
+ game .flags .ticksProcessed = 0
399
412
}
400
413
401
414
initTeamPlayer := func (team * common.TeamState , currRoundObj * round ) {
@@ -427,14 +440,6 @@ func processDemo(demoName string) {
427
440
// Reset round
428
441
game .potentialRound = newRound
429
442
430
- // if len(game.rounds) < game.flags.roundIntegrityStart {
431
- // //game.potentialRound = currRoundObj
432
- // } else {
433
- // //game.rounds[roundIntegrityStart - 1] = currRoundObj
434
- // fmt.Println(game.rounds[game.flags.roundIntegrityStart - 1].integrityCheck)
435
- // //game.rounds = append(game.rounds, currRoundObj)
436
- // }
437
-
438
443
//track the number of people alive for clutch checking and record keeping
439
444
game .flags .tAlive = len (terrorists .Members ())
440
445
game .flags .ctAlive = len (counterTerrorists .Members ())
@@ -461,6 +466,7 @@ func processDemo(demoName string) {
461
466
}
462
467
463
468
processRoundFinal := func (lastRound bool ) {
469
+ game .flags .inRound = false
464
470
game .potentialRound .endingTick = p .GameState ().IngameTick ()
465
471
game .flags .roundIntegrityEndOfficial = p .GameState ().TotalRoundsPlayed ()
466
472
if lastRound {
@@ -523,6 +529,8 @@ func processDemo(demoName string) {
523
529
}
524
530
525
531
//add multikills & saves & misc
532
+ highestImpactPoints := 0.0
533
+ mipPlayers := 0
526
534
for _ , player := range (game .potentialRound ).playerStats {
527
535
if player .deaths == 0 {
528
536
player .kastRounds = 1
@@ -546,19 +554,53 @@ func processDemo(demoName string) {
546
554
player ._5k = 1
547
555
}
548
556
557
+ if player .impactPoints > highestImpactPoints {
558
+ highestImpactPoints = player .impactPoints
559
+ }
560
+
549
561
if player .teamENUM == game .potentialRound .winnerENUM {
550
562
player .winPoints = player .impactPoints
563
+
551
564
player .RF = 1
552
- if player .name == "iNSANEmayne" {
553
- debugMsg := fmt .Sprintf ("---------%.2f win points for brod on round %d.------------\n " , player .impactPoints , game .potentialRound .roundNum )
554
- debugFile .WriteString (debugMsg )
555
- debugFile .Sync ()
556
- }
557
565
} else {
558
566
player .RA = 1
559
567
}
560
568
}
561
569
570
+ for _ , player := range (game .potentialRound ).playerStats {
571
+ if player .impactPoints == highestImpactPoints {
572
+ mipPlayers += 1
573
+ }
574
+ }
575
+ for _ , player := range (game .potentialRound ).playerStats {
576
+ if player .impactPoints == highestImpactPoints {
577
+ player .mip = 1.0 / float64 (mipPlayers )
578
+ }
579
+ }
580
+
581
+ //check the lurk
582
+ var susLurker uint64
583
+ susLurkBlips := 0
584
+ invalidLurk := false
585
+ for _ , player := range game .potentialRound .playerStats {
586
+ if player .side == 2 {
587
+ if player .lurkerBlips > susLurkBlips {
588
+ susLurkBlips = player .lurkerBlips
589
+ susLurker = player .steamID
590
+ }
591
+ }
592
+ }
593
+ for _ , player := range game .potentialRound .playerStats {
594
+ if player .side == 2 {
595
+ if player .lurkerBlips == susLurkBlips && player .steamID != susLurker {
596
+ invalidLurk = true
597
+ }
598
+ }
599
+ }
600
+ if ! invalidLurk && susLurkBlips > 3 {
601
+ game .potentialRound .playerStats [susLurker ].lurkRounds = 1
602
+ }
603
+
562
604
//add our valid round
563
605
game .rounds = append (game .rounds , game .potentialRound )
564
606
}
@@ -569,6 +611,48 @@ func processDemo(demoName string) {
569
611
570
612
//-------------ALL OUR EVENTS---------------------
571
613
614
+ p .RegisterEventHandler (func (e events.FrameDone ) {
615
+ if game .flags .inRound && game .flags .lastTickProcessed + (4 * game .tickRate ) < p .GameState ().IngameTick () {
616
+ game .flags .lastTickProcessed = p .GameState ().IngameTick ()
617
+ game .flags .ticksProcessed += 1
618
+
619
+ //this will be triggered every 4 seconds of in round time after the first 10 seconds
620
+
621
+ //check for lurker
622
+ if game .flags .tAlive > 2 && ! game .flags .postWinCon && p .GameState ().IngameTick () > (18 * game .tickRate )+ game .potentialRound .startingTick {
623
+ membersT := p .GameState ().TeamTerrorists ().Members ()
624
+ for _ , terrorist := range membersT {
625
+ if terrorist .IsAlive () {
626
+ for _ , teammate := range membersT {
627
+ if terrorist .SteamID64 != teammate .SteamID64 && teammate .IsAlive () {
628
+ dist := int (terrorist .Position ().Distance (teammate .Position ()))
629
+ if dist < 500 {
630
+ //invalidate the lurk blip b/c we have a close teammate
631
+ game .potentialRound .playerStats [terrorist .SteamID64 ].distanceToTeammates = - 999999
632
+ }
633
+ game .potentialRound .playerStats [terrorist .SteamID64 ].distanceToTeammates += dist
634
+ }
635
+ }
636
+ }
637
+ }
638
+ var lurkerSteam uint64
639
+ lurkerDist := 999999
640
+ for _ , terrorist := range membersT {
641
+ if terrorist .IsAlive () {
642
+ dist := game .potentialRound .playerStats [terrorist .SteamID64 ].distanceToTeammates
643
+ if dist < lurkerDist && dist > 0 {
644
+ lurkerDist = dist
645
+ lurkerSteam = terrorist .SteamID64
646
+ }
647
+ }
648
+ }
649
+ if lurkerSteam != 0 {
650
+ game .potentialRound .playerStats [lurkerSteam ].lurkerBlips += 1
651
+ }
652
+ }
653
+ }
654
+ })
655
+
572
656
p .RegisterEventHandler (func (e events.RoundStart ) {
573
657
fmt .Printf ("Round Start\n " )
574
658
})
@@ -908,12 +992,6 @@ func processDemo(demoName string) {
908
992
killValue *= ecoMod
909
993
910
994
pS [e .Killer .SteamID64 ].killPoints += killValue
911
- if e .Killer .Name == "iNSANEmayne" {
912
- debugMsg := fmt .Sprintf ("---------%.2f kill points for brod on round %d.------------\n " , killValue , game .potentialRound .roundNum )
913
- debugFile .WriteString (debugMsg )
914
- debugFile .Sync ()
915
- }
916
-
917
995
}
918
996
919
997
}
@@ -979,8 +1057,8 @@ func processDemo(demoName string) {
979
1057
}
980
1058
})
981
1059
982
- p .RegisterEventHandler (func (e events.PlayerJump ) {
983
- // fmt.Printf("Player Jumped\n" )
1060
+ p .RegisterEventHandler (func (e events.RoundImpactScoreData ) {
1061
+ fmt .Println ( "-------ROUNDIMPACTSCOREDATA" , e . RawMessage )
984
1062
})
985
1063
986
1064
p .RegisterEventHandler (func (e events.BombPlanted ) {
0 commit comments