Class UnitMath

Namespace
TDMaker.Editor
Assembly
TDMaker.Editor.dll

Unit Workshop numbers that follow the simulation's integer damage rules exactly (single-target hits without status effects or incoming multipliers): a hit rolls ceil(lerp(min, max, u)), projectile hits deal at least 1, the target keeps floor(rolled × (1 − reduction)) (soldiers: round(rolled − floor(rolled × reduction))), and the reduction is the matching defense minus pierce (explosion and electric use half the physical armor), clamped to [0, 1]. Ratio checks use the bands of the balance notes (new content starting points, not rules).

public static class UnitMath
Inheritance
UnitMath
Inherited Members

Fields

Kinds

The damage kinds listed in stat tables.

public static readonly DamageKind[] Kinds

Field Value

DamageKind[]

Methods

BountyDensity(EnemyAsset)

Gold per health point; the reference is the project's median over enemies (or this enemy alone).

public static float BountyDensity(EnemyAsset enemy)

Parameters

enemy EnemyAsset

Returns

float

Defenses(EntityAssetBase, out float, out float, out float)

Defenses of an enemy, soldier or hero asset (zero for other types).

public static void Defenses(EntityAssetBase unit, out float physical, out float magical, out float poison)

Parameters

unit EntityAssetBase
physical float
magical float
poison float

Dps(MeleeData, List<RangedAttackData>, float, float, float, float, bool)

Expected damage per second of a melee attack and ranged channels against a target with the given defenses.

public static double Dps(MeleeData melee, List<RangedAttackData> ranged, float scale, float physical, float magical, float poison, bool friendlyTarget = false)

Parameters

melee MeleeData
ranged List<RangedAttackData>
scale float
physical float
magical float
poison float
friendlyTarget bool

Returns

double

EffectiveHealth(float, float)

Effective health against a damage kind: health / (1 − reduction), infinite at full reduction.

public static double EffectiveHealth(float health, float reduction)

Parameters

health float
reduction float

Returns

double

EngagementSlot(int, Vector2, Vector2, float, bool)

Engagement slot offset of a rank (1-based) relative to the enemy: (s × (D + h × u), Y + h × v).

public static Vector2 EngagementSlot(int rank, Vector2 hostBias, Vector2 guestBias, float rowSpacing, bool movingRight)

Parameters

rank int
hostBias Vector2
guestBias Vector2
rowSpacing float
movingRight bool

Returns

Vector2

ExpectedHit(BasicDamageData, float, bool, bool)

Expected health removed by one single-target hit of a damage packet: every integer roll between ceil(min) and ceil(max) weighted by its probability.

public static double ExpectedHit(BasicDamageData damage, float reduction, bool projectile = true, bool friendlyTarget = false)

Parameters

damage BasicDamageData
reduction float
projectile bool
friendlyTarget bool

Returns

double

Health(EntityAssetBase)

Maximum health of a unit asset (zero for other types).

public static float Health(EntityAssetBase unit)

Parameters

unit EntityAssetBase

Returns

float

HeroRows(HeroAsset)

Hero growth rows with the bake's threshold and point rules.

public static List<UnitMath.HeroRow> HeroRows(HeroAsset hero)

Parameters

hero HeroAsset

Returns

List<UnitMath.HeroRow>

HitDamage(float, float, bool)

Health removed by one hit of rolled raw damage through reduction.

public static float HitDamage(float rolled, float reduction, bool friendlyTarget = false)

Parameters

rolled float
reduction float
friendlyTarget bool

Returns

float

HitsToKill(float, double)

Hits needed to remove health with a fixed per-hit amount; infinite when hits do nothing.

public static double HitsToKill(float health, double perHit)

Parameters

health float
perHit double

Returns

double

Kill(TowerAsset, EnemyAsset, int)

Expected time and hits for tower to kill enemy.

public static UnitMath.KillEstimate Kill(TowerAsset tower, EnemyAsset enemy, int tier = 1)

Parameters

tower TowerAsset
enemy EnemyAsset
tier int

Returns

UnitMath.KillEstimate

MedianBountyDensity(List<EnemyAsset>)

Median bounty density of the given enemies (zero when there are none).

public static float MedianBountyDensity(List<EnemyAsset> enemies)

Parameters

enemies List<EnemyAsset>

Returns

float

Outliers(EntityAssetBase, float)

Ratio checks for a unit (balance-note bands; product starting points, not rules).

public static List<UnitMath.Outlier> Outliers(EntityAssetBase unit, float referenceBountyDensity)

Parameters

unit EntityAssetBase
referenceBountyDensity float

Returns

List<UnitMath.Outlier>

Reduction(DamageKind, float, float, float, float, float)

Reduction against a hit of kind for a target with the given defenses (the simulation's switch).

public static float Reduction(DamageKind kind, float physical, float magical, float poison, float physicalPierce = 0, float magicalPierce = 0)

Parameters

kind DamageKind
physical float
magical float
poison float
physicalPierce float
magicalPierce float

Returns

float

TowerTiers(List<TowerAsset>)

Every tower tier in the project ordered by tree (root name) and depth.

public static List<KeyValuePair<TowerAsset, int>> TowerTiers(List<TowerAsset> all = null)

Parameters

all List<TowerAsset>

Returns

List<KeyValuePair<TowerAsset, int>>