function DamageArea takes unit attacker, location point, real area, real damage returns nothing
local unit u
local group g = CreateGroup()
local player p = GetOwningPlayer(attacker)
call GroupEnumUnitsInRange(g,GetLocationX(point),GetLocationY(point),area,Filter(null))
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u,p) and GetWidgetLife(u) > 0 and not (IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE) or IsUnitType(u,UNIT_TYPE_STRUCTURE)) then
call SetUnitExploded(u,true)
call UnitDamageTarget(attacker,u,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
call SetUnitExploded(u,false)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
set p = null
set attacker = null
set point = null
endfunction
function thunder takes location pos returns nothing
local effect spec
local lightning light
local real x = GetLocationX(pos)
local real y = GetLocationY(pos)
set light = AddLightningEx("CLPB",true,GetRandomReal(x-400,x+400),GetRandomReal(y-400,y+400),1000,x,y,0)
set spec = AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x,y)
call DestroyEffect(spec)
call TriggerSleepAction(0.1)
call DestroyLightning(light)
set light = null
set spec = null
endfunction
function redthunder takes location pos returns nothing
local effect spec
local lightning light
local real x = GetLocationX(pos)
local real y = GetLocationY(pos)
set light = AddLightningEx("AFOD",true,x,y,1000,x,y,0)
set spec = AddSpecialEffect("buildings\\other\\MageTower\\MageTower.mdl",x,y)
call DestroyEffect(spec)
call TriggerSleepAction(0.5)
call DestroyLightning(light)
set light = null
set spec = null
endfunction
function strikeac takes nothing returns nothing
local group g = CreateGroup()
local unit u
local location tar
local rect reg
local integer a
call GroupAddGroup(udg_locusts,g)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == 'h001' then
set a = GetUnitUserData(u)
set reg = RectFromCenterSizeBJ(GetUnitLoc(u), 420.00, 420.00)
set tar = GetRandomLocInRect(reg)
call DamageArea(u,tar,100,20+a*12)
call thunder(tar)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
call RemoveLocation(tar)
set tar = null
call RemoveRect(reg)
set reg = null
endfunction
function dummyac takes nothing returns nothing
local unit dummyu
local unit caster = GetTriggerUnit()
local location pos = GetSpellTargetLoc()
local integer a = GetUnitAbilityLevel(caster,'A000')
if ( GetSpellAbilityId() == 'A000' ) then
set dummyu = CreateUnitAtLoc(GetOwningPlayer(caster),'h001',pos,bj_UNIT_FACING)
call SetUnitUserData(dummyu,GetUnitAbilityLevel(caster,'A000'))
call DamageArea(caster,pos,300,0)
call SetUnitAnimation(dummyu,"birth")
call GroupAddUnit(udg_locusts,dummyu)
call TriggerSleepAction(3)
call GroupRemoveUnit(udg_locusts,dummyu)
call TriggerSleepAction(0.5)
call DamageArea(dummyu,pos,300,a*100)
call redthunder(pos)
call KillUnit(dummyu)
set dummyu = null
call RemoveLocation(pos)
set caster = null
endif
endfunction
//===========================================================================
function InitTrig_Thunder_Strike takes nothing returns nothing
local trigger strike
local trigger dummy
set dummy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( dummy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( dummy, function dummyac )
set strike = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( strike, 0.05 )
call TriggerAddAction( strike, function strikeac )
endfunction