• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Snapping Unit to Grid

Level 2
Joined
Apr 28, 2024
Messages
2
Can someone please show me how create a grid system like the video (3:13) below shows?


Specifically, what I want is the versatility of the grid acting as an interactable "region", which can be used for movements, abilities, etc. I have no doubt the trigger will be paragraphs long but if I can get a general direction, I will try to figure it out as I go.
Thank you in advance.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
A grid is just a container of nodes which each contain their own set of x/y/z coordinates. Although, you probably don't care about the Z axis.

Warcraft 3 already has it's own grid system which you can see in the World Editor when you press G. You can also see your Mouse coordinates in the bottom left corner -> Point: X, Y, Z. Unfortunately, you don't get direct access to this grid, so you'll have to layer your own custom grid on top of it, but that's not really an issue. My main point is that you can already see how the game handles it's own grid and use that as a frame of reference when designing your own.

The map in the video is using what appears to be 128x128 sized nodes in their custom grid. This is the same size as a Farm or Scout Tower and if you press G in the World Editor you can see that this size is used in one of the 3 different grid sizes.

With that in mind, here's a very basic idea for getting you started:
  • Set Variable Start_Point = (Center of bottom left corner region)
  • Set Variable Index = 0
  • Set Variable X = (X of Start_Point)
  • Set Variable BaseY = (Y of Start_Point)
  • For each integer Row from 1 to 10 do Actions
    • Loop - Actions
      • Set Variable Y = BaseY
      • For each integer Column from 1 to 10 do Actions
        • Loop - Actions
          • Set Variable Index = (Index + 1)
          • Set Variable Grid_Point[Index] = Point(X, Y)
          • Set Variable Y = (Y + 128.00)
      • Set Variable X = (X + 128.00)
This will create a 10x10 grid of Point variables starting from the bottom left corner of the map and generating up and to the right.

You should think of each Grid_Point as a node in your grid.

You will probably want to save the Minimum X, Maximum X, Minimum Y, and Maximum Y coordinates of each node in a Hashtable mapped to the Index. That way you can compare your Mouse coordinates to the coordinates of a node to determine if you're moused over it. You will then want to use Images to create the actual visual that you see in the video, this isn't too difficult and there's resources on Hive that do this already.

Speaking of resources:
 
Last edited:
Level 2
Joined
Apr 28, 2024
Messages
2
A grid is just a container of nodes which each contain their own set of x/y/z coordinates. Although, you probably don't care about the Z axis.

Warcraft 3 already has it's own grid system which you can see in the World Editor when you press G. You can also see your Mouse coordinates in the bottom left corner -> Point: X, Y, Z. Unfortunately, you don't get direct access to this grid, so you'll have to layer your own custom grid on top of it, but that's not really an issue. My main point is that you can already see how the game handles it's own grid and use that as a frame of reference when designing your own.

The map in the video is using what appears to be 128x128 sized nodes in their custom grid. This is the same size as a Farm or Scout Tower and if you press G in the World Editor you can see that this size is used in one of the 3 different grid sizes.

With that in mind, here's a very basic idea for getting you started:
  • Set Variable Start_Point = (Center of bottom left corner region)
  • Set Variable Index = 0
  • Set Variable X = (X of Start_Point)
  • Set Variable BaseY = (Y of Start_Point)
  • For each integer Row from 1 to 10 do Actions
    • Loop - Actions
      • Set Variable Y = BaseY
      • For each integer Column from 1 to 10 do Actions
        • Loop - Actions
          • Set Variable Index = (Index + 1)
          • Set Variable Grid_Point[Index] = Point(X, Y)
          • Set Variable Y = (Y + 128.00)
      • Set Variable X = (X + 128.00)
This will create a 10x10 grid of Point variables starting from the bottom left corner of the map and generating up and to the right.

You should think of each Grid_Point as a node in your grid.

You will probably want to save the Minimum X, Maximum X, Minimum Y, and Maximum Y coordinates of each Grid_Point in a Hashtable mapped to the Index. That way you can compare your Mouse coordinates to the coordinates of a node to determine if you're moused over it. You will then want to use Images to create the actual visual that you see in the video, this isn't too difficult and there's resources on Hive that do this already.

Speaking of systems:
Thank you for the quick response. Wasn't expecting such a proper answer.
Will see if I can get it to work.
 
Top