JASS problem ..

I

iNsaNe

Guest
im making a function that returns a certain number of randomly picked units in a unit group. The problem is, when I call the function nothing happens.

here's my jass (im new to jass by the way)
Code:
function FirePitChoose takes integer NumberOfPits returns group

     local unit RUnit
     local group Pits = GetUnitsOfTypeIdAll ( 'n001' )
     local group ReturnPits

     local integer Index = 1

     loop

         exitwhen Index > NumberOfPits
         set RUnit = GroupPickRandomUnit ( Pits )
         call GroupAddUnitSimple ( RUnit, ReturnPits )
         call GroupRemoveUnitSimple ( RUnit , Pits )
         set RUnit = null
         set Index = Index + 1

     endloop

     call DestroyGroup ( Pits )
     return ReturnPits

endfunction

and this is how i attempt to use it (so i get 10 units back in the unit group):
Code:
set udg_HeatPits = FirePitChoose ( 10 )
and of course udg_HeatPits is a unit group variable

edit:

when i say nothing happens i mean, the code doesn't execute for the function FirePitChoose. The map doesn't freeze, but it's like the code does.
 

SerraAvenger

Cuz I can
Reaction score
234
and btw you might want to replace the redundant bj calls:

call GroupAddUnitSimple ( RUnit, ReturnPits )
call GroupRemoveUnitSimple ( RUnit , Pits )

should be
Code:
call GroupAddUnit( ReturnPits, RUnit )
call GroupRemoveUnit( Pits, RUnit)

Thats two calls less * the number of units you wanna have.


greets davey
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top