• 🏆 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!

Reading Armor Values with Triggers?

Status
Not open for further replies.
Level 4
Joined
Nov 20, 2006
Messages
71
Is this possible?

Say that I want to create an effect where once a unit has 5 or more armor it also gains evasion. How could I accomplish this?

To be totally clear, I would like units to be given the evasion ability once they reach 5 armor, no matter how they do it (devotion aura/upgrades/etc).

Thanks for any suggestions.
 
Level 23
Joined
Oct 12, 2008
Messages
1,783
You cant measure armour directly.

However you could come up with some sort of a system where all armour sources in your map are saved and assigned a value.

From there you could calculate a units armour as an integer.
 
Real, armor would return a real. Here is some script to help you out:
JASS:
function GetUnitArmor takes unit u returns real
    local real hp = GetUnitState(u, UNIT_STATE_LIFE)
    local real damage
    call UnitDamageTarget( u, u, 10.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
    set damage = hp - GetUnitState(u, UNIT_STATE_LIFE)
    call SetUnitState(u, UNIT_STATE_LIFE, hp)
    if damage > 10.0 then
        set damage = 20.0 - damage
        return (damage-10.0)/(damage*0.06)
    endif
    return (10.0-damage)/(damage*0.06)
endfunction

Call it as
  • Custom script: set udg_Armor = GetUnitArmor (GetTriggerUnit())
Use a periodic event to check when a unit's armor hits a specific value.
 
Level 4
Joined
Nov 20, 2006
Messages
71
Thanks. I don't know much about JASS but if that's the way to do it I'll see where I can get.

I assume the same is true for reading unit damage values? Weird that these can't be done GUI.
 
Status
Not open for further replies.
Top