Skip to content

Commit aa1b925

Browse files
authored
Merge pull request #452 from micvbang/micvbang/grenade-trajectory-timing
grenade trajectories: collect timings of each location
2 parents 82827a9 + ed6f83a commit aa1b925

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

pkg/demoinfocs/common/common.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ func (h *DemoHeader) FrameTime() time.Duration {
6767
type GrenadeProjectile struct {
6868
Entity st.Entity
6969
WeaponInstance *Equipment
70-
Thrower *Player // Always seems to be the same as Owner, even if the grenade was picked up
71-
Owner *Player // Always seems to be the same as Thrower, even if the grenade was picked up
72-
Trajectory []r3.Vector // List of all known locations of the grenade up to the current point
70+
Thrower *Player // Always seems to be the same as Owner, even if the grenade was picked up
71+
Owner *Player // Always seems to be the same as Thrower, even if the grenade was picked up
72+
73+
// Deprecated: use Trajectory2 instead
74+
Trajectory []r3.Vector // List of all known locations of the grenade up to the current point
75+
76+
Trajectory2 []TrajectoryEntry // List of all known locations and the point in time of the grenade up to the current point
7377

7478
// uniqueID is used to distinguish different grenades (which potentially have the same, reused entityID) from each other.
7579
uniqueID int64
@@ -225,6 +229,13 @@ func NewTeamState(team Team, membersCallback func(Team) []*Player, demoInfoProvi
225229
}
226230
}
227231

232+
// TrajectoryEntry represents the location of a grenade's trajectory at a specific point in time.
233+
type TrajectoryEntry struct {
234+
Position r3.Vector
235+
FrameID int
236+
Time time.Duration
237+
}
238+
228239
// ConvertSteamIDTxtTo32 converts a Steam-ID in text format to a 32-bit variant.
229240
// See https://developer.valvesoftware.com/wiki/SteamID
230241
func ConvertSteamIDTxtTo32(steamID string) (uint32, error) {

pkg/demoinfocs/datatables.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,12 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
860860

861861
entity.OnPositionUpdate(func(newPos r3.Vector) {
862862
proj.Trajectory = append(proj.Trajectory, newPos)
863+
864+
proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
865+
Position: newPos,
866+
FrameID: p.CurrentFrame(),
867+
Time: p.CurrentTime(),
868+
})
863869
})
864870

865871
// Some demos don't have this property as it seems

0 commit comments

Comments
 (0)