# Damage
# Description
The Damage namespace provides damage calculation functionality, used for predicting and calculating various damage values.
# How to Use
// Calculate normal attack damage
float adDamage = Damage::CalculateAutoAttackDamage(myHero, target);
// Calculate skill damage
float skillDamage = Damage::CalculateSkillDamage(myHero, target, SkillSlot::Q, 1);
// Get target's remaining health
float healthAfterDamage = Damage::GetHealthAfterDamage(target, 100.0f, DamageType::Physical);
# CalculateAutoAttackDamage
float CalculateAutoAttackDamage(Unit* source, Unit* target, bool includeCritical = false)
Calculates the normal attack damage from source unit to target unit.
Parameter | Type | Description |
---|---|---|
source | Unit* | Source unit of damage |
target | Unit* | Target unit of damage |
includeCritical | bool | Whether to include critical hit, defaults to false |
// Calculate normal attack damage
float damage = Damage::CalculateAutoAttackDamage(myHero, enemy);
// Calculate normal attack damage including critical hit
float critDamage = Damage::CalculateAutoAttackDamage(myHero, enemy, true);
# CalculateSkillDamage
float CalculateSkillDamage(Unit* source, Unit* target, SkillSlot slot, int level = -1)
Calculates skill damage.
Parameter | Type | Description |
---|---|---|
source | Unit* | Source unit of damage |
target | Unit* | Target unit of damage |
slot | SkillSlot | Skill slot, such as Q, W, E, R |
level | int | Skill level, defaults to -1 meaning use current level |
// Calculate damage of Q skill at current level
float qDamage = Damage::CalculateSkillDamage(myHero, enemy, SkillSlot::Q);
// Calculate damage of Q skill at level 1
float qLevel1Damage = Damage::CalculateSkillDamage(myHero, enemy, SkillSlot::Q, 1);
// Calculate damage of ultimate at max level
float rMaxDamage = Damage::CalculateSkillDamage(myHero, enemy, SkillSlot::R, 3);
# GetHealthAfterDamage
float GetHealthAfterDamage(Unit* target, float rawDamage, DamageType damageType)
Calculates the remaining health of target after taking specified damage.
Parameter | Type | Description |
---|---|---|
target | Unit* | Target unit of damage |
rawDamage | float | Raw damage value |
damageType | DamageType | Damage type, such as physical, magical or true damage |
// Calculate remaining health after taking 100 physical damage
float healthAfterPhysical = Damage::GetHealthAfterDamage(enemy, 100.0f, DamageType::Physical);
// Calculate remaining health after taking 100 magical damage
float healthAfterMagical = Damage::GetHealthAfterDamage(enemy, 100.0f, DamageType::Magical);
// Calculate remaining health after taking 100 true damage
float healthAfterTrue = Damage::GetHealthAfterDamage(enemy, 100.0f, DamageType::True);
# CalculateDamageReduction
float CalculateDamageReduction(Unit* target, DamageType damageType)
Calculates the damage reduction percentage of target for specific damage type.
Parameter | Type | Description |
---|---|---|
target | Unit* | Target unit |
damageType | DamageType | Damage type |
// Calculate physical damage reduction rate
float physicalReduction = Damage::CalculateDamageReduction(enemy, DamageType::Physical);
// Calculate magical damage reduction rate
float magicalReduction = Damage::CalculateDamageReduction(enemy, DamageType::Magical);
# IsTargetKillable
bool IsTargetKillable(Unit* source, Unit* target, float extraDamage = 0.0f)
Determines if the target can be killed (calculates the total damage of all available skills and normal attacks).
Parameter | Type | Description |
---|---|---|
source | Unit* | Source unit of damage |
target | Unit* | Target unit |
extraDamage | float | Extra damage, defaults to 0 |
// Determine if target can be killed
bool canKill = Damage::IsTargetKillable(myHero, enemy);
// Determine if target can be killed with an extra 100 damage
bool canKillWithExtra = Damage::IsTargetKillable(myHero, enemy, 100.0f);