| 09-01-2003, 08:41 PM | #1 |
Code:
function Trig_Poisoned_Countdown_Func001Func001A takes nothing returns nothing
call SetUnitUserData( GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) - 1 ) )
endfunction
function Trig_Poisoned_Countdown_Actions takes nothing returns nothing
local integer a = 1
local integer b = 1
loop
exitwhen a > 3
call ForGroupBJ( udg_GameUNITGROUPPoisGroup[a], function Trig_Poisoned_Countdown_Func001Func001A )
set a = a + 1
endloop
if GetUnitUserData(GetEnumUnit()) == 0 then
loop
exitwhen b > 60
call GroupRemoveUnitSimple( GetEnumUnit(), udg_GameUNITGROUPPoisGroup[b] )
set b = b + 1
endloop
else
endif
endfunction
//===========================================================================
function InitTrig_Poisoned_Countdown takes nothing returns nothing
set gg_trg_Poisoned_Countdown = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Poisoned_Countdown, 0.50 )
call TriggerAddAction( gg_trg_Poisoned_Countdown, function Trig_Poisoned_Countdown_Actions )
endfunctionSome of this is GUI converted namely the function I want to merge into the original call. How would I go about doing that? Is it possible? |
| 09-01-2003, 09:29 PM | #2 |
Why am I always the one replying to your questions? :ggani: Anyway if the reason your doing this, is so you can use local varaibles in the ForGroup call then this is the only solution (replace the call ForGroup with all the code in this trigger): 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( <unit group> )
loop
exitwhen iA > jA
set random_unit = GroupPickRandomUnit( <unit group> )
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 ( udg_already_picked == false ) then
set unit_list[iA] = random_unit
set iA = iA + 1
endif
endloop
set iA = 1
loop
exitwhen iA > jA
// Do Picked Unit actions here
// Except use unit_list[iA] where you use GetEnumUnit()
endloop
endfunction |
| 09-01-2003, 09:38 PM | #3 |
That doesn't do what I want though. All this is supposed to do is pick all the units in the unit group 1-60 and subtract 1 from the custom value of the unit. That's all this is supposed to do. |
| 09-01-2003, 10:34 PM | #4 |
Just pass what group the picked unit belongs to with a global, it won't matter. Or have your remove statement work on a loop inside the function. Code:
-----------<Takes all units from group 1 to 60 and subtract one from their custom value>----------
function Trig_Poisoned_Countdown_Func001Func001A takes nothing returns nothing
if ( GetUnitUserData(GetEnumUnit()) == 0 ) then
Call GroupRemoveUnitSimple ( GetEnumUnit(), udg_gameUNITGROUPPoisGroup[udg_Remove])
else
call SetUnitUserData( GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) - 1 ) )
endif
endfunction
function Trig_Poisoned_Countdown_Actions takes nothing returns nothing
local integer a = 1
loop
exitwhen a > 60
set udg_Remove = a
call ForGroupBJ( udg_GameUNITGROUPPoisGroup[a], function Trig_Poisoned_Countdown_Func001Func001A )
set a = a + 1
endloop
endfunction
// ==================================================
=========================
function InitTrig_Poisoned_Countdown takes nothing returns nothing
set gg_trg_Poisoned_Countdown = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Poisoned_Countdown, 0.50 )
call TriggerAddAction( gg_trg_Poisoned_Countdown, function Trig_Poisoned_Countdown_Actions )
endfunction |
| 09-01-2003, 11:01 PM | #5 |
I don't want to have the function up top at all. I want it to be put in with the original call. so Code:
function Trig_Poisoned_Countdown_Func001Func001A takes nothing returns nothing
call SetUnitUserData( GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) - 1 ) )
endfunctionCode:
function Trig_Poisoned_Countdown_Actions takes nothing returns nothing
local integer a = 1
local integer b = 1
loop
exitwhen a > 3
call ForGroupBJ( udg_GameUNITGROUPPoisGroup[a], function Trig_Poisoned_Countdown_Func001Func001A )
set a = a + 1
endloop
if GetUnitUserData(GetEnumUnit()) == 0 then
loop
exitwhen b > 60
call GroupRemoveUnitSimple( GetEnumUnit(), udg_GameUNITGROUPPoisGroup[b] )
set b = b + 1
endloop
else
endif
endfunction |
| 09-01-2003, 11:50 PM | #6 |
The function I gave you is a workaround for the use of local variables. All that trigger does is pick every unit in a unit-group and adds them to an array, where they can be picked threw a for loop, and you can use any local variables. And it's not ment to be a seperate function, like I said in my last post, replace the ForGroup call with all the code in this trigger, so you copy all the code except the first and last lines (the ones that decalre the function) then paste that over your call to ForGroup(...) So you trigger should look like: Code:
function Trig_Poisoned_Countdown_Actions takes nothing returns nothing
local integer a = 1
local integer b = 1
loop
exitwhen a > 3
// ADD MY CODE HERE
set a = a + 1
endloop
if GetUnitUserData(GetEnumUnit()) == 0 then
loop
exitwhen b > 60
call GroupRemoveUnitSimple( GetEnumUnit(), udg_GameUNITGROUPPoisGroup[b] )
set b = b + 1
endloop
else
endif
endfunction |
