Squll2
je'ne sais pas
- Reaction score
- 76
Hey everyone. Begginner Vjasser here, with a very simple code that is playing up on me.
Would anyone care to explain to me why those code does not work at all and tell me how I can improve it, and make it faster... cleaner as such?
Thanks in advance!!
The simple aim of the spell, currently, is to create lightning from enemy units around the target point to the caster.
Also, with my GroupEnumUnitsInRange, how do I filter it through a condition? :nuts:
Would anyone care to explain to me why those code does not work at all and tell me how I can improve it, and make it faster... cleaner as such?
Thanks in advance!!
The simple aim of the spell, currently, is to create lightning from enemy units around the target point to the caster.
Also, with my GroupEnumUnitsInRange, how do I filter it through a condition? :nuts:
JASS:
scope CounterEnergy initializer Init
//Changeable / Alterable functions
private function ID takes nothing returns integer
return 039;A000039;
endfunction
private function Unit_ID takes nothing returns integer
return 039;h000039;
endfunction
private function Boo takes nothing returns boolexpr
return null
endfunction
private function Radius takes nothing returns real
return 350.00
endfunction
//Changeable / Alterable functions End.
private function Cons takes nothing returns boolean
return GetSpellAbilityId() == ID
endfunction
private function Actions takes nothing returns nothing
//Local Setting
local unit u = GetTriggerUnit()
local unit e
local unit d
local group g = CreateGroup()
local group g2 = CreateGroup()
local player p = GetOwningPlayer(u)
local integer a = 0
local integer b = 0
local location l = GetSpellTargetLoc()
local lightning array Light
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real X
local real Y
//Local Setting
call GroupEnumUnitsInRange(g, x, y, 500.00, null)
call GroupAddGroup(g, g2)
loop
set e = FirstOfGroup(g2)
exitwhen e == null
set X = GetUnitX(e)
set Y = GetUnitY(e)
set Light[a] = AddLightning( "CLPB", true, X, Y, x, y)
set a = a+1
call GroupRemoveUnit(g2, e)
endloop
call PolledWait(2.00)
loop
exitwhen a < 0
call DestroyLightning(Light[a])
set a = a-1
endloop
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( trig, Condition( function Cons ) )
call TriggerAddAction( trig, function Actions )
endfunction
endscope