Skip to content

Commit 66afee9

Browse files
authored
events: add PlayerFlashed.Projectile attribute (#158)
1 parent abfb31a commit 66afee9

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

datatables.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ func (p *Parser) nadeProjectileDestroyed(proj *common.GrenadeProjectile) {
419419
})
420420

421421
delete(p.gameState.grenadeProjectiles, proj.EntityID)
422+
423+
p.gameState.lastFlash.projectile = proj
422424
}
423425

424426
func (p *Parser) bindWeapon(entity *st.Entity, wepType common.EquipmentElement) {

events/events.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ type GrenadeProjectileDestroy struct {
248248

249249
// PlayerFlashed signals that a player was flashed.
250250
type PlayerFlashed struct {
251-
Player *common.Player
252-
Attacker *common.Player
251+
Player *common.Player
252+
Attacker *common.Player
253+
Projectile *common.GrenadeProjectile
253254
}
254255

255256
// FlashDuration returns the duration of the blinding effect.

game_events.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,16 @@ func (geh gameEventHandler) playerHurt(data map[string]*msg.CSVCMsg_GameEventKey
320320

321321
func (geh gameEventHandler) playerBlind(data map[string]*msg.CSVCMsg_GameEventKeyT) {
322322
geh.dispatch(events.PlayerFlashed{
323-
Player: geh.playerByUserID32(data["userid"].GetValShort()),
324-
Attacker: geh.gameState().lastFlasher,
323+
Player: geh.playerByUserID32(data["userid"].GetValShort()),
324+
Attacker: geh.gameState().lastFlash.player,
325+
Projectile: geh.gameState().lastFlash.projectile,
325326
})
326327
}
327328

328329
func (geh gameEventHandler) flashBangDetonate(data map[string]*msg.CSVCMsg_GameEventKeyT) {
329330
nadeEvent := geh.nadeEvent(data, common.EqFlash)
330331

331-
geh.gameState().lastFlasher = nadeEvent.Thrower
332+
geh.gameState().lastFlash.player = nadeEvent.Thrower
332333
geh.dispatch(events.FlashExplode{
333334
GrenadeEvent: nadeEvent,
334335
})

game_state.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ type GameState struct {
2424
gamePhase common.GamePhase
2525
isWarmupPeriod bool
2626
isMatchStarted bool
27-
lastFlasher *common.Player // Last player whose flash exploded, used to find the attacker for player_blind events
27+
lastFlash lastFlasher // Information about the last flash that exploded, used to find the attacker and projectile for player_blind events
2828
currentDefuser *common.Player // Player currently defusing the bomb, if any
2929
currentPlanter *common.Player // Player currently planting the bomb, if any
3030
}
3131

32+
type lastFlasher struct {
33+
player *common.Player
34+
projectile *common.GrenadeProjectile
35+
}
36+
3237
type ingameTickNumber int
3338

3439
func (gs *GameState) handleIngameTickNumber(n ingameTickNumber) {

test/default.golden

480 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)