events

package
v3.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 4 Imported by: 7

Documentation

Overview

Package events contains all events that can be sent out from demoinfocs.Parser.

Events are generally named in the tense that fits the best for each event. E.g. SmokeExpired is in the past tense because it's sent out when the smoke has completely faded away while SmokeStart is in the present tense because it's sent out when the smoke starts to bloom.

Index

Constants

View Source
const (
	BomsiteUnknown bombsite = 0
	BombsiteA      bombsite = 'A'
	BombsiteB      bombsite = 'B'
)

Bombsite identifiers

View Source
const (
	WarnTypeUndefined                  = iota
	WarnTypeBombsiteUnknown            // may occur on de_grind for bombsite B as the bounding box of the bombsite is wrong
	WarnTypeTeamSwapPlayerNil          // TODO: figure out why this happens
	WarnTypeGameEventBeforeDescriptors // may occur in POV demos

	// WarnTypeMissingNetMessageDecryptionKey occurs when encrypted net-messages are encountered and the decryption key is missing.
	// See ParserConfig.NetMessageDecryptionKey
	WarnTypeMissingNetMessageDecryptionKey

	// WarnTypeCantReadEncryptedNetMessage occurs when an encrypted net-messages can't be decrypted even though the decryption key is set.
	// May occur because the decryption key used is incorrect.
	// See ParserConfig.NetMessageDecryptionKey
	WarnTypeCantReadEncryptedNetMessage
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnouncementFinalRound

type AnnouncementFinalRound struct{}

AnnouncementFinalRound signals the 30th round, not raised if the match ends before that.

type AnnouncementLastRoundHalf

type AnnouncementLastRoundHalf struct{}

AnnouncementLastRoundHalf signals the last round of the first half.

type AnnouncementMatchStarted

type AnnouncementMatchStarted struct{}

AnnouncementMatchStarted signals that the announcement "Match Started" has been displayed.

type AnnouncementWinPanelMatch

type AnnouncementWinPanelMatch struct{}

AnnouncementWinPanelMatch signals that the 'win panel' has been displayed. I guess that's the final scoreboard.

type BombDefuseAborted

type BombDefuseAborted struct {
	Player *common.Player
}

BombDefuseAborted signals that the defuser aborted the action.

type BombDefuseStart

type BombDefuseStart struct {
	Player *common.Player
	HasKit bool
}

BombDefuseStart signals the start of defusing.

type BombDefused

type BombDefused struct {
	BombEvent
}

BombDefused signals that the bomb has been defused.

type BombDropped

type BombDropped struct {
	Player   *common.Player
	EntityID int
}

BombDropped signals that the bomb (C4) has been dropped onto the ground. Not fired if it has been dropped to another player (see BombPickup for this).

type BombEvent

type BombEvent struct {
	Player *common.Player
	Site   bombsite
}

BombEvent contains the common attributes of bomb events. Dont register handlers on this tho, you want BombEventIf for that.

type BombEventIf

type BombEventIf interface {
	// contains filtered or unexported methods
}

BombEventIf is the interface for all the bomb events. Like GrenadeEventIf for GrenadeEvents.

type BombExplode

type BombExplode struct {
	BombEvent
}

BombExplode signals that the bomb has exploded.

type BombPickup

type BombPickup struct {
	Player *common.Player
}

BombPickup signals that the bomb (C4) has been picked up.

type BombPlantAborted

type BombPlantAborted struct {
	Player *common.Player
}

BombPlantAborted signals the abortion of a plant.

type BombPlantBegin

type BombPlantBegin struct {
	BombEvent
}

BombPlantBegin signals the start of a plant.

type BombPlanted

type BombPlanted struct {
	BombEvent
}

BombPlanted signals that the bomb has been planted.

type BotConnect

type BotConnect struct {
	Player *common.Player
}

BotConnect signals that a bot has connected.

type BotTakenOver

type BotTakenOver struct {
	Taker *common.Player
}

BotTakenOver signals that a player took over a bot.

type ChatMessage

type ChatMessage struct {
	Sender    *common.Player
	Text      string
	IsChatAll bool
}

ChatMessage signals a player generated chat message. Since team chat is generally not recorded IsChatAll will probably always be false. See SayText for admin / console messages and SayText2 for raw network package data.

type ConVarsUpdated

type ConVarsUpdated struct {
	UpdatedConVars map[string]string
}

ConVarsUpdated signals that ConVars/CVars have been updated. See GameState.ConVars().

type DataTablesParsed

type DataTablesParsed struct{}

DataTablesParsed signals that the datatables were parsed. You can use the Parser.ServerClasses() after this event to register update notification on entities & properties.

type DecoyExpired

type DecoyExpired struct {
	GrenadeEvent
}

DecoyExpired signals the end of a decoy.

type DecoyStart

type DecoyStart struct {
	GrenadeEvent
}

DecoyStart signals the start of a decoy.

type FireGrenadeExpired

type FireGrenadeExpired struct {
	GrenadeEvent
}

FireGrenadeExpired signals that all fires of a molly/incendiary have extinguished. GrenadeType will always be EqIncendiary as it's not networked whether it's an incendiary or molotov. Thrower will always be nil as this isn't networked.

type FireGrenadeStart

type FireGrenadeStart struct {
	GrenadeEvent
}

FireGrenadeStart signals the start of a molly/incendiary. GrenadeType will always be EqIncendiary as it's not networked whether it's an incendiary or molotov. Thrower will always be nil as this isn't networked.

type FlashExplode

type FlashExplode struct {
	GrenadeEvent
}

FlashExplode signals the explosion of a Flash.

type Footstep

type Footstep struct {
	Player *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
}

Footstep occurs when a player makes a footstep.

type FrameDone

type FrameDone struct{}

FrameDone signals that a demo-frame has been processed. A frame can contain multiple ticks (usually 2 or 4) if the tv_snapshotrate differs from the tick-rate the game was played at.

type GameHalfEnded

type GameHalfEnded struct {
}

GameHalfEnded signals that the currently ongoing game half has ended. GameHalfEnded is usually dispatched in the end of a round, just before RoundEndOfficial.

type GamePhaseChanged

type GamePhaseChanged struct {
	OldGamePhase common.GamePhase
	NewGamePhase common.GamePhase
}

GamePhaseChanged signals that the game phase has changed. This event is for advanced usage, as more user friendly events are available for important game phase changes, such as TeamSideSwitch and GameHalfEnded.

type GenericGameEvent

type GenericGameEvent struct {
	Name string
	Data map[string]*msg.CSVCMsg_GameEventKeyT
}

GenericGameEvent signals any game-event. It contains the raw data as received from the net-message.

type GrenadeEvent

type GrenadeEvent struct {
	GrenadeType     common.EquipmentType
	Grenade         *common.Equipment // Maybe nil for InfernoStart & InfernoExpired since we don't know the thrower (at least in old demos)
	Position        r3.Vector
	Thrower         *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	GrenadeEntityID int
}

GrenadeEvent contains the common attributes of nade events. Dont register handlers on this tho, you want GrenadeEventIf for that

func (GrenadeEvent) Base

func (ne GrenadeEvent) Base() GrenadeEvent

Base returns the GrenadeEvent itself, used for catching all events with GrenadeEventIf.

type GrenadeEventIf

type GrenadeEventIf interface {
	Base() GrenadeEvent
}

GrenadeEventIf is the interface for all GrenadeEvents (except GrenadeProjectile* events). Used to catch the different events with the same handler.

type GrenadeProjectileBounce

type GrenadeProjectileBounce struct {
	Projectile *common.GrenadeProjectile
	BounceNr   int
}

GrenadeProjectileBounce signals that a nade has just bounced off a wall/floor/ceiling or object.

type GrenadeProjectileDestroy

type GrenadeProjectileDestroy struct {
	Projectile *common.GrenadeProjectile
}

GrenadeProjectileDestroy signals that a nade entity is being destroyed (i.e. it detonated / expired). This is different from the other Grenade events because it's sent out when the projectile entity is destroyed.

Mainly useful for getting the full trajectory of the projectile.

type GrenadeProjectileThrow

type GrenadeProjectileThrow struct {
	Projectile *common.GrenadeProjectile
}

GrenadeProjectileThrow signals that a nade has just been thrown. This is different from the WeaponFired because it's sent out when the projectile entity is created.

type HeExplode

type HeExplode struct {
	GrenadeEvent
}

HeExplode signals the explosion of a HE.

type HitGroup

type HitGroup byte

HitGroup is the type for the various HitGroupXYZ constants.

See PlayerHurt.

const (
	HitGroupGeneric  HitGroup = 0
	HitGroupHead     HitGroup = 1
	HitGroupChest    HitGroup = 2
	HitGroupStomach  HitGroup = 3
	HitGroupLeftArm  HitGroup = 4
	HitGroupRightArm HitGroup = 5
	HitGroupLeftLeg  HitGroup = 6
	HitGroupRightLeg HitGroup = 7
	HitGroupNeck     HitGroup = 8
	HitGroupGear     HitGroup = 10
)

HitGroup constants give information about where a player got hit. e.g. head, chest, legs etc.

type HostageHurt

type HostageHurt struct {
	Player  *common.Player
	Hostage *common.Hostage
}

HostageHurt signals that a hostage has been hurt.

type HostageKilled

type HostageKilled struct {
	Killer  *common.Player
	Hostage *common.Hostage
}

HostageKilled signals that a hostage has been killed.

type HostageRecued

type HostageRecued struct {
	Player  *common.Player
	Hostage *common.Hostage
}

HostageRecued signals that a hostage has been rescued.

type HostageRescuedAll

type HostageRescuedAll struct{}

HostageRescuedAll signals that all hostages have been rescued.

type HostageStateChanged

type HostageStateChanged struct {
	OldState common.HostageState
	NewState common.HostageState
	Hostage  *common.Hostage
}

HostageStateChanged signals that the state of a hostage has changed. e.g. being untied, picked up, rescued etc. See HostageState for all possible values.

type InfernoExpired

type InfernoExpired struct {
	Inferno *common.Inferno
}

InfernoExpired signals that all fire from a incendiary or Molotov has extinguished. This is different from the FireGrenadeExpire event because it's sent out when the inferno entity is destroyed instead of on the game-event.

Mainly useful for getting the final area of an inferno.

type InfernoStart

type InfernoStart struct {
	Inferno *common.Inferno
}

InfernoStart signals that the fire of a incendiary or Molotov is starting. This is different from the FireGrenadeStart because it's sent out when the inferno entity is created instead of on the game-event.

type IsWarmupPeriodChanged

type IsWarmupPeriodChanged struct {
	OldIsWarmupPeriod bool
	NewIsWarmupPeriod bool
}

IsWarmupPeriodChanged signals that the value of data table DT_GameRulesProxy.m_bIsWarmupPeriod has changed. This can be useful to ignore things that happen during the warmup.

type ItemDrop

type ItemDrop struct {
	Player *common.Player
	Weapon *common.Equipment
}

ItemDrop signals an item was dropped. This event is not available in all demos.

type ItemEquip

type ItemEquip struct {
	Player *common.Player
	Weapon *common.Equipment
}

ItemEquip signals an item was equipped. This event is not available in all demos.

type ItemPickup

type ItemPickup struct {
	Player *common.Player
	Weapon *common.Equipment
}

ItemPickup signals an item was bought or picked up. This event is not available in all demos.

type Kill

type Kill struct {
	Weapon            *common.Equipment
	Victim            *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Killer            *common.Player // May be nil for world damage (EqWorld) or if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Assister          *common.Player
	PenetratedObjects int
	IsHeadshot        bool
	AssistedFlash     bool
	AttackerBlind     bool
	NoScope           bool
	ThroughSmoke      bool
	Distance          float32
}

Kill signals that a player has been killed.

func (Kill) IsWallBang

func (k Kill) IsWallBang() bool

IsWallBang returns true if PenetratedObjects is larger than 0.

type MatchStart

type MatchStart struct{}

MatchStart signals that the match has started.

type MatchStartedChanged

type MatchStartedChanged struct {
	OldIsStarted bool
	NewIsStarted bool
}

MatchStartedChanged signals that the value of data table DT_GameRulesProxy.m_bHasMatchStarted has changed This can be useful for some demos where the MatchStart event is not sent.

type POVRecordingPlayerDetected added in v3.3.0

type POVRecordingPlayerDetected struct {
	PlayerSlot int
	PlayerInfo common.PlayerInfo
}

POVRecordingPlayerDetected signals that a player started recording the demo locally. If this event is dispatched, it means it's a client-side (POV) demo.

type ParserWarn

type ParserWarn struct {
	Message string
	Type    WarnType
}

ParserWarn signals that a non-fatal problem occurred during parsing.

type PlayerConnect

type PlayerConnect struct {
	Player *common.Player
}

PlayerConnect signals that a player connected.

type PlayerDisconnected

type PlayerDisconnected struct {
	Player *common.Player
}

PlayerDisconnected signals that a player has disconnected.

type PlayerFlashed

type PlayerFlashed struct {
	Player     *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Attacker   *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Projectile *common.GrenadeProjectile
}

PlayerFlashed signals that a player was flashed.

func (PlayerFlashed) FlashDuration

func (e PlayerFlashed) FlashDuration() time.Duration

FlashDuration returns the duration of the blinding effect. This is just a shortcut for Player.FlashDurationTime().

type PlayerHurt

type PlayerHurt struct {
	Player            *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Attacker          *common.Player // May be nil if the player is taking world damage (e.g. fall damage) or if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Health            int
	Armor             int
	Weapon            *common.Equipment // May be EqUnknown for world-damage (falling / bomb).
	WeaponString      string            // Wrong for CZ, M4A1-S etc.
	HealthDamage      int
	ArmorDamage       int
	HealthDamageTaken int // HealthDamage excluding over-damage (e.g. if player has 5 health and is hit for 15 damage this would be 5 instead of 15)
	ArmorDamageTaken  int // ArmorDamage excluding over-damage (e.g. if player has 5 armor and is hit for 15 armor damage this would be 5 instead of 15)
	HitGroup          HitGroup
}

PlayerHurt signals that a player has been damaged.

type PlayerInfo

type PlayerInfo struct {
	Index int
	Info  common.PlayerInfo
}

PlayerInfo signals that basic player information was read via stringtables.

type PlayerJump

type PlayerJump struct {
	Player *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
}

PlayerJump signals that a player has jumped.

type PlayerNameChange

type PlayerNameChange struct {
	Player  *common.Player
	OldName string
	NewName string
}

PlayerNameChange signals that a player's name has changed.

type PlayerSpottersChanged

type PlayerSpottersChanged struct {
	Spotted *common.Player
}

PlayerSpottersChanged signals that a player's spotters (other players that can se him) changed.

type PlayerTeamChange

type PlayerTeamChange struct {
	Player *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).

	// TeamState of the old team.
	// May be nil if player changed from spectators/unassigned (OldTeam == TeamSpectators || OldTeam == TeamUnassigned).
	NewTeamState *common.TeamState

	// TeamState of the old team.
	// May be nil if player changed from spectators/unassigned (OldTeam == TeamSpectators || OldTeam == TeamUnassigned).
	OldTeamState *common.TeamState

	NewTeam common.Team
	OldTeam common.Team

	Silent bool
	IsBot  bool
}

PlayerTeamChange occurs when a player swaps teams.

type RankUpdate

type RankUpdate struct {
	SteamID32  int32 // 32-bit variant of the SteamID. See https://developer.valvesoftware.com/wiki/SteamID
	RankChange float32
	RankOld    int
	RankNew    int
	WinCount   int
	Player     *common.Player // may be nil if the player has already disconnected
}

RankUpdate signals the new rank. Not sure if this only occurs if the rank changed.

func (RankUpdate) SteamID64

func (ru RankUpdate) SteamID64() uint64

SteamID64 converts SteamID32 to the 64-bit SteamID variant and returns the result. See https://developer.valvesoftware.com/wiki/SteamID

type RoundEnd

type RoundEnd struct {
	Message     string
	Reason      RoundEndReason
	Winner      common.Team
	WinnerState *common.TeamState // TeamState of the winner. May be nil if it's a draw (Winner == TeamSpectators)
	LoserState  *common.TeamState // TeamState of the loser. May be nil if it's a draw (Winner == TeamSpectators)
}

RoundEnd signals that a round just finished. Attention: TeamState.Score() won't be up to date yet after this. Add +1 to the winner's score as a workaround.

type RoundEndOfficial

type RoundEndOfficial struct{}

RoundEndOfficial signals that the round has 'officially' ended. After RoundEnd and before this players are still able to walk around.

type RoundEndReason

type RoundEndReason byte

RoundEndReason is the type for the various RoundEndReasonXYZ constants.

See RoundEnd.

const (
	RoundEndReasonTargetBombed         RoundEndReason = 1
	RoundEndReasonVIPEscaped           RoundEndReason = 2
	RoundEndReasonVIPKilled            RoundEndReason = 3
	RoundEndReasonTerroristsEscaped    RoundEndReason = 4
	RoundEndReasonCTStoppedEscape      RoundEndReason = 5
	RoundEndReasonTerroristsStopped    RoundEndReason = 6
	RoundEndReasonBombDefused          RoundEndReason = 7
	RoundEndReasonCTWin                RoundEndReason = 8
	RoundEndReasonTerroristsWin        RoundEndReason = 9
	RoundEndReasonDraw                 RoundEndReason = 10
	RoundEndReasonHostagesRescued      RoundEndReason = 11
	RoundEndReasonTargetSaved          RoundEndReason = 12
	RoundEndReasonHostagesNotRescued   RoundEndReason = 13
	RoundEndReasonTerroristsNotEscaped RoundEndReason = 14
	RoundEndReasonVIPNotEscaped        RoundEndReason = 15
	RoundEndReasonGameStart            RoundEndReason = 16
	RoundEndReasonTerroristsSurrender  RoundEndReason = 17
	RoundEndReasonCTSurrender          RoundEndReason = 18
)

RoundEndReason constants give information about why a round ended (Bomb defused, exploded etc.).

type RoundFreezetimeEnd

type RoundFreezetimeEnd struct{}

RoundFreezetimeEnd signals that the freeze time is over.

type RoundImpactScoreData

type RoundImpactScoreData struct {
	RawMessage *msg.CCSUsrMsg_RoundImpactScoreData
}

RoundImpactScoreData contains impact assessments of events that happened during the last round.

type RoundMVPAnnouncement

type RoundMVPAnnouncement struct {
	Player *common.Player
	Reason RoundMVPReason
}

RoundMVPAnnouncement signals the announcement of the last rounds MVP.

type RoundMVPReason

type RoundMVPReason byte

RoundMVPReason is the type for the various MVPReasonYXZ constants.

See RoundMVPAnnouncement.

const (
	MVPReasonMostEliminations RoundMVPReason = 1
	MVPReasonBombDefused      RoundMVPReason = 2
	MVPReasonBombPlanted      RoundMVPReason = 3
)

RoundMVPReasons constants give information about why a player got the MVP award.

type RoundStart

type RoundStart struct {
	TimeLimit int
	FragLimit int
	Objective string
}

RoundStart signals that a new round has started.

type SayText

type SayText struct {
	EntIdx    int // Not sure what this is, doesn't seem to be the entity-ID
	Text      string
	IsChat    bool // Not sure, from the net-message
	IsChatAll bool // Seems to always be false, team chat might not be recorded
}

SayText signals a chat message. It contains the raw network message data for admin / console messages. EntIdx will probably always be 0 See ChatMessage and SayText2 for player chat messages.

type SayText2

type SayText2 struct {
	EntIdx    int      // Not sure what this is, doesn't seem to be the entity-ID
	MsgName   string   // The message type, e.g. Cstrike_Chat_All for global chat
	Params    []string // The message's parameters, for Cstrike_Chat_All parameter 1 is the player and 2 the message for example
	IsChat    bool     // Not sure, from the net-message
	IsChatAll bool     // Seems to always be false, team chat might not be recorded
}

SayText2 signals a chat message. It just contains the raw network message. For player chat messages, ChatMessage may be more interesting. Team chat is generally not recorded so IsChatAll will probably always be false. See SayText for admin / console messages.

type ScoreUpdated

type ScoreUpdated struct {
	OldScore  int
	NewScore  int
	TeamState *common.TeamState
}

ScoreUpdated signals that the score of one of the teams has been updated. It has been observed that some demos do not always trigger the RoundEnd event as one would expect.

ScoreUpdated can be used to circumvent missing RoundEnd events in some cases, as (we assume) it is required in order to show the correct score in-game.

type SmokeExpired

type SmokeExpired struct {
	GrenadeEvent
}

SmokeExpired signals that a smoke as completely faded away.

type SmokeStart

type SmokeStart struct {
	GrenadeEvent
}

SmokeStart signals the start of a smoke (pop).

type StringTableCreated

type StringTableCreated struct {
	TableName string
}

StringTableCreated signals that a string table was created via net message. Can be useful for figuring out when player-info is available via Parser.GameState().[Playing]Participants(). E.g. after the table 'userinfo' has been created the player-data should be available after the next FrameDone. The reason it's not immediately available is because we need to do some post-processing to prep that data after a tick has finished.

type StringTablePlayerUpdateApplied

type StringTablePlayerUpdateApplied struct {
	Player *common.Player
}

StringTablePlayerUpdateApplied signals that a player has been updated via stringtables.

type TeamSideSwitch

type TeamSideSwitch struct {
}

TeamSideSwitch signals that teams are switching sides, i.e. swapping between T and CT. TeamSideSwitch is usually dispatched in the beginning of a round, just after OnRoundStart.

type TickRateInfoAvailable

type TickRateInfoAvailable struct {
	TickRate float64       // See Parser.TickRate()
	TickTime time.Duration // See Parser.TickTime()
}

TickRateInfoAvailable signals that the tick-rate information has been received via CSVCMsg_ServerInfo. This can be useful for corrupt demo headers where the tick-rate is missing in the beginning of the demo.

type WarnType

type WarnType int

WarnType identifies a kind of warning for the ParserWarn event.

type WeaponFire

type WeaponFire struct {
	Shooter *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
	Weapon  *common.Equipment
}

WeaponFire signals that a weapon has been fired.

type WeaponReload

type WeaponReload struct {
	Player *common.Player // May be nil if the demo is partially corrupt (player is 'unconnected', see #156 and #172).
}

WeaponReload signals that a player started to reload his weapon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL