function HowMuch takes nothing returns integer
return 3 //This value will be used to be devided by the sumup value: sumup/count, where count = HowMuch() = this very function.
endfunction
function WhichAbility takes nothing returns integer
return 'A001' //The rawcode of the life bonus ability.
endfunction
function TimedBonusRemoval takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId (t)
local unit u = LoadUnitHandle (udg_CM_Hash, id, StringHash("caster"))
local integer bonus = LoadInteger (udg_CM_Hash, id, StringHash("bonus"))
local integer i = WhichAbility()
set bonus = -bonus
loop
exitwhen bonus == 0
call UnitAddAbility(u, i)
if bonus >= 100 then
set bonus = bonus + 100
call SetUnitAbilityLevel(u, i, 7)
elseif bonus >= 10 then
set bonus = bonus + 10
call SetUnitAbilityLevel(u, i, 6)
else
set bonus = bonus + 1
call SetUnitAbilityLevel(u, i, 5)
endif
call UnitRemoveAbility(u, i)
endloop
call SetUnitTimeScalePercent (u, 100)
call UnitRemoveAbility (u, 'B000')
call FlushChildHashtable (udg_CM_Hash, id)
call DestroyTimer (t)
set t = null
set u = null
endfunction
function PickUp takes nothing returns nothing
local unit u = GetEnumUnit()
call FlushChildHashtable (udg_CM_Hash, GetHandleId (u))
call KillUnit (u)
set u = null
endfunction
function Trig_Clone_Machine_3_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local timer t = CreateTimer()
local integer id = GetHandleId (u)
local integer id2 = GetHandleId (t)
local unit caster = LoadUnitHandle (udg_CM_Hash, id, StringHash("caster"))
local integer count = HowMuch()
local real sumup = LoadReal (udg_CM_Hash, id, StringHash("sumup")) / count
local integer realamount = R2I(sumup)
local integer i = WhichAbility()
local unit a
local group g = LoadGroupHandle (udg_CM_Hash, id, StringHash("group"))
call DestroyEffect (AddSpecialEffect ("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl", GetUnitX(u), GetUnitY(u)))
call RemoveUnit (u)
call GroupRemoveUnit (udg_CM_CMGroup, u)
call ForGroup (g, function PickUp)
if realamount > 0 then
set a = CreateUnit (GetOwningPlayer(u), 'hfoo', GetUnitX (u), GetUnitY (u), 0)
call UnitApplyTimedLife (a, 'BTLF', 2)
call ShowUnit (a, false)
call UnitAddAbility (a, 'A004')
call IssueTargetOrder (a, "innerfire", caster)
call SaveInteger (udg_CM_Hash, id2, StringHash("bonus"), R2I(sumup))
call SaveUnitHandle (udg_CM_Hash, id2, StringHash("caster"), caster)
loop
exitwhen realamount == 0
call UnitAddAbility(caster, i)
if realamount >= 100 then
set realamount = realamount - 100
call SetUnitAbilityLevel(caster, i, 4)
elseif realamount >= 10 then
set realamount = realamount - 10
call SetUnitAbilityLevel(caster, i, 3)
else
set realamount = realamount - 1
call SetUnitAbilityLevel(caster, i, 2)
endif
call UnitRemoveAbility (caster, i)
endloop
call SetUnitTimeScalePercent (caster, 300)
call TimerStart (t, udg_CM_Duration, false, function TimedBonusRemoval)
call FlushChildHashtable (udg_CM_Hash, id)
endif
call DestroyGroup (g)
set u = null
set t = null
set caster = null
set a = null
set g = null
endfunction
//===========================================================================
function InitTrig_Clone_Machine_3 takes nothing returns nothing
set gg_trg_Clone_Machine_3 = CreateTrigger( )
call TriggerAddAction (gg_trg_Clone_Machine_3, function Trig_Clone_Machine_3_Actions )
endfunction