Exemplo n.º 1
0
        /*public List<PlayerMeta> assemblePlayers(IEnumerable<DemoInfoModded.Player> ps)
         * {
         *  if (ps == null)
         *      return null;
         *  List<PlayerMeta> players = new List<PlayerMeta>();
         *  foreach (var player in ps)
         *      players.Add(assemblePlayerMeta(player));
         *
         *  return players;
         * }*/


        internal PlayerDetailed AssemblePlayerDetailed(DemoInfo.Player p)
        {
            if (p == null)
            {
                return(null);
            }

            return(new PlayerDetailed
            {
                Playername = p.Name,
                player_id = p.SteamID,
                Position = new Point3D(p.Position.X, p.Position.Y, p.Position.Z),
                Facing = new Facing {
                    Yaw = p.ViewDirectionX, Pitch = p.ViewDirectionY
                },
                Team = p.Team.ToString(),
                IsDucking = p.IsDucking,
                IsSpotted = p.IsSpotted,
                IsScoped = p.IsScoped,
                IsWalking = p.IsWalking,
                HasHelmet = p.HasHelmet,
                HasDefuser = p.HasDefuseKit,
                HP = p.HP,
                Armor = p.Armor,
                Velocity = new Velocity {
                    VX = p.Velocity.X, VY = p.Velocity.Y, VZ = p.Velocity.Z
                },
                Items = AssembleWeapons(p.Weapons)
            });
        }
Exemplo n.º 2
0
 internal Event AssemblePlayerPosition(DemoInfo.Player p)
 {
     return(new Event
     {
         GameeventType = "player_position",
         Actor = AssemblePlayer(p)
     });
 }
Exemplo n.º 3
0
 internal ServerEvents assemblePlayerDisconnected(DemoInfo.Player player)
 {
     Console.WriteLine("Disconnect: " + player.Name + " ID: " + player.SteamID);
     return(new ServerEvents
     {
         GameeventType = "player_disconnected",
         Actor = AssemblePlayer(player)
     });
 }
Exemplo n.º 4
0
 internal ServerEvents assemblePlayerBind(DemoInfo.Player player)
 {
     Console.WriteLine("Bind: " + player.Name + " ID: " + player.SteamID);
     return(new ServerEvents
     {
         GameeventType = "player_bind",
         Actor = AssemblePlayer(player)
     });
 }
Exemplo n.º 5
0
 internal PlayerMeta AssemblePlayerMeta(DemoInfo.Player p)
 {
     return(new PlayerMeta
     {
         Playername = p.Name,
         player_id = p.SteamID,
         Team = p.Team.ToString(),
         Clanname = p.AdditionaInformations.Clantag
     });
 }
Exemplo n.º 6
0
 private void SetPlayerTeamName(DemoInfo.Player player, Models.Player victim)
 {
     if (player.Team == Team.Terrorist)
     {
         victim.TeamName = _demo.TClanName;
     }
     else
     {
         victim.TeamName = _demo.CTClanName;
     }
 }
Exemplo n.º 7
0
        public string playerInfoToSQL(Player player, float currentTime, int roundNumber)
        {
            var sb = new StringBuilder();

            var sql = sb.Append("insert into playerInfo values (")
                      .Append(f2s(player.Position.X)).Append(", ")
                      .Append(f2s(player.Position.Y)).Append(", ")
                      .Append(f2s(player.Position.Z)).Append(", ")
                      .Append(player.Armor).Append(", ")
                      .Append(player.CurrentEquipmentValue).Append(", ")
                      .Append(Convert.ToInt32(player.Disconnected)).Append(", ")
                      .Append(player.EntityID).Append(", ")
                      .Append(player.FreezetimeEndEquipmentValue).Append(", ")
                      .Append(Convert.ToInt32(player.HasDefuseKit)).Append(", ")
                      .Append(Convert.ToInt32(player.HasHelmet)).Append(", ")
                      .Append(player.HP).Append(", ")
                      .Append(Convert.ToInt32(player.IsAlive)).Append(", ")
                      .Append(Convert.ToInt32(player.IsDucking)).Append(", ")
                      .Append(f2s(player.LastAlivePosition.X)).Append(", ")
                      .Append(f2s(player.LastAlivePosition.Y)).Append(", ")
                      .Append(f2s(player.LastAlivePosition.Z)).Append(", ")
                      .Append(player.Money).Append(", ")
                      .Append(toSqlString(player.Name)).Append(", ")
                      .Append(player.RoundStartEquipmentValue).Append(", ")
                      .Append(player.SteamID).Append(", ")
                      .Append(toSqlString(player.Team.ToString())).Append(", ")
                      .Append(f2s(player.Velocity.X)).Append(", ")
                      .Append(f2s(player.Velocity.Y)).Append(", ")
                      .Append(f2s(player.Velocity.Z)).Append(", ")
                      .Append(f2s(player.ViewDirectionX)).Append(", ")
                      .Append(f2s(player.ViewDirectionY)).Append(", ")
                      .Append(roundNumber).Append(", ");
            var weapons = player.Weapons.ToArray<Equipment>();
            for(int i = 0; i < 2; i++) {
                if(i < weapons.Length)
                {
                    sql.Append(toSqlString(weapons[i].Weapon.ToString())).Append(", ");
                }
                else
                {
                    sql.Append(toSqlString("null")).Append(", ");
                }

            }
            sql.Append(f2s(currentTime )).Append(")");

            return sb.ToString();
        }
Exemplo n.º 8
0
        private int BlindedEnemies(DemoInfo.Player[] players, DemoInfo.Player playerThrownBy)
        {
            int blindedEnemies = 0;

            if (players.Length > 0)
            {
                for (int i = 0; i < players.Length; i++)
                {
                    if (players[i].Team != playerThrownBy.Team && players[i].FlashDuration >= 1)
                    {
                        blindedEnemies++;
                    }
                }
            }

            return(blindedEnemies);
        }
Exemplo n.º 9
0
 internal Data.Gameobjects.Player AssemblePlayer(DemoInfo.Player p)
 {
     return(new Data.Gameobjects.Player
     {
         Playername = p.Name,
         player_id = p.SteamID,
         Position = new Point3D(p.Position.X, p.Position.Y, p.Position.Z),
         Facing = new Facing {
             Yaw = p.ViewDirectionX, Pitch = p.ViewDirectionY
         },
         Velocity = new Velocity {
             VX = p.Velocity.X, VY = p.Velocity.Y, VZ = p.Velocity.Z
         },
         Team = p.Team.ToString(),
         IsSpotted = p.IsSpotted,
         HP = p.HP
     });
 }
Exemplo n.º 10
0
        internal PlayerFlashed AssembleFlashPlayer(DemoInfo.Player p)
        {
            PlayerFlashed player = new PlayerFlashed
            {
                Playername = p.Name,
                player_id  = p.SteamID,
                Position   = new Point3D(p.Position.X, p.Position.Y, p.Position.Z),
                Velocity   = new Velocity {
                    VX = p.Velocity.X, VY = p.Velocity.X, VZ = p.Velocity.X
                },
                Facing = new Facing {
                    Yaw = p.ViewDirectionX, Pitch = p.ViewDirectionY
                },
                HP              = p.HP,
                IsSpotted       = p.IsSpotted,
                Team            = p.Team.ToString(),
                Flashedduration = p.FlashDuration
            };

            return(player);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Copy this instance for multi-threading use. 
        /// </summary>
        public Player Copy()
        {
            Player me = new Player();
            me.EntityID = -1; //this should bot be copied
            me.Entity = null;

            me.Name = Name;
            me.SteamID = SteamID;
            me.HP = HP;
            me.Armor = Armor;

            me.ViewDirectionX = ViewDirectionX;
            me.ViewDirectionY = ViewDirectionY;
            me.Disconnected = Disconnected;

            me.Team = Team;

            me.HasDefuseKit = HasDefuseKit;
            me.HasHelmet = HasHelmet;

            if (Position != null)
                me.Position = Position.Copy(); //Vector is a class, not a struct - thus we need to make it thread-safe.

            if (LastAlivePosition != null)
                me.LastAlivePosition = LastAlivePosition.Copy();

            if (Velocity != null)
                me.Velocity = Velocity.Copy();

            return me;
        }
Exemplo n.º 12
0
 private bool IsPlayerWalking(DemoInfo.Player jogador) => (jogador.Velocity.Absolute >= 75 && jogador.Velocity.Absolute <= 140);
Exemplo n.º 13
0
		private bool AttributeWeapon(int weaponEntityIndex, Player p)
		{
			var weapon = weapons[weaponEntityIndex];
			weapon.Owner = p;
			p.rawWeapons [weaponEntityIndex] = weapon;

			return true;
		}
Exemplo n.º 14
0
		private void HandleNewPlayer(Entity playerEntity)
		{
			Player p = null;
			if (this.PlayerInformations [playerEntity.ID - 1] != null) {
				p = this.PlayerInformations [playerEntity.ID - 1];
			} else {
				p = new Player ();
				this.PlayerInformations [playerEntity.ID - 1] = p;
				p.SteamID = -1;
				p.Name = "unconnected";
			}

			p.EntityID = playerEntity.ID;
			p.Entity = playerEntity;
			p.Position = new Vector();
			p.Velocity = new Vector();

			//position update
			playerEntity.FindProperty("cslocaldata.m_vecOrigin").VectorRecived += (sender, e) => {
				p.Position.X = e.Value.X; 
				p.Position.Y = e.Value.Y;
			};

			playerEntity.FindProperty("cslocaldata.m_vecOrigin[2]").FloatRecived += (sender, e) => {
				p.Position.Z = e.Value; 
			};

			//team update
			//problem: Teams are networked after the players... How do we solve that?
			playerEntity.FindProperty("m_iTeamNum").IntRecived += (sender, e) => { 

				p.TeamID = e.Value;

				if (e.Value == ctID)
					p.Team = Team.CounterTerrorist;
				else if (e.Value == tID)
					p.Team = Team.Terrorist;
				else
					p.Team = Team.Spectate;
			};

			//update some stats
			playerEntity.FindProperty("m_iHealth").IntRecived += (sender, e) => p.HP = e.Value;
			playerEntity.FindProperty("m_ArmorValue").IntRecived += (sender, e) => p.Armor = e.Value;
			playerEntity.FindProperty("m_bHasDefuser").IntRecived += (sender, e) => p.HasDefuseKit = e.Value == 1;
			playerEntity.FindProperty("m_bHasHelmet").IntRecived += (sender, e) => p.HasHelmet = e.Value == 1;
			playerEntity.FindProperty("localdata.m_Local.m_bDucking").IntRecived += (sender, e) =>  p.IsDucking = e.Value == 1;
			playerEntity.FindProperty("m_iAccount").IntRecived += (sender, e) => p.Money = e.Value;
			playerEntity.FindProperty("m_angEyeAngles[1]").FloatRecived += (sender, e) => p.ViewDirectionX = e.Value;
			playerEntity.FindProperty("m_angEyeAngles[0]").FloatRecived += (sender, e) => p.ViewDirectionY = e.Value;


			playerEntity.FindProperty("localdata.m_vecVelocity[0]").FloatRecived += (sender, e) => p.Velocity.X = e.Value;
			playerEntity.FindProperty("localdata.m_vecVelocity[1]").FloatRecived += (sender, e) => p.Velocity.Y = e.Value;
			playerEntity.FindProperty("localdata.m_vecVelocity[2]").FloatRecived += (sender, e) => p.Velocity.Z = e.Value;



			playerEntity.FindProperty("m_unCurrentEquipmentValue").IntRecived += (sender, e) => p.CurrentEquipmentValue = e.Value;
			playerEntity.FindProperty("m_unRoundStartEquipmentValue").IntRecived += (sender, e) => p.RoundStartEquipmentValue = e.Value;
			playerEntity.FindProperty("m_unFreezetimeEndEquipmentValue").IntRecived += (sender, e) => p.FreezetimeEndEquipmentValue = e.Value;

			//Weapon attribution
			string weaponPrefix = "m_hMyWeapons.";

			if (playerEntity.Props.All (a => a.Entry.PropertyName != "m_hMyWeapons.000"))
				weaponPrefix = "bcc_nonlocaldata.m_hMyWeapons.";


			int[] cache = new int[MAXWEAPONS];

			for(int i = 0; i < MAXWEAPONS; i++)
			{
				int iForTheMethod = i; //Because else i is passed as reference to the delegate. 

				playerEntity.FindProperty(weaponPrefix + i.ToString().PadLeft(3, '0')).IntRecived += (sender, e) => {

					int index = e.Value & INDEX_MASK;

					if (index != INDEX_MASK) {
						if(cache[iForTheMethod] != 0) //Player already has a weapon in this slot. 
						{
							p.rawWeapons.Remove(cache[iForTheMethod]);
							cache[iForTheMethod] = 0;
						}
						cache[iForTheMethod] = index;

						AttributeWeapon(index, p);
					} else {
						if (cache[iForTheMethod] != 0 && p.rawWeapons.ContainsKey(cache[iForTheMethod]))
						{
							p.rawWeapons[cache[iForTheMethod]].Owner = null;
						}
						p.rawWeapons.Remove(cache[iForTheMethod]);

						cache[iForTheMethod] = 0;
					}
				};
			}

			playerEntity.FindProperty("m_hActiveWeapon").IntRecived += (sender, e) => p.ActiveWeaponID = e.Value & INDEX_MASK;

			for (int i = 0; i < 32; i++) {
				int iForTheMethod = i;

				playerEntity.FindProperty ("m_iAmmo." + i.ToString ().PadLeft (3, '0')).IntRecived += (sender, e) => {
					p.AmmoLeft [iForTheMethod] = e.Value;
				};
			}


		}