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

Help me with algorithm for changing the tileset

Status
Not open for further replies.
Hey i'm trying to change the tiles of the whole map, by checking centemeter by centimeter the map.

I don;t have much successes. It changes some tiles, but not most and there is space between them.

My idea is to begin from the top left corner and check by incrementing the point with offset +10 and then begin from y -10 again and so on. Like rows .

here;s what I did but its not working:

I will upload a test map to show
there are 2 regions: 1 is the top corner from where the checks begin and 2. the bottom left,where it ends, if TwmpYPoint meets with the second region
it goes like:
1.increment with TilesCheckAreaIncrement until you reach the horizontal end of the map.
2. then increment vertical poiint (begin of a new row) and repeat 1. until you reach the second region which is the bottom left corner of the map

  • Command summer
    • Events
      • Player - Player 1 (Red) types a chat message containing -summer as An exact match
    • Conditions
      • SeasonSet Equal to False
    • Actions
      • -------- --------------------------------- --------
      • Set SeasonSet = True
      • -------- --------------------------------- --------
      • Set TempPoint = (Center of Region 000 <gen>)
      • Set TopCornerPoint = TempPoint
      • Set TempYPoint = TempPoint
      • Set TilesCheckAreaIncrement = 100
      • -------- --------------------------------- --------
      • -------- --------------------------------- --------
      • For each (Integer A) from 1 to (Integer((((Width of (Playable map area)) + (Height of (Playable map area))) / (Real(TilesCheckAreaIncrement))))), do (Actions)
        • Loop - Actions
          • -------- set X and Y increment coordinates of next check --------
          • -------- set X and Y coordinates of next check --------
          • Set SeasonsXCount = (SeasonsXCount + TilesCheckAreaIncrement)
          • Set TempPoint = (TempYPoint offset by (Real(SeasonsXCount)) towards 360.00 degrees)
          • -------- --------------------------------- --------
          • -------- --------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Lordaeron Fall - Dirt
            • Then - Actions
              • Environment - Change terrain type at TempPoint to Lordaeron Summer - Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Lordaeron Fall - Rough Dirt
            • Then - Actions
              • Environment - Change terrain type at TempPoint to Lordaeron Summer - Rough Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Lordaeron Fall - Grassy Dirt
            • Then - Actions
              • Environment - Change terrain type at TempPoint to Lordaeron Summer - Grassy Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Lordaeron Fall - Grass
            • Then - Actions
              • Environment - Change terrain type at TempPoint to Lordaeron Summer - Grass using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Lordaeron Fall - Dark Grass
            • Then - Actions
              • Environment - Change terrain type at TempPoint to Lordaeron Summer - Dark Grass using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • -------- --------------------------------- --------
          • -------- --------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SeasonsXCount Greater than or equal to (Integer(((Width of (Playable map area)) / (Real(TilesCheckAreaIncrement)))))
            • Then - Actions
              • Set SeasonsYCount = (SeasonsYCount + TilesCheckAreaIncrement)
              • Set TempYPoint = (TopCornerPoint offset by (Real(SeasonsYCount)) towards 270.00 degrees)
              • Set SeasonsXCount = 0
              • Custom script: call RemoveLocation(udg_TempPoint)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Region 001 <gen> contains TempYPoint) Equal to True
                • Then - Actions
                  • Skip remaining actions
                  • Custom script: call RemoveLocation(udg_TempYPoint)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_TempYPoint)
            • Else - Actions
      • Trigger - Turn off (This trigger)
 

Attachments

  • test_replacetiles.w3x
    18.1 KB · Views: 21
Last edited:
Level 18
Joined
Jan 1, 2018
Messages
728
I rewrote the trigger from scratch since it was faster than trying to debug what you already had.
Your trigger didn't work partially because you're incorrectly removing locations (when I disabled the RemoveLocations it worked 'better', but still incorrect), didn't investigate much further.

What I did different is basically:
- Use GetWorldBounds() instead of regions;
- Distance between tiles 100 -> 128;
- Nested loop instead of only one loop;
- Re-use the location by using MoveLocation().

It will still stop when it's around halfway done, this is due to JASS limitations. Solution is either to detect the trigger stopped and restart it where it left off, or change your map to lua.
 

Attachments

  • test_replacetiles - Copy.w3x
    17.1 KB · Views: 17

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Tiles are exactly 128 x 128 WC3 units square in the XY axis. The tile type limit of at most 16 tile types still applies to trigger loaded tile types, so if the map already uses many tile types any ones past the limit will select tile types that were already loaded. Due to the number of tiles on a map performing an iterative pass of all of them in a single thread instantly is prone to a thread crash, as such you will need to either use multiple threads or stagger the processing over a period of time.
 
Level 18
Joined
Jan 1, 2018
Messages
728
@Drake53 I converted it with your tool.

Your version of the command is not working as expected.

See for yourself.
This is caused by what Dr Super Good mentioned earlier:
Due to the number of tiles on a map performing an iterative pass of all of them in a single thread instantly is prone to a thread crash, as such you will need to either use multiple threads or stagger the processing over a period of time.

I did not bother fixing this since IMO the best solution is to simply use lua, but since you're on 1.26 I guess this is not an option.
I will make a working version later today when I have time.

EDIT: Fixed it.
 

Attachments

  • replacetilesv2 - Copy.w3x
    72.4 KB · Views: 24
Last edited:
Status
Not open for further replies.
Top