|
9 | 9 | common "github.com/markus-wa/demoinfocs-golang/common" |
10 | 10 | events "github.com/markus-wa/demoinfocs-golang/events" |
11 | 11 | msg "github.com/markus-wa/demoinfocs-golang/msg" |
| 12 | + st "github.com/markus-wa/demoinfocs-golang/sendtables" |
12 | 13 | ) |
13 | 14 |
|
14 | 15 | func (p *Parser) handleGameEventList(gel *msg.CSVCMsg_GameEventList) { |
@@ -197,31 +198,32 @@ func (p *Parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) { |
197 | 198 | Y: float64(data["y"].ValFloat), |
198 | 199 | Z: float64(data["z"].ValFloat), |
199 | 200 | } |
| 201 | + entity := p.entities[int(data["entityid"].GetValShort())] |
200 | 202 |
|
201 | 203 | switch d.Name { |
202 | 204 | case "flashbang_detonate": // Flash exploded |
203 | | - p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position)}) |
| 205 | + p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position, entity)}) |
204 | 206 |
|
205 | 207 | case "hegrenade_detonate": // HE exploded |
206 | | - p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position)}) |
| 208 | + p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position, entity)}) |
207 | 209 |
|
208 | 210 | case "decoy_started": // Decoy started |
209 | | - p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position)}) |
| 211 | + p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, entity)}) |
210 | 212 |
|
211 | 213 | case "decoy_detonate": // Decoy exploded/expired |
212 | | - p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position)}) |
| 214 | + p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, entity)}) |
213 | 215 |
|
214 | 216 | case "smokegrenade_detonate": // Smoke popped |
215 | | - p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position)}) |
| 217 | + p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, entity)}) |
216 | 218 |
|
217 | 219 | case "smokegrenade_expired": // Smoke expired |
218 | | - p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position)}) |
| 220 | + p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, entity)}) |
219 | 221 |
|
220 | 222 | case "inferno_startburn": // Incendiary exploded/started |
221 | | - p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position)}) |
| 223 | + p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, entity)}) |
222 | 224 |
|
223 | 225 | case "inferno_expire": // Incendiary expired |
224 | | - p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position)}) |
| 226 | + p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, entity)}) |
225 | 227 | } |
226 | 228 |
|
227 | 229 | case "player_connect": // Bot connected, players come in via string tables & data tables |
@@ -449,11 +451,12 @@ func mapGameEventData(d *msg.CSVCMsg_GameEventListDescriptorT, e *msg.CSVCMsg_Ga |
449 | 451 | } |
450 | 452 |
|
451 | 453 | // Just so we can nicely create NadeEvents in one line |
452 | | -func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector) events.NadeEvent { |
| 454 | +func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector, entity *st.Entity) events.NadeEvent { |
453 | 455 | return events.NadeEvent{ |
454 | 456 | NadeType: nadeType, |
455 | 457 | Thrower: thrower, |
456 | 458 | Position: position, |
| 459 | + Entity: entity, |
457 | 460 | } |
458 | 461 | } |
459 | 462 |
|
|
0 commit comments