• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Inaccurate damage reduction value?

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
530
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