/// <summary> /// When a player is hurted /// Trigerred only with demos > 6/30/2015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandlePlayerHurted(object sender, PlayerHurtEventArgs e) { if (!IsMatchStarted) return; // may be a bot on MM demos PlayerExtended hurted = Demo.Players.FirstOrDefault(player => player.SteamId == e.Player.SteamID); if (hurted == null) return; PlayerExtended attacker = null; // attacker may be null (hurted by world) if (e.Attacker != null) attacker = Demo.Players.FirstOrDefault(player => player.SteamId == e.Attacker.SteamID); PlayerHurtedEvent playerHurtedEvent = new PlayerHurtedEvent(Parser.IngameTick) { Attacker = attacker, Hurted = hurted, Armor = e.Armor, ArmorDamage = e.ArmorDamage, Health = e.Health, HealthDamage = e.HealthDamage, HitGroup = e.Hitgroup, Weapon = new Weapon(e.Weapon), RoundNumber = CurrentRound.Number }; attacker?.PlayersHurted.Add(playerHurtedEvent); hurted?.PlayersHurted.Add(playerHurtedEvent); CurrentRound.PlayersHurted.Add(playerHurtedEvent); }
/// <summary> /// When a player is hurted /// Trigerred only with demos > 06/30/2015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void HandlePlayerHurted(object sender, PlayerHurtEventArgs e) { if (!IsMatchStarted || e.Player == null) return; // may be a bot on MM demos PlayerExtended hurted = Demo.Players.FirstOrDefault(player => player.SteamId == e.Player.SteamID); Weapon weapon = Weapon.WeaponList.FirstOrDefault(w => w.Element == e.Weapon.Weapon); if (hurted == null || weapon == null) return; PlayerExtended attacker = null; // attacker may be null (hurted by world) if (e.Attacker != null) attacker = Demo.Players.FirstOrDefault(player => player.SteamId == e.Attacker.SteamID); PlayerHurtedEvent playerHurtedEvent = new PlayerHurtedEvent(Parser.IngameTick, Parser.CurrentTime) { AttackerSteamId = attacker?.SteamId ?? 0, HurtedSteamId = hurted.SteamId, ArmorDamage = e.ArmorDamage, HealthDamage = e.HealthDamage, HitGroup = e.Hitgroup, Weapon = weapon, RoundNumber = CurrentRound.Number }; Demo.PlayersHurted.Add(playerHurtedEvent); attacker?.PlayersHurted.Add(playerHurtedEvent); hurted.PlayersHurted.Add(playerHurtedEvent); CurrentRound.PlayersHurted.Add(playerHurtedEvent); }