//DETECT THE ARMOR OF AN UNIT
function GetUnitArmorType takes unit whichUnit returns integer
local real armor = GetUnitArmor(whichUnit)
local real damage
call UnitAddAbility(whichUnit, 039;allz039;)
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, 039;allz039;)
return 8 //divine
elseif (damage>16.02) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 2 //medium
elseif (damage<15.98) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 4 //fortified
endif
set damage = EvalDamage(whichUnit, 16.00, ATTACK_TYPE_SIEGE, armor)
if (damage<15.98) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 6 //hero
elseif (damage>16.02) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 7 //unarmored
endif
if (EvalDamage(whichUnit,16.00,ATTACK_TYPE_PIERCE,armor)>16.02) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 1 //small
endif
if (EvalDamage(whichUnit,16.00,ATTACK_TYPE_MAGIC,armor)>16.02) then
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 3 //large
else
call UnitRemoveAbility(whichUnit, 039;allz039;)
return 5 //normal
endif
endfunction