protected void HandleTickDone(object sender, TickDoneEventArgs e) { if (!isMatchStarted || isFreezetime || currentRoundNumber > stopRoundNumber) { return; } if (showDetailInfo) { if (parser.CurrentTick % 5000 == 0) { txtResult.AppendText("Parser progress:" + parser.CurrentTick + " / " + parser.Header.PlaybackTicks); txtResult.AppendText(Environment.NewLine); } } int activeWeapon = -1; if (parser.PlayingParticipants.Any()) { foreach (Player player in parser.PlayingParticipants) { if (player.IsAlive) { if (player.ActiveWeapon != null) { activeWeapon = (int)player.ActiveWeapon.Weapon; } swMovement.WriteLine(parser.CurrentTick + "," + currentRoundNumber.ToString() + "," + parser.Map + "," + player.SteamID + "," + player.Name + "," + (int)player.Team + "," + player.Position.X + "," + player.Position.Y + "," + player.Position.Z + "," + player.Velocity.X + "," + player.Velocity.Y + "," + player.Velocity.Z + "," + player.ViewDirectionX + "," + player.ViewDirectionY + "," + activeWeapon + "," + (int)ActionEnum.Movement + ",0,0,0,0"); } } } }
private void Parser_TickDone(object sender, TickDoneEventArgs e) { if (!hasStarted) { return; } foreach (var player in parser.Participants) { if (player == null) { continue; } Vector3 position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z); double previousMovement; if (!stats.Movement.TryGetValue(player.SteamID, out previousMovement)) { previousMovement = 0.0; } Vector3 previousPosition; if (positions.TryGetValue(player.SteamID, out previousPosition)) { stats.Movement[player.SteamID] = previousMovement + (position - previousPosition).Length(); } else { stats.Movement[player.SteamID] = 0.0; } positions[player.SteamID] = position; } }
protected new void HandleTickDone(object sender, TickDoneEventArgs e) { if (Parser.PlayingParticipants.Count() >= 10 && Parser.PlayingParticipants.FirstOrDefault(p => p.SteamID == 0) == null && !_isTeamsInitialized) { Application.Current.Dispatcher.Invoke(delegate { if (Demo.Players.Count < 10) { AddTeams(); } else { _isTeamsInitialized = true; } Demo.Rounds.Clear(); RoundCount = 0; CreateNewRound(); CurrentRound.EquipementValueTeam1 = Parser.Participants.Where(a => a.Team == Team.CounterTerrorist).Sum(a => a.CurrentEquipmentValue); CurrentRound.EquipementValueTeam2 = Parser.Participants.Where(a => a.Team == Team.Terrorist).Sum(a => a.CurrentEquipmentValue); if (!string.IsNullOrEmpty(Parser.CTClanName)) { Demo.TeamCT.Name = Parser.CTClanName; } if (!string.IsNullOrEmpty(Parser.TClanName)) { Demo.TeamT.Name = Parser.TClanName; } }); } base.HandleTickDone(sender, e); }
void HandleTickDone(object sender, TickDoneEventArgs e) { float timeInRound = (parser.CurrentTick - roundStartTick) * parser.TickTime; if (parser.CurrentTick % Math.Round((parser.TickRate / 2), 0) == 0) //all 500 ms { foreach (var player in parser.PlayingParticipants.Where(a => a.SteamID != 0 && a.IsAlive)) { if (!afterFirstKill && timeInRound > 15) //15 sec freezetime + 10 sec running { if (player.Team == Team.CounterTerrorist) { CTHoldingPosition.AddPoint(MapPoint(player)); } else { THoldingPosition.AddPoint(MapPoint(player)); } } } } if (parser.CurrentTick % Math.Round((parser.TickRate / 4), 0) == 0) //all 250 ms { foreach (var player in parser.PlayingParticipants.Where(a => a.SteamID != 0 && a.IsAlive)) { /* if (player.Team == Team.CounterTerrorist) * CTPosition.AddPoint(MapPoint(player)); * else * TPosition.AddPoint(MapPoint(player)); */ } } }
private static void parser_TickDone(object sender, TickDoneEventArgs e) { Console.WriteLine($"IngameTick: {parser.CurrentTick}"); foreach (var playingParticipants in parser.PlayingParticipants) { Console.WriteLine($"{playingParticipants.Name} - position: {playingParticipants.Position}"); } }
void parser_TickDone(object sender, TickDoneEventArgs e) { if (i++ % 1 != 0) { return; } g.Clear(Color.Transparent); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; foreach (var player in parser.PlayingParticipants) { var p = MapPoint(player.LastAlivePosition); var endPoint = p; var p2 = p; var p3 = p; p2.X -= 7; p2.Y -= 7; p3.X += 20; Brush brush = null; if (player.IsAlive) { brush = player.Team == Team.Terrorist ? brush1 : brush2; if (firequeue.Contains(player)) { brush = brush3; firequeue.RemoveAll(a => a == player); } } else { brush = new SolidBrush(Color.Red); } endPoint.X += (int)(Math.Sin((player.ViewDirectionX / 360) * 2 * Math.PI + Math.PI / 2) * 20); endPoint.Y += (int)(Math.Cos((player.ViewDirectionX / 360) * 2 * Math.PI + Math.PI / 2) * 20); g.FillEllipse(brush, new Rectangle(p2, new Size(15, 15))); g.DrawString(player.Name + " | " + player.HP.ToString(), new Font(FontFamily.GenericSansSerif, 14), brush, p3); g.DrawLine(new Pen(brush, 3), p, endPoint); } pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Image = drawingBitmap; }
private static void parser_TickDone(object sender, TickDoneEventArgs e) { Console.CursorLeft = 0; Console.CursorTop = 0; //Console.Clear(); Console.WriteLine($"IngameTick: {demoParser.CurrentTick}"); foreach (var playingParticipants in demoParser.PlayingParticipants) { //Console.WriteLine($"{playingParticipants.Name} - position: {playingParticipants.Position}"); //if (playingParticipants.Name == "jacano") //{ Console.WriteLine($"{playingParticipants.Name} - position: {playingParticipants.Position}"); //} } }
private void OnTickDone(object sender, TickDoneEventArgs args) { if (isBombPlanted && !isRoundOver) { bombPlantTotalElapsedTicks++; bombPlantYieldResultElapsedTicks++; var elapsedSeconds = secondsPerTick * bombPlantYieldResultElapsedTicks; if (elapsedSeconds > 1f) { snapshotResultThisTick = true; bombPlantYieldResultElapsedTicks = 0; } } }
private static void Parser_TickDone(object sender, TickDoneEventArgs e) { if (_roundEndedCount == 0) { return; } _roundEndedCount++; if (_roundEndedCount < _parser.TickRate * 2) { return; } _roundEndedCount = 0; RoundEnd(); }
protected new void HandleTickDone(object sender, TickDoneEventArgs e) { ProgressCallback?.Invoke(Demo.Id, Parser.ParsingProgess); if (!_isTeamsInitialized) { Application.Current.Dispatcher.Invoke(delegate { if (Demo.Players.Count < 10) InitMatch(); Demo.Rounds.Clear(); CreateNewRound(); // since some demos are already started we can't use the freezetime event if (CurrentRound.Number == 1) IsFreezetime = false; }); } base.HandleTickDone(sender, e); }
private void Parser_TickDone(object sender, TickDoneEventArgs e) { if (roundEndedCount == 0) { return; } roundEndedCount++; // Wait 2 seconds after round ends to properly record winner of the round if (roundEndedCount < parser.TickRate * 2) { return; } roundEndedCount = 0; RoundEnd(); }
protected new void HandleTickDone(object sender, TickDoneEventArgs e) { if (Parser.PlayingParticipants.Count() >= 10 && Parser.PlayingParticipants.FirstOrDefault(p => p.SteamID == 0) == null && !_isTeamsInitialized) { Application.Current.Dispatcher.Invoke(delegate { if (Demo.Players.Count < 10) { AddTeams(); } else { _isTeamsInitialized = true; } Demo.Rounds.Clear(); RoundCount = 0; CreateNewRound(); CurrentRound.EquipementValueTeam1 = Parser.Participants.Where(a => a.Team == Team.CounterTerrorist).Sum(a => a.CurrentEquipmentValue); CurrentRound.EquipementValueTeam2 = Parser.Participants.Where(a => a.Team == Team.Terrorist).Sum(a => a.CurrentEquipmentValue); }); } base.HandleTickDone(sender, e); }
/// <summary> /// Handle each tick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandleTickDone(object sender, TickDoneEventArgs e) { if (!IsMatchStarted || IsFreezetime || !AnalyzePlayersPosition) return; if (Parser.PlayingParticipants.Any()) { if (Demo.Players.Any()) { // Reset bomber foreach (PlayerExtended playerExtended in Demo.Players) { playerExtended.HasBomb = false; } // Update players position foreach (Player player in Parser.PlayingParticipants) { if (!player.IsAlive) continue; PlayerExtended pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); if (pl == null || pl.SteamId == 0) continue; // Set the bomber if (player.Weapons.FirstOrDefault(w => w.Weapon == EquipmentElement.Bomb) != null) pl.HasBomb = true; PositionPoint positionPoint = new PositionPoint { X = player.Position.X, Y = player.Position.Y, Round = CurrentRound, Team = player.Team, Player = pl.Clone() }; Demo.PositionsPoint.Add(positionPoint); } } } }
/// <summary> /// Handle each tick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandleTickDone(object sender, TickDoneEventArgs e) { if (!IsMatchStarted || IsFreezetime) return; if (AnalyzeFlashbang) { foreach (Player player in Parser.PlayingParticipants) { PlayerExtended pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); if (pl != null && player.FlashDuration >= pl.FlashDurationTemp) { PlayerBlindedEvent playerBlindedEvent = new PlayerBlindedEvent(Parser.CurrentTick, Parser.CurrentTime) { ThrowerSteamId = LastPlayerExplodedFlashbang.SteamId, ThrowerName = LastPlayerExplodedFlashbang.Name, ThrowerTeamName = LastPlayerExplodedFlashbang.TeamName, VictimSteamId = pl.SteamId, VictimName = pl.Name, VictimTeamName = pl.TeamName, RoundNumber = CurrentRound.Number, Duration = player.FlashDuration - pl.FlashDurationTemp }; Demo.PlayerBlindedEvents.Add(playerBlindedEvent); } } AnalyzeFlashbang = false; } if (!AnalyzePlayersPosition) return; if (Parser.PlayingParticipants.Any()) { if (Demo.Players.Any()) { // Reset bomber foreach (PlayerExtended playerExtended in Demo.Players) { playerExtended.HasBomb = false; } // Update players position foreach (Player player in Parser.PlayingParticipants) { if (!player.IsAlive) continue; PlayerExtended pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); if (pl == null || pl.SteamId == 0) continue; // Set the bomber if (player.Weapons.FirstOrDefault(w => w.Weapon == EquipmentElement.Bomb) != null) pl.HasBomb = true; PositionPoint positionPoint = new PositionPoint { X = player.Position.X, Y = player.Position.Y, RoundNumber = CurrentRound.Number, Team = player.Team, PlayerName = player.Name, PlayerSteamId = player.SteamID, PlayerHasBomb = pl.HasBomb }; Demo.PositionsPoint.Add(positionPoint); } } } }
/// <summary> /// Handle each tick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandleTickDone(object sender, TickDoneEventArgs e) { if (!IsMatchStarted || IsFreezetime || !AnalyzePlayersPosition) return; if (Parser.PlayingParticipants.Any()) { if (Demo.Players.Any()) { // Update players position foreach (Player player in Parser.PlayingParticipants) { if (!player.IsAlive) continue; PlayerExtended pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); if (pl == null || pl.SteamId == 0) continue; PositionPoint positionPoint = new PositionPoint { X = player.Position.X, Y = player.Position.Y, Round = CurrentRound, Team = player.Team, Player = pl }; Demo.PositionsPoint.Add(positionPoint); } } } }
private void HandleTickDone(object sender, TickDoneEventArgs e) { CurrentTick.IngameTick = Parser.IngameTick; if (Parser.CTScore != lastCtScore || Parser.TScore != lastTScore || Parser.CTClanName != lastCtName || Parser.TClanName != lastTName || Parser.CTFlag != lastCtFlag || Parser.TFlag != lastTFlag) { TeanInfoUpdateEvent infoUpdate = new TeanInfoUpdateEvent() { CTScore = Parser.CTScore, TScore = Parser.TScore, CTName = Parser.CTClanName, TName = Parser.TClanName, CTFlag = Parser.CTFlag, TFlag = Parser.TFlag }; lastCtScore = Parser.CTScore; lastTScore = Parser.TScore; lastCtName = Parser.CTClanName; lastTName = Parser.TClanName; lastCtFlag = Parser.CTFlag; lastTFlag = Parser.TFlag; CurrentTick.Events.Add(infoUpdate); } //Store the names and steam IDs for every steam account in the server, including casters, bots and referees foreach (var participant in Parser.Participants) { byte NameIndex = 0; if (Demo.NameMappings.ContainsValue(participant.Name)) { NameIndex = Demo.NameMappings.FirstOrDefault(x => x.Value == participant.Name).Key; } else { NameIndex = CurrentNameIndex; Demo.NameMappings.Add(NameIndex, participant.Name); CurrentNameIndex++; } byte SteamIDIndex = 0; if (Demo.SteamIDMappings.ContainsValue(participant.SteamID)) { SteamIDIndex = Demo.SteamIDMappings.FirstOrDefault(x => x.Value == participant.SteamID).Key; } else { SteamIDIndex = CurrentSteamIDIndex; Demo.SteamIDMappings.Add(SteamIDIndex, participant.SteamID); CurrentSteamIDIndex++; } } //Loop though players that are actually playing the match foreach (var player in Parser.PlayingParticipants) { byte NameIndex = 0; if (Demo.NameMappings.ContainsValue(player.Name)) { NameIndex = Demo.NameMappings.FirstOrDefault(x => x.Value == player.Name).Key; } else { NameIndex = CurrentNameIndex; Demo.NameMappings.Add(NameIndex, player.Name); CurrentNameIndex++; } byte SteamIDIndex = 0; if (Demo.SteamIDMappings.ContainsValue(player.SteamID)) { SteamIDIndex = Demo.SteamIDMappings.FirstOrDefault(x => x.Value == player.SteamID).Key; } else { SteamIDIndex = CurrentSteamIDIndex; Demo.SteamIDMappings.Add(SteamIDIndex, player.SteamID); CurrentSteamIDIndex++; } Dictionary <byte, byte> AmmoLeft = new Dictionary <byte, byte>(); for (int i = 0; i < 32; i++) { if (player.AmmoLeft[i] != 0) { AmmoLeft.Add((byte)i, (byte)player.AmmoLeft[i]); } } Dictionary <short, Weapon> Weapons = new Dictionary <short, Weapon>(); foreach (var pair in player.rawWeapons) { Weapons.Add((short)pair.Key, new Weapon() { Equipment = (Models.EquipmentElement)((int)pair.Value.Weapon), OriginalString = pair.Value.OriginalString, AmmoInMagazine = (short)pair.Value.AmmoInMagazine, AmmoType = (short)pair.Value.AmmoType, ZoomLevel = (byte)pair.Value.ZoomLevel }); } FullPlayerState fullPlayerState = new FullPlayerState() { Type = PlayerStateType.Full, NameIndex = NameIndex, SteamIDIndex = SteamIDIndex, Position = new Models.Vector(player.Position.X, player.Position.Y, player.Position.Z), ViewOffsetZ = player.ViewOffset.Z, HP = (byte)player.HP, Armor = (byte)player.Armor, Velocity = new Models.Vector(player.Velocity.X, player.Velocity.Y, player.Velocity.Z), ViewDirectionX = player.ViewDirectionX, ViewDirectionY = player.ViewDirectionY, FlashDuration = player.FlashDuration, Money = (short)player.Money, CurrentEquipmentValue = (short)player.CurrentEquipmentValue, FreezetimeEndEquipmentValue = (short)player.FreezetimeEndEquipmentValue, RoundStartEquipmentValue = (short)player.RoundStartEquipmentValue, IsDucking = player.IsDucking, ActiveWeaponID = (byte)player.ActiveWeaponID, Team = (Models.Team)((int)player.Team), HasDefuseKit = player.HasDefuseKit, HasHelmet = player.HasHelmet, AmmoLeft = AmmoLeft, Weapons = Weapons, IsScoped = player.IsScoped, ShotsFired = player.ShotsFired, AimPunchAngle = new Models.Vector(player.AimPunchAngle.X, player.AimPunchAngle.Y, player.AimPunchAngle.Z), }; PositionPlayerState positionPlayerState = new PositionPlayerState(fullPlayerState); bool positionStateEqual = false; bool fullStateEqual = false; if (MostRecentPlayerStates.ContainsKey(SteamIDIndex)) { FullPlayerState mostRecentFullState = MostRecentPlayerStates[SteamIDIndex]; positionStateEqual = positionPlayerState.Equals(mostRecentFullState); fullStateEqual = fullPlayerState.Equals(mostRecentFullState); } if (fullStateEqual && positionStateEqual) { CurrentTick.PlayerStates.Add(new BasePlayerState() { Type = PlayerStateType.Base, SteamIDIndex = SteamIDIndex }); } else { MostRecentPlayerStates[SteamIDIndex] = fullPlayerState; if (fullStateEqual && !positionStateEqual) { CurrentTick.PlayerStates.Add(positionPlayerState); } else { CurrentTick.PlayerStates.Add(fullPlayerState); } } } foreach (var entity in Parser.Entities) { FullEntityState fullEntityState = new FullEntityState() { Type = EntityStateType.Full, ID = (short)entity.ID, EntityType = (Models.EntityType)((int)entity.Type), Position = new Models.Vector(entity.Position.X, entity.Position.Y, entity.Position.Z), Rotation = new Models.Vector(entity.Rotation.X, entity.Rotation.Y, entity.Rotation.Z), ModelIndex = entity.ModelIndex, ModelLocation = entity.ModelLocation }; if (MostRecentEntityStates.ContainsKey(entity.ID)) { FullEntityState mostRecentFullState = MostRecentEntityStates[entity.ID]; bool fullStateEqual = fullEntityState.Equals(mostRecentFullState); if (fullStateEqual && !CurrentTick.Events.Any((evnt) => evnt.Type == EventType.RoundStart)) { CurrentTick.EntityStates.Add(new BaseEntityState(fullEntityState)); } else { CurrentTick.EntityStates.Add(fullEntityState); MostRecentEntityStates[entity.ID] = fullEntityState; } } else { MostRecentEntityStates[entity.ID] = fullEntityState; CurrentTick.EntityStates.Add(fullEntityState); } } Demo.Ticks.Add(CurrentTick); CurrentTick = new Tick(); }