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

[General] Help with more specific Terrain manipulation through JASS/Triggers

Status
Not open for further replies.
Level 5
Joined
Feb 13, 2019
Messages
128
Would it be possible to be more specific in how I want to manipulate terrain than with just regions?

I'm really just concerned with changing out tiles, I imagine through JASS this is possible?



o_O


EDIT:

Idk if I'm asking my question specifically enough, say for instance I want the grass to "grow" and change the tile but I don't want to affect the dirt path that is the road, that's possible right?
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
No, sounds like Jim wants to selectively change tiles in an arbitrary area without overwriting specific pre-existing tiles.

Yes it is possible. I believe there is a condition to check for the tile at a location as well as functions to change the tile at just that point (not in an area). If not in GUI it’s accessible in JASS. The functions take a point (or xy coordinates) and change the tile underneath that point, so all you have to do is give it the location you want to change and it will do the right tile.

Loop over all tiles in an area by incrementing some x and y variables by +-128.00 in a loop, because tiles are 128 wide this will definitively be a different tile every time even if the first point wasn’t directly in the center. Check the tile at that point and if it’s not one of the protected tiles then change it to whatever you want.
 
Level 9
Joined
Sep 20, 2015
Messages
385
Yes it's possible, but if teh area is tto big it may lag a bit. I tested this in one of my maps. Also @Pyrogasm helped me with a similar problem, but i think you can use the same code.

This is the Pyrogasm code i used to check the points of the terrain, orizontally(128) and diagonally(181)

JASS:
if angle/90 == (angle+45)/90 then
  set d = 128. //not 129.
else
  set d = 181 //128*sqrt(2)
endif
set px = px + d*Cos(angle*bj_DEGTORAD)
set py = py + d*Sin(angle*bj_DEGTORAD)
[code=jass]

If you use that with 
[code=jass]
if GetTerrainType(px, py) == LowGrass  then
             
                call SetTerrainType(px, py, GrownGrass, -1, 1, 0)
         endif
[code=jass]
 
Level 6
Joined
Mar 7, 2011
Messages
124
I think all of the above responses are good. What you're trying to do is definitely possible. I'm not sure your familiarity with JASS, so here's a bit more clarification, if you want it:
  • His code is to apply the terrain change logic in a circular-ish shape (as circular as it can be, given each tile is a square). if you wanted to adapt it for a rectangular shape, you'd replace the angle bits with two loops for length and width. if youre trying to run it on your whole map area, then youre going to have performance issues, and you'll want to think of a strategy to deal with that
  • LowGrass is a constant variable wc3neverdies defined, which refers to a Warcraft terrain ID, his excluded code probably looks like public constant integer LowGrass = 'Lgrs'. Each terrain tile has a identifier, which is the only way to reference terrain tiles in code Terrain type Raw Value. You can skip storing the terrain ID in a global unless you want to reference that ID multiple times, in which case using the global helps keep code consistent and readable
  • You could filter out multiple terrain types using "and" logic, GetTerrainType(x, y) != 'tid1' and GetTerrainType(x, y) != 'tid2'
  • You could probably do your logic just fine using a GUI trigger for both the loops representing your rectangle
 
Level 5
Joined
Feb 13, 2019
Messages
128
As always, you guys at hive are my heros.

+Rep for quick, solid responses.


Buuuuut,

Yes it's possible, but if teh area is tto big it may lag a bit. I tested this in one of my maps. Also @Pyrogasm helped me with a similar problem, but i think you can use the same code.

This is the Pyrogasm code i used to check the points of the terrain, orizontally(128) and diagonally(181)

JASS:
if angle/90 == (angle+45)/90 then
  set d = 128. //not 129.
else
  set d = 181 //128*sqrt(2)
endif
set px = px + d*Cos(angle*bj_DEGTORAD)
set py = py + d*Sin(angle*bj_DEGTORAD)
[code=jass]

If you use that with
[code=jass]
if GetTerrainType(px, py) == LowGrass  then
           
                call SetTerrainType(px, py, GrownGrass, -1, 1, 0)
         endif
[code=jass]


could you possibly throw me an example map or just walk me through how to actually implement and test that, the most I've done in my JASS studies so far is make my "hello world" :'(

Are these just custom scripts I'd throw in trigger editor?

I just mainly don't seem to grasp how the code knows the area in which it is changing the terrain :/ ?

I feel like this is a bit advanced for someone with pretty much no JASS knowledge but I am confident I could somewhat grasp it if you were willing to walk me through it, you don't have to though, I know that's a lot to ask.

Thank you all so much :)
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
It's not easy to give an example of how to use it until you can be more specific about how you want it to be used. Are there specific points of grass that you want to grow and expand, should points randomly grow and expand, or should all grass grow and expand? In what areas of the map (whole map, specific regions, etc.)? How do you envision the spreading to work chronologically? Should it take time or happen instantly? How much should it expand at once?
 
Level 5
Joined
Feb 13, 2019
Messages
128
It's not easy to give an example of how to use it until you can be more specific about how you want it to be used. Are there specific points of grass that you want to grow and expand, should points randomly grow and expand, or should all grass grow and expand? In what areas of the map (whole map, specific regions, etc.)? How do you envision the spreading to work chronologically? Should it take time or happen instantly? How much should it expand at once?

That's fair :razz: Sorry haha.


I’ll be honest. I was being purposely obscure in the hopes of learning this myself to have my first real resource to present to hive, but the fact of the matter is as of right now I’m simply not knowledgeable enough to execute this myself, and I think if it was hive minded (hehe) we’d have a really awesome little system for the WC community so here we go.

A weather system.

So I’m thinking we use village tile, slowly over time in an aesthetically pleasing, and realistic way, some tiles and trees change to the fall set, until it’s completely the fall set, and then what I imagine the real trick would be is we start to add snow tiles in specific areas, until it is all snow except say the roads and certain patches of grass until it’s deep winter, and then the snow could “melt” by basically the reverse happening.

Serenity said he would think about how this could be done, but it would take me quite some time to produce.

I’m all for doing it myself, and honestly wanted to so I could finally have something to bring to the table to pay you guys back for all the help I’ve received, but I certainly wouldn’t argue with anyone taking the reins or pointing me in the right direction! :wgrin:
 
Level 9
Joined
Sep 20, 2015
Messages
385
Well that seems a very complicated stuff. The code i showed you is only a small parto of my entire trigger. The trigger is made to spread fire on the yellow grass tile. The code i posted can be used to check tarrain type around a point.

I suggest you to learn JASS because if you want to do that in GUI it would be very clunky and tedious to make.

If you want to change the terrain across the whole map i don't know if it's a good method, maybe there is a better way to do it. It needs to be a slow process otherwise it may lagg a bit.

The first thing i suggest you to do is to create global variables for terrain types as Serenity90 said, and global variables for trees types.

You can't "reverse" the process, you can just replace the snow with grass tyles.


I think you can do it with a loop, that every 5 or 6 seconds checks for the terrain type and change it to the current season terrain, in the loop you also checks for destructables (trees) and change them as well.
 
Status
Not open for further replies.
Top