HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Getting a Unit's Armor Value?

03-06-2007, 02:11 AM#1
Ignitedstar
I'm having a difficult time trying to get a hero's armor value. I've tried to tinker around with Devotion Aura by doing a number of experiments that have failed. Let it be known first that I changed the fields so that it'll give/take a percent amount of armor. The first level decreases armor by 40%, the second level 100%(or zero), and the final level that reduces the armor by 200%(or reverses it).

1. First, I tried giving the heroes the ability itself(reverse Devotion Auras), it does work, but the problem came when the heroes started gaining levels and got defense bonuses from items. The aura did not count armor that was recieved by items or even the Agility stat. Let's say that my hero originally has 3 armor on level one. It gains a level and it now has 4 armor. If I give it the 2nd level of the ability, it still reduces armor by 3, not 4 like it should. Heroes that started off with an armor value of 0 got no bonus from the Devotion Aura at all.

2. I thought it was just me, so I switched all of the percentages to increase armor by a percent, but it did the exact same thing. Only, it gave an increase in armor.

3. I was confused afterwards. Finally, I gave the heroes items that increased armor. And still, the hero with the 3 armor that got a armor bonus of 2 still had it's armor decreased by 3.

This leads me to conclude that Devotion Aura's percentage increase/decrease only works for the unit's original armor value. This is completely fine for regular units, I just don't know what to do now that it doesn't work for a hero that gets armor from items/stats.

Which is why I have come to ask you guys: What kind of workaround would I need in order for me to increase/decrease the armor value of a hero by a percent?
03-06-2007, 03:24 AM#2
Rising_Dusk
Here is the system created by Daelin.
Best thing he's ever made in my opinion. :P

If you changed the gameplay constant for armor damage reduction in your map, you'll need to tweak the formula.
03-06-2007, 03:25 AM#3
Earth-Fury
if i understand you correctly:
you would need to calculate his total armor by looking at items and agility, and adjust his armor with an ability. (if you want item-based armor bonuses to count)

note: i've been out of the loop for a while, so don't take my words as a 1:1 with reality.

Edit: beaten to it AND bested all in one punch. thats what i get for multi-tasking =(
03-06-2007, 03:32 AM#4
Rising_Dusk
Daelin's system is hawt, hardcorelike.
It adjusts for armor based on ANYTHING.
Agility, items, debuffs, whatever -- It factors it all. <3
03-06-2007, 04:30 AM#5
Daelin
Because it simulates an instant damage/life lost attack on the unit and based on that, it determines the armor. If you change the gameplay constant, I think it will be pretty easy to adjust the system. If I have some time, I may make a constant function for that in the system too. :)

~Daelin
03-07-2007, 03:56 AM#6
Ignitedstar
Okay, I'll check it out as soon as I get time to work with the World Editor. Thanks for the help. I may ask further questions, though.
09-02-2008, 02:34 AM#7
Ignitedstar
Yes, I know that this thread is a year old, but a lot has happened in the past year.

Here's Daelin's system's code that discovers what armor type a unit has:

Collapse JASS:
function GetUnitArmorType takes unit whichUnit returns integer
    local real armor = GetUnitArmor(whichUnit)
    local real damage

    call UnitAddAbility(whichUnit, 'allz')
    set damage = EvalDamage(whichUnit, 16.00,ATTACK_TYPE_MELEE, armor)
    if (damage<=2.00 and EvalDamage(whichUnit, 16.00, ATTACK_TYPE_CHAOS, armor)>=15.98) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 8 //divine
    elseif (damage>16.02) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 2 //medium
    elseif (damage<15.98) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 4 //fortified
    endif
    
    set damage = EvalDamage(whichUnit, 16.00, ATTACK_TYPE_SIEGE, armor)
    if (damage<15.98) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 6 //hero
    elseif (damage>16.02) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 7 //unarmored
    endif

    if (EvalDamage(whichUnit,16.00,ATTACK_TYPE_PIERCE,armor)>16.02) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 1 //small
    endif

    if (EvalDamage(whichUnit,16.00,ATTACK_TYPE_MAGIC,armor)>16.02) then
        call UnitRemoveAbility(whichUnit, 'allz')
        return 3 //large
    else
        call UnitRemoveAbility(whichUnit, 'allz')
        return 5 //normal
    endif
endfunction  

Okay, I understand this now (finally!).

Although, I was wondering... since I've changed the armor values around quite a bit, would this still work even though the percent-reduction values within Game Constants are different? This includes both the damage tables and the armor damage reduction bonus.