stats

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PercentPseudoStats = []PercentPseudoStat{
	meleeHitPseudoStat,
	spellHitPseudoStat,
	meleeCritPseudoStat,
	spellCritPseudoStat,
	{BlockPercent, proto.PseudoStat_PseudoStatBlockPercent, nil},
	rangedHitPseudoStat,
	rangedCritPseudoStat,
	{DodgePercent, proto.PseudoStat_PseudoStatDodgePercent, nil},
	{ParryPercent, proto.PseudoStat_PseudoStatParryPercent, nil},
	{ExpertisePercent, proto.PseudoStat_PseudoStatExpertisePercent, nil},
}
View Source
var ProtoStatsLen = len(proto.Stat_name)
View Source
var PseudoStatsLen = len(proto.PseudoStat_name)

Functions

func NewSchoolFloatArray

func NewSchoolFloatArray() [SchoolLen]float64

func PseudoStatValue

func PseudoStatValue(pseudoStats []float64, pseudoStat proto.PseudoStat) float64

Types

type Bonuses

type Bonuses struct {
	Multiplier float64          // multiplier added to all stat gains from this stat.
	Deps       map[Stat]float64 // multiplier added to Stat when this stat is changed.
}

Bonuses for a single stat

type PercentPseudoStat

type PercentPseudoStat struct {
	Stat       Stat
	PseudoStat proto.PseudoStat
	MeleeShare *PercentPseudoStat
}

A percent the character sheet shows as a PseudoStat and the back end models as a Stat. A ranged total on the sheet includes its MeleeShare, which the ranged Stat leaves out.

type PseudoStats

type PseudoStats struct {
	SpellCostPercentModifier int32 // Multiplies spell cost.

	CastSpeedMultiplier   float64
	MeleeSpeedMultiplier  float64
	RangedSpeedMultiplier float64
	RangedHasteMultiplier float64
	AttackSpeedMultiplier float64 // Used for real haste effects that modify resoruce regen and are used for RPPM effects
	WeaponSpeedMultiplier float64 // Seal of the Crusader's faster, lighter swings, which a rate on the weapon's speed divides by

	FiveSecondRuleRefreshTime time.Duration // last time a spell was cast
	SpiritRegenRateCasting    float64       // percentage of spirit regen allowed during casting

	SpiritRegenMultiplier float64 // Multiplier on spirit portion of mana regen.
	EnergizeMP5           float64 // The share of MP5 that periodic energize auras tick, which Innervate leaves unscaled.

	// If true, allows block/parry.
	InFrontOfTarget bool

	BonusMHDps     float64
	BonusOHDps     float64
	BonusRangedDps float64

	DisableDWMissPenalty bool // Used by Heroic Strike and Cleave

	IncreasedMissChance float64 // Insect Swarm and Scorpid Sting
	DodgeReduction      float64 // Used by Warrior talent 'Weapon Mastery' and SWP boss auras.

	WeaponSkills       [proto.WeaponSkill_WeaponSkillWands + 1]float64 // Bonus skill over the level-based maximum per weapon skill, which a skill below it makes negative.
	MHWeaponSkill      float64                                         // Bonus skill for whatever weapon the main hand holds, on top of its WeaponSkills entry.
	OHWeaponSkill      float64                                         // Bonus skill for whatever weapon the off hand holds, on top of its WeaponSkills entry.
	FeralCombatSkill   float64
	FeralCombatEnabled bool // While set the unit swings its form's paw: FeralCombatSkill replaces the weapon's skill. A weapon proc's strike off that swing rolls no weapon proc (R-0040).

	ThreatMultiplier       float64            // Modulates the threat generated. Affected by things like salv.
	SchoolThreatMultiplier [SchoolLen]float64 // The threat of one spell school, on top of ThreatMultiplier.

	DamageDealtMultiplier          float64            // All damage
	SchoolDamageDealtMultiplier    [SchoolLen]float64 // For specific spell schools (arcane, fire, shadow, etc).
	SchoolSpellPiercing            [SchoolLen]float64 // Target resistance ignored by spells of one school, on top of SpellPiercing.
	DotDamageMultiplierAdditive    float64            // All periodic damage
	HealingDealtMultiplier         float64            // All non-shield healing
	PeriodicHealingDealtMultiplier float64            // All periodic healing (on top of HealingDealtMultiplier)
	CritDamageMultiplier           float64            // All multiplicative crit damage

	BonusRangedAttackPower float64 // Hunter's mark
	BonusAttackPower       float64 // Also Hunter's Mark

	// Important when unit is attacker or target
	BlockValueMultiplier  float64
	BlockValuePerStrength float64

	// Only used for NPCs, governs variance in enemy auto-attack damage
	DamageSpread float64

	Incapacitated bool // Under crowd control (e.g. a boss's Fear); cannot cast or queue any spell. Procs still fire.
	Stunned       bool // Prevents blocks, dodges, and parries. Read while this unit is the target.
	FearImmune    bool // Fear effects cannot be applied to this unit. (ie. Berserker Rage)
	StunImmune    bool // Stun effects cannot be applied to this unit.

	// Scale how long a Fear/Stun lasts on this unit, e.g. the Warrior talent Iron Will.
	FearDurationMultiplier float64
	StunDurationMultiplier float64

	CanBlock       bool
	CanBlockSpells bool // With CanBlock, enemy spells and non-physical melee attacks roll a block too (A_ALLOW_BLOCKING_SPELLS).
	CanParry       bool
	CanCrush       bool

	ParryHaste bool

	// Avoidance % not affected by Diminishing Returns, represented as
	// probabilities (between 0 and 1).
	BaseDodgeChance float64
	BaseParryChance float64
	BaseBlockChance float64

	BaseReducedCritTakenPercent float64 // Base crit reduction from talents/auras (before the Defense contribution).
	ReducedCritTakenPercent     float64 // Total crit reduction including the Defense contribution.

	BonusHealingTaken          float64 // Talisman of Troll Divinity
	BonusSpellCritPercentTaken float64 // Imp Shadow Bolt / Imp Scorch / Winter's Chill debuff
	BonusPhysicalDamageTaken   float64 // Gift of Arthas, Stoneskin Totem; lands before armor, never on a tick
	BonusSpellDamageTaken      float64 // Amp Magic
	BonusRangedDamageTaken     float64 // Physical ranged attacks only: Windwall

	DamageTakenMultiplier       float64            // All damage
	SchoolDamageTakenMultiplier [SchoolLen]float64 // For specific spell schools (arcane, fire, shadow, etc.)
	SchoolBonusSpellDamage      [SchoolLen]float64 // Flat school damage the target takes extra, ex: Judgement of the Crusader; added at the spell's coefficient after the caster's done multipliers, before the outcome; none on a spell with SpellFlagIgnoreTargetSchoolBonus (a damage shield)
	SchoolBonusHitChance        [SchoolLen]float64 // The bonus stats' school hit, on every spell of the school with a ClassSpellMask or class flags; a talent's school hit is a class-flags mod with ShowAsSchoolHit

	DiseaseDamageTakenMultiplier          float64
	PeriodicPhysicalDamageTakenMultiplier float64
	MeleeDamageTakenMultiplier            float64 // Melee attacks of any school

	ArmorMultiplier float64 // Major/minor/special multiplicative armor modifiers

	ReducedPhysicalHitTakenChance float64
	ReducedArcaneHitTakenChance   float64
	ReducedFireHitTakenChance     float64
	ReducedFrostHitTakenChance    float64
	ReducedNatureHitTakenChance   float64
	ReducedShadowHitTakenChance   float64

	HealingTakenMultiplier         float64 // All healing sources including self-healing
	ExternalHealingTakenMultiplier float64 // Modulates the output of the individual tank sim healing model
	MovementSpeedMultiplier        float64 // Multiplier for movement speed, default to 1. Player base movement 7 yards/s. All effects affecting movements are multipliers.
	SelfHealingMultiplier          float64 // Healing from spells and abilities, only-self
	PushbackChance                 float64 // Chance of being pushed back by a spell cast, defaults to 1.
}

func NewPseudoStats

func NewPseudoStats() PseudoStats

type SchoolIndex

type SchoolIndex byte
const (
	SchoolIndexNone     SchoolIndex = 0
	SchoolIndexPhysical SchoolIndex = iota
	SchoolIndexArcane
	SchoolIndexFire
	SchoolIndexFrost
	SchoolIndexHoly
	SchoolIndexNature
	SchoolIndexShadow

	SchoolLen
)

type Stat

type Stat byte
const (
	Strength Stat = iota
	Agility
	Stamina
	Intellect
	HealingPower
	SpellDamage
	ArcaneDamage
	FireDamage
	FrostDamage
	HolyDamage
	NatureDamage
	ShadowDamage
	SpellPiercing
	Spirit
	AttackPower
	RangedAttackPower
	FeralAttackPower
	HitRating
	CritRating
	HasteRating
	ArmorPenetration
	ExpertiseRating
	DefenseRating
	BlockRating
	BlockValue
	DodgeRating
	ParryRating
	Armor
	BonusArmor
	Health
	Mana
	MP5
	ArcaneResistance
	FireResistance
	FrostResistance
	NatureResistance
	ShadowResistance
	PhysicalDamage
	ArmorNoMods

	// The remaining stats below are stored as PseudoStats rather than as
	// Stats in UnitStats proto messages, since they are not required in the
	// database files. However, it is valuable to keep these as proper Stats
	// in the back-end, since they are used in various stat dependencies.
	// The units for all 11 of these are percentages (between 0 and 100).
	PhysicalHitPercent
	SpellHitPercent
	PhysicalCritPercent
	SpellCritPercent
	BlockPercent
	RangedHitPercent
	RangedCritPercent
	DodgePercent
	ParryPercent
	ReducedCritTakenPercent
	ExpertisePercent

	SimStatsLen
)

Use internal representation instead of proto.Stat so we can add functions and use 'byte' as the data type.

This needs to stay synced with proto.Stat: it is okay for SimStatsLen to exceed ProtoStatsLen, but the shared indices between the two must match 1:1 .

func IntTupleToStatsList

func IntTupleToStatsList(statType1 int32, statType2 int32, statType3 int32) []Stat

func ProtoArrayToStatsList

func ProtoArrayToStatsList(protoStats []proto.Stat) []Stat

func (Stat) StatName

func (s Stat) StatName() string

type StatDependency

type StatDependency struct {
	// contains filtered or unexported fields
}

func (StatDependency) String

func (sd StatDependency) String() string

func (*StatDependency) UpdateValue

func (dep *StatDependency) UpdateValue(newAmount float64)

Updates the "amount" field for a previously defined dep. Note that if this is called after the stats measurement phase, then ApplyStatDependencies() must be immediately called afterwards!

type StatDependencyManager

type StatDependencyManager struct {
	// contains filtered or unexported fields
}

Manages dependencies between stats.

func NewStatDependencyManager

func NewStatDependencyManager() StatDependencyManager

func (*StatDependencyManager) AddFlooredStatDependency

func (sdm *StatDependencyManager) AddFlooredStatDependency(src Stat, dst Stat, step float64, amount float64)

Adds amount of dst per point of src, counting src in whole steps of step points only.

func (*StatDependencyManager) AddStatDependency

func (sdm *StatDependencyManager) AddStatDependency(src Stat, dst Stat, amount float64)

func (*StatDependencyManager) AddUnmultipliedStatDependency

func (sdm *StatDependencyManager) AddUnmultipliedStatDependency(src Stat, dst Stat)

Adds all of src to dst after dst's own multipliers, which scale the rest of dst and leave src's share whole. Every dependency that reads dst counts all of it.

func (*StatDependencyManager) ApplyStatDependencies

func (sdm *StatDependencyManager) ApplyStatDependencies(s Stats) Stats

func (*StatDependencyManager) ApplyStatDependenciesInPlace

func (sdm *StatDependencyManager) ApplyStatDependenciesInPlace(s *Stats)

ApplyStatDependenciesInPlace is ApplyStatDependencies without copying the array.

func (*StatDependencyManager) DisableDynamicStatDep

func (sdm *StatDependencyManager) DisableDynamicStatDep(dep *StatDependency) bool

Returns whether the state changed.

func (*StatDependencyManager) EnableDynamicStatDep

func (sdm *StatDependencyManager) EnableDynamicStatDep(dep *StatDependency) bool

Returns whether the state changed.

func (*StatDependencyManager) FinalizeStatDeps

func (sdm *StatDependencyManager) FinalizeStatDeps()

func (*StatDependencyManager) GetStatDependencyCoeff

func (sdm *StatDependencyManager) GetStatDependencyCoeff(src, dst Stat) float64

The combined linear coefficient for how much of dst is gained per unit of src from all currently-enabled dependencies.

func (*StatDependencyManager) IsFinalized

func (sdm *StatDependencyManager) IsFinalized() bool

func (*StatDependencyManager) MultiplyStat

func (sdm *StatDependencyManager) MultiplyStat(s Stat, amount float64)

func (*StatDependencyManager) NewDynamicMultiplyStat

func (sdm *StatDependencyManager) NewDynamicMultiplyStat(s Stat, amount float64) *StatDependency

func (*StatDependencyManager) NewDynamicStatDependency

func (sdm *StatDependencyManager) NewDynamicStatDependency(src Stat, dst Stat, amount float64) *StatDependency

func (*StatDependencyManager) ResetStatDeps

func (sdm *StatDependencyManager) ResetStatDeps()

func (*StatDependencyManager) SortAndApplyStatDependencies

func (sdm *StatDependencyManager) SortAndApplyStatDependencies(s Stats) Stats

type Stats

type Stats [SimStatsLen]float64

func FromProtoArray

func FromProtoArray(values []float64) Stats

func FromProtoMap

func FromProtoMap(m map[int32]float64) Stats

func FromPseudoStatsProto

func FromPseudoStatsProto(pseudoStats []float64) Stats

The percent PseudoStats an item or enchant states, as the back-end Stats that model them. Ranged hit and crit are totals that include the melee share. Dodge, parry and block are read as chance added to the base; GetPseudoStatsProto writes them as the total chance.

func FromUnitStatsProto

func FromUnitStatsProto(unitStatsMessage *proto.UnitStats) Stats

Runs FromProtoArray() on the stats array embedded in the UnitStats message, but additionally imports any PseudoStats that we want to model as proper Stats in the back-end. Make sure to update this function if you add any back-end Stat entries that are modeled as PseudoStats in the front-end.

func WeightsFromUnitStatsProto

func WeightsFromUnitStatsProto(weights *proto.UnitStats) Stats

The weights a UnitStats message carries, per point of whatever each stat counts: a percent's weight is copied as it is, so Block% stays per percent and ranged hit and crit keep their own weight.

func (Stats) Add

func (stats Stats) Add(other Stats) Stats

Adds two Stats together, returning the new Stats.

func (*Stats) AddInplace

func (stats *Stats) AddInplace(other *Stats)

Adds another to Stats to this, in-place. For performance, only.

func (Stats) ApplyMultipliers

func (stats Stats) ApplyMultipliers(multipliers map[Stat]float64) Stats

Higher performance variant of the above.

func (Stats) DotProduct

func (stats Stats) DotProduct(other Stats) Stats

Multiplies two Stats together by multiplying the values of corresponding stats, like a dot product operation.

func (Stats) Equals

func (stats Stats) Equals(other Stats) bool

func (Stats) EqualsWithTolerance

func (stats Stats) EqualsWithTolerance(other Stats, tolerance float64) bool

func (Stats) FlatString

func (stats Stats) FlatString() string

Like String() but without the newlines.

func (Stats) Floor

func (stats Stats) Floor() Stats

Rounds all stat values down to the nearest integer, returning the new Stats.

func (Stats) FloorGameStats

func (stats Stats) FloorGameStats() Stats

Rounds attributes down to integers, matching how the game stores them. Must be applied after stat dependencies are resolved.

func (*Stats) FloorGameStatsInPlace

func (stats *Stats) FloorGameStatsInPlace()

FloorGameStatsInPlace is FloorGameStats without copying the array.

func (Stats) GetBuffedStatTypes

func (stats Stats) GetBuffedStatTypes() []Stat

Returns all Stat types with positive representation in this Stats array.

func (Stats) GetHighestStatType

func (stats Stats) GetHighestStatType(statTypeOptions []Stat) Stat

Given an array of Stat types, return the Stat whose value is largest within this Stats array.

func (Stats) Invert

func (stats Stats) Invert() Stats

func (Stats) Multiply

func (stats Stats) Multiply(multiplier float64) Stats

func (Stats) String

func (stats Stats) String() string

func (Stats) Subtract

func (stats Stats) Subtract(other Stats) Stats

Subtracts another Stats from this one, returning the new Stats.

func (Stats) ToProtoArray

func (stats Stats) ToProtoArray() []float64

func (Stats) ToProtoMap

func (stats Stats) ToProtoMap() map[int32]float64

type UnitStat

type UnitStat int

func UnitStatFromIdx

func UnitStatFromIdx(s int) UnitStat

func UnitStatFromPseudoStat

func UnitStatFromPseudoStat(s proto.PseudoStat) UnitStat

func UnitStatFromStat

func UnitStatFromStat(s Stat) UnitStat

func (UnitStat) AddToStatsProto

func (s UnitStat) AddToStatsProto(p *proto.UnitStats, value float64)

func (UnitStat) EqualsPseudoStat

func (s UnitStat) EqualsPseudoStat(other proto.PseudoStat) bool

func (UnitStat) EqualsStat

func (s UnitStat) EqualsStat(other Stat) bool

func (UnitStat) IsPseudoStat

func (s UnitStat) IsPseudoStat() bool

func (UnitStat) IsStat

func (s UnitStat) IsStat() bool

func (UnitStat) PseudoStatIdx

func (s UnitStat) PseudoStatIdx() int

func (UnitStat) StatIdx

func (s UnitStat) StatIdx() int

Jump to

Keyboard shortcuts

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