Jump to content
Sign in to follow this  
demonized

how to count how many GROUPS in a area?

Recommended Posts

is there a way i can count amount of groups not units inside a area?

Example i have 3 groups of takis spawned with BIS_fnc_spawngroup and they are guarding an area, is there a way i can count amount of groups without knowing their group names?

groupnames are _locallgrpname in spawn script.

Share this post


Link to post
Share on other sites

Get all units within the area, get their group, add it to a list if its not there yet. Once out of units, count your list.

Share this post


Link to post
Share on other sites
_trigger = _this select 0;  		// trigger east present repeated.


_allUnits = [];				// ready array for units.
_allgroups = [];				// ready array for groups.

_allUnits = _allUnits + _this;	// add all units in trigger to array.

while {count _allUnits > 0} do {
_unit = _this select 0;
_group = group _unit;
if (_group in _allgroups) then {
	_allUnits = _allUnits - _unit;
	hint "not adding already in there";
} else {
	_allUnits = _allUnits - _unit;
	_allgroups = _allgroups + _group;
};
};
_amountgrps = count _allgroups;
hint format["%1",_allgroups];  // this is the amount of groups inside trigger.

maybe this will work??

Share this post


Link to post
Share on other sites

enemygroups=[]

{if (side _x==east and _x in list areatrigger and !(group _x in enemygroups)) then {enemygroups=enemygroups+[group _x]}} forEach allUnits

Assuming that the area is set by a trigger named "areatrigger" repeatedly activated by anyone or east.

count enemygroups will give you the amount.

Share this post


Link to post
Share on other sites

tnx will try that right now.

Edit: works nicely thank you.

Edit2: above works fine, but when i try using local variable _enemygroups instead of global enemygroups it returns 0, any idea why?

when using no space inbetween it returns 0 if using _enemygroups,

adding a space like here woked fine.

_enemygroups=[];
{if (side _x==east and _x in list areatrigger and !(group _x in _enemygroups)) then {_enemygroups = _enemygroups+[group _x]}} forEach allUnits;
_nu = count _enemygroups;
hint format["%1",_nu];

Edited by Demonized

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×