HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Question about Jass

08-18-2003, 03:45 PM#1
Newhydra
How would I modify call forLoopBJ(function my_func) if I needed to pass my_func an integer(or any other variable)?
08-18-2003, 04:08 PM#2
MarSara
Code:
local integer i
local integer j
set i = 0
set j = 10
loop
    exitwhen i > j
    // do whatever
endloop
08-18-2003, 04:18 PM#3
PitzerMike
and of course:

set i = i + 1

at the end of the loop
08-18-2003, 08:19 PM#4
Newhydra
No, that's not what I meant...Here's another example:

call ForGroupBJ( GetUnitsInRangeOfLocAll(150.00, PolarProjectionBJ(unitLoc), ( 150.00 * I2R(i) ), attackAngle)), function Trig_Do_Damage_Func004Func001A )

Now, Trig_Do_Damage_Func004Func001A needs to take a unit as a parameter, how do I modify this so I can pass it a unit?
08-18-2003, 08:52 PM#5
MarSara
ahh that problem, if you are willing to use global variables just do that, otherwise here's the trigger for a Unit-Group:
Code:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local integer iA
    local integer jA
    local integer iB
    local integer jB
    local unit random_unit
    local unit array unit_list
    local boolean already_picked

    set iA = 1
    set jA = CountUnitsInGroup(GetUnitsInRectAll(GetPlayableMapRect()))
    loop
        exitwhen iA > jA
        set random_unit = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
        set already_picked = false
        set iB = 1
        set jB = iA
        loop
            exitwhen iB > jB
            if ( unit_list[iB] == random_unit ) then
                set already_picked = true
            endif
            set iB = iB + 1
        endloop
        if ( already_picked == false ) then
            set unit_list[iA] = random_unit
            set iA = iA + 1
        endif
    endloop


    set iA = 1
    loop
        exitwhen iA > iJ
        // Do Picked Unit actions here
        // Except use unit_list[iA] where you use GetEnumUnit()
    set iA = iA +1
    endloop
endfunction
just make sure to change GetPlayableMapRect() to the region.

EDIT: fixed a typo
08-18-2003, 09:29 PM#6
Newhydra
ugh...there isn't a way to make a variable global to the trigger or something? (I can't use globals because this trigger is going to be called alot and the risk of them getting confused...)
08-18-2003, 10:21 PM#7
MarSara
No, you can use globals, or if you need to use locals, just use my trigger.