|
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) { |
@@ -181,31 +182,32 @@ func (p *Parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) { |
181 | 182 | Y: float64(data["y"].ValFloat), |
182 | 183 | Z: float64(data["z"].ValFloat), |
183 | 184 | } |
| 185 | + nadeEntity := p.entities[int(data["entityid"].GetValShort())] |
184 | 186 |
|
185 | 187 | switch d.Name { |
186 | 188 | case "flashbang_detonate": // Flash exploded |
187 | | - p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position)}) |
| 189 | + p.eventDispatcher.Dispatch(events.FlashExplodedEvent{NadeEvent: buildNadeEvent(common.EqFlash, thrower, position, nadeEntity)}) |
188 | 190 |
|
189 | 191 | case "hegrenade_detonate": // HE exploded |
190 | | - p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position)}) |
| 192 | + p.eventDispatcher.Dispatch(events.HeExplodedEvent{NadeEvent: buildNadeEvent(common.EqHE, thrower, position, nadeEntity)}) |
191 | 193 |
|
192 | 194 | case "decoy_started": // Decoy started |
193 | | - p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position)}) |
| 195 | + p.eventDispatcher.Dispatch(events.DecoyStartEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntity)}) |
194 | 196 |
|
195 | 197 | case "decoy_detonate": // Decoy exploded/expired |
196 | | - p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position)}) |
| 198 | + p.eventDispatcher.Dispatch(events.DecoyEndEvent{NadeEvent: buildNadeEvent(common.EqDecoy, thrower, position, nadeEntity)}) |
197 | 199 |
|
198 | 200 | case "smokegrenade_detonate": // Smoke popped |
199 | | - p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position)}) |
| 201 | + p.eventDispatcher.Dispatch(events.SmokeStartEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntity)}) |
200 | 202 |
|
201 | 203 | case "smokegrenade_expired": // Smoke expired |
202 | | - p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position)}) |
| 204 | + p.eventDispatcher.Dispatch(events.SmokeEndEvent{NadeEvent: buildNadeEvent(common.EqSmoke, thrower, position, nadeEntity)}) |
203 | 205 |
|
204 | 206 | case "inferno_startburn": // Incendiary exploded/started |
205 | | - p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position)}) |
| 207 | + p.eventDispatcher.Dispatch(events.FireNadeStartEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntity)}) |
206 | 208 |
|
207 | 209 | case "inferno_expire": // Incendiary expired |
208 | | - p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position)}) |
| 210 | + p.eventDispatcher.Dispatch(events.FireNadeEndEvent{NadeEvent: buildNadeEvent(common.EqIncendiary, thrower, position, nadeEntity)}) |
209 | 211 | } |
210 | 212 |
|
211 | 213 | case "player_connect": // Bot connected or player reconnected, players normally come in via string tables & data tables |
@@ -446,11 +448,12 @@ func mapGameEventData(d *msg.CSVCMsg_GameEventListDescriptorT, e *msg.CSVCMsg_Ga |
446 | 448 | } |
447 | 449 |
|
448 | 450 | // Just so we can nicely create NadeEvents in one line |
449 | | -func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector) events.NadeEvent { |
| 451 | +func buildNadeEvent(nadeType common.EquipmentElement, thrower *common.Player, position r3.Vector, nadeEntity *st.Entity) events.NadeEvent { |
450 | 452 | return events.NadeEvent{ |
451 | | - NadeType: nadeType, |
452 | | - Thrower: thrower, |
453 | | - Position: position, |
| 453 | + NadeType: nadeType, |
| 454 | + Thrower: thrower, |
| 455 | + Position: position, |
| 456 | + NadeEntity: nadeEntity, |
454 | 457 | } |
455 | 458 | } |
456 | 459 |
|
|
0 commit comments