• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Reading Armor Values with Triggers?

Status
Not open for further replies.
Level 4
Joined
Nov 20, 2006
Messages
70
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
70
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