scope ChargesDam initializer init
private function onDamage takes nothing returns nothing
local integer slot = 0
local integer charges = 0
local real fullDamage
local item it
if damageType == PHYSICAL then
loop
set it = UnitItemInSlot(source, slot)
if GetItemTypeId(it)=='I000' and GetItemCharges(it) > 0 then
set charges = GetItemCharges(it)
exitwhen true
endif
set slot = slot + 1
exitwhen slot==6
endloop
set fullDamage = charges*amount //this is the damage
call UnitDamageTarget(source, target, fullDamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
endif
set it = null
endfunction
private function init takes nothing returns nothing
call AddDamageHandler(function onDamage)
endfunction
endscope