Having the custom map Desert Strike in mind. How could I duplicate units from a region into another region. In a sense copy paste what player X has into BattleRegion. Units in BattleRegion can die but the original units cannot..
You need to use a process called "point translation".
For each unit in the region which you want to copy, you get its point, add a displacement point to it and use the resulting point to create a unit of the same type. The displacement point is computed by taking the difference of points of reference between the placement region and the desired spawn region. A good point of reference would be the centre of the regions. Since the spawn region does not actually need to be a region you can simply move it around by its point of reference.
This uses a feature of Galaxy known as point arithmetic operators which is not directly available in GUI. The point object type supports addition and subtraction with other point objects to produce a new point with X, Y and Z cords identical to if the points were treated as vectors. The advantage of this is that you can use a single point to efficiently displace points in a constant way. You would compute the displacement point once and then use that for displacing all points from the placement region into the respective spawn region. Since the result is data fed you can easily alter the spawn and placement regions without needing to modify any code.
I did this last year for someone. Originally he used thousands of regions in a very data intensive and hard to modify system to do it. After migrating to a point translation system only 2-3 triggers were needed as well as 1 hard-coded region per player resulting in a massive reduction in his map complexity.
Edit: If you wanted to get more fancy and keep the units relative positions like ImperialGood is mentioning, I would suggest looking into the function point with polar offset.
Having the custom map Desert Strike in mind. How could I duplicate units from a region into another region. In a sense copy paste what player X has into BattleRegion. Units in BattleRegion can die but the original units cannot..
You need to use a process called "point translation".
For each unit in the region which you want to copy, you get its point, add a displacement point to it and use the resulting point to create a unit of the same type. The displacement point is computed by taking the difference of points of reference between the placement region and the desired spawn region. A good point of reference would be the centre of the regions. Since the spawn region does not actually need to be a region you can simply move it around by its point of reference.
This uses a feature of Galaxy known as point arithmetic operators which is not directly available in GUI. The point object type supports addition and subtraction with other point objects to produce a new point with X, Y and Z cords identical to if the points were treated as vectors. The advantage of this is that you can use a single point to efficiently displace points in a constant way. You would compute the displacement point once and then use that for displacing all points from the placement region into the respective spawn region. Since the result is data fed you can easily alter the spawn and placement regions without needing to modify any code.
I did this last year for someone. Originally he used thousands of regions in a very data intensive and hard to modify system to do it. After migrating to a point translation system only 2-3 triggers were needed as well as 1 hard-coded region per player resulting in a massive reduction in his map complexity.
This is the thread I am referring to. The final version I provided shows a solution using point translation. http://www.sc2mapster.com/forums/development/galaxy-scripting-and-trigger-lib/71576-create-units-for-a-region-to-other-region/
Or in more layman's terms, something like this:
Edit: If you wanted to get more fancy and keep the units relative positions like ImperialGood is mentioning, I would suggest looking into the function point with polar offset.