@@ -205,7 +205,7 @@ public static MatchData FromDemoFile(string file, bool parseChickens, bool lowOu
205205 {
206206 var text = message . Message ;
207207
208- if ( text . ToLower ( ) . StartsWith ( ">fb" ) || text . ToLower ( ) . StartsWith ( ">feedback" ) || text . ToLower ( ) . StartsWith ( "!fb" ) )
208+ if ( IsMessageFeedback ( text ) )
209209 {
210210 //Sets round to 0 as anything before a match start event should always be classed as warmup
211211 currentfeedbackMessages . Add ( new FeedbackMessage ( )
@@ -219,7 +219,11 @@ public static MatchData FromDemoFile(string file, bool parseChickens, bool lowOu
219219 XLastAlivePosition = message . XLastAlivePosition ,
220220 YLastAlivePosition = message . YLastAlivePosition ,
221221 ZLastAlivePosition = message . ZLastAlivePosition ,
222- Message = message . Message
222+ XCurrentViewAngle = message . XCurrentViewAngle ,
223+ YCurrentViewAngle = message . YCurrentViewAngle ,
224+ SetPosCommandCurrentPosition = message . SetPosCommandCurrentPosition ,
225+ Message = message . Message ,
226+ TimeInRound = 0 , // overwrites whatever the TimeInRound value was before, 0 is generally used for messages sent in Warmup
223227 } ) ;
224228 }
225229 }
@@ -245,7 +249,7 @@ public static MatchData FromDemoFile(string file, bool parseChickens, bool lowOu
245249
246250 var text = e . Text . ToString ( ) ;
247251
248- if ( text . ToLower ( ) . StartsWith ( ">fb" ) || text . ToLower ( ) . StartsWith ( ">feedback" ) )
252+ if ( IsMessageFeedback ( text ) )
249253 {
250254 int round = GetCurrentRoundNum ( md ) ;
251255
@@ -268,6 +272,8 @@ public static MatchData FromDemoFile(string file, bool parseChickens, bool lowOu
268272 string [ ] currentPositions = SplitPositionString ( player ? . Position . ToString ( ) ) ;
269273 string [ ] lastAlivePositions = playerAlive ? null : SplitPositionString ( player ? . LastAlivePosition . ToString ( ) ) ;
270274
275+ string setPosCurrentPosition = GenerateSetPosCommand ( currentPositions , player ? . ViewDirectionX , player ? . ViewDirectionY ) ;
276+
271277 var roundsEndedEvents = md . events . Where ( k => k . Key . Name . ToString ( ) == "RoundEndedEventArgs" ) . Select ( v => v . Value ) ;
272278 var freezetimesEndedEvents = md . events . Where ( k => k . Key . Name . ToString ( ) == "FreezetimeEndedEventArgs" ) . Select ( v => v . Value ) . ElementAt ( 0 ) ;
273279
@@ -286,12 +292,15 @@ public static MatchData FromDemoFile(string file, bool parseChickens, bool lowOu
286292 Round = round ,
287293 SteamID = steamId ,
288294 TeamName = teamName , // works out TeamName in GetFeedbackMessages() if it is null
289- XCurrentPosition = double . Parse ( currentPositions [ 1 ] ) ,
290- YCurrentPosition = double . Parse ( currentPositions [ 2 ] ) ,
291- ZCurrentPosition = double . Parse ( currentPositions [ 3 ] ) ,
292- XLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 1 ] ) : null ,
293- YLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 2 ] ) : null ,
294- ZLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 3 ] ) : null ,
295+ XCurrentPosition = double . Parse ( currentPositions [ 0 ] ) ,
296+ YCurrentPosition = double . Parse ( currentPositions [ 1 ] ) ,
297+ ZCurrentPosition = double . Parse ( currentPositions [ 2 ] ) ,
298+ XLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 0 ] ) : null ,
299+ YLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 1 ] ) : null ,
300+ ZLastAlivePosition = ( lastAlivePositions != null ) ? ( double ? ) double . Parse ( lastAlivePositions [ 2 ] ) : null ,
301+ XCurrentViewAngle = player ? . ViewDirectionX ,
302+ YCurrentViewAngle = player ? . ViewDirectionY ,
303+ SetPosCommandCurrentPosition = setPosCurrentPosition ,
295304 Message = text ,
296305 TimeInRound = timeInRound , // counts messages sent after the round_end event fires as the next round, set to '0' as if it was the next round's warmup (done this way instead of using round starts to avoid potential issues when restarting rounds)
297306 } ;
@@ -667,7 +676,7 @@ public DataAndPlayerNames GetDataAndPlayerNames(ProcessedData processedData)
667676
668677 public versionNumber GetVersionNumber ( )
669678 {
670- return new versionNumber ( ) { Version = "1.1.14 " } ;
679+ return new versionNumber ( ) { Version = "1.1.15 " } ;
671680 }
672681
673682 public List < string > GetSupportedGamemodes ( )
@@ -958,9 +967,9 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
958967
959968 //plant position
960969 string [ ] positions = SplitPositionString ( bombPlanted . Player . LastAlivePosition . ToString ( ) ) ;
961- bombPlanted . XPosition = double . Parse ( positions [ 1 ] ) ;
962- bombPlanted . YPosition = double . Parse ( positions [ 2 ] ) ;
963- bombPlanted . ZPosition = double . Parse ( positions [ 3 ] ) ;
970+ bombPlanted . XPosition = double . Parse ( positions [ 0 ] ) ;
971+ bombPlanted . YPosition = double . Parse ( positions [ 1 ] ) ;
972+ bombPlanted . ZPosition = double . Parse ( positions [ 2 ] ) ;
964973 }
965974 if ( processedData . BombsiteExplodeValues . Any ( p => p . Round == roundNum ) )
966975 {
@@ -1027,17 +1036,17 @@ public GeneralroundsStats GetGeneralRoundsStats(ProcessedData processedData, Dic
10271036 string [ ] positionsRescueA = hostageRescuedA != null ? SplitPositionString ( hostageRescuedA . Player . LastAlivePosition . ToString ( ) ) : null ;
10281037 if ( positionsRescueA != null )
10291038 {
1030- hostageRescuedA . XPosition = double . Parse ( positionsRescueA [ 1 ] ) ;
1031- hostageRescuedA . YPosition = double . Parse ( positionsRescueA [ 2 ] ) ;
1032- hostageRescuedA . ZPosition = double . Parse ( positionsRescueA [ 3 ] ) ;
1039+ hostageRescuedA . XPosition = double . Parse ( positionsRescueA [ 0 ] ) ;
1040+ hostageRescuedA . YPosition = double . Parse ( positionsRescueA [ 1 ] ) ;
1041+ hostageRescuedA . ZPosition = double . Parse ( positionsRescueA [ 2 ] ) ;
10331042 }
10341043
10351044 string [ ] positionsRescueB = hostageRescuedB != null ? SplitPositionString ( hostageRescuedB . Player . LastAlivePosition . ToString ( ) ) : null ;
10361045 if ( positionsRescueB != null )
10371046 {
1038- hostageRescuedB . XPosition = double . Parse ( positionsRescueB [ 1 ] ) ;
1039- hostageRescuedB . YPosition = double . Parse ( positionsRescueB [ 2 ] ) ;
1040- hostageRescuedB . ZPosition = double . Parse ( positionsRescueB [ 3 ] ) ;
1047+ hostageRescuedB . XPosition = double . Parse ( positionsRescueB [ 0 ] ) ;
1048+ hostageRescuedB . YPosition = double . Parse ( positionsRescueB [ 1 ] ) ;
1049+ hostageRescuedB . ZPosition = double . Parse ( positionsRescueB [ 2 ] ) ;
10411050 }
10421051 }
10431052
@@ -1184,11 +1193,11 @@ public List<grenadesSpecificStats> GetGrenadesSpecificStats(List<IEnumerable<Nad
11841193 var flash = nade as FlashEventArgs ;
11851194 int numOfPlayersFlashed = flash . FlashedPlayers . Count ( ) ;
11861195
1187- grenadesSpecificStats . Add ( new grenadesSpecificStats ( ) { NadeType = nade . NadeType . ToString ( ) , SteamID = steamId , XPosition = double . Parse ( positions [ 1 ] ) , YPosition = double . Parse ( positions [ 2 ] ) , ZPosition = double . Parse ( positions [ 3 ] ) , NumPlayersFlashed = numOfPlayersFlashed } ) ;
1196+ grenadesSpecificStats . Add ( new grenadesSpecificStats ( ) { NadeType = nade . NadeType . ToString ( ) , SteamID = steamId , XPosition = double . Parse ( positions [ 0 ] ) , YPosition = double . Parse ( positions [ 1 ] ) , ZPosition = double . Parse ( positions [ 2 ] ) , NumPlayersFlashed = numOfPlayersFlashed } ) ;
11881197 }
11891198 else
11901199 {
1191- grenadesSpecificStats . Add ( new grenadesSpecificStats ( ) { NadeType = nade . NadeType . ToString ( ) , SteamID = steamId , XPosition = double . Parse ( positions [ 1 ] ) , YPosition = double . Parse ( positions [ 2 ] ) , ZPosition = double . Parse ( positions [ 3 ] ) } ) ;
1200+ grenadesSpecificStats . Add ( new grenadesSpecificStats ( ) { NadeType = nade . NadeType . ToString ( ) , SteamID = steamId , XPosition = double . Parse ( positions [ 0 ] ) , YPosition = double . Parse ( positions [ 1 ] ) , ZPosition = double . Parse ( positions [ 2 ] ) } ) ;
11921201 }
11931202 }
11941203 }
@@ -1216,12 +1225,12 @@ public List<killsStats> GetKillsStats(ProcessedData processedData, Dictionary<lo
12161225 if ( playerKilledEvent != null )
12171226 {
12181227 int round = playerKilledEvent . Round ;
1228+
1229+ string [ ] killPositionSplit = SplitPositionString ( kills . ElementAt ( i ) . LastAlivePosition . ToString ( ) ) ;
1230+ string killPositions = $ "{ killPositionSplit [ 0 ] } ,{ killPositionSplit [ 1 ] } ,{ killPositionSplit [ 2 ] } ";
12191231
1220- string [ ] killPositionSplit = kills . ElementAt ( i ) . LastAlivePosition . ToString ( ) . Split ( new string [ ] { "{X: " , ", Y: " , ", Z: " , "}" } , StringSplitOptions . None ) ;
1221- string killPositions = $ "{ killPositionSplit [ 1 ] } ,{ killPositionSplit [ 2 ] } ,{ killPositionSplit [ 3 ] } ";
1222-
1223- string [ ] deathPositionSplit = deaths . ElementAt ( i ) . LastAlivePosition . ToString ( ) . Split ( new string [ ] { "{X: " , ", Y: " , ", Z: " , "}" } , StringSplitOptions . None ) ;
1224- string deathPositions = $ "{ deathPositionSplit [ 1 ] } ,{ deathPositionSplit [ 2 ] } ,{ deathPositionSplit [ 3 ] } ";
1232+ string [ ] deathPositionSplit = SplitPositionString ( deaths . ElementAt ( i ) . LastAlivePosition . ToString ( ) ) ;
1233+ string deathPositions = $ "{ deathPositionSplit [ 0 ] } ,{ deathPositionSplit [ 1 ] } ,{ deathPositionSplit [ 2 ] } ";
12251234
12261235 //retrieve steam ID using player name if the event does not return it correctly
12271236 long killerSteamId = kills . ElementAt ( i ) != null ? ( ( kills . ElementAt ( i ) . SteamID == 0 ) ? GetSteamIdByPlayerName ( playerNames , kills . ElementAt ( i ) . Name ) : kills . ElementAt ( i ) . SteamID ) : 0 ;
@@ -1245,14 +1254,14 @@ public List<killsStats> GetKillsStats(ProcessedData processedData, Dictionary<lo
12451254 Weapon = weaponUsed ,
12461255 KillerSteamID = killerSteamId ,
12471256 KillerBotTakeover = playerKilledEvent . KillerBotTakeover ,
1248- XPositionKill = double . Parse ( killPositionSplit [ 1 ] ) ,
1249- YPositionKill = double . Parse ( killPositionSplit [ 2 ] ) ,
1250- ZPositionKill = double . Parse ( killPositionSplit [ 3 ] ) ,
1257+ XPositionKill = double . Parse ( killPositionSplit [ 0 ] ) ,
1258+ YPositionKill = double . Parse ( killPositionSplit [ 1 ] ) ,
1259+ ZPositionKill = double . Parse ( killPositionSplit [ 2 ] ) ,
12511260 VictimSteamID = victimSteamId ,
12521261 VictimBotTakeover = playerKilledEvent . VictimBotTakeover ,
1253- XPositionDeath = double . Parse ( deathPositionSplit [ 1 ] ) ,
1254- YPositionDeath = double . Parse ( deathPositionSplit [ 2 ] ) ,
1255- ZPositionDeath = double . Parse ( deathPositionSplit [ 3 ] ) ,
1262+ XPositionDeath = double . Parse ( deathPositionSplit [ 0 ] ) ,
1263+ YPositionDeath = double . Parse ( deathPositionSplit [ 1 ] ) ,
1264+ ZPositionDeath = double . Parse ( deathPositionSplit [ 2 ] ) ,
12561265 AssisterSteamID = assisterSteamId ,
12571266 AssisterBotTakeover = playerKilledEvent . AssisterBotTakeover ,
12581267 FirstKillOfTheRound = firstKillOfTheRound ,
@@ -1711,7 +1720,20 @@ public int CheckForUpdatedUserId(int userId)
17111720
17121721 public static string [ ] SplitPositionString ( string position )
17131722 {
1714- return position . Split ( new string [ ] { "{X: " , ", Y: " , ", Z: " , "}" } , StringSplitOptions . None ) ;
1723+ var positionString = position . Split ( new string [ ] { "{X: " , ", Y: " , ", Z: " , " }" } , StringSplitOptions . None ) ;
1724+ return positionString . Where ( x => ! string . IsNullOrWhiteSpace ( x ) ) . ToArray ( ) ;
1725+ }
1726+
1727+ public static string GenerateSetPosCommand ( string [ ] currentPositions , float ? viewDirectionX , float ? viewDirectionY )
1728+ {
1729+ return string . Concat ( "setpos " , currentPositions [ 0 ] , " " , currentPositions [ 1 ] , " " , currentPositions [ 2 ] , "; setang " ,
1730+ ( Convert . ToString ( viewDirectionX ) ?? "0.0" ) , " " , ( Convert . ToString ( viewDirectionY ) ?? "0.0" ) // Z axis is optional
1731+ ) ;
1732+ }
1733+
1734+ public static bool IsMessageFeedback ( string text )
1735+ {
1736+ return text . ToLower ( ) . StartsWith ( ">fb" ) || text . ToLower ( ) . StartsWith ( ">feedback" ) || text . ToLower ( ) . StartsWith ( "!fb" ) || text . ToLower ( ) . StartsWith ( "!feedback" ) ;
17151737 }
17161738
17171739 public BombPlantedError ValidateBombsite ( IEnumerable < BombPlanted > bombPlantedArray , char bombsite )
0 commit comments