Im making a spell where a wisp is created and sending a chain Lighting effect to the units around the hero. Now my problem is the effect is not showing up but the units are damaged any help will be great. heres my code
JASS:
function NatureLightning_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A012'
endfunction
function Lighting_Filter takes nothing returns boolean
return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
endfunction
function NatureLightning_Actions takes nothing returns nothing
local unit u1 = GetTriggerUnit()
local unit u
local unit f
local integer i = GetUnitAbilityLevel(u1, 'A012')
local effect e
local lightning l
local real x = GetUnitX(u1)
local real y = GetUnitY(u1)
local real x1
local real y1
local real x2
local real y2
local boolexpr b = Condition(function Lighting_Filter)
local group g = CreateGroup()
set e = AddSpecialEffectTarget("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", u1, "origin")
call GroupEnumUnitsInRange(g, x, y, 300.00, b)
set u = CreateUnit(GetOwningPlayer(u1), 'e000', x, y, bj_UNIT_FACING)
set x1 = GetUnitX(u)
set y1 = GetUnitY(u)
loop
set f = FirstOfGroup(g)
set x2 = GetUnitX(f)
set y2 = GetUnitY(f)
exitwhen f == null
set l = AddLightning("CLPB", false, x1, y1, x2, y2)
call MoveLightning(l, true, x1, y1, x2, y2)
call UnitDamageTarget(u, f, 25*i, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
call GroupRemoveUnit(g, f)
call DestroyLightning(l)
endloop
call RemoveUnit(u)
set u = null
set u1 = null
call DestroyEffect(e)
set e = null
set l = null
set g = null
call DestroyGroup(g)
set g = null
call DestroyBoolExpr(b)
set b = null
endfunction
//===========================================================================
function InitTrig_NatureLighting takes nothing returns nothing
set gg_trg_NatureLighting = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_NatureLighting, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_NatureLighting, Condition( function NatureLightning_Conditions ) )
call TriggerAddAction( gg_trg_NatureLighting, function NatureLightning_Actions )
endfunction