Skip to content

Commit 16db346

Browse files
committed
fix nade trajectories
1 parent da6b345 commit 16db346

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed
-21.1 KB
Loading

pkg/demoinfocs/datatables.go

+30-10
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,16 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
944944
})
945945
}
946946

947+
newPos := proj.Position()
948+
949+
proj.Trajectory = append(proj.Trajectory, newPos)
950+
951+
proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
952+
Position: newPos,
953+
FrameID: p.CurrentFrame(),
954+
Time: p.CurrentTime(),
955+
})
956+
947957
if p.isSource2() && !p.disableMimicSource1GameEvents {
948958
p.eventDispatcher.Dispatch(events.WeaponFire{
949959
Shooter: proj.Owner,
@@ -957,6 +967,16 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
957967
})
958968

959969
entity.OnDestroy(func() {
970+
newPos := proj.Position()
971+
972+
proj.Trajectory = append(proj.Trajectory, newPos)
973+
974+
proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
975+
Position: newPos,
976+
FrameID: p.CurrentFrame(),
977+
Time: p.CurrentTime(),
978+
})
979+
960980
if p.demoInfoProvider.IsSource2() && wep == common.EqFlash && !p.disableMimicSource1GameEvents {
961981
p.gameEventHandler.dispatch(events.FlashExplode{
962982
GrenadeEvent: events.GrenadeEvent{
@@ -1010,16 +1030,6 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
10101030
}
10111031
})
10121032

1013-
entity.OnPositionUpdate(func(newPos r3.Vector) {
1014-
proj.Trajectory = append(proj.Trajectory, newPos)
1015-
1016-
proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
1017-
Position: newPos,
1018-
FrameID: p.CurrentFrame(),
1019-
Time: p.CurrentTime(),
1020-
})
1021-
})
1022-
10231033
// Some demos don't have this property as it seems
10241034
// So we need to check for nil and can't send out bounce events if it's missing
10251035
if bounceProp := entity.Property("m_nBounces"); bounceProp != nil {
@@ -1035,6 +1045,16 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
10351045
BounceNr: bounceNumber,
10361046
})
10371047
}
1048+
1049+
newPos := proj.Position()
1050+
1051+
proj.Trajectory = append(proj.Trajectory, newPos)
1052+
1053+
proj.Trajectory2 = append(proj.Trajectory2, common.TrajectoryEntry{
1054+
Position: newPos,
1055+
FrameID: p.CurrentFrame(),
1056+
Time: p.CurrentTime(),
1057+
})
10381058
})
10391059
}
10401060
}

0 commit comments

Comments
 (0)