constant function MF_AbiId takes nothing returns integer
return 'A000'
endfunction
constant function MF_Interval takes nothing returns real
return .1
endfunction
constant function MF_Radius takes nothing returns real
return 170.+25.
endfunction
constant function MF_DamageAmount takes nothing returns real
return 300.+300.
endfunction
constant function MF_SpecEffect takes nothing returns string
return "war3mapImported\\DivineWrathTarget.mdx"
endfunction
constant function MF_Counter takes nothing returns integer
return 20
endfunction
constant function MF_DmgFactor takes nothing returns integer
return 1 // 2 3 4 5
endfunction
constant function MF_IgnoreDead takes unit u returns boolean
return GetUnitTypeId(u)<1 or IsUnitType(u,UNIT_TYPE_DEAD) //GetWidgetLife(u)<.405
endfunction
function FlushTrigger takes trigger t,hashtable h returns nothing
local integer id=GetHandleId(t)
if(t!=null)then
call DisableTrigger(t)
call DestroyTrigger(t)
call FlushChildHashtable(h,id)
endif
endfunction
function MF_Filter takes unit u,unit t returns boolean
local boolean a=IsUnitType(t,UNIT_TYPE_HERO)
local boolean b=IsUnitEnemy(u,GetOwningPlayer(t))
local boolean c=IsUnitType(t,UNIT_TYPE_STRUCTURE)
local boolean d=IsUnitType(t,UNIT_TYPE_ANCIENT)
return a and b and not c and not d and not MF_IgnoreDead(t)
endfunction
function MF_DamageOptions takes unit u,unit t,integer i,real d returns nothing
if i==0 then
return
endif
if i==1 then
call UnitDamageTarget(u,t,d,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
elseif i==2 then
call UnitDamageTarget(u,t,d,true,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif i==3 then
call UnitDamageTarget(u,t,d,true,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
elseif i==4 then
call UnitDamageTarget(u,t,d,true,true,ATTACK_TYPE_PIERCE,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif i==5 then
call UnitDamageTarget(u,t,d,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
endif
endfunction
function MF_DamageTarget takes unit u,unit t,integer i,group g returns nothing
call MF_DamageOptions(u,t,MF_DmgFactor(),((MF_DamageAmount()*i)/bj_groupCountUnits)/MF_Counter())
endfunction
function MF_Periodic takes nothing returns boolean
local trigger t=GetTriggeringTrigger()
local integer id=GetHandleId(t)
local unit u=LoadUnitHandle(udg_MF_Hash,id,0)
local real x=LoadReal(udg_MF_Hash,id,1)
local real y=LoadReal(udg_MF_Hash,id,2)
local integer lvl=LoadInteger(udg_MF_Hash,id,3)
local unit uFirst
if GetTriggerEvalCount(t)>20 then
call FlushTrigger(t,udg_MF_Hash)
else
call GroupEnumUnitsInRange(bj_lastCreatedGroup,x,y,MF_Radius(),null)
set bj_groupCountUnits=0
loop
set uFirst=FirstOfGroup(bj_lastCreatedGroup)
exitwhen uFirst==null
if MF_Filter(u,uFirst)then
set bj_groupCountUnits=bj_groupCountUnits+1
call MF_DamageTarget(u,uFirst,lvl,bj_lastCreatedGroup)
endif
call GroupRemoveUnit(bj_lastCreatedGroup,uFirst)
endloop
endif
set t=null
set u=null
set uFirst=null
return false
endfunction
function MF_Actions takes nothing returns boolean
local trigger t
local integer id
local unit u
local real x
local real y
local integer lvl
if GetSpellAbilityId()==MF_AbiId() then
set t=CreateTrigger()
set id=GetHandleId(t)
set u=GetTriggerUnit()
set x=GetSpellTargetX()
set y=GetSpellTargetY()
set lvl=GetUnitAbilityLevel(u,MF_AbiId())
call TriggerRegisterTimerEvent(t,MF_Interval(),true)
call TriggerAddCondition(t,Condition(function MF_Periodic))
call SaveAgentHandle(udg_MF_Hash,id,0,u)
call SaveReal(udg_MF_Hash,id,1,x*1.)
call SaveReal(udg_MF_Hash,id,2,y*1.)
call SaveInteger(udg_MF_Hash,id,3,lvl)
call DestroyEffect(AddSpecialEffect(MF_SpecEffect(),x,y))
set t=null
set u=null
endif
return false
endfunction
function InitTrig_Mystic_Flare takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function MF_Actions))
set t=null
endfunction