events

package
Version: v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: MIT Imports: 4 Imported by: 27

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 (
	BombsiteA bombsite = 'A'
	BombsiteB bombsite = 'B'
)

Bombsite identifiers

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnouncementFinalRound added in v1.0.0

type AnnouncementFinalRound struct{}

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

type AnnouncementLastRoundHalf added in v1.0.0

type AnnouncementLastRoundHalf struct{}

AnnouncementLastRoundHalf signals the last round of the first half.

type AnnouncementMatchStarted added in v1.0.0

type AnnouncementMatchStarted struct{}

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

type AnnouncementWinPanelMatch added in v1.0.0

type AnnouncementWinPanelMatch struct{}

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

type BombDefuseAborted added in v1.0.0

type BombDefuseAborted struct {
	Player *common.Player
}

BombDefuseAborted signals that the defuser aborted the action.

type BombDefuseStart added in v1.0.0

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

BombDefuseStart signals the start of defusing.

type BombDefused added in v1.0.0

type BombDefused struct {
	BombEvent
}

BombDefused signals that the bomb has been defused.

type BombDropped added in v1.0.0

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 added in v1.0.0

type BombExplode struct {
	BombEvent
}

BombExplode signals that the bomb has exploded.

type BombPickup added in v1.0.0

type BombPickup struct {
	Player *common.Player
}

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

type BombPlantAborted added in v1.5.0

type BombPlantAborted struct {
	Player *common.Player
}

BombPlantAbort signals the abortion of a plant.

type BombPlantBegin added in v1.0.0

type BombPlantBegin struct {
	BombEvent
}

BombPlantBegin signals the start of a plant.

type BombPlanted added in v1.0.0

type BombPlanted struct {
	BombEvent
}

BombPlanted signals that the bomb has been planted.

type BotTakenOver added in v1.0.0

type BotTakenOver struct {
	Taker *common.Player
}

BotTakenOver signals that a player took over a bot.

type ChatMessage added in v1.0.0

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 added in v1.3.0

type ConVarsUpdated struct {
	UpdatedConVars map[string]string
}

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

type DataTablesParsed added in v1.0.0

type DataTablesParsed struct{}

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

type DecoyExpired added in v1.0.0

type DecoyExpired struct {
	GrenadeEvent
}

DecoyExpired signals the end of a decoy.

type DecoyStart added in v1.0.0

type DecoyStart struct {
	GrenadeEvent
}

DecoyStart signals the start of a decoy.

type FireGrenadeExpired added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

type FlashExplode struct {
	GrenadeEvent
}

FlashExplode signals the explosion of a Flash.

type Footstep added in v1.0.0

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 added in v1.2.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v0.5.0

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 added in v1.0.0

type GrenadeEvent struct {
	GrenadeType     common.EquipmentElement
	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 added in v1.0.0

func (ne GrenadeEvent) Base() GrenadeEvent

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

type GrenadeEventIf added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

type HeExplode struct {
	GrenadeEvent
}

HeExplode signals the explosion of a HE.

type HitGroup added in v1.0.0

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
	HitGroupGear     HitGroup = 10
)

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

type InfernoExpired added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

type ItemDrop struct {
	Player    *common.Player
	Weapon    common.Equipment // Value of WeaponPtr, use WeaponPtr instead
	WeaponPtr *common.Equipment
}

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

type ItemEquip added in v1.0.0

type ItemEquip struct {
	Player    *common.Player
	Weapon    common.Equipment // Value of WeaponPtr, use WeaponPtr instead
	WeaponPtr *common.Equipment
}

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

type ItemPickup added in v1.0.0

type ItemPickup struct {
	Player *common.Player
	Weapon common.Equipment // UniqueID() of this cannot be used to trace the weapon, use WeaponTraceable() instead
}

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

func (ItemPickup) WeaponTraceable added in v1.3.0

func (pu ItemPickup) WeaponTraceable() *common.Equipment

WeaponTraceable attempts to return the original Equipment instance. This can be used to trace the same weapon with UniqueID() when it's being dropped to other players.

If the original instance cannot be found, the returned Equipment will still have a different UniqueID().

type Kill added in v1.0.0

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
}

Kill signals that a player has been killed.

type MatchStart added in v1.0.0

type MatchStart struct{}

MatchStart signals that the match has started.

type MatchStartedChanged added in v1.0.0

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 ParserWarn added in v1.0.0

type ParserWarn struct {
	Message string
}

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

type PlayerConnect added in v1.0.0

type PlayerConnect struct {
	Player *common.Player
}

PlayerConnect signals that a player has started connecting.

type PlayerDisconnected added in v1.0.0

type PlayerDisconnected struct {
	Player *common.Player
}

PlayerDisconnected signals that a player has disconnected.

type PlayerFlashed added in v1.0.0

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 added in v1.0.0

func (e PlayerFlashed) FlashDuration() time.Duration

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

type PlayerHurt added in v1.0.0

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
	HitGroup     HitGroup
}

PlayerHurt signals that a player has been damaged.

type PlayerJump added in v1.0.0

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 PlayerSpottersChanged added in v1.2.0

type PlayerSpottersChanged struct {
	Spotted *common.Player
}

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

type PlayerTeamChange added in v1.0.0

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 added in v1.0.0

type RankUpdate struct {
	SteamID    int64 // 32-bit SteamID. Deprecated, use SteamID32 instead
	SteamID32  int32
	RankChange float32
	RankOld    int
	RankNew    int
	WinCount   int
}

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

type RoundEnd added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

type RoundFreezetimeEnd struct{}

RoundFreezetimeEnd signals that the freeze time is over.

type RoundMVPAnnouncement added in v1.0.0

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

RoundMVPAnnouncement signals the announcement of the last rounds MVP.

type RoundMVPReason added in v1.0.0

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 added in v1.0.0

type RoundStart struct {
	TimeLimit int
	FragLimit int
	Objective string
}

RoundStart signals that a new round has started.

type SayText added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

type SmokeExpired struct {
	GrenadeEvent
}

SmokeExpired signals that a smoke as completely faded away.

type SmokeStart added in v1.0.0

type SmokeStart struct {
	GrenadeEvent
}

SmokeStart signals the start of a smoke (pop).

type StringTableCreated added in v1.0.0

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 TeamSideSwitch added in v1.0.0

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 TickDone added in v1.0.0

type TickDone struct{}

TickDone is deprecated, use the identical FrameDone event instead. It does NOT signal the end of a tick, it signals the end of a demo-frame instead.

type WeaponFire added in v1.0.0

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 added in v1.3.0

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.

Source Files

Jump to

Keyboard shortcuts

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