• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Inaccurate damage reduction value?

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
542
This function should return the damage bonus of an attack type against an armor from Gameplay Constants.
JASS:
function hAI_GetUnitArmorReduction takes unit u, attacktype aType returns real
    local boolean dmgEventEnabled = IsTriggerEnabled(udg_hAI_DE_DamageEventTrigger)
    local real originalArmor = BlzGetUnitArmor(u)
    local real originalMaxLife = BlzGetUnitMaxHP(u)
    local real originalLife = GetWidgetLife(u)
    local real testLife
 
    call BlzSetUnitArmor(u, 1)
    call BlzSetUnitMaxHP(u, 10000)
    call SetWidgetLife(u, 10000.)
    call DisableTrigger(udg_hAI_DE_DamageEventTrigger)
    call UnitDamageTarget(u, u, 100., false, false, aType, DAMAGE_TYPE_NORMAL, null)
    set testLife = GetWidgetLife(u)
 
    if dmgEventEnabled then
        call EnableTrigger(udg_hAI_DE_DamageEventTrigger)
    endif
    call BlzSetUnitArmor(u, originalArmor)
    call BlzSetUnitMaxHP(u, R2I(originalMaxLife))
    call SetWidgetLife(u, originalLife)
 
    return (10000. - testLife) / 100.
endfunction

What I tried and happened
Using ATTACK_TYPE_PIERCE:
- Unit armor = Hero --> returns 0.472 (should be: 0.50)
- Unit armor = Fortified --> returns 0.330 (should be: 0.35)
- Unit armor = Normal --> returns 0.943 (should be: 1.00)

Gameplay constants is default, which is:
Combat - Damage Bonus Table - Pierce
- Small: 2.00
- Medium: 0.75
- Large: 1.00
- Fortified: 0.35
- Normal: 1.00
- Hero: 0.50
- Divine: 0.05
- Unarmored: 1.50

I solved this myself so nevermind :D
Sorry..

Solution:
Use DAMAGE_TYPE_UNKNOWN instead.
 
Last edited:
Status
Not open for further replies.
Top