I am Jassing for two days. That makes me a big noob in Jass. So I coded a spell, that creates units as a line and adds them to a unit group. This is ok.
But I want to do this:
If a unit in unit group dies, kill all units in unit group. And clean the leaks and memory. Thanks...
But I want to do this:
If a unit in unit group dies, kill all units in unit group. And clean the leaks and memory. Thanks...
JASS:
function Trig_ET_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A000039;
endfunction
function filtre takes nothing returns boolean
return ( GetDestructableTypeId(GetFilterDestructable()) == 039;ATtr039; )
endfunction
function Trig_ET_Actions takes nothing returns nothing
local unit u
local player p
local group g = CreateGroup()
local destructable t1
local destructable t2
local location loc0
local location loc1
local location loc2
local real x
local real y
local real dis
local integer mc
local integer count
local rect area
local unit m
set count = 0
set u = GetSpellAbilityUnit()
set p = GetOwningPlayer(u)
set t1 = GetSpellTargetDestructable()
set loc0 = GetUnitLoc(u)
set area = RectFromCenterSizeBJ(loc0, 300.00, 300.00)
set t2 = RandomDestructableInRectBJ(area, Condition(function filtre))
set loc1 = GetDestructableLoc(t1)
set loc2 = GetDestructableLoc(t2)
set x = GetDestructableX(t2)
set y = GetDestructableY(t2)
set dis = DistanceBetweenPoints(loc1, loc2)
set mc = R2I(dis/30)
set abp = bj_RADTODEG * Atan2(GetLocationY(loc1) - GetLocationY(loc2), GetLocationX(loc1) - GetLocationX(loc2))
loop
exitwhen count > mc
set x = x + 30 * Cos(abp * bj_DEGTORAD)
set y = y + 30 * Sin(abp * bj_DEGTORAD)
set m = CreateUnit(p, 039;n001039;, x, y, 0)
call GroupAddUnit(g, m)
set count = count + 1
endloop
endfunction
function InitTrig_ET takes nothing returns nothing
set gg_trg_ET = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ET, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_ET, Condition( function Trig_ET_Conditions ) )
call TriggerAddAction( gg_trg_ET, function Trig_ET_Actions )
endfunction