View Single Post
Old 07-07-2008, 05:16 AM   #7
Switch33
User
 
Join Date: Oct 2003
Posts: 150

Switch33 is on a distinguished road (13)

Default

Yea, that sounds better. So basically i would use something like 10 unit groups or so and recycle them(like re-empty them at the end of triggers and get a free one when i needed one).

Also it would be slower if u searched through all units with data on them in one single group than searching several groups i think.

This is what i got so far... am i on the right track?
Collapse JASS:
library GroupRecycle
globals
unit group G[1] = CreateGroup()
unit group G[2] = CreateGroup()
unit group G[3] = CreateGroup()
unit group G[4] = CreateGroup()
unit group G[5] = CreateGroup()
unit group G[6] = CreateGroup()
unit group G[7] = CreateGroup()
unit group G[8] = CreateGroup()
unit group G[9] = CreateGroup()
unit group G[10] = CreateGroup()
endglobals
    
function GetGroup takes nothing returns integer
//this gives you a free group integer
     loop
        exitwhen i > 10          //Max # of groups
            if CountUnitsInGroup(G[i]) == 0 then                 
                return i               //Returns first empty group it finds
            endif
           set i = i + 1
     endloop
       return 11 //error if it ever gets this far
endfunction
function GroupRelease takes integer groupid returns nothing
//this clears your free group integer
     call GroupClear(G[groupid])
endfunction
endlibrary
//Simple example of a trigger:
function m takes nothing returns booleanexpr
return true //standard filter function
endfunction
function forgroupfunc takes nothing returns nothing
//do something with the units here
endfunction
function usegroup takes nothing returns nothing
local integer i =  GetGroup()
local booleanxpr = Condition(m)
set G[i] = GroupEnumUnitsInRange(G[i],x,y,radius, condition)
call ForGroup(G[i],function forgroupfunc)
//wait.. (spell ends)
call GroupRelease(i)
endfunction
Quote:
I think all these timer systems are confusing the hell out of people

QFT, yea... They all seem to all have "personal benefits" for each of them too if it wasn't enough to annoy the heck out of you trying to choose which ones to use. I think using like TT and HSAS works good.
(Since i think HSAS is faster than ABC, but not faster than TT. Also TT only uses 1 timer.
Another reason why is i don't like going back to gamecache really either.)
Switch33 is offline   Reply With Quote