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
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
enemyEnemyAsset
Returns
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
unitEntityAssetBasephysicalfloatmagicalfloatpoisonfloat
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
meleeMeleeDatarangedList<RangedAttackData>scalefloatphysicalfloatmagicalfloatpoisonfloatfriendlyTargetbool
Returns
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
Returns
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
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
damageBasicDamageDatareductionfloatprojectileboolfriendlyTargetbool
Returns
Health(EntityAssetBase)
Maximum health of a unit asset (zero for other types).
public static float Health(EntityAssetBase unit)
Parameters
unitEntityAssetBase
Returns
HeroRows(HeroAsset)
Hero growth rows with the bake's threshold and point rules.
public static List<UnitMath.HeroRow> HeroRows(HeroAsset hero)
Parameters
heroHeroAsset
Returns
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
Returns
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
Returns
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
towerTowerAssetenemyEnemyAssettierint
Returns
MedianBountyDensity(List<EnemyAsset>)
Median bounty density of the given enemies (zero when there are none).
public static float MedianBountyDensity(List<EnemyAsset> enemies)
Parameters
enemiesList<EnemyAsset>
Returns
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
unitEntityAssetBasereferenceBountyDensityfloat
Returns
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
Returns
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
allList<TowerAsset>