Warcraft III resources & community, 2003–2006 · archived

SelectNumberOfId

not rated
Submitted by AIAndyFunctions0 downloads
Returns a group of n units of type id that are in g (if available). Mainly for usage in AI as it destroys g.
Usually used like this:
set g = SelectNumberOfId(g, 5, 'hkni')

Source

function SelectNumberOfId takes group g, integer n, integer id returns group
     local integer c = 0
     local unit u = null
     local group rg = CreateGroup()
     loop
       set u = FirstOfGroup(g)
       exitwhen u == null
       exitwhen c == n
       if GetUnitTypeId(u) == id then
          set c = c + 1
          call GroupAddUnit(rg, u ) 
       endif
       call GroupRemoveUnit(g, u )
     endloop
     call DestroyGroup(g)
     return rg
endfunction

Comments

0

No comments.