This trigger works fine in that it assigns the all 4 custom values to each building it selects. As far as I know the pick each unit trigger always starts from the bottom-most unit and then works its way up. The problem with this trigger is that it doesn't apply the actions to any units besides or above the building called "1 Building - Capital". I added a ping action for each building it selected and saw that it simply stops. Any unit below the Capital has all 4 custom values filled out when probed for its custom values. Any unit besides or above the capital will have no custom values. The centralization ended message that should appear on completion of the trigger also fails to appear.
think the problem might have something to do with the nested loops but removing the 2nd unit loop didn't fix the problem and one of them is a for loop (so there shouldn't be a problem with the nested loops to begin with). I have cut up this script is many various ways and still cannot isolate the problem. I hope that you guys can help.
All units are the same exact type of units which fits the required Structure condition of the pick each unit loop.
Trigger is probably hitting the op limit as it appears to have an inherit complexity of O(n^2). Use the trigger debugger for more detail, it should log errors as well as allowing you to inspect what is exactly going on at any given time in the trigger.
Units are picked based on internal ordering within data structures. This will probably be biased in some direction based on how quad trees or other internal data structures are travelled.
I managed to produce a divide by zero error by copy pasting a fresh version of this trigger and the trigger to probe for custom values of buildings to a clean map. For some reason, this error would not show on my main map. I managed to then fix the problem by adding an if command that makes sure the value of "capitaldistance" and "colonydistance" is always greater than 0. Thank you for your help.