Naming Many Regions

Status
Not open for further replies.
Level 1
Joined
May 9, 2020
Messages
5
Hey there,

I'm attempting to make a 'dota auto chess' / 'teamfight tactics' clone.

(this is a terrible idea for a noob like me, if you have a suggestion for an easy idea which I might find satisfying to help me learn some of the basics I'll need to know to do a good job at something like this, I'd much appreciate it!)

I have 8 player arenas, each with 8 columns and 7 rows of chess tiles. The players' units are intended to be triggered to move only from tile to tile, and only be able to attack if they are within range from the tile they are standing on.

I'd like to know if the correct method to handle all this location-sorting jazz is to use a bajillion regions, and if that would be the recommended method, how can I rename a bajillion regions in a more user friendly way than 1-by-1 selecting them and editing properties? (I figured out double-clicking the region, which helps, but is still a pretty big pain)

Hopefully it's a simple answer such as, "don't put those regions in manually! you should generate them with triggers!" or "just open up this file in eclipse and you'll find all the region labels in this section"

For visual aide, here's a screenshot.

wAnTyZO.png


Thanks!
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,240
I'd recommend a Tower Defense as one of the better beginner projects, but your map can be handled in a way that it doesn't become too complex as well.

Anyway, you don't even have to rely on Regions necessarily (at least not entirely). Points exist as well and serve a very similar purpose, although they lack the "A unit enters/leaves Region" Events which can be pretty be useful.

Here's a map I threw together that generates Points using a simple bit of math and then stores them to a Hashtable so you can reference them rather easily.

All you have to do to set this up is fill out a few Variables and setup a few Regions and the system will do the rest for you. It needs a Region for each "Row", so regarding your picture, it looks like you have 7 Rows of Regions in that Base so you would only need 7 Regions for each Player's Base. That means you'll only need 56 Regions in total which should save you a major headache.

Here's the Setup trigger. Configure this to use your Total # of Points (Think of Points as if they were Regions), I use 8 since my test map only has 3 Rows, and the Rows have 3/2/3 Points each (I kept the same pattern you used but scaled it down).
  • Setup Point Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet Points_Hashtable = (Last created hashtable)
      • -------- --------
      • -------- CONFIGURE: --------
      • -------- Set this to the total number of Points you will create for a single player's base (you can think of these Points as Regions) --------
      • Set VariableSet Setup_Total_Points = 8
      • -------- --------
      • -------- Copy and paste these variables for each Player and adjust them accordingly --------
      • -------- Player 1: --------
      • Set VariableSet Player_Number = 1
      • Set VariableSet Setup_Region_Row[1] = P1 Region Row 1 <gen>
      • Set VariableSet Setup_Region_Row[2] = P1 Region Row 2 <gen>
      • Set VariableSet Setup_Region_Row[3] = P1 Region Row 3 <gen>
      • Trigger - Run Create Points For Player <gen> (ignoring conditions)
      • -------- --------
      • -------- Player 2: --------
      • Set VariableSet Player_Number = 2
      • Set VariableSet Setup_Region_Row[1] = P2 Region Row 1 <gen>
      • Set VariableSet Setup_Region_Row[2] = P2 Region Row 2 <gen>
      • Set VariableSet Setup_Region_Row[3] = P2 Region Row 3 <gen>
      • Trigger - Run Create Points For Player <gen> (ignoring conditions)
You'll need to adjust this next trigger as well, mainly the MaxCount variable, and possibly the Point_Offset (512.00).

What this trigger is doing is creating Points offset from a given position, incrementing the offset as it goes. It knows how many Points to create per Row and the Offsets based on what you set MaxCount to, and what you increase the Offset by (512.00 by default). Specifically, it takes the Regions (Setup_Region_Rows) that we setup earlier, and creates Points starting at the position of these Regions and continues creating Points at an increasing offset towards the right side. It does this until it reaches the very end of the right side, and then jumps down to the next Row, starting the process all over again. It's also saving these Points to the Hashtable so we can reference them easily in other triggers.
  • Create Points For Player
    • Events
    • Conditions
    • Actions
      • -------- You'll want to adjust MaxCount to equal your total number of Points per Row (I made it so it alternates between the longer/shorter Rows) --------
      • Set VariableSet Point_Offset = 0.00
      • Set VariableSet Row = 1
      • Set VariableSet Count = 0
      • Set VariableSet MaxCount = 3
      • Set VariableSet Setup_Points[0] = (Center of Setup_Region_Row[Row])
      • For each (Integer Point_Loop) from 1 to Setup_Total_Points, do (Actions)
        • Loop - Actions
          • Set VariableSet Count = (Count + 1)
          • Set VariableSet Point_Index = (Point_Index + 1)
          • Set VariableSet Setup_Points[Point_Index] = (Setup_Points[0] offset by (Point_Offset, 0.00))
          • Hashtable - Save Handle OfSetup_Points[Point_Index] as Point_Loop of Player_Number in Points_Hashtable.
          • Set VariableSet Point_Offset = (Point_Offset + 512.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Count Equal to MaxCount
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxCount Equal to 3
                • Then - Actions
                  • Set VariableSet MaxCount = 2
                • Else - Actions
                  • Set VariableSet MaxCount = 3
              • Set VariableSet Row = (Row + 1)
              • Set VariableSet Count = 0
              • Set VariableSet Point_Offset = 0.00
              • Custom script: call RemoveLocation(udg_Setup_Points[0])
              • Set VariableSet Setup_Points[0] = (Center of Setup_Region_Row[Row])
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Setup_Points[0])
You'll see that I set MaxCount = 3. In your case, following the picture you provided, this needs to be set to 8 instead. So anywhere in the trigger that you see 3 in regards to MaxCount, change it to 8. And then change "Set VariableSet MaxCount = 2" to equal 7 (1 less than 8 since this is the smaller row). Hopefully this makes sense, I understand if it's a bit much.

I want to expand upon this but first I want to see if you're comfortable with the design. I could potentially incorporate Regions using this same method but it's a bit more complicated than you'd expect to do so.
 

Attachments

  • Point Setup Example.w3m
    20.7 KB · Views: 17
Last edited:
Level 1
Joined
May 9, 2020
Messages
5
Hi Uncle!

Thanks so much for taking the time to show me your approach! I've downloaded the file you put there, and have started investigating to see if I can figure out how to use it. It does seem that your method will certainly help with spawning units in.

I'll check back in when I've done some significant work with your example and have more questions.
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,240
Hey, no problem. So I added some more stuff to the system. I tried to keep it simple but it was difficult as Blizzard didn't make it very easy to Create Regions in GUI.

-I replaced the Points with pseudo-Regions. Unfortunately, you can't use these Regions with the standard "A unit enters Region/A unit leaves Region" Events, however, I've created my own system for doing so. You'll see two triggers, Enter Region, and Leave Region, which have instructions on how to use them. (Note: Technically I still use the Points, it's just that I replace them with Regions at the end of the Setup process once they're no longer needed)

-I added two Chess Movement example triggers to show you how you could take advantage of these Regions for tile-based Movement.

-I added GetPointsAndRegions, a trigger that allows you to get access to a Player's Regions and Points.


How to use GetPointsAndRegions:

All you have to do is set the variable PlayerNumber to be equal to the number of your desired player, then run GetPointsAndRegions.
  • Set VariableSet PlayerNumber = 1
  • Trigger - Run GetPointsAndRegions <gen> (ignoring conditions)
This will provide you access to that player's Regions as well as Points at the center of each of these Regions. These are provided as the GetRegion and GetPoint variables.

So referencing the trigger example above, I'm getting all of Player 1's Regions/Points for their base.

GetRegion[1] = The first region, GetRegion[2] = The second region, etc...
GetPoint[1] = A Point referencing the center of GetRegion[1], GetPoint[2] = A Point referencing the center of GetRegion[2], etc...

The Regions are stored in order from top to bottom, left to right.

Once you have access to these variables you can reference them with triggers like:
  • Unit - Create 1 Paladin for Player 1 (Red) at GetPoint[4] facing Default building facing degrees
Just remember, these can only be set for one player at a time, so you'll need to change PlayerNumber and run the trigger again if you want to reference another player's Regions/Points.


That being said, you aren't required to use GetPointsAndRegions. You can always reference the Hashtable directly like so:
  • Set VariableSet TempRegion = (Load 3 of 1 in Points_Hashtable.)
3 = The Region # you're loading
1 = The Player's number
The last value is the name of the Hashtable.

So TempRegion is set to the 3rd Region in Player 1's base.
 

Attachments

  • Point2Region System 1.w3m
    27.4 KB · Views: 12
Last edited:
Status
Not open for further replies.
Top