Documentation
¶
Index ¶
- Variables
- func NewSchoolFloatArray() [SchoolLen]float64
- func PseudoStatValue(pseudoStats []float64, pseudoStat proto.PseudoStat) float64
- type Bonuses
- type PercentPseudoStat
- type PseudoStats
- type SchoolIndex
- type Stat
- type StatDependency
- type StatDependencyManager
- func (sdm *StatDependencyManager) AddFlooredStatDependency(src Stat, dst Stat, step float64, amount float64)
- func (sdm *StatDependencyManager) AddStatDependency(src Stat, dst Stat, amount float64)
- func (sdm *StatDependencyManager) AddUnmultipliedStatDependency(src Stat, dst Stat)
- func (sdm *StatDependencyManager) ApplyStatDependencies(s Stats) Stats
- func (sdm *StatDependencyManager) ApplyStatDependenciesInPlace(s *Stats)
- func (sdm *StatDependencyManager) DisableDynamicStatDep(dep *StatDependency) bool
- func (sdm *StatDependencyManager) EnableDynamicStatDep(dep *StatDependency) bool
- func (sdm *StatDependencyManager) FinalizeStatDeps()
- func (sdm *StatDependencyManager) GetStatDependencyCoeff(src, dst Stat) float64
- func (sdm *StatDependencyManager) IsFinalized() bool
- func (sdm *StatDependencyManager) MultiplyStat(s Stat, amount float64)
- func (sdm *StatDependencyManager) NewDynamicMultiplyStat(s Stat, amount float64) *StatDependency
- func (sdm *StatDependencyManager) NewDynamicStatDependency(src Stat, dst Stat, amount float64) *StatDependency
- func (sdm *StatDependencyManager) ResetStatDeps()
- func (sdm *StatDependencyManager) SortAndApplyStatDependencies(s Stats) Stats
- type Stats
- func (stats Stats) Add(other Stats) Stats
- func (stats *Stats) AddInplace(other *Stats)
- func (stats Stats) ApplyMultipliers(multipliers map[Stat]float64) Stats
- func (stats Stats) DotProduct(other Stats) Stats
- func (stats Stats) Equals(other Stats) bool
- func (stats Stats) EqualsWithTolerance(other Stats, tolerance float64) bool
- func (stats Stats) FlatString() string
- func (stats Stats) Floor() Stats
- func (stats Stats) FloorGameStats() Stats
- func (stats *Stats) FloorGameStatsInPlace()
- func (stats Stats) GetBuffedStatTypes() []Stat
- func (stats Stats) GetHighestStatType(statTypeOptions []Stat) Stat
- func (stats Stats) Invert() Stats
- func (stats Stats) Multiply(multiplier float64) Stats
- func (stats Stats) String() string
- func (stats Stats) Subtract(other Stats) Stats
- func (stats Stats) ToProtoArray() []float64
- func (stats Stats) ToProtoMap() map[int32]float64
- type UnitStat
- func (s UnitStat) AddToStatsProto(p *proto.UnitStats, value float64)
- func (s UnitStat) EqualsPseudoStat(other proto.PseudoStat) bool
- func (s UnitStat) EqualsStat(other Stat) bool
- func (s UnitStat) IsPseudoStat() bool
- func (s UnitStat) IsStat() bool
- func (s UnitStat) PseudoStatIdx() int
- func (s UnitStat) StatIdx() int
Constants ¶
This section is empty.
Variables ¶
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}, }
var ProtoStatsLen = len(proto.Stat_name)
var PseudoStatsLen = len(proto.PseudoStat_name)
var UnitStatsLen = ProtoStatsLen + PseudoStatsLen
Functions ¶
func NewSchoolFloatArray ¶
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
}
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, and a weapon proc's strike off that swing rolls none (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, non-physical melee attacks roll a block too (A_ALLOW_BLOCKING_SPELLS). Magic spells stay unblockable.
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
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 ProtoArrayToStatsList ¶
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.
Some examples: Increases your AP by 30% of your Int Increases agility by X% Reduces armor by 50%
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
GetStatDependencyCoeff returns 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 FromProtoMap ¶
func FromPseudoStatsProto ¶
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 ¶
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. This allows us to include only essential basic properties in database stats arrays, while still letting the back-end Stat enum include derived properties when it is computationally convenient to do so (such as for automatically applying stat dependencies). 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 ¶
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) AddInplace ¶
Adds another to Stats to this, in-place. For performance, only.
func (Stats) ApplyMultipliers ¶
Higher performance variant of the above.
func (Stats) DotProduct ¶
Multiplies two Stats together by multiplying the values of corresponding stats, like a dot product operation.
func (Stats) EqualsWithTolerance ¶
func (Stats) FlatString ¶
Like String() but without the newlines.
func (Stats) FloorGameStats ¶
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 ¶
Returns all Stat types with positive representation in this Stats array.
func (Stats) GetHighestStatType ¶
Given an array of Stat types, return the Stat whose value is largest within this Stats array.
func (Stats) ToProtoArray ¶
func (Stats) ToProtoMap ¶
type UnitStat ¶
type UnitStat int
func UnitStatFromIdx ¶
func UnitStatFromPseudoStat ¶
func UnitStatFromPseudoStat(s proto.PseudoStat) UnitStat
func UnitStatFromStat ¶
func (UnitStat) AddToStatsProto ¶
func (UnitStat) EqualsPseudoStat ¶
func (s UnitStat) EqualsPseudoStat(other proto.PseudoStat) bool