• 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.

Armor

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,243
From http://www.hiveworkshop.com/forums/...ing-armor-values-triggers-197129/#post1934531

I modified it so that the unit can't die from the damage. There's an ability that temporarily increases the units max hp. You must use the raw code of the ability. Customize it in the script after you've copied it to your map. You can check raw codes by clicking Ctrl + D in object editor.

JASS:
function GetUnitArmor takes unit u returns real
    local real hp1 = GetUnitState(u, UNIT_STATE_LIFE)
    local real hp2
    local real damage
    call UnitAddAbility(u, 'A000')
    call SetUnitAbilityLevel(u, 'A000', 2)
    call UnitRemoveAbility(u, 'A000')
    set hp2 = GetUnitState(u, UNIT_STATE_LIFE)
    call UnitDamageTarget( u, u, 10.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
    set damage = hp2 - GetUnitState(u, UNIT_STATE_LIFE)
    call UnitAddAbility(u, 'A000')
    call SetUnitAbilityLevel(u, 'A000', 3)
    call UnitRemoveAbility(u, 'A000')
    call SetUnitState(u, UNIT_STATE_LIFE, hp1)
    if damage > 10.0 then
        set damage = 10.0 - damage
        return (damage-10.0)/(damage*0.06)
    endif
    return (10.0-damage)/(damage*0.06)
endfunction

http://www.hiveworkshop.com/forums/pastebin.php?id=zti5sz
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
This requires some conditions.

Chaos attack type should deal 100% to all defense types.
The 0.06 originates from armor reduction factor in gameplay constants.
Not sure why DAMAGE_TYPE_NORMAL was chosen, this does not work against ethereal units, it also cancels heal salve for example.
UnitDamageTarget runs damage events and there is also a unit life event that can react to SetUnitState.

There are few object editor fields that can be natively read out via trigger nor are there so many for units or widgets in general.
 
Status
Not open for further replies.
Top