JASS:
library GetUnitCount uses UnitIndexer/*
by edo494 v1.2
requires - UnitIndexer: http://www.hiveworkshop.com/forums/jass-resources-412/system-unit-indexer-172090/
API:
function GetUnitCount takes nothing returns integer
- returns current number of indexed units on the map
*/
private struct UnitCount extends array
readonly static integer count = 0
private static method onIndex takes nothing returns boolean
set count = count + 1
return false
endmethod
private static method onDeindex takes nothing returns boolean
set count = count - 1
return false
endmethod
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onIndex), UnitIndexer.INDEX)
call RegisterUnitIndexEvent(Condition(function thistype.onDeindex), UnitIndexer.DEINDEX)
endmethod
endstruct
function GetUnitCount takes nothing returns integer
return UnitCount.count
endfunction
endlibrary
- added function GetUnitCountEx, takes:
- boolean countLocust - whether or not we want to count locust units
- boolean countDeadUnit - whether or not we want to count dead units
- boolean countDeadHero - whether or not we want to count dead heroes
- remade whole code, now fires on INDEX/DEINDEX events
- rewrote code to mag's version
Last edited: