Ok, first of all I wold like to say that I have no experience in JASS whatsoever, and I started learning it few days ago. I read through Daelin's GUI to JASS guide. At chapter 12, about picking units, I tried to understand the code that was given, and I wrote a new one according to that one. The difference is that i used my own variable names and the spell that would be casted, but it doesn't seem to work.
Any ideas on what might be wrong?
Code:
function Distortion_Condition takes nothing returns boolean
return GetSpellAbilityId()=='A000'
endfunction
function Distortion_Action takes nothing returns nothing
local unit u
local group g
local unit c
local unit d
local location p
set c = GetTriggerUnit()
set p = GetSpellTargetLoc()
set g = GetUnitsInRangeOfLocAll(600.00, p)
loop
set u = FirstOfGroup(g)
exitwhen u==null
if IsUnitEnemy(u, GetOwningPlayer(c))==true then
call GroupRemoveUnit(g,u)
set d = CreateUnitAtLoc(GetOwningPlayer(c), 'h000', GetUnitLoc(u), 0.00)
call IssueTargetOrderBJ(d, "purge", u)
call UnitApplyTimedLifeBJ(1.00, 'BTLF', d)
set d = null
endif
endloop
set g = null
set u = null
set c = null
set p = null
endfunction
function InitTrig_distortion takes nothing returns nothing
local trigger t
set t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Distortion_Condition))
call TriggerAddAction(t, function Distortion_Action)
endfunction
Any ideas on what might be wrong?