common

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package common contains common types, constants and functions used over different demoinfocs packages. Some constants prefixes: MVPReason - the reason why someone got the MVP award. HG - HitGroup - where a bullet hit the player. EE - EquipmentElement - basically the weapon identifiers. RER - RoundEndReason - why the round ended (bomb exploded, defused, time ran out. . .). EC - EquipmentClass - type of equipment (pistol, smg, heavy. . .).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalPlayerInformation

type AdditionalPlayerInformation struct {
	Kills          int
	Deaths         int
	Assists        int
	Score          int
	MVPs           int
	Ping           int
	ClanTag        string
	TotalCashSpent int
}

AdditionalPlayerInformation contains mostly scoreboard information.

type DemoHeader

type DemoHeader struct {
	Filestamp       string
	Protocol        int
	NetworkProtocol int
	ServerName      string
	ClientName      string
	MapName         string
	GameDirectory   string
	PlaybackTime    float32
	PlaybackTicks   int
	PlaybackFrames  int
	SignonLength    int
}

DemoHeader contains information from a demo's header.

func (DemoHeader) FrameRate added in v0.4.0

func (h DemoHeader) FrameRate() float32

FrameRate returns the frame rate of the demo (frames / demo-ticks per second). Not necessarily the tick-rate the server ran on during the game. VolvoPlx128TixKTnxBye

func (DemoHeader) FrameTime added in v0.4.0

func (h DemoHeader) FrameTime() float32

FrameTime returns the time a frame / demo-tick takes in seconds.

type Equipment

type Equipment struct {
	EntityID       int
	Weapon         EquipmentElement
	OriginalString string
	SkinID         string
	AmmoInMagazine int
	AmmoType       int
	Owner          *Player
	ReserveAmmo    int
	// contains filtered or unexported fields
}

Equipment is a weapon / piece of equipment belonging to a player. This also includes the skin and some additional data.

func NewEquipment

func NewEquipment(eqName string) Equipment

NewEquipment is a wrapper for NewSkinEquipment to create weapons without skins.

Intended for internal use only.

func NewSkinEquipment

func NewSkinEquipment(eqName string, skinID string) Equipment

NewSkinEquipment creates an equipment with a skin from a skinID and equipment name.

Intended for internal use only.

func (Equipment) Class

func (e Equipment) Class() EquipmentClass

Class returns the class of the equipment. E.g. pistol, smg, heavy etc.

func (Equipment) UniqueID added in v0.5.4

func (e Equipment) UniqueID() int64

UniqueID returns the unique id of the equipment element. The unique id is a random int generated internally by this library and can be used to differentiate equipment from each other. This is needed because demo-files reuse entity ids.

type EquipmentClass

type EquipmentClass int

EquipmentClass is the type for the various EqClassXYZ constants.

const (
	EqClassUnknown   EquipmentClass = 0
	EqClassPistols   EquipmentClass = 1
	EqClassSMG       EquipmentClass = 2
	EqClassHeavy     EquipmentClass = 3
	EqClassRifle     EquipmentClass = 4
	EqClassEquipment EquipmentClass = 5
	EqClassGrenade   EquipmentClass = 6
)

EquipmentClass constants give information about the type of an equipment (SMG, Rifle, Grenade etc.).

Note: (EquipmentElement+99) / 100 = EquipmentClass

type EquipmentElement

type EquipmentElement int

EquipmentElement is the type for the various EqXYZ constants.

const (
	EqUnknown EquipmentElement = 0

	EqP2000        EquipmentElement = 1
	EqGlock        EquipmentElement = 2
	EqP250         EquipmentElement = 3
	EqDeagle       EquipmentElement = 4
	EqFiveSeven    EquipmentElement = 5
	EqDualBarettas EquipmentElement = 6
	EqTec9         EquipmentElement = 7
	EqCZ           EquipmentElement = 8
	EqUSP          EquipmentElement = 9
	EqRevolver     EquipmentElement = 10

	EqMP7   EquipmentElement = 101
	EqMP9   EquipmentElement = 102
	EqBizon EquipmentElement = 103
	EqMac10 EquipmentElement = 104
	EqUMP   EquipmentElement = 105
	EqP90   EquipmentElement = 106

	EqSawedOff EquipmentElement = 201
	EqNova     EquipmentElement = 202
	EqMag7     EquipmentElement = 203 // You should consider using EqSwag7 instead
	EqSwag7    EquipmentElement = 203
	EqXM1014   EquipmentElement = 204
	EqM249     EquipmentElement = 205
	EqNegev    EquipmentElement = 206

	EqGalil  EquipmentElement = 301
	EqFamas  EquipmentElement = 302
	EqAK47   EquipmentElement = 303
	EqM4A4   EquipmentElement = 304
	EqM4A1   EquipmentElement = 305
	EqScout  EquipmentElement = 306
	EqSSG08  EquipmentElement = 306
	EqSG556  EquipmentElement = 307
	EqSG553  EquipmentElement = 307
	EqAUG    EquipmentElement = 308
	EqAWP    EquipmentElement = 309
	EqScar20 EquipmentElement = 310
	EqG3SG1  EquipmentElement = 311

	EqZeus      EquipmentElement = 401
	EqKevlar    EquipmentElement = 402
	EqHelmet    EquipmentElement = 403
	EqBomb      EquipmentElement = 404
	EqKnife     EquipmentElement = 405
	EqDefuseKit EquipmentElement = 406
	EqWorld     EquipmentElement = 407

	EqDecoy      EquipmentElement = 501
	EqMolotov    EquipmentElement = 502
	EqIncendiary EquipmentElement = 503
	EqFlash      EquipmentElement = 504
	EqSmoke      EquipmentElement = 505
	EqHE         EquipmentElement = 506
)

EquipmentElement constants give information about what weapon a player has equipped.

func MapEquipment

func MapEquipment(eqName string) EquipmentElement

MapEquipment creates an EquipmentElement from the name of the weapon / equipment.

func (EquipmentElement) Class added in v0.5.1

func (e EquipmentElement) Class() EquipmentClass

Class returns the class of the equipment. E.g. pistol, smg, heavy etc.

func (EquipmentElement) String added in v0.5.2

func (e EquipmentElement) String() string

String returns a human readable name for the equipment. E.g. 'AK-47', 'UMP-45', 'Smoke Grenade' etc.

type GrenadeProjectile added in v0.5.4

type GrenadeProjectile struct {
	EntityID int
	Weapon   EquipmentElement
	Thrower  *Player
	Owner    *Player

	Position r3.Vector
	// contains filtered or unexported fields
}

GrenadeProjectile is a grenade thrown intentionally by a player. It is used to track grenade projectile positions between the time at which they are thrown and until they detonate.

func NewGrenadeProjectile added in v0.5.4

func NewGrenadeProjectile() *GrenadeProjectile

NewGrenadeProjectile creates a grenade projectile and sets.

Intended for internal use only.

func (GrenadeProjectile) UniqueID added in v0.5.4

func (g GrenadeProjectile) UniqueID() int64

UniqueID returns the unique id of the grenade. The unique id is a random int generated internally by this library and can be used to differentiate grenades from each other. This is needed because demo-files reuse entity ids.

type HitGroup

type HitGroup byte

HitGroup is the type for the various HitGroupXYZ constants.

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 Player

type Player struct {
	SteamID                     int64
	Position                    r3.Vector
	LastAlivePosition           r3.Vector
	Velocity                    r3.Vector
	EntityID                    int
	Name                        string
	Hp                          int
	Armor                       int
	Money                       int
	CurrentEquipmentValue       int
	FreezetimeEndEquipmentValue int
	RoundStartEquipmentValue    int
	ActiveWeaponID              int
	RawWeapons                  map[int]*Equipment
	AmmoLeft                    [32]int
	Entity                      *st.Entity
	AdditionalPlayerInformation *AdditionalPlayerInformation
	ViewDirectionX              float32
	ViewDirectionY              float32
	FlashDuration               float32
	Team                        Team
	IsBot                       bool
	IsDucking                   bool
	IsDisconnected              bool
	HasDefuseKit                bool
	HasHelmet                   bool
	Connected                   bool
}

Player contains mostly game-relevant player information.

func NewPlayer

func NewPlayer() *Player

NewPlayer creates a *Player with an initialized equipment map.

Intended for internal use only.

func (*Player) ActiveWeapon

func (p *Player) ActiveWeapon() *Equipment

ActiveWeapon returns the currently active / equipped weapon of the player.

func (*Player) IsAlive

func (p *Player) IsAlive() bool

IsAlive returns true if the Hp of the player are > 0.

func (*Player) Weapons

func (p *Player) Weapons() []*Equipment

Weapons returns all weapons in the player's possession.

type RoundEndReason

type RoundEndReason byte

RoundEndReason is the type for the various RoundEndReasonXYZ constants.

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
)

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

type RoundMVPReason

type RoundMVPReason byte

RoundMVPReason is the type for the various MVPReasonYXZ constants.

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

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

type Team

type Team byte

Team is the type for the various TeamXYZ constants.

const (
	TeamUnassigned Team = iota
	TeamSpectators
	TeamTerrorists
	TeamCounterTerrorists
)

Team constants give information about which team a player is on.

Jump to

Keyboard shortcuts

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