I will comment as I look through. Coverfire.sqs -
First problem:
if (side _unit == west) then {_enemy = east} else {_enemy = west}
Surpising though it may seem _enemy will be undefined after this statement. Local variable that are define within a {} only exists there and not later. To achieve what you want you should try:
_enemy = west
if (side _unit == west) then {_enemy = east}
That way _enemy is defined before the If statement and so will contunie to exist after it.
EDIT: Oops - just saw your definitions at the top.
Next point:
#initpos;
_pos = getpos _group select _i;
_initpos = _initpos+[_pos];
_i =_i+1;
_p =_p+1;
? _p < _groupcount : goto "initpos";
Will cause you to miss the last element of _group
Replace with:
#initpos
_pos = getpos _group select _i
_initpos = _initpos+[_pos]
_i =_i+1
? _i < _groupcount : goto "initpos"
Bye the way you don't need a ; at the end of each line in a script.
Ditto:
_i = 0;
_p = 1;
#secondpos
_pos = getpos _group select _i;
_c = _secondpos+[_pos];
_i =_i+1;
_p =_p+1;
? _p < _groupcount : goto "initpos";
Should be:
_i = 0
#secondpos
_pos = getpos _group select _i
_c = _secondpos+[_pos]
_i =_i+1
? _i < _groupcount : goto "secondpos"
Note also that I have changed the destination lable in the goto statement to send it to the correct place.
This part of the code is trying to establish if units are moving. Why not use the command speed?
Next:
Get rid of the _p here as well:
_i = 0;
_p = 1;
#checkmove
if ((_initpos select _i) distance (_secondpos select _i) > _sensitivity) then {_identified = _identified + [_group select _i]};
_i =_i+1;
_p =_p+1;
? _p < _groupcount : goto "checkmove";
There is a deeper problem with this though. The distance command will only work between two objects not between two locations.
You do realise that there will always be a value for _i where _unit will == _group select _i in the following line?
? _unit distance (_group select _i) <= _d : goto "checkenemy";
_i =_i+1;
_p =_p+1;
? _p < _groupcount : goto "checkdistloop2";
_d =_d+1;
goto "checkdistloop1";
There you go with _p again.
So this bit of code is stepping _d from 1 upwards until you find a member of _group that is closer to the _unit than _d. As I mentioned above the test will find that _unit is very close to _unit. Why not just calculate all the distances in one go and then select the smallest?
I am skipping quickly over stuff now. Next obvious problem is:
if (_unit knowsAbout _enemylist select _i ) then {_enemylistknown = _enemylistknown + [_enemylist select _i]};
(_unit knowsAbout _enemylist select _i ) is a number not a boolean at the very least you should have
if ((_unit knowsAbout _enemylist select _i ) > 0.105) then {_enemylistknown = _enemylistknown + [_enemylist select _i]};
More to come...
Err... actually there isn't. I think you have a lot to be going on with just restructuring it to fix these things. Then I suggest you have a look through the comref
http://www.ofpec.com/editors/comref.phpThere is a lot of stuff in there that will give you ideas about what to do, like using speed for example. Also it will explain fully the use of knowsAbout etc.
I also suggest you investigate the forEach instruction.
Keep at it. It is a neat idea, and your code is tidy, just not accurate. I guess you have programmed elsewhere but are newish to this?