Skip to content

Commit

Permalink
Merge pull request #452 from micvbang/micvbang/grenade-trajectory-timing
Browse files Browse the repository at this point in the history
grenade trajectories: collect timings of each location
  • Loading branch information
markus-wa authored Oct 23, 2023
2 parents 82827a9 + ed6f83a commit aa1b925
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/demoinfocs/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ func (h *DemoHeader) FrameTime() time.Duration {
type GrenadeProjectile struct {
Entity st.Entity
WeaponInstance *Equipment
Thrower *Player // Always seems to be the same as Owner, even if the grenade was picked up
Owner *Player // Always seems to be the same as Thrower, even if the grenade was picked up
Trajectory []r3.Vector // List of all known locations of the grenade up to the current point
Thrower *Player // Always seems to be the same as Owner, even if the grenade was picked up
Owner *Player // Always seems to be the same as Thrower, even if the grenade was picked up

// Deprecated: use Trajectory2 instead
Trajectory []r3.Vector // List of all known locations of the grenade up to the current point

Trajectory2 []TrajectoryEntry // List of all known locations and the point in time of the grenade up to the current point

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

// TrajectoryEntry represents the location of a grenade's trajectory at a specific point in time.
type TrajectoryEntry struct {
Position r3.Vector
FrameID int
Time time.Duration
}

// ConvertSteamIDTxtTo32 converts a Steam-ID in text format to a 32-bit variant.
// See https://developer.valvesoftware.com/wiki/SteamID
func ConvertSteamIDTxtTo32(steamID string) (uint32, error) {
Expand Down
6 changes: 6 additions & 0 deletions pkg/demoinfocs/datatables.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,12 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {

entity.OnPositionUpdate(func(newPos r3.Vector) {
proj.Trajectory = append(proj.Trajectory, newPos)

proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
Position: newPos,
FrameID: p.CurrentFrame(),
Time: p.CurrentTime(),
})
})

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

0 comments on commit aa1b925

Please sign in to comment.