Manix
Well-Known Member
- Reaction score
- 29
Hey, I'm just getting into jass and I'm making a little spell effect in order to learn. But what is bugging me is that I can't seem to figure out how to pass anonymous functions, for example in the code I have
How could I pass the group actions and conditions as anonymous functions?
JASS:
scope AttackSFX initializer init
private function Cond takes nothing returns boolean
if(GetUnitAbilityLevel(GetAttacker(),039;AHbh039;)>0) then
if( GetRandomInt(1,5) == 1 ) then
return true
endif
endif
return false
endfunction
private function DamageGroupCond takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetAttacker())) == true )
endfunction
private function DamageGroup takes nothing returns nothing
call UnitDamageTarget( GetAttacker(), GetEnumUnit(), 200, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
endfunction
private function Actions takes nothing returns nothing
local location p
local effect e
local group ug
set p = GetUnitLoc(GetAttacker())
set e = AddSpecialEffectLoc("Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl" , p)
set e = null
set ug = GetUnitsInRangeOfLocMatching(300, p, function DamageGroupCond)
call ForGroup(ug,function DamageGroup)
set p = null
set ug = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(t, function Cond)
call TriggerAddAction( t, function Actions )
set t = null
endfunction
endscope
How could I pass the group actions and conditions as anonymous functions?