I have been getting the undefined error despite the fact that the variable is defined and it shows up in a hint with the value. Despite the error the script works it just fills the rpt file up with that dang on error.
I am trying to propagate the knows about factor of the unit's targets through out the other groups. The script works it is just that dang on error pops up.
the error occurs at "_leader knowsabout" and "leader reveal _x" _leader being the undefined variable that is actually defined......
EDIT: I was playing around with the script and some of the groups were returning as null, that might be the problem but when i try to exlude them from the array with if (!isnull blah blah)... it stil adds null objects to the array. I am getting a tumor from this.
would appreciate any insight anyone may have on this.
private ["_unitleaders","_allgroups","_allgrpcnt","_targetarray","_enemyunits","_allunits","_allcount","_leader","_intel"];
_unitleaders = [];
_allgroups = allgroups;
_allgrpcnt = count _allgroups;
for [{_i=0}, {_i<_allgrpcnt}, {_i=_i+1}] do
{
_checkunit = _allgroups select _i;
if (side _checkunit == west)then
{
_leader = leader _checkunit;
_unitleaders set [_i,_leader];
};
};
_targetarray = [];
_enemyunits = [];
_allunits = allunits;
_allcount = count _allunits;
for [{_i=0}, {_i<_allcount}, {_i=_i+1}] do
{
_checkunit = _allunits select _i;
if (side _checkunit == east)then
{
_enemyunits set [_i,_checkunit];
}
};
_count = 0;
{
if (alive _x) then
{
for [{_i=0}, {_i<_allgrpcnt}, {_i=_i+1}] do
{
_leader = _unitleaders select _i;
hintsilent format ["%1",_leader];
_intel = _leader knowsabout _x;
if (_intel > 1)then
{
_targetarray set [_count,_x];
_count = _count + 1;
};
};
};
} foreach _enemyunits;
{
for [{_i=0}, {_i<_allgrpcnt}, {_i=_i+1}] do
{
_leader = _unitleaders select _i;
_leader reveal _x;
};
} foreach _targetarray;