1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

project critical

This commit is contained in:
Robin Appelman 2025-06-26 16:56:04 +02:00
commit 331a9fe593
4 changed files with 127 additions and 50 deletions

View file

@ -322,6 +322,7 @@ pub struct Projectile {
pub bounds: Option<Box>, pub bounds: Option<Box>,
pub launcher: Handle, pub launcher: Handle,
pub ty: ProjectileType, pub ty: ProjectileType,
pub critical: bool,
} }
impl Projectile { impl Projectile {
@ -336,6 +337,7 @@ impl Projectile {
bounds: None, bounds: None,
launcher: Handle::default(), launcher: Handle::default(),
ty: ProjectileType::new(class_name, None), ty: ProjectileType::new(class_name, None),
critical: false,
} }
} }
} }

View file

@ -597,6 +597,14 @@ impl GameStateAnalyser {
SendPropIdentifier::new("DT_TFBaseRocket", "m_angRotation"); SendPropIdentifier::new("DT_TFBaseRocket", "m_angRotation");
const GRENADE_ROTATION: SendPropIdentifier = const GRENADE_ROTATION: SendPropIdentifier =
SendPropIdentifier::new("DT_TFWeaponBaseGrenadeProj", "m_angRotation"); SendPropIdentifier::new("DT_TFWeaponBaseGrenadeProj", "m_angRotation");
const CRITICAL_GRENADE: SendPropIdentifier =
SendPropIdentifier::new("DT_TFWeaponBaseGrenadeProj", "m_bCritical");
const CRITICAL_ROCKET: SendPropIdentifier =
SendPropIdentifier::new("DT_TFProjectile_Rocket", "m_bCritical");
const CRITICAL_FLARE: SendPropIdentifier =
SendPropIdentifier::new("DT_TFProjectile_Flare", "m_bCritical");
const CRITICAL_ARROW: SendPropIdentifier =
SendPropIdentifier::new("DT_TFProjectile_Arrow", "m_bCritical");
if entity.update_type == UpdateType::Delete { if entity.update_type == UpdateType::Delete {
self.state.projectile_destroy(entity.entity_index); self.state.projectile_destroy(entity.entity_index);
@ -643,6 +651,10 @@ impl GameStateAnalyser {
let rotation = Vector::try_from(&prop.value).unwrap_or_default(); let rotation = Vector::try_from(&prop.value).unwrap_or_default();
projectile.rotation = rotation; projectile.rotation = rotation;
} }
CRITICAL_GRENADE | CRITICAL_ROCKET | CRITICAL_FLARE | CRITICAL_ARROW => {
let critical = bool::try_from(&prop.value).unwrap_or_default();
projectile.critical = critical;
}
_ => {} _ => {}
} }
} }

View file

@ -1039,6 +1039,19 @@ impl TryFrom<&SendPropValue> for i64 {
} }
} }
impl TryFrom<&SendPropValue> for bool {
type Error = MalformedSendPropDefinitionError;
fn try_from(value: &SendPropValue) -> std::result::Result<Self, Self::Error> {
match value {
SendPropValue::Integer(val) => Ok(*val > 0),
_ => Err(MalformedSendPropDefinitionError::WrongPropType {
expected: "boolean",
value: value.clone(),
}),
}
}
}
impl TryFrom<&SendPropValue> for Vector { impl TryFrom<&SendPropValue> for Vector {
type Error = MalformedSendPropDefinitionError; type Error = MalformedSendPropDefinitionError;
fn try_from(value: &SendPropValue) -> std::result::Result<Self, Self::Error> { fn try_from(value: &SendPropValue) -> std::result::Result<Self, Self::Error> {

View file

@ -812,7 +812,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 0, "launcher": 0,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -839,7 +840,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -866,7 +868,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -893,7 +896,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -920,7 +924,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -947,7 +952,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -974,7 +980,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1001,7 +1008,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1028,7 +1036,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1055,7 +1064,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1082,7 +1092,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1109,7 +1120,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1136,7 +1148,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1163,7 +1176,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1190,7 +1204,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1217,7 +1232,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1244,7 +1260,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1271,7 +1288,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1298,7 +1316,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1325,7 +1344,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1352,7 +1372,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1379,7 +1400,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1406,7 +1428,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1433,7 +1456,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1460,7 +1484,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1487,7 +1512,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 2036553, "launcher": 2036553,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1514,7 +1540,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1541,7 +1568,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1568,7 +1596,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1595,7 +1624,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1622,7 +1652,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1649,7 +1680,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1676,7 +1708,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1703,7 +1736,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1730,7 +1764,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1757,7 +1792,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1784,7 +1820,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1811,7 +1848,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1838,7 +1876,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1865,7 +1904,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1892,7 +1932,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1919,7 +1960,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 447062, "launcher": 447062,
"ty": "Sticky" "ty": "Sticky",
"critical": false
} }
}, },
{ {
@ -1946,7 +1988,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -1973,7 +2016,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2000,7 +2044,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2027,7 +2072,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2054,7 +2100,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 197220, "launcher": 197220,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2081,7 +2128,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 59974, "launcher": 59974,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2108,7 +2156,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 1237729, "launcher": 1237729,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
}, },
{ {
@ -2135,7 +2184,8 @@ expression: state
}, },
"bounds": null, "bounds": null,
"launcher": 820045, "launcher": 820045,
"ty": "Rocket" "ty": "Rocket",
"critical": false
} }
} }
], ],