Code
function UnitGetImmunityAmount takes unit whichUnit, integer immunityType returns real
return LoadReal(udg_ImmunityHash,GetHandleId(u),immunityType)
endfunction
function UnitSetImmunityAmount takes unit whichUnit, integer immunityType, real newImmunityValue returns nothing
call SaveReal(udg_ImmunityHash,GetHandleId(u),immunityType,newImmunityValue)
endfunction
function UnitDealDamageToUnit takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
local real dmg = amount
local integer i = 0
loop
exitwhen i > 26
if damageType == ConvertDamageType(i) then
set dmg = amount - UnitGetImmunityAmount(target,i)
return UnitDamageTarget(whichUnit,target,dmg,attack,ranged,attackType,damageType,weaponType)
endif
set i = i + 1
endloop
return false
endfunction
function Resist_Init takes nothing returns nothing
set udg_ImmunityHash = InitHashtable()
endfunction
return LoadReal(udg_ImmunityHash,GetHandleId(u),immunityType)
endfunction
function UnitSetImmunityAmount takes unit whichUnit, integer immunityType, real newImmunityValue returns nothing
call SaveReal(udg_ImmunityHash,GetHandleId(u),immunityType,newImmunityValue)
endfunction
function UnitDealDamageToUnit takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
local real dmg = amount
local integer i = 0
loop
exitwhen i > 26
if damageType == ConvertDamageType(i) then
set dmg = amount - UnitGetImmunityAmount(target,i)
return UnitDamageTarget(whichUnit,target,dmg,attack,ranged,attackType,damageType,weaponType)
endif
set i = i + 1
endloop
return false
endfunction
function Resist_Init takes nothing returns nothing
set udg_ImmunityHash = InitHashtable()
endfunction
Эта система позволяет сократить персонально любой урон из имеющихся в WarCraft'e. Вы просто указываете ID этого урона и пишете ему сокращение. Урон наносите функцией UnitDealDamageToUnit. Функцию Resist_Init запустите в инициализации карты.
Требует глобалку ImmunityHash типа Хэш-таблица.