FireWalker 329 Posted September 22, 2017 Would someone explain why this line deletes all placed AI units once the mission runs? It deletes all AI regardless of side. (east, west, civ, geur) And it cleans up dead units. It can be tested in the debug console. {{deleteVehicle _x} forEach units _x; deleteGroup _x} forEach allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}; It doesn't matter if the marker is placed or not. And therefore the radius doesn't matter. Shouldn't this only delete AI units from side EAST that are within 60' of the marker? If someone thinks I should title this topic better please let me know. Fire 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted September 22, 2017 always wrap such array after forEach : (allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}) {{deleteVehicle _x} forEach units _x; deleteGroup _x} forEach (allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}); 3 Share this post Link to post Share on other sites
FireWalker 329 Posted September 22, 2017 Ok, That makes sense now that I see it. Without it wrapped it reads the second half as two different command sections? Seems like it ends up reading this section : {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}; more of a null statement then a command to do anything. It didn't throw any errors, that I could find. Looking at it further: {{deleteVehicle _x} forEach units _x; deleteGroup _x} forEach allGroups I guess this is the part that gets read as a command, and thats whats telling it to delete all ai? Fire 1 Share this post Link to post Share on other sites
Tajin 348 Posted September 22, 2017 I'd blame the lack of brackets in the condition. { { deleteVehicle _x; } forEach units _x; deleteGroup _x; } forEach allGroups select { side _x == EAST && {((leader _x) distance (getMarkerPos "_marker")) < 60}}; 2 Share this post Link to post Share on other sites
FireWalker 329 Posted September 22, 2017 @pierremgi This code works correctly for the situation. With the marker within 60 only EAST AI gets deleted, if the marker is outside of the 60 range, then nothing happens to any of the units: {{deleteVehicle _x} forEach units _x; deleteGroup _x} forEach (allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}); @Tajin This does not correct the issue. It will still delete all AI units in the map even without the marker close enough: {{deleteVehicle _x;} forEach units _x; deleteGroup _x;} forEach allGroups select { side _x == EAST && {((leader _x) distance (getMarkerPos "_marker")) < 60}}; Tested using the debug in a clean environment with a couple AI from each side. Not trying to call anybody out, just wanted to try to make it clear if someone else swings in and reads through this. Thank you all for the help. Fire (for clarity: the situation here is to delete all the AI from side EAST that are within 60 meters of a marker named: _marker when the code is called) And a link to the mission file if anyone wants to test in the editor: DropBox 1 Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted September 23, 2017 Typical precedence issue. forEach wants an array, the first element after it is an array so forEach got what it wants and doesn't care about anything behind that array. The round brackets basically yell at forEach: "NOT SO FAST" and force the encased commands to be evaluated first. That's why @pierremgis solution works. Cheers 3 Share this post Link to post Share on other sites
Robustcolor 30 Posted September 4, 2020 On 9/22/2017 at 10:10 AM, pierremgi said: always wrap such array after forEach : (allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}) {{deleteVehicle _x} forEach units _x; deleteGroup _x} forEach (allGroups select {side _x == EAST and {leader _x distance getMarkerPos "_marker" < 60}}); What does the extra curly brackets do inside this deleteVehicle _x code? Does Lazy evaluation work outside a if then? (allGroups select {side _x == EAST and {leader _x distance getMarkerpos "_marker"<60}}); Share this post Link to post Share on other sites
pierremgi 4739 Posted September 4, 2020 Yep, but not very significant difference with few groups. The more BLUFOR groups, the greater difference. 1 Share this post Link to post Share on other sites