@@ -164,19 +164,30 @@ func (p *parser) bindBomb() {
164
164
165
165
if p .isSource2 () {
166
166
ownerProp := bombEntity .PropertyValueMust ("m_hOwnerEntity" )
167
- planter := p .gameState .Participants ().FindByPawnHandle (ownerProp .Handle ())
168
- if planter == nil {
169
- return
167
+
168
+ var planter * common.Player
169
+
170
+ if ownerProp .Any != nil {
171
+ planter = p .gameState .Participants ().FindByPawnHandle (ownerProp .Handle ())
172
+
173
+ if planter != nil {
174
+ planter .IsPlanting = false
175
+ }
170
176
}
177
+
171
178
isTicking := true
172
- planter .IsPlanting = false
173
179
174
- siteNumber := bombEntity .PropertyValueMust ("m_nBombSite" ).Int ()
180
+ siteNumberVal := bombEntity .PropertyValueMust ("m_nBombSite" )
181
+
175
182
site := events .BomsiteUnknown
176
- if siteNumber == 0 {
177
- site = events .BombsiteA
178
- } else if siteNumber == 1 {
179
- site = events .BombsiteB
183
+
184
+ if siteNumberVal .Any != nil {
185
+ siteNumber := siteNumberVal .Int ()
186
+ if siteNumber == 0 {
187
+ site = events .BombsiteA
188
+ } else if siteNumber == 1 {
189
+ site = events .BombsiteB
190
+ }
180
191
}
181
192
182
193
if ! p .disableMimicSource1GameEvents {
@@ -190,6 +201,10 @@ func (p *parser) bindBomb() {
190
201
191
202
// Set to true when the bomb has been planted and to false when it has been defused or has exploded.
192
203
bombEntity .Property ("m_bBombTicking" ).OnUpdate (func (val st.PropertyValue ) {
204
+ if val .Any == nil {
205
+ return
206
+ }
207
+
193
208
isTicking = val .BoolVal ()
194
209
if isTicking {
195
210
return
@@ -214,31 +229,51 @@ func (p *parser) bindBomb() {
214
229
215
230
// Updated when a player starts/stops defusing the bomb
216
231
bombEntity .Property ("m_hBombDefuser" ).OnUpdate (func (val st.PropertyValue ) {
232
+ if val .Any == nil {
233
+ return
234
+ }
235
+
217
236
isValidPlayer := val .Handle () != constants .InvalidEntityHandleSource2
218
237
if isValidPlayer {
219
238
defuser := p .gameState .Participants ().FindByPawnHandle (val .Handle ())
220
239
p .gameState .currentDefuser = defuser
240
+ hasKit := false
241
+
242
+ // defuser may be nil for POV demos
243
+ if defuser != nil {
244
+ hasKit = defuser .HasDefuseKit ()
245
+ }
246
+
221
247
if ! p .disableMimicSource1GameEvents {
222
248
p .eventDispatcher .Dispatch (events.BombDefuseStart {
223
249
Player : defuser ,
224
- HasKit : defuser . HasDefuseKit () ,
250
+ HasKit : hasKit ,
225
251
})
226
252
}
253
+
227
254
return
228
255
}
229
256
230
- isDefused := bombEntity .PropertyValueMust ("m_bBombDefused" ).BoolVal ()
231
- if ! isDefused && p .gameState .currentDefuser != nil {
232
- p .eventDispatcher .Dispatch (events.BombDefuseAborted {
233
- Player : p .gameState .currentDefuser ,
234
- })
257
+ isDefusedVal := bombEntity .PropertyValueMust ("m_bBombDefused" )
258
+
259
+ if isDefusedVal .Any != nil {
260
+ isDefused := isDefusedVal .BoolVal ()
261
+ if ! isDefused && p .gameState .currentDefuser != nil {
262
+ p .eventDispatcher .Dispatch (events.BombDefuseAborted {
263
+ Player : p .gameState .currentDefuser ,
264
+ })
265
+ }
235
266
}
236
267
237
268
p .gameState .currentDefuser = nil
238
269
})
239
270
240
271
// Updated when the bomb has been planted and defused.
241
272
bombEntity .Property ("m_bBombDefused" ).OnUpdate (func (val st.PropertyValue ) {
273
+ if val .Any == nil {
274
+ return
275
+ }
276
+
242
277
isDefused := val .BoolVal ()
243
278
if isDefused && ! p .disableMimicSource1GameEvents {
244
279
defuser := p .gameState .Participants ().FindByPawnHandle (bombEntity .PropertyValueMust ("m_hBombDefuser" ).Handle ())
0 commit comments