demoinfo icon indicating copy to clipboard operation
demoinfo copied to clipboard

Nade Trajectory

Open thiagofelix opened this issue 7 years ago • 5 comments

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

thiagofelix avatar Jan 23 '18 15:01 thiagofelix

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.

econoraptor avatar Jan 23 '18 19:01 econoraptor

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

moritzuehling avatar Jan 23 '18 21:01 moritzuehling

@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.

thiagofelix avatar Jan 24 '18 13:01 thiagofelix

@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.

moritzuehling avatar Jan 24 '18 14:01 moritzuehling

@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

thiagofelix avatar Jan 24 '18 14:01 thiagofelix