StatsHelix / demoinfo

A library to analyze CS:GO demos in C#
MIT License
321 stars 78 forks source link

Nade Trajectory #139

Open thiagofelix opened 6 years ago

thiagofelix commented 6 years ago

Is it possible to grab the grenade trajectory from point where it is fired to the point where it explodes?

econoraptor commented 6 years ago

Yes, it's possible, though not through the public API. Each grenade has an associated projectile entity that you can track in the air. HEs and flashes are both CBaseCSGrenadeProjectile, molotovs and incendiaries use CMolotovProjectile and the others use CSmokeGrenadeProjectile CDecoyProjectile. You can track their positions using the Cell properties. If you want to see an implementation, look here: https://github.com/econoraptor/demoinfo/tree/DetonateInterpolate2

At a minimum you'll need to subscribe to the properties and use SetCellWidth and CellsToCoords to map the Cell values to normal position values.

moritzuehling commented 6 years ago

We'd be open to a PR that opens the grenade-projectiles up via the API.

thiagofelix commented 6 years ago

@econoraptor thanks for the explanation, I've been trying to track their trajectory using grenades velocity, angle, position at the throw moment but I think the cell strategy is more bullet proof.

moritzuehling commented 6 years ago

@thiagofelix That method might have worked for demos where the snapshotrate matched the tickrate, but it would have been fairly inaccurate for all other demos.

thiagofelix commented 6 years ago

@moritzuehling you'r right, just tried out using the cells and it worked like a charm =) thank you so much.

I am building a replay viewer that parses the demo in the browser itself on user's computer, sort of standalone app without need of a server, so far got everything I wanted working (player's position, nades, memory consumption acceptable)

Thanks again for the help