### Install Demoparser2 for NodeJS Source: https://github.com/laihoe/demoparser/blob/main/README.md Install the demoparser2 library for NodeJS using npm. ```bash npm i @laihoe/demoparser2 ``` -------------------------------- ### Install Demoparser2 for WASM Source: https://github.com/laihoe/demoparser/blob/main/README.md Install the demoparser2 library for WebAssembly (WASM) using npm. ```bash npm i demoparser2 ``` -------------------------------- ### Build and Install Demoparser Source: https://github.com/laihoe/demoparser/blob/main/src/python/README.md Use this command to build and install the demoparser package in release mode. Ensure you are in a virtual environment (venv or conda) before running. ```bash maturin develop --release ``` -------------------------------- ### Run Rust Demo Parser Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md Example of how to run the Rust parser with a demo file. Ensure the `main.rs` file is in the `src/` directory. ```rust use ahash::AHashMap; use memmap2::MmapOptions; use parser::first_pass::parser_settings::ParserInputs; use parser::parse_demo::Parser; use parser::second_pass::parser_settings::create_huffman_lookup_table; use std::fs::File; fn main() { let path_to_demo = "test_demo.dem"; let huf = create_huffman_lookup_table(); let settings = ParserInputs { wanted_players: vec![], real_name_to_og_name: AHashMap::default(), wanted_player_props: vec!["X".to_string()], wanted_events: vec!["player_death".to_string()], wanted_other_props: vec![], parse_ents: true, wanted_ticks: vec![], parse_projectiles: false, only_header: false, list_props: false, only_convars: false, huffman_lookup_table: &huf, fallback_bytes: None, wanted_prop_states: AHashMap::default(), order_by_steamid: false, }; let mut ds = Parser::new(settings, parser::parse_demo::ParsingMode::Normal); let file = File::open(path_to_demo).unwrap(); let mmap = unsafe { MmapOptions::new().map(&file).unwrap() }; let _output = ds.parse_demo(&mmap).unwrap(); } ``` -------------------------------- ### Install Demoparser2 for Python Source: https://github.com/laihoe/demoparser/blob/main/README.md Install the demoparser2 library for Python using pip. Requires Python version 3.8 or higher. ```bash pip install demoparser2 ``` -------------------------------- ### Example Player Info Data Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This is an example of the data structure returned by the parse_player_info function, listing player names, Steam IDs, and team numbers. ```json [ { name: 'player1', steamid: '76511111111111111', team_number: 3 }, { name: 'player2', steamid: '76511111111111112', team_number: 3 }, { name: 'player3', steamid: '76511111111111113', team_number: 3 }, { name: 'player4', steamid: '76511111111111114', team_number: 3 }, { name: 'player5', steamid: '76511111111111115', team_number: 3 }, { name: 'player6', steamid: '76511111111111116', team_number: 2 }, { name: 'player7', steamid: '76511111111111117', team_number: 2 }, { name: 'player8', steamid: '76511111111111118', team_number: 2 }, { name: 'player9', steamid: '76511111111111119', team_number: 2 }, { name: 'player10', steamid: '7651111111111110', team_number: 2 } ] ``` -------------------------------- ### Example Header Data Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This is an example of the data structure returned by the parse_header function. The 'map_name' field is often of primary interest. ```JavaScript { addons: '', allow_clientside_entities: 'true', allow_clientside_particles: 'true', client_name: 'SourceTV Demo', demo_file_stamp: 'PBDEMS2\u0000', demo_version_guid: '8e9d71ab-04a1-4c01-bb61-acfede27c046', demo_version_name: 'valve_demo_2', fullpackets_version: '2', game_directory: '/opt/srcds/cs2/csgo_v2000111/csgo', map_name: 'de_overpass', network_protocol: '13928', server_name: 'Valve Counter-Strike 2 eu_north Server' } ``` -------------------------------- ### Example Grenade Data Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This is an example of the data structure returned by the parse_grenades function. It includes entity ID, grenade type, thrower name, tick, and coordinates. The 'entity_id' can distinguish between multiple grenades of the same type thrown by a player. ```JavaScript [ { entity_id: 280, grenade_type: 'SmokeGrenade', name: 'player1', steamid: '76561111111111111', tick: 5920, x: 694.5, y: 2116.90625, z: 258.71875 }, ... ] ``` -------------------------------- ### Build Demoparser with Yarn Source: https://github.com/laihoe/demoparser/blob/main/src/node/readme.md Run this command in your terminal to build the project. ```bash yarn build ``` -------------------------------- ### Build Project with Cargo Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md Use this command to build the project in release mode. ```bash cargo build --release ``` -------------------------------- ### Import Demoparser Functions Source: https://github.com/laihoe/demoparser/blob/main/src/node/readme.md Import the necessary parsing functions after building the project. Ensure the path is correct for your project structure. ```javascript var {parseEvent, parseTicks} = require('./index'); ``` -------------------------------- ### Run Tests with Cargo Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md Execute all tests for the project in release mode. ```bash cargo test --release ``` -------------------------------- ### Parse Player Deaths from Demo File Source: https://github.com/laihoe/demoparser/blob/main/src/wasm/www/index.html Initializes the demoparser library and sets up an event listener for file input. It then parses the demo file to extract player death events and other specified game events. The parsed data is logged to the console and can be used to generate a table. ```javascript import init, { parseEvent, listGameEvents, parseGrenades, parseHeader, parseEvents } from './pkg/demoparser2.js'; await init(); document.getElementById("file\_picker").addEventListener( "change", async function () { var startTime = performance.now() const reader = new FileReader(); reader.onload = function (event) { const uint8Array = new Uint8Array(event.target.result); let result = parseEvents(uint8Array, ["player\_death", "player\_footstep"], [], ["total\_rounds\_played", "is\_warmup\_period"] ); // let result = parseHeader(uint8Array) console.log(result) // generateTableFromData(result) }; reader.readAsArrayBuffer(this.files[0]); }, false ); ``` -------------------------------- ### parse_header Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns the header information of the demo file. This includes details like server name, map name, and game directory. ```APIDOC ## parse_header ### Description Parses and returns the header information of the demo file. This includes details like server name, map name, and game directory. ### Method ```python def parse_header(self) -> Dict[str, str]: ``` ### Parameters This method takes no arguments. ### Response Returns a dictionary containing header fields such as: - "addons" - "server_name" - "demo_file_stamp" - "network_protocol" - "map_name" - "fullpackets_version" - "allow_clientside_entities" - "allow_clientside_particles" - "demo_version_name" - "demo_version_guid" - "client_name" - "game_directory" ``` -------------------------------- ### Demoparser Main Loop Logic Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md This simplified code illustrates the outer loop of the parser, reading commands, ticks, and sizes from the demo file until a DEM_Stop command is encountered. ```rust pub fn start(&mut self){ loop { let cmd = self.read_varint()?; let tick = self.read_varint()?; let size = self.read_varint()?; let bytes = self.bytes[cur_pos..cur_pos + size] cur_pos += size match demo_cmd_type_from_int(msg_type as i32) { DEM_Packet => self.parse_packet(&bytes), DEM_FileHeader => self.parse_header(&bytes), DEM_FileInfo => self.parse_file_info(&bytes), DEM_SendTables => self.parse_classes(&bytes), DEM_ClassInfo => self.parse_class_info(&bytes), DEM_SignonPacket => self.parse_packet(&bytes), DEM_FullPacket => self.parse_full_packet(&bytes), DEM_UserCmd => self.parse_user_command_cmd(&bytes), DEM_StringTables => self.parse_stringtable_cmd(&bytes), DEM_Stop => break, _ => {}, }; } } ``` -------------------------------- ### Generate Table from Parsed Events Source: https://github.com/laihoe/demoparser/blob/main/src/wasm/www/index.html Takes an array of parsed demo events, filters out warmup periods, and generates an HTML table to display specific columns like attacker name, user name, tick, total rounds played, and weapon. The table is styled with a scrollable container. ```javascript function generateTableFromData(eventsNoFilter) { let events = eventsNoFilter.filter(x => x.get("is\_warmup\_period") === false); const columnNames = ["attacker\_name", "user\_name", "tick", "total\_rounds\_played", "weapon"]; const table = document.createElement("table"); table.setAttribute("border", "2"); const tblBody = document.createElement("tbody"); events.forEach((event, rowIndex) => { const row = table.insertRow(rowIndex); columnNames.forEach((columnName, cellIndex) => { row.insertCell(cellIndex).innerHTML = event.get(columnName); }); }); table.appendChild(tblBody); // Create header row after appending tblBody const header = table.createTHead(); const headerRow = header.insertRow(0); columnNames.forEach((columnName, index) => { headerRow.insertCell(index).innerHTML = columnName; }); const tableContainer = document.createElement("div"); tableContainer.style.height = "600px"; tableContainer.style.overflowY = "auto"; tableContainer.appendChild(table); document.body.appendChild(tableContainer); } ``` -------------------------------- ### Parse Player Deaths and Ticks in Python Source: https://github.com/laihoe/demoparser/blob/main/README.md Initialize the DemoParser in Python and parse specific events like player deaths or tick data. Specify player names or other fields to filter results. ```python from demoparser2 import DemoParser parser = DemoParser("path_to_demo.dem") event_df = parser.parse_event("player_death", player=["X", "Y"], other=["total_rounds_played"]) ticks_df = parser.parse_ticks(["X", "Y"]) ``` -------------------------------- ### parse_player_info Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns information about players in the demo, including their steamID, name, and team. ```APIDOC ## parse_player_info ### Description Parses and returns information about players in the demo, including their steamID, name, and team. ### Method ```python def parse_player_info(self) -> pd.DataFrame: ``` ### Parameters This method takes no arguments. ### Response Returns a pandas DataFrame with player information. Example columns include: - "steamid" - "name" - "team_number" ``` -------------------------------- ### parse_skins Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns information about player skins used in the demo. ```APIDOC ## parse_skins ### Description Parses and returns information about player skins used in the demo. ### Method ```python def parse_skins(self) -> pd.DataFrame: ``` ### Parameters This method takes no arguments. ### Response Returns a pandas DataFrame containing skin information. ``` -------------------------------- ### Python Constructor Signature Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Defines the signature for a Python class constructor. It takes a string path as an argument and returns None. ```Python def __init__(self, path: str) -> None: ... ``` -------------------------------- ### parseEvents Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Parses multiple types of game events from a demo file simultaneously. Similar to `parseEvent` but designed for batch processing of events. ```APIDOC ## parseEvents ### Description Parses multiple types of game events from a demo file simultaneously. Similar to `parseEvent` but designed for batch processing of events. ### Method ```javascript parseEvents(path: string, eventNames?: Array | undefined | null, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null): any ``` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the demo file. #### Query Parameters - **eventNames** (Array) - Optional - An array of event names to parse (e.g., ["player_death", "weapon_fire"]). - **extraPlayer** (Array) - Optional - An array of player-specific properties to include in the output. - **extraOther** (Array) - Optional - An array of game state properties to include in the output. ### Request Example ```javascript parseEvents("path_to_demo.dem", ["player_death", "weapon_fire"]) ``` ### Response #### Success Response (JSON) Returns a JSON object containing data for all requested event types. ``` -------------------------------- ### Sequence_game_events Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Retrieves a list of game events that occurred in sequence during the demo. ```APIDOC ## Sequence_game_events ### Description Retrieves a list of game events that occurred in sequence during the demo. ### Method ```python def Sequence_game_events(self) -> List[str]: ``` ### Parameters This method takes no arguments. ### Response Returns a list of strings, where each string represents a game event. ``` -------------------------------- ### Run Rust Parser with Debug Flag Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md Run the parser with debug output enabled to inspect decoded entity updates based on your filter. ```bash cargo run --release -- -debug true ``` -------------------------------- ### Parse Header Function Signature Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This function signature is for parsing the demo header. It returns a dictionary containing header information. Performance differences are minimal for small numbers of ticks. ```Python def parse_header(): -> Dict[str, str] ``` -------------------------------- ### parseEvent Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Parses and returns a specific type of game event from a demo file. Allows for requesting additional player-specific or game state information. ```APIDOC ## parseEvent ### Description Parses and returns a specific type of game event from a demo file. Allows for requesting additional player-specific or game state information. ### Method ```javascript parseEvent(path: string, eventName: string, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null): any ``` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the demo file. #### Query Parameters - **eventName** (string) - Required - The name of the event to parse (e.g., "bomb_planted"). - **extraPlayer** (Array) - Optional - An array of player-specific properties to include in the output (e.g., ["X", "Y"]). - **extraOther** (Array) - Optional - An array of game state properties to include in the output (e.g., ["total_rounds_played"]). ### Request Example ```javascript parseEvent("path_to_demo.dem", "bomb_planted", ["X", "Y"], ["total_rounds_played"]) ``` ### Response #### Success Response (JSON) Returns a JSON object containing the requested event data, potentially with extra player or game state information. #### Response Example ```json { "site": 292, "tick": 17916, "user_name": "player1", "user_steamid": "76561111111111111", "user_X": 213.4, "user_Y": 874.6 } ``` ``` -------------------------------- ### Demoparser Function Signatures (TypeScript) Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Provides the type signatures for various parsing functions available in the Demoparser library. ```TypeScript function parseChatMessages(path: string): any function listGameEvents(path: string): any function parseHeader(path: string): any function parsePlayerInfo(path: string): any function parseGrenades(path: string, extra?: Array | undefined | null, grenades?: boolean): any function parseEvent(path: string, eventName: string, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null): any function parseEvents(path: string, eventNames?: Array | undefined | null, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null): any function parseTicks(path: string, wantedProps: Array, wantedTicks?: Array | undefined | null): any ``` -------------------------------- ### Parse Player Info Function Signature Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This function signature is for parsing player information, returning data in a DataFrame format. ```Python def parse_player_info(): -> DataFrame ``` -------------------------------- ### Parse a Single Game Event (JavaScript) Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Parses a specific type of game event from a demo file. Use 'player_extra' to request additional player-specific data not in the original event, and 'extraOther' for game state information. ```JavaScript function parseEvent(path: string, eventName: string, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null) -> JSON ``` ```JavaScript parseEvent("path_to_demo.dem","bomb_planted") ``` ```JavaScript parseEvent("path_to_demo.dem", "bomb_planted", ["X", "Y"]) ``` ```JavaScript parseEvent("path_to_demo.dem", "bomb_planted", ["X", "Y"], ["total_rounds_played"]) ``` -------------------------------- ### Parse Multiple Game Events (JavaScript) Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Parses multiple types of game events simultaneously from a demo file. This function is provided for consistency with other language versions. ```JavaScript function parseEvents(path: string, eventNames?: Array | undefined | null, extraPlayer?: Array | undefined | null, extraOther?: Array | undefined | null): any ``` ```JavaScript parseEvents("path_to_demo.dem", ["player_death", "weapon_fire"]) ``` -------------------------------- ### Other Parsing Functions Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Provides basic parsing functions for chat messages, game events, and player information without advanced options. ```APIDOC ## Other Parsing Functions ### Description Provides basic parsing functions for chat messages, game events, and player information without advanced options. ### Methods - **parseChatMessages(path: string): any** Parses chat messages from a demo file. - **listGameEvents(path: string): any** Lists all available game events in a demo file. - **parseHeader(path: string): any** Parses the header information of a demo file. - **parsePlayerInfo(path: string): any** Parses player information from a demo file. ``` -------------------------------- ### parseTicks Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Extracts specific properties for players on a per-tick basis from a demo file. Supports filtering by tick numbers and choosing output format. ```APIDOC ## parseTicks ### Description Extracts specific properties for players on a per-tick basis from a demo file. Supports filtering by tick numbers and choosing output format. ### Method ```javascript parseTicks(path: string, wantedProps: Array, wantedTicks?: Array | undefined | null, structOfArrays?: boolean | undefined | null): any ``` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the demo file. #### Query Parameters - **wantedProps** (Array) - Required - An array of properties to collect for each player (e.g., ["X", "Y"]). - **wantedTicks** (Array) - Optional - An array of specific tick numbers to retrieve data for. If omitted, all ticks are parsed. - **structOfArrays** (boolean) - Optional - If true, returns data as arrays of properties; otherwise, returns an array of objects. Defaults to false. ### Request Example ```javascript parseTicks("path_to_demo.dem", ["X", "Y"], [10000, 10001], false) ``` ### Response #### Success Response (Array of Objects or Struct of Arrays) Returns data structured as either an array of objects (each representing a player's state at a tick) or a struct of arrays (where each array holds values for a specific property across all ticks and players). #### Response Example (Array of Objects) ```json [ { "name": "person1", "steamid": "76511111111111111", "tick": 10000, "X": 123.456, "Y": 456.789 }, { "name": "person2", "steamid": "76511111111111112", "tick": 10000, "X": 897.456, "Y": 4877.456 } ] ``` #### Response Example (Struct of Arrays) ```json { "X": [ 123.456, 897.456 ], "Y": [ 456.789, 4877.456 ], "name": [ "person1", "person2" ], "steamid": [ '76511111111111111', '76511111111111112' ], "tick": [ 10000, 10000 ] } ``` ``` -------------------------------- ### parse_item_drops Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns information about item drops that occurred during the demo. ```APIDOC ## parse_item_drops ### Description Parses and returns information about item drops that occurred during the demo. ### Method ```python def parse_item_drops(self) -> pd.DataFrame: ``` ### Parameters This method takes no arguments. ### Response Returns a pandas DataFrame containing details about item drops. ``` -------------------------------- ### list_game_events Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Returns a list of all available game event names that can be parsed. ```APIDOC ## list_game_events ### Description Returns a list of all available game event names that can be parsed. This function can be as time-consuming as calling `parse_event` or `parse_events`. ### Method ```python def list_game_events() -> List[str]: ``` ### Parameters This method takes no arguments. ### Response Returns a list of strings, where each string is a name of a game event (e.g., 'weapon_fire', 'player_death'). ``` -------------------------------- ### parse_chat_messages Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns all chat messages from the demo, formatted as a pandas DataFrame. ```APIDOC ## parse_chat_messages ### Description Parses and returns all chat messages from the demo, formatted as a pandas DataFrame. ### Method ```python def parse_chat_messages(self) -> pd.DataFrame: ``` ### Parameters This method takes no arguments. ### Response Returns a pandas DataFrame containing chat messages, likely with columns for sender, message content, and timestamp. ``` -------------------------------- ### List Game Events Function Signature Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This function signature is for listing game events. It is noted that enabling this option can significantly speed up parsing for all ticks. ```Python def list_game_events(): -> List[str] ``` -------------------------------- ### Parse Player Deaths and Ticks in NodeJS Source: https://github.com/laihoe/demoparser/blob/main/README.md Use the imported parseEvent and parseTicks functions in NodeJS to analyze demo files. Filter events by player or other relevant fields. ```javascript var {parseEvent, parseTicks} = require('@laihoe/demoparser2'); let event_json = parseEvent("path_to_demo.dem", "player_death", ["X", "Y"], ["total_rounds_played"]) let ticks_json = parseTicks("path_to_demo.dem", ["X", "Y"]) ``` -------------------------------- ### Parse Tick Data (JavaScript) Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md Retrieves specific properties for players across specified ticks from a demo file. The 'StructOfArrays' option allows for an alternative output format where data is organized into arrays per property. ```JavaScript export function parseTicks(path: string, wantedProps: Array, wantedTicks?: Array | undefined | null, structOfArrays?: boolean | undefined | null): any ``` ```JavaScript parseTicks("path_to_demo.dem", ["X", "Y"] [10000, 10001]) ``` ```JavaScript [ { name: 'person1', steamid: '76511111111111111', tick: 10000, X: 123.456 Y: 456.789 }, { name: 'person2', steamid: '76511111111111112', tick: 10000, X: 897.456 Y: 4877.456 }, { name: 'person1', steamid: '76511111111111111', tick: 10001, X: 127.456 Y: 459.789 }, { name: 'person2', steamid: '76511111111111112', tick: 10001, X: 898.456 Y: 4889.456 }, ] ``` ```JavaScript X: [ 123.456, 897.456, 127.456, 898.456, ], Y: [ 456.789 4877.456 459.789 4889.456 ], name: [ "person1", "person2", "person1", "person2", ], steamid: [ '76511111111111111', '76511111111111112', '76511111111111111', '76511111111111112', ], tick: [ 10000, 10000, 10001, 10001 ] ``` ```JavaScript { name: name[2], steamid: steamid[2], tick: tick[2], X: X[2] Y: Y[2] } ``` -------------------------------- ### Parse Tick Data Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Retrieves specific properties from players for given ticks. If the 'ticks' argument is omitted, all ticks in the demo will be parsed. ```Python def parse_ticks(wanted_props: Sequence[str], ticks=Sequence[int]): -> DataFrame ``` ```Python parse_ticks(wanted_props=["X", "Y", "Z"], ticks=[983]) ``` -------------------------------- ### parse_voice Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns voice data from the demo, typically as a dictionary mapping speaker identifiers to their voice data. ```APIDOC ## parse_voice ### Description Parses and returns voice data from the demo, typically as a dictionary mapping speaker identifiers to their voice data. ### Method ```python def parse_voice(self) -> Dict[str, bytes]: ``` ### Parameters This method takes no arguments. ### Response Returns a dictionary where keys might represent player IDs or timestamps, and values are byte strings containing the voice data. ``` -------------------------------- ### Parse Specific Game Event Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Retrieves a DataFrame of a specific game event. Use 'player' to add player-specific data and 'other' to add game state data. ```Python def parse_event(event_name: str, player=List[str], other=List[str]): -> DataFrame ``` ```Python parse_event("bomb_planted") ``` ```Python parse_event("bomb_planted", player=["X", "Y"]) ``` ```Python parse_event("bomb_planted", player=["X", "Y"], other=["total_rounds_played"]) ``` -------------------------------- ### parse_grenades Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns detailed information about all grenades thrown in the demo, including their coordinates, thrower, and type. ```APIDOC ## parse_grenades ### Description Parses and returns detailed information about all grenades thrown in the demo, including their coordinates, thrower, and type. The `entity_id` can be used to uniquely identify grenades. ### Method ```python def parse_grenades(self, extra: Optional[Sequence[str]] = None, grenades: bool = True) -> pd.DataFrame: ``` ### Parameters #### Optional Parameters - **extra** (Optional[Sequence[str]]) - Allows requesting additional data related to grenades. - **grenades** (bool) - Defaults to True. Likely controls whether grenade data is parsed. ### Response Returns a pandas DataFrame with grenade details. Example columns: - "X" - "Y" - "Z" - "tick" - "thrower_steamid" - "grenade_type" - "entity_id" ``` -------------------------------- ### parse_events Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses multiple game events simultaneously and returns them as a list of tuples, where each tuple contains the event name and its corresponding DataFrame. ```APIDOC ## parse_events ### Description Parses multiple game events simultaneously and returns them as a list of tuples, where each tuple contains the event name and its corresponding DataFrame. This is an extension of `parse_event` for batch processing. ### Method ```python def parse_events(self, event_name: Sequence[str], player: Optional[Sequence[str]] = None, other: Optional[Sequence[str]] = None) -> List[Tuple[str, pd.DataFrame]]: ``` ### Parameters #### Path Parameters - **event_name** (Sequence[str]) - Required - A list of event names to parse. #### Optional Parameters - **player** (Optional[Sequence[str]]) - A list of player-related properties to include for each event. - **other** (Optional[Sequence[str]]) - A list of game state properties to include for each event. ### Request Example ```python # Example: Get data for player deaths and weapon fires parser.parse_events(["player_death", "weapon_fire"]) ``` ### Response Returns a list of tuples. Each tuple contains an event name (string) and a pandas DataFrame with the data for that event. ``` -------------------------------- ### parse_event Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Retrieves a DataFrame of a specific game event, with options to include extra player-specific or game state information. ```APIDOC ## parse_event ### Description Retrieves a DataFrame of a specific game event. You can optionally include extra player-specific values or game state information using the `player` and `other` arguments. ### Method ```python def parse_event(self, event_name: str, player: Optional[Sequence[str]] = None, other: Optional[Sequence[str]] = None) -> pd.DataFrame: ``` ### Parameters #### Path Parameters - **event_name** (str) - Required - The name of the game event to parse (e.g., "bomb_planted"). #### Optional Parameters - **player** (Optional[Sequence[str]]) - A list of player-related properties to include in the output (e.g., ["X", "Y"]). - **other** (Optional[Sequence[str]]) - A list of game state properties to include (e.g., ["total_rounds_played"]). ### Request Example ```python # Example: Get bomb planted events with player coordinates and total rounds played parser.parse_event("bomb_planted", player=["X", "Y"], other=["total_rounds_played"]) ``` ### Response Returns a pandas DataFrame containing the requested event data. Columns will include standard event fields and any additional fields requested via `player` or `other` arguments (prefixed with "user_" for player data). ``` -------------------------------- ### parse_convars Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Parses and returns console variables (convars) set during the demo. ```APIDOC ## parse_convars ### Description Parses and returns console variables (convars) set during the demo. ### Method ```python def parse_convars(self) -> Dict[str, str]: ``` ### Parameters This method takes no arguments. ### Response Returns a dictionary where keys are convar names and values are their corresponding settings. ``` -------------------------------- ### Parse Multiple Game Events Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Similar to parse_event, but allows querying multiple events simultaneously. Returns a list of tuples, where each tuple contains the event name and its corresponding DataFrame. ```Python def parse_events(event_name: Sequence[str], player_extra=Sequence[str]): -> [(str, DataFrame)] ``` ```Python parse_events(["player_death", "weapon_fire"]) ``` -------------------------------- ### Dem_packet Decoding Logic Source: https://github.com/laihoe/demoparser/blob/main/src/parser/README.md This snippet shows how a DEM_Packet is decoded by reading message types and sizes from a bitstream. It handles various netmessage types, including entity updates and game events. ```rust let mut bitreader = Bitreader::new(&bytes); while bitreader.reader.has_bits_remaining(8) { let msg_type = bitreader.read_u_bit_var().unwrap(); let size = bitreader.read_varint().unwrap(); let msg_bytes = bitreader.read_n_bytes(size as usize).unwrap(); match netmessage_type_from_int(msg_type as i32) { svc_PacketEntities => self.parse_packet_ents(&msg_bytes), svc_CreateStringTable => self.parse_create_stringtable(&msg_bytes), svc_UpdateStringTable => self.update_string_table(&msg_bytes), GE_Source1LegacyGameEventList => self.parse_game_event_map(&msg_bytes), GE_Source1LegacyGameEvent => self.parse_event(&msg_bytes), // ... some extra left out _ => {}, }; } ``` -------------------------------- ### parse_ticks Source: https://github.com/laihoe/demoparser/blob/main/documentation/python/README.md Retrieves specific properties for players across specified ticks, returning the data as a pandas DataFrame. ```APIDOC ## parse_ticks ### Description Retrieves specific properties for players across specified ticks, returning the data as a pandas DataFrame. If no `ticks` are specified, all ticks are processed. ### Method ```python def parse_ticks(self, wanted_props: Sequence[str], player: Optional[Sequence[int]] = None, ticks: Optional[Sequence[int]] = None) -> pd.DataFrame: ``` ### Parameters #### Path Parameters - **wanted_props** (Sequence[str]) - Required - A list of property names to retrieve (e.g., ["X", "Y", "Z"]). #### Optional Parameters - **player** (Optional[Sequence[int]]) - A list of player identifiers to filter the data by. - **ticks** (Optional[Sequence[int]]) - A list of specific tick numbers to retrieve data for. If omitted, all ticks are parsed. ### Request Example ```python # Example: Get X, Y, Z coordinates for tick 983 parser.parse_ticks(wanted_props=["X", "Y", "Z"], ticks=[983]) ``` ### Response Returns a pandas DataFrame containing the requested properties for the specified ticks and players. Columns typically include the requested properties, `tick`, `steamid`, and `name`. ``` -------------------------------- ### Parse Grenades Function Signature Source: https://github.com/laihoe/demoparser/blob/main/documentation/js/README.md This function signature is for parsing grenade data, returning coordinates and thrower information. It returns a DataFrame. ```Python def parse_grenades(): -> DataFrame ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.