afisakov
You can change this now in User CP.
- Reaction score
- 37
I am quiet new to Jass and need some help getting the syntax right. I am trying to make a function that can conveniently create groups of units at a specified location without leaking and need some help with the syntax.
The trigger I am trying to make is the third one, first 2 just context.
I am trying to fix leaks on a map that spawns units like this
Which I am pretty sure creates a large number of point and unit group leaks
my first attempt at a fix looked like
it worked but was tedious since it required making a new trigger for every unit type
now I am hoping to make a more comprehensive trigger to handle all the unit types and be easier to use
I am hoping to make a trigger of the type:
however I do not know if I made this right nor do I know how to call on a trigger like this.
would I use a line like
? or how would I call on this? also do I remove the points in the spawn function after the endloop, or in the trigger that called on it?
Please explain how to properly implement a trigger/function like this.
The trigger I am trying to make is the third one, first 2 just context.
I am trying to fix leaks on a map that spawns units like this
Code:
call CreateNUnitsAtLocFacingLocBJ($C,'nzom',Player(5),GetRectCenter(MB),GetUnitLoc(ev[0]))
call CreateNUnitsAtLocFacingLocBJ(3,'n006',Player(5),GetRectCenter(MB),GetUnitLoc(ev[0]))
call CreateNUnitsAtLocFacingLocBJ($A,'nzom',Player(5),GetRectCenter(pB),GetUnitLoc(ev[0]))
call CreateNUnitsAtLocFacingLocBJ(5,'n006',Player(5),GetRectCenter(pB),GetUnitLoc(ev[0]))
call CreateNUnitsAtLocFacingLocBJ($A,'nzom',Player(5),GetRectCenter(PB),GetUnitLoc(ev[0]))
call CreateNUnitsAtLocFacingLocBJ(5,'n006',Player(5),GetRectCenter(PB),GetUnitLoc(ev[0]))
my first attempt at a fix looked like
Code:
function spn0062 takes nothing returns nothing
set bj_forLoopBIndex=1
set bj_forLoopBIndexEnd=spa
loop
exitwhen bj_forLoopBIndex>bj_forLoopBIndexEnd
call CreateNUnitsAtLoc(1,'n006',Player($C),hx,90.)
call IssuePointOrderByIdLoc(bj_lastCreatedUnit,$D000F,gx)
set bj_forLoopBIndex=bj_forLoopBIndex+1
endloop
endfunction
...
set hx=GetRandomLocInRect(MB)
set gx=GetUnitLoc(ev[0])
set spa=3
call TriggerExecute (spn006m)
call RemoveLocation (hx)
set hx=GetRectCenter(pB)
now I am hoping to make a more comprehensive trigger to handle all the unit types and be easier to use
I am hoping to make a trigger of the type:
Code:
function spnu takes integer spa,unittype spu,location hx,location gx returns nothing
set bj_forLoopBIndex=1
set bj_forLoopBIndexEnd=spa
loop
exitwhen bj_forLoopBIndex>bj_forLoopBIndexEnd
call CreateNUnitsAtLoc(1,spu,Player($C),hx,90.)
call IssuePointOrderByIdLoc(bj_lastCreatedUnit,$D000F,gx)
set bj_forLoopBIndex=bj_forLoopBIndex+1
endloop
endfunction
...
function main...
set spawnu=CreateTrigger()
call TriggerAddAction(spnawnu,function spnu)
would I use a line like
Code:
call TriggerExecute (spawnu(10,'n006',GetRandomLocInRect(MB),GetRandomLocInRect(MC)))
Please explain how to properly implement a trigger/function like this.