common

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package common contains common types, constants and functions used over different demoinfocs packages.

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 Bomb

type Bomb struct {
	// Intended for internal use only. Use Position() instead.
	// Contains the last location of the dropped or planted bomb.
	LastOnGroundPosition r3.Vector
	Carrier              *Player
}

Bomb tracks the bomb's position, and the player carrying it, if any.

func (Bomb) Position

func (b Bomb) Position() r3.Vector

Position returns the current position of the bomb. This is either the position of the player holding it or LastOnGroundPosition if it's dropped or planted.

type DemoHeader

type DemoHeader struct {
	Filestamp       string        // aka. File-type, must be HL2DEMO
	Protocol        int           // Should be 4
	NetworkProtocol int           // Not sure what this is for
	ServerName      string        // Server's 'hostname' config value
	ClientName      string        // Usually 'GOTV Demo'
	MapName         string        // E.g. de_cache, de_nuke, cs_office, etc.
	GameDirectory   string        // Usually 'csgo'
	PlaybackTime    time.Duration // Demo duration in seconds (= PlaybackTicks / Server's tickrate)
	PlaybackTicks   int           // Game duration in ticks (= PlaybackTime * Server's tickrate)
	PlaybackFrames  int           // Amount of 'frames' aka demo-ticks recorded (= PlaybackTime * Demo's recording rate)
	SignonLength    int           // Length of the Signon package in bytes
}

DemoHeader contains information from a demo's header.

func (DemoHeader) FrameRate added in v0.4.0

func (h DemoHeader) FrameRate() float64

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.

func (DemoHeader) FrameTime added in v0.4.0

func (h DemoHeader) FrameTime() time.Duration

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

func (DemoHeader) TickRate

func (h DemoHeader) TickRate() float64

TickRate returns the tick-rate the server ran on during the game. VolvoPlx128TixKTnxBye

func (DemoHeader) TickTime

func (h DemoHeader) TickTime() time.Duration

TickTime returns the time a single tick takes in seconds.

type Equipment

type Equipment struct {
	EntityID       int              // ID of the game entity
	Weapon         EquipmentElement // The type of weapon which the equipment instantiates.
	Owner          *Player          // The player carrying the equipment, not necessarily the buyer.
	AmmoType       int              // TODO: Remove this? doesn't seem applicable to CS:GO
	AmmoInMagazine int              // Amount of bullets in the weapon's magazine
	AmmoReserve    int              // Amount of reserve bullets
	OriginalString string           // E.g. 'models/weapons/w_rif_m4a1_s.mdl'. Used internally to differentiate alternative weapons (M4A4 / M4A1-S etc.).
	// 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(wep EquipmentElement) Equipment

NewEquipment creates a new Equipment and sets the UniqueID.

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 Fire

type Fire struct {
	r3.Vector

	IsBurning bool
}

Fire is a component of an Inferno.

type GrenadeProjectile added in v0.5.4

type GrenadeProjectile struct {
	EntityID   int
	Weapon     EquipmentElement
	Thrower    *Player // Always seems to be the same as Owner, even if the grenade was picked up
	Owner      *Player // Always seems to be the same as Thrower, even if the grenade was picked up
	Position   r3.Vector
	Trajectory []r3.Vector // List of all known locations of the grenade up to the current point
	// 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 the Unique-ID.

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 Inferno

type Inferno struct {
	EntityID int
	Fires    []*Fire
	// contains filtered or unexported fields
}

Inferno is a list of Fires with helper functions. Also contains already extinguished fires.

See also: Inferno.Active() and Fire.IsBurning

func NewInferno

func NewInferno() *Inferno

NewInferno creates a inferno and sets the Unique-ID.

Intended for internal use only.

func (Inferno) Active

func (inf Inferno) Active() Inferno

Active returns an Inferno containing only the active fires of the original. The returned Inferno will have the same Unique-ID as the original.

func (Inferno) ConvexHull2D

func (inf Inferno) ConvexHull2D() *s2.Loop

ConvexHull2D returns the 2D convex hull of all the fires in the inferno. Useful for drawing on 2D maps.

func (Inferno) ConvexHull3D

func (inf Inferno) ConvexHull3D() *s2.Loop

ConvexHull3D returns the 3D convex hull of all the fires in the inferno.

func (Inferno) UniqueID

func (inf Inferno) UniqueID() int64

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

type Player

type Player struct {
	SteamID                     int64     // int64 representation of the User's Steam ID
	Position                    r3.Vector // In-game coordinates. Like the one you get from cl_showpos 1
	LastAlivePosition           r3.Vector // The location where the player was last alive. Should be equal to Position if the player is still alive.
	Velocity                    r3.Vector // Movement velocity
	EntityID                    int       // The ID of the player-entity, see Entity field
	UserID                      int       // Mostly used in game-events to address this player
	Name                        string    // Steam / in-game user name
	Hp                          int
	Armor                       int
	Money                       int
	CurrentEquipmentValue       int
	FreezetimeEndEquipmentValue int
	RoundStartEquipmentValue    int
	ActiveWeaponID              int                // Used internally to set the active weapon, see ActiveWeapon()
	RawWeapons                  map[int]*Equipment // All weapons the player is currently carrying
	AmmoLeft                    [32]int            // Ammo left in the various weapons, index corresponds to key of RawWeapons
	Entity                      *st.Entity
	AdditionalPlayerInformation *AdditionalPlayerInformation // Mostly scoreboard information such as kills, deaths, etc.
	ViewDirectionX              float32
	ViewDirectionY              float32
	FlashDuration               float32 // How long this player is flashed for from now on
	Team                        Team
	IsBot                       bool
	IsDucking                   bool
	HasDefuseKit                bool
	HasHelmet                   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 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