yasha

package module
v0.0.0-...-caf82ce Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2014 License: MIT Imports: 10 Imported by: 0

README

Yasha

Dota 2 (Source 1) replay parser written in Go, extracted from Dotabuff TrueSight.

We're working on both maintaining the parser for replays of both Source 1 and Source 2 Engines.

About Source 1

This parser is able to parse replays recorded since about 2012.

About Source 2

The upcoming Source 2 Engine requires several incompatible changes, so we work on it in a separate repository.

See also Sange, the Dota 2 (Source 2) parser

Installation

Simple as:

$ go get github.com/dotabuff/yasha

And in your code:

import "github.com/dotabuff/yasha"

Please be aware that you can't import Sange and Yasha in the same binary! The Protocol Buffer definitions conflict, and will panic.

Test Coverage

Yasha is a dependency of and was extracted from Dotabuff TrueSight. Test coverage is currently upstream. We'll be working to implement comprehensive testing in both Yasha and Sange and are especially grateful for contributions in this area.

Usage

See the examples directory.

License

MIT, see the LICENSE file.

Help

If you have any questions, just ask manveru in the #dota2replay channel on QuakeNet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Abilities

type Abilities []*AbilityTracker

func (Abilities) Len

func (p Abilities) Len() int

func (Abilities) Less

func (p Abilities) Less(i, j int) bool

func (Abilities) Swap

func (p Abilities) Swap(i, j int)

type AbilityTracker

type AbilityTracker struct {
	HeroHandle int
	Level      int
	Tick       int
	Name       string
}

type CombatLogAbility

type CombatLogAbility struct {
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Ability            string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	IsDebuff           int     `logIndex:"7"` // seen values: 0,1,2
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

TODO: only observed 2,3,4,7,13 so far, but the others would make sense too.

func (CombatLogAbility) Timestamp

func (c CombatLogAbility) Timestamp() float32

func (CombatLogAbility) Type

type CombatLogBuyback

type CombatLogBuyback struct {
	Hero        string  `logIndex:"7" logTable:"CombatLogNames"`
	DeathTime   float32 `logIndex:"9"`
	BuybackTime float32 `logIndex:"11"`
}
7  val_short: 9
9  val_float: 2625.6892

11 val_float: 2666.3

func (CombatLogBuyback) Timestamp

func (c CombatLogBuyback) Timestamp() float32

func (CombatLogBuyback) Type

type CombatLogDamage

type CombatLogDamage struct {
	Source             string  `logIndex:"1" logTable:"CombatLogNames"`
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Cause              string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	Value              int     `logIndex:"7"`
	Health             int     `logIndex:"8"`
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

0: val_byte:0 ), 1: val_short:3 ), 2: val_short:27 ), 3: val_short:3 ), 4: val_short:0 ), 5: val_bool:false ), 6: val_bool:false ), 7: val_short:70 ), 8: val_short:429 ), 9: val_float:229.45338 ), 10: val_short:27 ), 11: val_float:238.43335 ), 12: val_bool:true ), 13: val_bool:false )

func (CombatLogDamage) Timestamp

func (c CombatLogDamage) Timestamp() float32

func (CombatLogDamage) Type

type CombatLogDeath

type CombatLogDeath struct {
	Source             string  `logIndex:"1" logTable:"CombatLogNames"`
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Cause              string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogDeath) Timestamp

func (c CombatLogDeath) Timestamp() float32

func (CombatLogDeath) Type

type CombatLogEntry

type CombatLogEntry interface {
	Type() dota.DOTA_COMBATLOG_TYPES
	Timestamp() float32
}

type CombatLogGameState

type CombatLogGameState struct {
	State int     `logIndex:"7"`
	Time  float32 `logIndex:"9"`
}

func (CombatLogGameState) Timestamp

func (c CombatLogGameState) Timestamp() float32

func (CombatLogGameState) Type

type CombatLogGold

type CombatLogGold struct {
	Target int     `logIndex:"2"`
	Value  int     `logIndex:"7"`
	Time   float32 `logIndex:"9"`
}

func (CombatLogGold) Timestamp

func (c CombatLogGold) Timestamp() float32

func (CombatLogGold) Type

type CombatLogHeal

type CombatLogHeal struct {
	Source             string  `logIndex:"1" logTable:"CombatLogNames"`
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Modifier           string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	Value              int     `logIndex:"7"`
	Health             int     `logIndex:"8"`
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogHeal) Timestamp

func (c CombatLogHeal) Timestamp() float32

func (CombatLogHeal) Type

type CombatLogItem

type CombatLogItem struct {
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	User               string  `logIndex:"3" logTable:"CombatLogNames"`
	Item               string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	Time               float32 `logIndex:"9"`
	UserIsHero         bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogItem) Timestamp

func (c CombatLogItem) Timestamp() float32

func (CombatLogItem) Type

type CombatLogLocation

type CombatLogLocation struct {
	Source             string  `logIndex:"1" logTable:"CombatLogNames"`
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Modifier           string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	Value              int     `logIndex:"7"`
	Health             int     `logIndex:"8"`
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogLocation) Timestamp

func (c CombatLogLocation) Timestamp() float32

func (CombatLogLocation) Type

type CombatLogModifierAdd

type CombatLogModifierAdd struct {
	Source             string  `logIndex:"1" logTable:"CombatLogNames"`
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Attacker           string  `logIndex:"3" logTable:"CombatLogNames"`
	Modifier           string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	IsDebuff           bool    `logIndex:"7"`
	Health             int     `logIndex:"8"`
	Time               float32 `logIndex:"9"`
	TargetSource       string  `logIndex:"10" logTable:"CombatLogNames"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogModifierAdd) Timestamp

func (c CombatLogModifierAdd) Timestamp() float32

func (CombatLogModifierAdd) Type

type CombatLogModifierRemove

type CombatLogModifierRemove struct {
	Target             string  `logIndex:"2" logTable:"CombatLogNames"`
	Caster             string  `logIndex:"3" logTable:"CombatLogNames"`
	Modifier           string  `logIndex:"4" logTable:"CombatLogNames"`
	AttackerIsIllusion bool    `logIndex:"5"`
	TargetIsIllusion   bool    `logIndex:"6"`
	IsDebuff           bool    `logIndex:"7"`
	Health             int     `logIndex:"8"`
	Time               float32 `logIndex:"9"`
	AttackerIsHero     bool    `logIndex:"12"`
	TargetIsHero       bool    `logIndex:"13"`
}

func (CombatLogModifierRemove) Timestamp

func (c CombatLogModifierRemove) Timestamp() float32

func (CombatLogModifierRemove) Type

type CombatLogPurchase

type CombatLogPurchase struct {
	Time  float32 `logIndex:"9"`
	Buyer string  `logIndex:"2" logTable:"CombatLogNames"`
	Item  string  `logIndex:"7" logTable:"CombatLogNames"`
}

func (CombatLogPurchase) Timestamp

func (c CombatLogPurchase) Timestamp() float32

func (CombatLogPurchase) Type

type CombatLogXP

type CombatLogXP struct {
	Target string  `logIndex:"2" logTable:"CombatLogNames"`
	Value  int     `logIndex:"7"`
	Time   float32 `logIndex:"9"`
}

func (CombatLogXP) Timestamp

func (c CombatLogXP) Timestamp() float32

func (CombatLogXP) Type

type LastHitTracker

type LastHitTracker struct {
	HeroHandle int
	Tick       int
	LastHit    int
}

type LastHits

type LastHits []*LastHitTracker

func (LastHits) Len

func (p LastHits) Len() int

func (LastHits) Less

func (p LastHits) Less(i, j int) bool

func (LastHits) Swap

func (p LastHits) Swap(i, j int)

type PacketEntity

type PacketEntity struct {
	Tick         int
	Index        int
	SerialNum    int
	ClassId      int
	EntityHandle int
	Name         string
	Type         UpdateType
	Values       map[string]interface{}
	Delta        map[string]interface{}
	OldDelta     map[string]interface{}
}

func (*PacketEntity) Clone

func (pe *PacketEntity) Clone() *PacketEntity

func (*PacketEntity) Handle

func (pe *PacketEntity) Handle() int

type Parser

type Parser struct {
	Parser *parser.Parser

	ClassIdNumBits        int
	ClassInfosIdMapping   map[string]int
	ClassInfosNameMapping map[int]string
	FileHeader            *dota.CDemoFileHeader
	GameEventMap          map[int32]*dota.CSVCMsg_GameEventListDescriptorT
	Mapping               map[int][]*send_tables.SendProp
	Multiples             map[int]map[string]int
	ServerInfo            *dota.CSVCMsg_ServerInfo
	Sth                   *send_tables.Helper
	Stsh                  *string_tables.StateHelper
	VoiceInit             *dota.CSVCMsg_VoiceInit

	ActiveModifiers map[int]*dota.CDOTAModifierBuffTableEntry
	Entities        []*PacketEntity
	ByHandle        map[int]*PacketEntity

	OnEntityCreated   func(*PacketEntity)
	OnEntityDeleted   func(*PacketEntity)
	OnEntityPreserved func(*PacketEntity)

	OnActiveModifierDelta func(map[int]*string_tables.StringTableItem, string_tables.ModifierBuffs)

	OnChatEvent            func(tick int, obj *dota.CDOTAUserMsg_ChatEvent)
	OnOverheadEvent        func(tick int, obj *dota.CDOTAUserMsg_OverheadEvent)
	OnSayText2             func(tick int, obj *dota.CUserMsg_SayText2)
	OnSounds               func(tick int, obj *dota.CSVCMsg_Sounds)
	OnSpectatorPlayerClick func(tick int, obj *dota.CDOTAUserMsg_SpectatorPlayerClick)
	OnChatWheel            func(tick int, obj *dota.CDOTAUserMsg_ChatWheel)

	OnFileInfo  func(obj *dota.CDemoFileInfo)
	OnSetConVar func(obj *dota.CNETMsg_SetConVar)
	OnVoiceData func(obj *dota.CSVCMsg_VoiceData)

	OnCombatLog func(log CombatLogEntry)

	OnTablename func(name string)

	BeforeTick func(tick int)
	AfterTick  func(tick int)
	// contains filtered or unexported fields
}

func NewParser

func NewParser(data []byte) *Parser

func ParserFromFile

func ParserFromFile(path string) *Parser

func (*Parser) Parse

func (p *Parser) Parse()

func (*Parser) ParsePacket

func (p *Parser) ParsePacket(tick int, pe *dota.CSVCMsg_PacketEntities)

func (*Parser) PrintDistinctCombatLogTypes

func (p *Parser) PrintDistinctCombatLogTypes()

type UpdateType

type UpdateType int
const (
	Create UpdateType = iota
	Delete
	Leave
	Preserve
)

func ReadUpdateType

func ReadUpdateType(br *utils.BitReader) UpdateType

Directories

Path Synopsis
Package dota is a generated protocol buffer package.
Package dota is a generated protocol buffer package.
google/protobuf
Package google_protobuf is a generated protocol buffer package.
Package google_protobuf is a generated protocol buffer package.
examples
NOTE: This file is generated by tool/update_pbem.rb
NOTE: This file is generated by tool/update_pbem.rb

Jump to

Keyboard shortcuts

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