Skip to content

Commit c43ef5b

Browse files
committed
events: add WeaponReload (#137)
1 parent 02b8cd2 commit c43ef5b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

events/events.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ type WeaponFire struct {
157157
Weapon *common.Equipment
158158
}
159159

160+
// WeaponReload signals that a player started to reload his weapon.
161+
type WeaponReload struct {
162+
Player *common.Player
163+
}
164+
160165
// GrenadeEventIf is the interface for all GrenadeEvents (except GrenadeProjectile* events).
161166
// Used to catch the different events with the same handler.
162167
type GrenadeEventIf interface {

game_events.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func newGameEventHandler(parser *Parser) gameEventHandler {
141141
"tournament_reward": nil, // Dunno
142142
"weapon_fire": geh.weaponFire, // Weapon was fired
143143
"weapon_fire_on_empty": nil, // Sounds boring
144-
"weapon_reload": nil, // Weapon reloaded
144+
"weapon_reload": geh.weaponReload, // Weapon reloaded
145145
"weapon_zoom": nil, // Zooming in
146146
}
147147

@@ -247,6 +247,12 @@ func (geh gameEventHandler) weaponFire(data map[string]*msg.CSVCMsg_GameEventKey
247247
})
248248
}
249249

250+
func (geh gameEventHandler) weaponReload(data map[string]*msg.CSVCMsg_GameEventKeyT) {
251+
geh.dispatch(events.WeaponReload{
252+
Player: geh.playerByUserID32(data["userid"].GetValShort()),
253+
})
254+
}
255+
250256
func (geh gameEventHandler) playerDeath(data map[string]*msg.CSVCMsg_GameEventKeyT) {
251257
killer := geh.playerByUserID32(data["attacker"].GetValShort())
252258
wepType := common.MapEquipment(data["weapon"].GetValString())

0 commit comments

Comments
 (0)