Bloody hell... I can't keep up.
Lol yes it has been a bit of a shambles, sorry.
For each unit that is in a group of N units that unit will be given the required instructions N times for each loop (applies to both Sections1 & 2). I suppose it gets the message home. I think writing it from scratch an alternative might be to ignore units that are not group leaders and then run all the instructions for each member of each group. I would not suggest you change now though.
The multiple passes are required for some reason: with single pass a fair number of loons just hide in forests. I suspect that they are so stupendously scared that the allowFleeing 0 command kinda wears off.
There are several hints that have not yet been commented out.
I think I got them all in the BETTER version.
1.; these variables ensure that the setpos loop is done only once
Fixed
2. allowGetin false is used in Section2 but not in Section1. Is this okay?
Yes. Section 1 is not about getting loons out of vehicles really: section 2 is.
3. What does setUnitPos {auto} do? I presume it is ok to use lowercase?? Comref shows all uppercase.
OFP code is supposed to be case insensitive. It usually is, though rare and obscure counterexamples have been reported. There are some units (eg snipers) that have setUnitPos "down" commands: this keeps them on their bellies. "Auto" allows them to stand up, which means they don't have to crawl up the hill.
4. Section1: _cargo is a sub-set of _group. I think therefore that all of the following is redundant:
It would be if the loons in cargo were in the same group as the vehicle. If they are a seperate group then you need to duplicate the code. In fact, the only group where this occurs is the Bradleys (light armour) and it's unlikey they would still be alive, but you never know. If a group is totally in cargo in a seperate vehicle you can't grab them with a West present trigger.
Edit: yes of course I should have added the arrays together. Duh-oh.
5. This appears a lot:
trigList = list mapTrig
_upList = +_trigList
_count = count _upList
The command + is vital: it crystallises the array. If you don't use it, then the array you are dealing with updates automatically while the loop is running. Consequently lots of bad stuff happens becuase your counters get screwed up as the number of loons in the array changes. The number can go both up and down of course. You could code your way out of it but this seems easier.
6. The line:
Code:? (alive _endLoon1) and (_endLoon1 distance flag1 > 250) and ((flag1 distance _endLoon1 < (_pos1 + 2)) and (flag1 distance _endLoon1 > (_pos1 - 2))) : _endLoon0 setPos [(getPos object 42683 select 0) + 2, (getPos object 42683 select 1) + 5, 0]
Should read:
? (alive _endLoon1) and (_endLoon1 distance flag1 > 250) and ((flag1 distance _endLoon1 < (_pos1 + 2)) and (flag1 distance _endLoon1 > (_pos1 - 2))) : _endLoon1 setPos [(getPos object 42683 select 0) + 2, (getPos object 42683 select 1) + 5, 0]
Now that is a very impressive spot. :thumbsup: I found it myself, sadly: it is the most important change between WORKS and BETTER.
Many thanks for hacking through this. I've found several other minor mistakes in the mission while trying to fix it.