I was trying to fix my chain healing spell, but i can't make it work...
Can any1 help? Here i the code:
Can any1 help? Here i the code:
JASS:
function Cond takes nothing returns boolean
return GetSpellAbilityId() == 039;A002039;
endfunction
function ChainHeal takes nothing returns nothing
local unit cast = GetTriggerUnit()
local unit prevtarg
local unit targ = GetSpellTargetUnit()
local unit nexttarg
local unit dummy
local location p = GetUnitLoc(targ)
local group postargets = GetUnitsInRangeOfLocAll( 500.00 , p)
local group donetargets
local integer noofdone
local integer heroint = GetHeroStatBJ(bj_HEROSTAT_INT, cast, true)
if IsUnitAlly(targ , GetOwningPlayer(cast)) == true then
if IsUnitInGroup(targ , donetargets) == false then
set dummy = CreateUnitAtLoc( GetOwningPlayer(cast) , 039;h000039; , GetUnitLoc(cast) , 0.00 )
call IssueTargetOrder( dummy , "ChainHeal" , targ )
call UnitApplyTimedLife( dummy , 039;BTLF039; , 3.00)
call SetUnitLifeBJ(targ , ( GetUnitStateSwap(UNIT_STATE_LIFE, targ) + ( 3 * heroint)))
call TriggerSleepAction(3.00)
endif
endif
set dummy = null
set nexttarg = FirstOfGroup(postargets)
set p = GetUnitLoc(nexttarg)
set postargets = GetUnitsInRangeOfLocAll( 500.00 , p)
call GroupAddUnit(donetargets, targ)
set noofdone = noofdone + 1
set prevtarg = targ
set targ = nexttarg
set heroint = heroint * ( 3 / 4 )
loop
exitwhen noofdone == 16
if IsUnitAlly(targ , GetOwningPlayer(cast)) == true then
if IsUnitInGroup( targ , donetargets) == false then
set dummy = CreateUnitAtLoc( GetOwningPlayer(cast) , 039;h000039; , GetUnitLoc(prevtarg) , 0.00 )
call IssueTargetOrder( dummy , "ChainHeal" , targ )
call UnitApplyTimedLife( dummy , 039;BTLF039; , 3.00)
call SetUnitLifeBJ(targ , ( GetUnitStateSwap(UNIT_STATE_LIFE, targ) + ( 3 * heroint)))
endif
endif
set nexttarg = FirstOfGroup(postargets)
set p = GetUnitLoc(nexttarg)
set postargets = GetUnitsInRangeOfLocAll( 500.00 , p)
set dummy = null
call GroupAddUnit(donetargets, targ)
set noofdone = noofdone + 1
set prevtarg = targ
set targ = nexttarg
set heroint = heroint * ( 3 / 4 )
endloop
set cast = null
set targ = null
set prevtarg = null
set nexttarg = null
set p = null
set postargets = null
set donetargets = null
endfunction
function InitTrig_ChainHeal takes nothing returns nothing
local trigger t
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition(function Cond))
call TriggerAddAction( t, function ChainHeal)
endfunction