• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Moving regions with triggers

Status
Not open for further replies.
Level 5
Joined
Aug 18, 2013
Messages
85
I have 12 regions that form a perfect circle. I want to move them to another part of the map while keeping that shape.

I want to move regions together while keeping their formation
How do I do this?

Is it possible or should I just copy and paste these regions?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
What are you trying to achieve? Maybe you don't need regions at all.

It is possible to move regions, however it requires you to know a few things beforehand:
If regions form a circle, then the distance of a region from the center of the circle and number of regions.

You will have to create a variable of type "Region" with "array" checked to get a region array.
At map initialization do this:
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set region_arr[1] = *some region*
      • Set region_arr[2] = *some region*
      • ... etc.
When you move regions, you do the following. Here I will assume you have 12 regions and the range from the center of the circle to each region is 300.00.
  • Move rect
    • Events
      • *your event*
    • Conditions
      • *your condition*
    • Actions
      • Set angle = 30.00
      • For each (Integer loop_var) from 1 to 12, do (Actions)
        • Loop - Actions
          • Region - Center region_arr[loop_var] on ((Center of (Playable map area)) offset by 300.00 towards ((Real(loop_var)) x angle) degrees)
angle is 30.00 because full circle is 360 degrees. Since you have 12 regions, I did 360/12 = 30. So the angle between two regions should be 30 degrees.

Of course the above leaks memory, so to prevent that you need to add few additional lines:
  • Move rect
    • Events
      • *your event*
    • Conditions
      • *your condition*
    • Actions
      • Set center = *center of your circle*
      • Set angle = 30.00
      • For each (Integer loop_var) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set loc = (center offset by 300.00 towards ((Real(loop_var)) x 30.00) degrees)
          • Region - Center region_arr[loop_var] on loc
          • Custom script: call RemoveLocation(udg_loc)
      • Custom script: call RemoveLocation(udg_center)
Note the indentation of each action.
Variable used here are:
center, loc = Point variable
angle = Real variable
loop_var = Integer variable

This may deform your circle a bit however due to how regions can be moved and placed on the map (grid movement).
Another, but more complicated approach, which would never deform the circle, would be to first store the X and Y offset of each region from the center of the circle and when moving regions use these X/Y offsets.

Do note a very important thing:
If you're moving regions so that this event:
  • Unit - A unit enters/leaves *some region*
fires somewhere else, it will not work as you think!

If you're not using it for that purpose, I think you don't even need regions, hence why I asked at the start of this post what are you trying to achieve.
 
Level 5
Joined
Aug 18, 2013
Messages
85
Thank you

What am I trying to achieve? Well I have a cinematic sequence. But it only happens in one area of the map. I'd like that same cinematic sequence to be used again in another area of the map. Using the same regions.

Instead of copying and pasting the regions or redoing it again from scratch.
 
Status
Not open for further replies.
Top