I made this spell its supposed to deal damage to all living enemies in three areas in front of the caster. The script executes, but no damage is dealt.
If anyone can help me fix I'd appreciate it. This is my second scripted spell so give me a break if something is inefficient.
If anyone can help me fix I'd appreciate it. This is my second scripted spell so give me a break if something is inefficient.
JASS:
function Trig_ArcaneWave_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A002' ) ) then
return false
endif
return true
endfunction
function Trig_ArcaneWave_Actions takes nothing returns nothing
local group g1 = CreateGroup()
local group g2 = CreateGroup()
local group g3 = CreateGroup()
local location l1 = GetUnitLoc(GetSpellAbilityUnit())
local location l2 = PolarProjectionBJ(l1, 256.00, GetUnitFacing(GetSpellAbilityUnit()))
local location l3 = PolarProjectionBJ(l2, 512.00, GetUnitFacing(GetSpellAbilityUnit()))
local location l4 = PolarProjectionBJ(l3, 768.00, GetUnitFacing(GetSpellAbilityUnit()))
local unit u1 = GetSpellAbilityUnit()
local unit u2
local real d1 = ( GetHeroLevel(u1) / 4 )
local real d2 = ( 100 + ( GetHeroStatBJ(bj_HEROSTAT_INT, u1, true) * ( d1 + 1 ) ) )
set g1 = GetUnitsInRangeOfLocAll(150.00, l2)
set g2 = GetUnitsInRangeOfLocAll(150.00, l3)
set g3 = GetUnitsInRangeOfLocAll(150.00, l4)
call TriggerSleepAction( 0.33 )
loop
set u2 = FirstOfGroup(g1)
if ( not ( IsUnitEnemy(u2, GetOwningPlayer(u1)) == true ) ) then
if ( not ( IsUnitAliveBJ(u2) == true ) ) then
exitwhen u2 == null
call GroupRemoveUnit(g1, u2)
call UnitDamageTargetBJ( u1, u2, d2, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
else
endif
else
call GroupRemoveUnit(g1 , u2)
endif
endloop
call TriggerSleepAction( 0.33 )
loop
set u2 = FirstOfGroup(g2)
if ( not ( IsUnitEnemy(u2, GetOwningPlayer(u1)) == true ) ) then
if ( not ( IsUnitAliveBJ(u2) == true ) ) then
exitwhen u2 == null
call GroupRemoveUnit(g2, u2)
call UnitDamageTargetBJ( u1, u2, d2, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
else
endif
else
call GroupRemoveUnit(g2 , u2)
endif
endloop
call TriggerSleepAction( 0.33 )
loop
set u2 = FirstOfGroup(g3)
if ( not ( IsUnitEnemy(u2, GetOwningPlayer(u1)) == true ) ) then
if ( not ( IsUnitAliveBJ(u2) == true ) ) then
exitwhen u2 == null
call GroupRemoveUnit(g3, u2)
call UnitDamageTargetBJ( u1, u2, d2, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
else
endif
else
call GroupRemoveUnit(g3 , u2)
endif
endloop
call RemoveLocation(l1)
set l1 = null
call RemoveLocation(l2)
set l2 = null
call RemoveLocation(l3)
set l3 = null
call RemoveLocation(l4)
set l4 = null
call DestroyGroup(g1)
set g1 = null
call DestroyGroup(g2)
set g2 = null
call DestroyGroup(g3)
set g3 = null
set u1 = null
set u2 = null
endfunction
//===========================================================================
function InitTrig_ArcaneWave takes nothing returns nothing
set gg_trg_ArcaneWave = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ArcaneWave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ArcaneWave, Condition( function Trig_ArcaneWave_Conditions ) )
call TriggerAddAction( gg_trg_ArcaneWave, function Trig_ArcaneWave_Actions )
endfunction