• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

A checkerboard with 3 or more types?

Status
Not open for further replies.
Diagonals are all the same color. Rotate through all colors and then repeat.

3 color checkerboard - Google-Suche
Uh, I don't know how to make a diagonal one.
[trigger=]
Checkerboard
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Set Temp_Integer_1 = 2
Set Temp_Loc_1 = (Position of Temp_Unit_1)
-------- ------------------------- --------
-------- Terrain changing system --------
-------- ------------------------- --------
Set Temp_Loc_2 = (Temp_Loc_1 offset by ((((Real(GridSize)) - 1.00) x 0.50) x (Square root((2.00 x (Power(128.00, 2.00)))))) towards 225.00 degrees)
For each (Integer A) from 1 to GridSize, do (Actions)
Loop - Actions
Set Temp_Loc_3 = (Temp_Loc_2 offset by ((Real(((Integer A) - 1))) x 128.00) towards 90.00 degrees)
For each (Integer B) from 1 to GridSize, do (Actions)
Loop - Actions
Set Temp_Loc_4 = (Temp_Loc_3 offset by ((Real(((Integer B) - 1))) x 128.00) towards 0.00 degrees)
Wait 0.00 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Temp_Integer_1 Equal to 1
Then - Actions
Environment - Change terrain type at Temp_Loc_4 to CI_Terrain_Types[0] using variation -1 in an area of size 1 and shape Square
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(GridSize mod 2) Equal to 0
((Integer A) mod 2) Equal to 1
(Integer B) Equal to GridSize
Then - Actions
Set Temp_Integer_1 = 1
Else - Actions
Set Temp_Integer_1 = 2
Else - Actions
Environment - Change terrain type at Temp_Loc_4 to CI_Terrain_Types[1] using variation -1 in an area of size 1 and shape Square
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(GridSize mod 2) Equal to 0
((Integer A) mod 2) Equal to 0
(Integer B) Equal to GridSize
Then - Actions
Set Temp_Integer_1 = 2
Else - Actions
Set Temp_Integer_1 = 1
Custom script: call RemoveLocation(udg_Temp_Loc_4)
Custom script: call RemoveLocation(udg_Temp_Loc_3)
Custom script: call RemoveLocation(udg_Temp_Loc_1)
Custom script: call RemoveLocation(udg_Temp_Loc_2)

[/trigger]
Unsure how to apply that here.
 
It's also a repeating pattern across rows. ABC-ABC-ABC then the next row down is BCA-BCA-BCA, then third down is CAB-CAB-CAB (aka the same pattern order repeats going vertically as well). You can easily modify your code to function this way.
This is as close as I could get currently, doesn't look right though not sure...? It's either 2 top or 2 right.
 

Attachments

You are probably doing something wrong with your looping, and honestly I didn't look. However, the main reason it's going to look weird is how wc3 connects adjacent tiles of the same type and layers different tiles on top of/underneath each other based on tile priority. If you attempt a grid where each tile is only 1x1 it will basically just look like diagonal lines (or for only 2 styles you get a bizarrely uneven weighting of the tiles), so to actually trick the terrain system into not doing that you need to make each square in the grid 2x2 (or 3x3).

I made a map so you can see the effects of overlapping terrain tiles and different sizes/priorities. Note that they all look like proper checkerboards on the minimap, but the in-game display is different. If you really want a 1x1 grid I think your best solution is going to be to make some custom tilesets that explicitly function the way you want (no overlapping or connecting when tiles are adjacent diagonally).
 

Attachments

You are probably doing something wrong with your looping, and honestly I didn't look. However, the main reason it's going to look weird is how wc3 connects adjacent tiles of the same type and layers different tiles on top of/underneath each other based on tile priority. If you attempt a grid where each tile is only 1x1 it will basically just look like diagonal lines (or for only 2 styles you get a bizarrely uneven weighting of the tiles), so to actually trick the terrain system into not doing that you need to make each square in the grid 2x2 (or 3x3).

I made a map so you can see the effects of overlapping terrain tiles and different sizes/priorities. Note that they all look like proper checkerboards on the minimap, but the in-game display is different. If you really want a 1x1 grid I think your best solution is going to be to make some custom tilesets that explicitly function the way you want (no overlapping or connecting when tiles are adjacent diagonally).
Well I was only using terrain to show the system easier, it will actually be images with the textures known as black32 and white so connecting/overlapping will not be an issue. However as you mentioned there is something wrong with the looping so it looks wierd as well. Any idea on how to correct the loop?
 
I didn't really look at your trigger because it seemed to be doing a lot more than it needed to.
  • Set TileImage[1] = black32.blp
  • Set TileImage[2] = white32.blp
  • Set TileImage[3] = pink32.blp
  • Set HorizWidth = 32.00
  • Set VertWidth = (-1.00 x TileWidth) //so we build from top left to bottom right
  • -------- --------
  • Set Columns = 8
  • Set Rows = 8
  • Set StartVariation = 1
  • Set NumVariations = 3
  • Set StartPoint = Wherever
  • -------- --------
  • For each (Integer RowInt) from 0 to (Rows-1) do (Actions)
    • Loop - Actions
      • Set VarInt = Modulo(StartVariation + RowInt, NumVariations)
      • For each (Integer ColInt) from 0 to (Columns-1) do (Actions)
        • Loop - Actions
          • Set TP = StartPoint offset by ((HorizWidth x Real(ColInt)), (VertWidth x Real(RowInt)))
          • Image - Create image using TileImage[VarInt] at TP
          • -------- do anything else you need to do here --------
          • Custom script: call RemoveLocation(udg_TP)
          • Set VarInt = Modulo(VarInt + 1, NumVariations)
 
I didn't really look at your trigger because it seemed to be doing a lot more than it needed to.
  • Set TileImage[1] = black32.blp
  • Set TileImage[2] = white32.blp
  • Set TileImage[3] = pink32.blp
  • Set HorizWidth = 32.00
  • Set VertWidth = (-1.00 x TileWidth) //so we build from top left to bottom right
  • -------- --------
  • Set Columns = 8
  • Set Rows = 8
  • Set StartVariation = 1
  • Set NumVariations = 3
  • Set StartPoint = Wherever
  • -------- --------
  • For each (Integer RowInt) from 0 to (Rows-1) do (Actions)
    • Loop - Actions
      • Set VarInt = Modulo(StartVariation + RowInt, NumVariations)
      • For each (Integer ColInt) from 0 to (Columns-1) do (Actions)
        • Loop - Actions
          • Set TP = StartPoint offset by ((HorizWidth x Real(ColInt)), (VertWidth x Real(RowInt)))
          • Image - Create image using TileImage[VarInt] at TP
          • -------- do anything else you need to do here --------
          • Custom script: call RemoveLocation(udg_TP)
          • Set VarInt = Modulo(VarInt + 1, NumVariations)
This doesn't seem to work very well?


other-jpg.326627


[trigger=]
Untitled Trigger 001
Events
Player - Player 1 (Red) types a chat message containing 0 as An exact match
Conditions
Actions
Set TileWidth = 32.00
Set HorzWidth = 32.00
Set VertWidth = (1.00 x TileWidth)
Set Columns = 8
Set Rows = 8
Set StartVariaton = 1
Set NumVariations = 4
Set StartPoint = (Position of Temp_Unit_1)
For each (Integer RowInt) from 1 to (Rows - 1), do (Actions)
Loop - Actions
Set VarInt = ((StartVariaton + RowInt) mod NumVariations)
For each (Integer ColInt) from 0 to (Columns - 1), do (Actions)
Loop - Actions
Set TP = (StartPoint offset by ((HorzWidth x (Real(ColInt))), (VertWidth x (Real(RowInt)))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VarInt Equal to 1
Then - Actions
Image - Create an image using Textures\white.blp of size 32.00 at TP with Z offset 0.00 using image type Ubersplat
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VarInt Equal to 2
Then - Actions
Image - Create an image using Textures\Black32.blp of size 32.00 at TP with Z offset 0.00 using image type Ubersplat
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VarInt Equal to 3
Then - Actions
Image - Create an image using Textures\white.blp of size 32.00 at TP with Z offset 0.00 using image type Ubersplat
Image - Change the color of (Last created image) to (0.00%, 100.00%, 0.00%) with 0.00% transparency
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VarInt Equal to 4
Then - Actions
Image - Create an image using Textures\white.blp of size 32.00 at TP with Z offset 0.00 using image type Ubersplat
Image - Change the color of (Last created image) to (78.00%, 42.00%, 4.00%) with 0.00% transparency
Else - Actions
Image - Change (Last created image): Enable render always state
Set VarInt = ((VarInt + 1) mod NumVariations)

[/trigger]

Currently this is what I got.

showb-jpg.326624


 

Attachments

  • showb.jpg
    showb.jpg
    706.6 KB · Views: 160
  • Checkerboard.w3x
    Checkerboard.w3x
    19.9 KB · Views: 32
  • other.jpg
    other.jpg
    641.4 KB · Views: 158
Last edited:
You are still massively overcomplicating it by trying to use some if blocks and additional counters. Get some variables and learn to use the Modulo function, because its most basic use is for repeating patterns. That being said I forgot two things in my above trigger:
  • A Set VarInt = Modulo(VarInt + 1, NumVariations) in the inner loop.
  • That to use modulo like this the indices have to start at 0, not at 1.
  • Pyro Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TileImage = Textures\white.blp
      • Set NumVariations = 0
      • Set TileColorR[NumVariations] = 0.00
      • Set TileColorG[NumVariations] = 0.00
      • Set TileColorB[NumVariations] = 0.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 0.00
      • Set TileColorG[NumVariations] = 100.00
      • Set TileColorB[NumVariations] = 0.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 78.00
      • Set TileColorG[NumVariations] = 42.00
      • Set TileColorB[NumVariations] = 4.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 100.00
      • Set TileColorG[NumVariations] = 100.00
      • Set TileColorB[NumVariations] = 100.00
      • Set NumVariations = (NumVariations + 1)
      • -------- --------
      • Set GridSize = 12
      • Set GridWidth = 256.00
      • Set StartVariation = 0
  • Pyro
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Point = (Position of Blood Mage 0002 <gen>)
      • For each (Integer RowInt) from 0 to (GridSize - 1), do (Actions)
        • Loop - Actions
          • Set VarInt = ((RowInt + StartVariation) mod NumVariations)
          • For each (Integer ColInt) from 0 to (GridSize - 1), do (Actions)
            • Loop - Actions
              • Set Point2 = (Point offset by (((Real(ColInt)) x GridWidth), ((Real(RowInt)) x GridWidth)))
              • Image - Create an image using TileImage of size 0.00 at Point2 with Z offset 0.00 using image type Ubersplat
              • Image - Change the color of (Last created image) to (TileColorR[VarInt]%, TileColorG[VarInt]%, TileColorB[VarInt]%) with 0.00% transparency
              • Image - Change (Last created image): Enable render always state
              • Set VarInt = ((VarInt + 1) mod NumVariations)
              • Custom script: call RemoveLocation(udg_Point2)
      • Custom script: call RemoveLocation(udg_Point)
Now as for the edges: the problem is that the white.blp you're using is actually a 256x256 image and the image size specification in the action where you create it actually does nothing. In my trigger above I used size 0 and it doesn't change anything; images in wc3 have always been awful and this is no exception. Change your grid size to 256 and it will appear properly. You don't need black32.blp because you can just use the white one at 0% color for all of them. Also image coordinates are in the bottom left so I changed the order to be botleft -> topright rather than topleft -> botright.
 

Attachments

You are still massively overcomplicating it by trying to use some if blocks and additional counters. Get some variables and learn to use the Modulo function, because its most basic use is for repeating patterns. That being said I forgot two things in my above trigger:
  • A Set VarInt = Modulo(VarInt + 1, NumVariations) in the inner loop.
  • That to use modulo like this the indices have to start at 0, not at 1.
  • Pyro Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TileImage = Textures\white.blp
      • Set NumVariations = 0
      • Set TileColorR[NumVariations] = 0.00
      • Set TileColorG[NumVariations] = 0.00
      • Set TileColorB[NumVariations] = 0.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 0.00
      • Set TileColorG[NumVariations] = 100.00
      • Set TileColorB[NumVariations] = 0.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 78.00
      • Set TileColorG[NumVariations] = 42.00
      • Set TileColorB[NumVariations] = 4.00
      • Set NumVariations = (NumVariations + 1)
      • Set TileColorR[NumVariations] = 100.00
      • Set TileColorG[NumVariations] = 100.00
      • Set TileColorB[NumVariations] = 100.00
      • Set NumVariations = (NumVariations + 1)
      • -------- --------
      • Set GridSize = 12
      • Set GridWidth = 256.00
      • Set StartVariation = 0
  • Pyro
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Point = (Position of Blood Mage 0002 <gen>)
      • For each (Integer RowInt) from 0 to (GridSize - 1), do (Actions)
        • Loop - Actions
          • Set VarInt = ((RowInt + StartVariation) mod NumVariations)
          • For each (Integer ColInt) from 0 to (GridSize - 1), do (Actions)
            • Loop - Actions
              • Set Point2 = (Point offset by (((Real(ColInt)) x GridWidth), ((Real(RowInt)) x GridWidth)))
              • Image - Create an image using TileImage of size 0.00 at Point2 with Z offset 0.00 using image type Ubersplat
              • Image - Change the color of (Last created image) to (TileColorR[VarInt]%, TileColorG[VarInt]%, TileColorB[VarInt]%) with 0.00% transparency
              • Image - Change (Last created image): Enable render always state
              • Set VarInt = ((VarInt + 1) mod NumVariations)
              • Custom script: call RemoveLocation(udg_Point2)
      • Custom script: call RemoveLocation(udg_Point)
Now as for the edges: the problem is that the white.blp you're using is actually a 256x256 image and the image size specification in the action where you create it actually does nothing. In my trigger above I used size 0 and it doesn't change anything; images in wc3 have always been awful and this is no exception. Change your grid size to 256 and it will appear properly. You don't need black32.blp because you can just use the white one at 0% color for all of them. Also image coordinates are in the bottom left so I changed the order to be botleft -> topright rather than topleft -> botright.
Thanks, a lot better and reminded me of a few issues with images. So a 32x32 white.blp would work then?
 
From my above trigger, the center of each square is Point2 offset by (Gridwith/2, Gridwith/2). There can be simpler ways to figure this out but you can store the 'generator' point that you used to start the whole checkerboard and then recompute the center of each tile as necessary. What specifically are you doing? You could also generate regions for each of the tiles when creating them.
 
From my above trigger, the center of each square is Point2 offset by (Gridwith/2, Gridwith/2). There can be simpler ways to figure this out but you can store the 'generator' point that you used to start the whole checkerboard and then recompute the center of each tile as necessary. What specifically are you doing? You could also generate regions for each of the tiles when creating them.
That's what I am trying to do, regions at the center however either its actually at the bottom left or top right of each tile or its size is incorrect.
Set Point3 = (Point2 offset by ((TileWidth / 2.00), (TileWidth / 2.00))) Only gave me the top right of each tile.

Currently I am trying to make a checkerboard of 4 colors and be able to easily identify which color a unit is on to do stuff too like teleport or stun or more.
 
Images being funky is the reason. If you try creating sfx at Point2 you'll see that the images themselves are not anchored by their lower left corner like they should be. It appears to me to be anchored in the center of the lower left quadrant of the image.
Guess I should try with units or sfxes & regions then... Thanks.
 
Last edited:
Status
Not open for further replies.
Back
Top