From d461dbc7c1049046831216079f3c91d885c653cc Mon Sep 17 00:00:00 2001 From: ExplodingImplosion Date: Mon, 29 Sep 2025 17:06:31 -0400 Subject: [PATCH] add player flags (right now I've only done stuff for checking if player is on ground) --- src/demo/data/game_state.rs | 6 ++++++ src/demo/parser/gamestateanalyser/player.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/demo/data/game_state.rs b/src/demo/data/game_state.rs index 7e23643..b0cecb5 100644 --- a/src/demo/data/game_state.rs +++ b/src/demo/data/game_state.rs @@ -86,6 +86,7 @@ pub struct Player { pub bounds: Box, pub weapons: [Handle; 3], pub handle: Handle, + pub flags: u16, pub(crate) conditions: [u8; 20], } @@ -150,6 +151,7 @@ pub const PLAYER_BOX_DEFAULT: Box = Box { }; impl Player { + pub const FL_ONGROUND: u16 = 1; pub fn new(entity: EntityId) -> Player { Player { entity, @@ -158,6 +160,10 @@ impl Player { } } + pub fn is_in_air(&self) -> bool { + self.flags & Player::FL_ONGROUND == 0 + } + pub fn collides(&self, projectile: &Projectile, time_per_tick: f32) -> bool { let current_position = projectile.position; let next_position = projectile.position + (projectile.initial_speed * time_per_tick); diff --git a/src/demo/parser/gamestateanalyser/player.rs b/src/demo/parser/gamestateanalyser/player.rs index fe13e2f..ecf9390 100644 --- a/src/demo/parser/gamestateanalyser/player.rs +++ b/src/demo/parser/gamestateanalyser/player.rs @@ -16,6 +16,9 @@ pub fn handle_player_entity( const OUTER: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeContainer", "m_hOuter"); const OUTER2: SendPropIdentifier = SendPropIdentifier::new("DT_AttributeManager", "m_hOuter"); + const FLAGS_PROP: SendPropIdentifier = + SendPropIdentifier::new("DT_BasePlayer", "m_fFlags"); + const HEALTH_PROP: SendPropIdentifier = SendPropIdentifier::new("DT_BasePlayer", "m_iHealth"); const MAX_HEALTH_PROP: SendPropIdentifier = SendPropIdentifier::new("DT_BasePlayer", "m_iMaxHealth"); @@ -114,6 +117,9 @@ pub fn handle_player_entity( let handle = Handle::try_from(&prop.value).unwrap_or_default(); player.weapons[2] = handle; } + FLAGS_PROP => { + player.flags = i64::try_from(&prop.value).unwrap_or_default() as u16; + } PLAYER_COND | PLAYER_COND_BITS => { player.conditions[0..4].copy_from_slice( &i64::try_from(&prop.value).unwrap_or_default().to_le_bytes()[0..4],