common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: MIT Imports: 6 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 about the demo's header.

type Equipment

type Equipment struct {
	EntityID       int
	Weapon         EquipmentElement
	OriginalString string
	SkinID         string
	AmmoInMagazine int
	AmmoType       int
	Owner          *Player
	ReserveAmmo    int
}

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.

func NewSkinEquipment

func NewSkinEquipment(eqName string, skinID string) Equipment

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

func (Equipment) Class

func (e Equipment) Class() EquipmentClass

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

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 / 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
	EqSwag7    EquipmentElement = 203
	EqXM1014   EquipmentElement = 204
	EqM249     EquipmentElement = 205
	EqNegev    EquipmentElement = 206

	EqGallil EquipmentElement = 301
	EqFamas  EquipmentElement = 302
	EqAK47   EquipmentElement = 303
	EqM4A4   EquipmentElement = 304
	EqM4A1   EquipmentElement = 305
	EqScout  EquipmentElement = 306
	EqSG556  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.

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
	TeamID                      int
	Name                        string
	Hp                          int
	Armor                       int
	Money                       int
	CurrentEquipmentValue       int
	FreezetimeEndEquipmentValue int
	RoundStartEquipmentValue    int
	ActiveWeaponID              int
	RawWeapons                  map[int]*Equipment
	Weapons                     []*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
}

Player contains mostly game-relevant player information.

func NewPlayer

func NewPlayer() *Player

NewPlayer creates a *Player with an initialized equipment map.

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.

type PlayerInfo

type PlayerInfo struct {
	Version     int64
	XUID        int64
	Name        string
	UserID      int
	GUID        string
	FriendsID   int
	FriendsName string
	// Custom files stuff (CRC)
	CustomFiles0 int
	CustomFiles1 int
	CustomFiles2 int
	CustomFiles3 int
	// Amount of downloaded files from the server
	FilesDownloaded byte
	// Bots
	IsFakePlayer bool
	// HLTV Proxy
	IsHltv bool
}

PlayerInfo contains general player information

func ParsePlayerInfo

func ParsePlayerInfo(reader io.Reader) *PlayerInfo

ParsePlayerInfo parses player information from a byte stream.

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