Exemple #1
0
 internal void RaiseWeaponFired(WeaponFiredEventArgs fire)
 {
     if (WeaponFired != null)
     {
         WeaponFired(this, fire);
     }
 }
Exemple #2
0
		internal void RaiseWeaponFired(WeaponFiredEventArgs fire)
		{
			if (WeaponFired != null)
				WeaponFired(this, fire);
		}
		protected new void HandleWeaponFired(object sender, WeaponFiredEventArgs e)
		{
			if (!_isTeamsInitialized) return;

			base.HandleWeaponFired(sender, e);
		}
		protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e)
		{
			if (!IsMatchStarted || e.Shooter == null) return;

			if (!IsFirstShotOccured)
			{
				IsFirstShotOccured = true;
				if (IsHalfMatch)
				{
					CurrentRound.EquipementValueTeam1 = Parser.Participants.Where(a => a.Team == Team.Terrorist).Sum(a => a.CurrentEquipmentValue);
					CurrentRound.EquipementValueTeam2 = Parser.Participants.Where(a => a.Team == Team.CounterTerrorist).Sum(a => a.CurrentEquipmentValue);
				}
				else
				{
					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);
				}

				// Not 100% accurate maybe improved it with current equipement...
				if (CurrentRound.StartMoneyTeam1 == 4000 && CurrentRound.StartMoneyTeam2 == 4000)
				{
					CurrentRound.Type = RoundType.PISTOL_ROUND;
				}
				else
				{
					double diffPercent = Math.Abs(Math.Round((((double)CurrentRound.EquipementValueTeam1 - CurrentRound.EquipementValueTeam2) / (((double)CurrentRound.EquipementValueTeam1 + CurrentRound.EquipementValueTeam2) / 2) * 100), 2));
					if (diffPercent >= 90)
					{
						CurrentRound.Type = RoundType.ECO;
					}
					else if (diffPercent >= 75 && diffPercent < 90)
					{
						CurrentRound.Type = RoundType.SEMI_ECO;
					}
					else if (diffPercent >= 50 && diffPercent < 75)
					{
						CurrentRound.Type = RoundType.FORCE_BUY;
					}
					else
					{
						CurrentRound.Type = RoundType.NORMAL;
					}

					if (CurrentRound.Type != RoundType.NORMAL)
					{
						if (IsOvertime)
						{
							if (IsHalfMatch)
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTrouble = Demo.Teams[0];
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
								else
								{
									CurrentRound.TeamTrouble = Demo.Teams[1];
									CurrentRound.SideTrouble = Team.Terrorist;
								}
							}
							else
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTrouble = Demo.Teams[1];
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
								else
								{
									CurrentRound.TeamTrouble = Demo.Teams[0];
									CurrentRound.SideTrouble = Team.Terrorist;
								}
							}
						}
						else
						{
							if (IsHalfMatch)
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTrouble = Demo.Teams[0];
									CurrentRound.SideTrouble = Team.Terrorist;
								}
								else
								{
									CurrentRound.TeamTrouble = Demo.Teams[1];
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
							}
							else
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTrouble = Demo.Teams[1];
									CurrentRound.SideTrouble = Team.Terrorist;
								}
								else
								{
									CurrentRound.TeamTrouble = Demo.Teams[0];
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
							}
						}
					}
						
				}
			}

			if (AnalyzeHeatmapPoint || AnalyzePlayersPosition)
			{
				WeaponFire shoot = new WeaponFire(Parser.IngameTick)
				{
					Shooter = Demo.Players.FirstOrDefault(p => p.SteamId == e.Shooter.SteamID),
					Weapon = new Weapon(e.Weapon)
				};

				if (AnalyzeHeatmapPoint && shoot.Shooter != null)
				{
					shoot.Point = new HeatmapPoint
					{
						X = e.Shooter.Position.X,
						Y = e.Shooter.Position.Y,
						Round = CurrentRound,
						Player = shoot.Shooter,
						Team = e.Shooter.Team
					};
				}

				Demo.WeaponFired.Add(shoot);

				if (AnalyzePlayersPosition || AnalyzeHeatmapPoint && shoot.Shooter != null)
				{
					if (e.Shooter.SteamID == 0) return;

					switch (e.Weapon.Weapon)
					{
						case EquipmentElement.Incendiary:
						case EquipmentElement.Molotov:
							LastPlayersThrowedMolotov.Enqueue(Demo.Players.First(p => p.SteamId == e.Shooter.SteamID));
							if (AnalyzeHeatmapPoint) return;
							goto case EquipmentElement.Decoy;
						case EquipmentElement.Decoy:
						case EquipmentElement.Flash:
						case EquipmentElement.HE:
						case EquipmentElement.Smoke:
							PositionPoint positionPoint = new PositionPoint
							{
								X = e.Shooter.Position.X,
								Y = e.Shooter.Position.Y,
								Player = Demo.Players.First(p => p.SteamId == e.Shooter.SteamID),
								Team = e.Shooter.Team,
								Event = shoot,
								Round = CurrentRound
							};
							Demo.PositionsPoint.Add(positionPoint);
							break;
					}
				}
			}
			else
			{
				PlayerExtended shooter = Demo.Players.FirstOrDefault(p => p.SteamId == e.Shooter.SteamID);
				if (shooter == null) return;
				
				switch (e.Weapon.Weapon)
				{
					case EquipmentElement.Incendiary:
						shooter.IncendiaryThrowedCount++;
						break;
					case EquipmentElement.Molotov:
						shooter.MolotovThrowedCount++;
						break;
					case EquipmentElement.Decoy:
						shooter.DecoyThrowedCount++;
						break;
					case EquipmentElement.Flash:
						shooter.FlashbangThrowedCount++;
						break;
					case EquipmentElement.HE:
						shooter.HeGrenadeThrowedCount++;
						break;
					case EquipmentElement.Smoke:
						shooter.SMokeThrowedCount++;
						break;
				}
			}
		}
		protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e)
		{
			if (!IsMatchStarted || e.Shooter == null) return;

			if (!IsFirstShotOccured)
			{
				IsFirstShotOccured = true;
				// update the equipement value for each player
				foreach (Player pl in Parser.PlayingParticipants)
				{
					PlayerExtended player = Demo.Players.FirstOrDefault(p => p.SteamId == pl.SteamID);
					if (player != null && !player.EquipementValueRounds.ContainsKey(CurrentRound.Number))
					{
						player.EquipementValueRounds.Add(CurrentRound.Number, pl.CurrentEquipmentValue);
					}
				}

				if (IsHalfMatch)
				{
					CurrentRound.EquipementValueTeam1 = Parser.Participants.Where(a => a.Team == Team.Terrorist).Sum(a => a.CurrentEquipmentValue);
					CurrentRound.EquipementValueTeam2 = Parser.Participants.Where(a => a.Team == Team.CounterTerrorist).Sum(a => a.CurrentEquipmentValue);
				}
				else
				{
					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);
				}

				// Not 100% accurate maybe improved it with current equipement...
				if (CurrentRound.StartMoneyTeam1 == 4000 && CurrentRound.StartMoneyTeam2 == 4000)
				{
					CurrentRound.Type = RoundType.PISTOL_ROUND;
				}
				else
				{
					double diffPercent = Math.Abs(Math.Round((((double)CurrentRound.EquipementValueTeam1 - CurrentRound.EquipementValueTeam2) / (((double)CurrentRound.EquipementValueTeam1 + CurrentRound.EquipementValueTeam2) / 2) * 100), 2));
					if (diffPercent >= 90)
					{
						CurrentRound.Type = RoundType.ECO;
					}
					else if (diffPercent >= 75 && diffPercent < 90)
					{
						CurrentRound.Type = RoundType.SEMI_ECO;
					}
					else if (diffPercent >= 50 && diffPercent < 75)
					{
						CurrentRound.Type = RoundType.FORCE_BUY;
					}
					else
					{
						CurrentRound.Type = RoundType.NORMAL;
					}

					if (CurrentRound.Type != RoundType.NORMAL)
					{
						if (IsOvertime)
						{
							if (IsHalfMatch)
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTroubleName = Demo.TeamCT.Name;
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
								else
								{
									CurrentRound.TeamTroubleName = Demo.TeamT.Name;
									CurrentRound.SideTrouble = Team.Terrorist;
								}
							}
							else
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTroubleName = Demo.TeamT.Name;
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
								else
								{
									CurrentRound.TeamTroubleName = Demo.TeamCT.Name;
									CurrentRound.SideTrouble = Team.Terrorist;
								}
							}
						}
						else
						{
							if (IsHalfMatch)
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTroubleName = Demo.TeamCT.Name;
									CurrentRound.SideTrouble = Team.Terrorist;
								}
								else
								{
									CurrentRound.TeamTroubleName = Demo.TeamT.Name;
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
							}
							else
							{
								if (CurrentRound.EquipementValueTeam1 > CurrentRound.EquipementValueTeam2)
								{
									CurrentRound.TeamTroubleName = Demo.TeamT.Name;
									CurrentRound.SideTrouble = Team.Terrorist;
								}
								else
								{
									CurrentRound.TeamTroubleName = Demo.TeamCT.Name;
									CurrentRound.SideTrouble = Team.CounterTerrorist;
								}
							}
						}
					}
						
				}
			}

			PlayerExtended shooter = Demo.Players.FirstOrDefault(p => p.SteamId == e.Shooter.SteamID);
			Weapon weapon = Weapon.WeaponList.FirstOrDefault(w => w.Element == e.Weapon.Weapon);
			if (shooter == null || weapon == null) return;

			switch (e.Weapon.Weapon)
			{
				case EquipmentElement.Incendiary:
					CurrentRound.IncendiaryThrownCount++;
					shooter.IncendiaryThrownCount++;
					break;
				case EquipmentElement.Molotov:
					CurrentRound.MolotovThrownCount++;
					shooter.MolotovThrownCount++;
					break;
				case EquipmentElement.Decoy:
					CurrentRound.DecoyThrownCount++;
					shooter.DecoyThrownCount++;
					break;
				case EquipmentElement.Flash:
					CurrentRound.FlashbangThrownCount++;
					shooter.FlashbangThrownCount++;
					PlayersFlashQueue.Enqueue(shooter);
					break;
				case EquipmentElement.HE:
					CurrentRound.HeGrenadeThrownCount++;
					shooter.HeGrenadeThrownCount++;
					break;
				case EquipmentElement.Smoke:
					CurrentRound.SmokeThrownCount++;
					shooter.SmokeThrownCount++;
					break;
			}

			WeaponFire shoot = new WeaponFire(Parser.IngameTick, Parser.CurrentTime)
			{
				ShooterSteamId = shooter.SteamId,
				ShooterName = shooter.Name,
				Weapon = weapon,
				RoundNumber = CurrentRound.Number,
				ShooterVelocityX = e.Shooter.Velocity.X,
				ShooterVelocityY = e.Shooter.Velocity.Y,
				ShooterVelocityZ = e.Shooter.Velocity.Z
			};
			Demo.WeaponFired.Add(shoot);

			if (AnalyzeHeatmapPoint || AnalyzePlayersPosition)
			{
				if (AnalyzeHeatmapPoint)
				{
					shoot.Point = new HeatmapPoint
					{
						X = e.Shooter.Position.X,
						Y = e.Shooter.Position.Y,
						Round = CurrentRound,
						Player = Demo.Players.First(p => p.SteamId == shoot.ShooterSteamId),
						Team = e.Shooter.Team
					};
				}

				if (AnalyzePlayersPosition || AnalyzeHeatmapPoint)
				{
					if (e.Shooter.SteamID == 0) return;

					switch (e.Weapon.Weapon)
					{
						case EquipmentElement.Incendiary:
						case EquipmentElement.Molotov:
							LastPlayersThrownMolotov.Enqueue(Demo.Players.First(p => p.SteamId == e.Shooter.SteamID));
							if (AnalyzeHeatmapPoint) return;
							goto case EquipmentElement.Decoy;
						case EquipmentElement.Decoy:
						case EquipmentElement.Flash:
						case EquipmentElement.HE:
						case EquipmentElement.Smoke:
							PositionPoint positionPoint = new PositionPoint
							{
								X = e.Shooter.Position.X,
								Y = e.Shooter.Position.Y,
								PlayerSteamId = e.Shooter.SteamID,
								PlayerName = e.Shooter.Name,
								Team = e.Shooter.Team,
								Event = shoot,
								RoundNumber = CurrentRound.Number
							};
							Demo.PositionsPoint.Add(positionPoint);
							break;
					}
				}
			}
		}
		protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e)
		{
			if (!AnalyzeHeatmapPoint && !AnalyzePlayersPosition || !IsMatchStarted || e.Shooter == null) return;

			WeaponFire shoot = new WeaponFire(Parser.IngameTick)
			{
				Shooter = Demo.Players.FirstOrDefault(p => p.SteamId == e.Shooter.SteamID),
				Weapon = new Weapon(e.Weapon)
			};

			if (AnalyzeHeatmapPoint && shoot.Shooter != null)
			{
				shoot.Point = new HeatmapPoint
				{
					X = e.Shooter.Position.X,
					Y = e.Shooter.Position.Y,
					Round = CurrentRound,
					Player = shoot.Shooter,
					Team = e.Shooter.Team
				};
			}

			Demo.WeaponFired.Add(shoot);

			if (AnalyzePlayersPosition || AnalyzeHeatmapPoint && shoot.Shooter != null)
			{
				switch (e.Weapon.Weapon)
				{
					case EquipmentElement.Incendiary:
					case EquipmentElement.Molotov:
						LastPlayersThrowedMolotov.Enqueue(Demo.Players.First(p => p.SteamId == e.Shooter.SteamID));
						if (AnalyzeHeatmapPoint) return;
						goto case EquipmentElement.Decoy;
					case EquipmentElement.Decoy:
					case EquipmentElement.Flash:
					case EquipmentElement.HE:
					case EquipmentElement.Smoke:
						PositionPoint positionPoint = new PositionPoint
						{
							X = e.Shooter.Position.X,
							Y = e.Shooter.Position.Y,
							Player = Demo.Players.First(p => p.SteamId == e.Shooter.SteamID),
							Team = e.Shooter.Team,
							Event = shoot,
							Round = CurrentRound
						};
						Demo.PositionsPoint.Add(positionPoint);
						break;
				}
			}
		}