• 🏆 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!

Need help to create a trigger!

Status
Not open for further replies.
Level 15
Joined
Aug 11, 2009
Messages
1,606
Hey guys!
I am making a random terrain trigger...until now here is what i have done
  • Create Terrain
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Random_Terrain[1] = Lordaeron Summer - Dirt
      • Set Random_Terrain[2] = Lordaeron Summer - Rough Dirt
      • Set Random_Terrain[3] = Lordaeron Summer - Grassy Dirt
      • Set Random_Terrain[4] = Lordaeron Summer - Rock
      • Set Random_Terrain[5] = Lordaeron Summer - Grass
      • Set Random_Terrain[6] = Lordaeron Summer - Dark Grass
      • Set Random_Terrain[7] = Lordaeron Fall - Dirt
      • Set Random_Terrain[8] = Lordaeron Fall - Rough Dirt
      • Set Random_Terrain[9] = Lordaeron Fall - Grassy Dirt
      • Set Random_Terrain[10] = Lordaeron Fall - Rock
      • Set Random_Terrain[11] = Lordaeron Fall - Grass
      • Set Random_Terrain[12] = Lordaeron Fall - Dark Grass
      • Set Random_Terrain[13] = Lordaeron Winter - Dirt
      • Set Random_Terrain[14] = Lordaeron Winter - Rough Dirt
      • Set Random_Terrain[15] = Lordaeron Winter - Grassy Snow
      • Set Random_Terrain[16] = Lordaeron Winter - Rock
      • Set Random_Terrain[17] = Lordaeron Winter - Grass
      • Set Random_Terrain[18] = Lordaeron Winter - Snow
      • Set Random_Terrain[19] = Barrens - Dirt
      • Set Random_Terrain[20] = Barrens - Rough Dirt
      • Set Random_Terrain[21] = Barrens - Pebbles
      • Set Random_Terrain[22] = Barrens - Grassy Dirt
      • Set Random_Terrain[23] = Barrens - Desert
      • Set Random_Terrain[24] = Barrens - Dark Desert
      • Set Random_Terrain[25] = Barrens - Rock
      • Set Random_Terrain[26] = Barrens - Grass
      • Set Random_Terrain[27] = Ashenvale - Dirt
      • Set Random_Terrain[28] = Ashenvale - Rough Dirt
      • Set Random_Terrain[29] = Ashenvale - Grass
      • Set Random_Terrain[30] = Ashenvale - Rock
      • Set Random_Terrain[31] = Ashenvale - Lumpy Grass
      • Set Random_Terrain[32] = Ashenvale - Vines
      • Set Random_Terrain[33] = Ashenvale - Grassy Dirt
      • Set Random_Terrain[34] = Ashenvale - Leaves
      • Set Random_Terrain[35] = Felwood - Dirt
      • Set Random_Terrain[36] = Felwood - Rough Dirt
      • Set Random_Terrain[37] = Felwood - Poison
      • Set Random_Terrain[38] = Felwood - Rock
      • Set Random_Terrain[38] = Felwood - Vines
      • Set Random_Terrain[39] = Felwood - Grass
      • Set Random_Terrain[40] = Felwood - Leaves
      • Set Random_Terrain[41] = Northrend - Dirt
      • Set Random_Terrain[42] = Northrend - Dark Dirt
      • Set Random_Terrain[43] = Northrend - Rock
      • Set Random_Terrain[44] = Northrend - Grass
      • Set Random_Terrain[45] = Northrend - Ice
      • Set Random_Terrain[46] = Northrend - Snow
      • Set Random_Terrain[47] = Northrend - Rocky Snow
      • Set Random_Terrain[48] = Cityscape - Dirt
      • Set Random_Terrain[49] = Cityscape - Rough Dirt
      • Set Random_Terrain[50] = Cityscape - Black Marble
      • Set Random_Terrain[51] = Cityscape - Brick
      • Set Random_Terrain[52] = Cityscape - Square Tiles
      • Set Random_Terrain[53] = Cityscape - Round Tiles
      • Set Random_Terrain[54] = Cityscape - Grass
      • Set Random_Terrain[55] = Cityscape - Grass Trim
      • Set Random_Terrain[56] = Cityscape - White Marble
      • Set Random_Terrain[57] = Village - Dirt
      • Set Random_Terrain[58] = Village - Rough Dirt
      • Set Random_Terrain[59] = Village - Crops
      • Set Random_Terrain[60] = Village - Cobble Path
      • Set Random_Terrain[61] = Village - Stone Path
      • Set Random_Terrain[62] = Village - Short Grass
      • Set Random_Terrain[63] = Village Fall - Rocks
      • Set Random_Terrain[64] = Village Fall - Thick Grass
      • Set Random_Terrain[65] = Dalaran - Dirt
      • Set Random_Terrain[66] = Dalaran - Rough Dirt
      • Set Random_Terrain[67] = Dalaran - Black Marble
      • Set Random_Terrain[68] = Dalaran - Brick Tiles
      • Set Random_Terrain[69] = Dalaran - Square Tiles
      • Set Random_Terrain[70] = Dalaran - Round Tiles
      • Set Random_Terrain[71] = Dalaran - Grass
      • Set Random_Terrain[72] = Dalaran - Trim Grass
      • Set Random_Terrain[73] = Dalaran - White Marble
      • Set Random_Terrain[74] = Dungeon - Dirt
      • Set Random_Terrain[75] = Dungeon - Brick
      • Set Random_Terrain[76] = Dungeon - Red Stones
      • Set Random_Terrain[77] = Dungeon - Lava Cracks
      • Set Random_Terrain[78] = Dungeon - Lava
      • Set Random_Terrain[79] = Dungeon - Dark Rocks
      • Set Random_Terrain[80] = Dungeon - Grey Stones
      • Set Random_Terrain[81] = Dungeon - Square Tiles
      • Set Random_Terrain[82] = Underground - Dirt
      • Set Random_Terrain[83] = Underground - Brick
      • Set Random_Terrain[84] = Underground - Red Stones
      • Set Random_Terrain[85] = Underground - Lava Cracks
      • Set Random_Terrain[86] = Underground - Lava
      • Set Random_Terrain[87] = Underground - Dark Rocks
      • Set Random_Terrain[88] = Underground - Grey Stones
      • Set Random_Terrain[89] = Underground - Square Tiles
      • Set Random_Terrain[90] = Sunken Ruins - Dirt
      • Set Random_Terrain[91] = Sunken Ruins - Rough Dirt
      • Set Random_Terrain[92] = Sunken Ruins - Grassy Dirt
      • Set Random_Terrain[93] = Sunken Ruins - Small Bricks
      • Set Random_Terrain[94] = Sunken Ruins - Sand
      • Set Random_Terrain[95] = Sunken Ruins - Large Bricks
      • Set Random_Terrain[96] = Sunken Ruins - Round Tiles
      • Set Random_Terrain[97] = Sunken Ruins - Grass
      • Set Random_Terrain[98] = Sunken Ruins - Dark Grass
      • Set Random_Terrain[99] = Icecrown Glacier - Dirt
      • Set Random_Terrain[100] = Icecrown Glacier - Rough Dirt
      • Set Random_Terrain[101] = Icecrown Glacier - Dark Ice
      • Set Random_Terrain[102] = Icecrown Glacier - Black Bricks
      • Set Random_Terrain[103] = Icecrown Glacier - Rune Bricks
      • Set Random_Terrain[104] = Icecrown Glacier - Tiled Bricks
      • Set Random_Terrain[105] = Icecrown Glacier - Ice
      • Set Random_Terrain[106] = Icecrown Glacier - Black Squares
      • Set Random_Terrain[107] = Icecrown Glacier - Snow
      • Set Random_Terrain[108] = Outland - Dirt
      • Set Random_Terrain[109] = Outland - Light Dirt
      • Set Random_Terrain[110] = Outland - Rough Dirt
      • Set Random_Terrain[111] = Outland - Cracked Dirt
      • Set Random_Terrain[112] = Outland - Flat Stones
      • Set Random_Terrain[113] = Outland - Rock
      • Set Random_Terrain[114] = Outland - Light Flat Stones
      • Set Random_Terrain[115] = Outland - Abyss
      • Set Random_Terrain[116] = Black Citadel - Dirt
      • Set Random_Terrain[117] = Black Citadel - Light Dirt
      • Set Random_Terrain[118] = Black Citadel - Rough Dirt
      • Set Random_Terrain[119] = Black Citadel - Flat Stones
      • Set Random_Terrain[120] = Black Citadel - Small Bricks
      • Set Random_Terrain[121] = Black Citadel - Large Bricks
      • Set Random_Terrain[122] = Black Citadel - Square Tiles
      • Set Random_Terrain[123] = Black Citadel - Dark Tiles
      • Set Random_Terrain[124] = Dalaran Ruins - Dirt
      • Set Random_Terrain[125] = Dalaran Ruins - Rough Dirt
      • Set Random_Terrain[126] = Dalaran Ruins - Black Marble
      • Set Random_Terrain[127] = Dalaran Ruins - Brick Tiles
      • Set Random_Terrain[128] = Dalaran Ruins - Square Tiles
      • Set Random_Terrain[129] = Dalaran Ruins - Round Tiles
      • Set Random_Terrain[130] = Dalaran Ruins - Grass
      • Set Random_Terrain[131] = Dalaran Ruins - Trim Grass
      • Set Random_Terrain[132] = Dalaran Ruins - White Marble
      • For each (Integer A) from 1 to 256, do (Actions)
        • Loop - Actions
          • Set Random_Position = (Random point in (Entire map))
          • Environment - Change terrain type at Random_Position to Random_Terrain[(Random integer number between 1 and 132)] using variation -1 in an area of size (Random integer number between 1 and 4) and shape Circle
          • Custom script: call RemoveLocation (udg_Random_Position)
      • For each (Integer A) from 1 to 128, do (Actions)
        • Loop - Actions
          • Set Random_Position = (Random point in (Entire map))
          • Environment - Change terrain type at Random_Position to Random_Terrain[(Random integer number between 1 and 132)] using variation -1 in an area of size (Random integer number between 1 and 2) and shape Circle
          • Custom script: call RemoveLocation (udg_Random_Position)
      • For each (Integer A) from 1 to 64, do (Actions)
        • Loop - Actions
          • Set Random_Position = (Random point in (Entire map))
          • Environment - Change terrain type at Random_Position to Random_Terrain[(Random integer number between 1 and 132)] using variation -1 in an area of size (Random integer number between 1 and 10) and shape Circle
          • Custom script: call RemoveLocation (udg_Random_Position)
      • For each (Integer A) from 1 to 32, do (Actions)
        • Loop - Actions
          • Set Random_Position = (Random point in (Entire map))
          • Environment - Change terrain type at Random_Position to Random_Terrain[(Random integer number between 1 and 132)] using variation -1 in an area of size (Random integer number between 1 and 3) and shape Square
          • Custom script: call RemoveLocation (udg_Random_Position)
The problem is...that the same random position is picked again and again and i end up having just half of my map terrained.Is there any way to check the picked point and choose a different one each time?

+Rep for the one who solves my problem.
Thanks!
 
I know the random seed thing,its not this...and as i mentioned i just get half of the map terrained so it works...but the problem is that chooses every time a random point.The same point might get picked more than once...this is what i want to track and make it pick different ones...

maybe you can have a base tile that is present in the whole map at first (in the editor) then check if the point's terrain is that then change its terrain so it wont change the terrain if the terrain of the picked point is equal to the base... then I would suggest you use a variable for the loop end integer so that you can reset it if the terrain picked is not equal to the base or maybe you can already add as a condition for the random pick... sorry if this is a little vague, I dont have my editor right not so I cannot try it and create the trigger...
 
Level 15
Joined
Aug 11, 2009
Messages
1,606
maybe you can have a base tile that is present in the whole map at first (in the editor) then check if the point's terrain is that then change its terrain so it wont change the terrain if the terrain of the picked point is equal to the base... then I would suggest you use a variable for the loop end integer so that you can reset it if the terrain picked is not equal to the base or maybe you can already add as a condition for the random pick... sorry if this is a little vague, I dont have my editor right not so I cannot try it and create the trigger...

I didn't quite understood this..but i don't think it will work,i also want the terrain to be totally random each time.

Gonna check the map you mentioned,too.
 
Level 4
Joined
Nov 7, 2009
Messages
83
Maybe you could make an array to simbolize the 32x32 squares in the map (a 2D array that represents the map), then initialize it with al null values and start assigning random terrains to the regions, if the value is not null, pick another region. Also add a counter that counts how many regions you have terrained (increase value by 1 each time you terrain a 32x32 region) and when the value of the counter equals the amount of regions, you are done.
 
Level 15
Joined
Aug 11, 2009
Messages
1,606
Maybe you could make an array to simbolize the 32x32 squares in the map (a 2D array that represents the map), then initialize it with al null values and start assigning random terrains to the regions, if the value is not null, pick another region. Also add a counter that counts how many regions you have terrained (increase value by 1 each time you terrain a 32x32 region) and when the value of the counter equals the amount of regions, you are done.

Hmmm,could you show me an example?
EDIT:
Never mind a made a completely different trigger now...but it doesn't work and i really cannot understand why...+rep for the one who fixes it.
Map Attached.
 
Last edited:
Level 4
Joined
Nov 7, 2009
Messages
83
It's just too big, and I think it will have nearly the same trouble than the first one you did, so I'll try to explain with some few images

First, your map is something like this
Blur.png


Now, each of the squares is a region of 32x32 I think, so, you would need a 2D array to represent the whole map.

As GUI has no 2D arrays, you'll have to use a 1D array with size rows*columns.

f3-4.png


When you complete the array with random values, you'll search it like this: array[row i*(columns)+column j] (in C like, row major) and assign it to it's corresponding region in the map.

array2d.png


I don't know if that's clear enough.

Then, when you fill up the 1D array, you loop until every position has a random terrain, if a position has a null terrain, you put a random one and increase a counter, if it is not null, you just pick another position. When the counter equals rows*columns, you exit the filling loop.
 
Status
Not open for further replies.
Top