• 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.

How do you check every point in a map?

Are you a n00b or a n00b eater?

  • y35 1 15 n00b loloololllol!1!!!!!1

    Votes: 0 0.0%

  • Total voters
    14
Status
Not open for further replies.
I want to create a trigger that checks every single point in a map. That way, say I made a map using the Lordaeron Summer Tile Set; I could check each tile and then run conditions and actions that would convert each tile into its equivalent in the Lordaeron Fall Tile Set, Winter Tile Set, etc.

I would like to mention I am proficient with triggers and know how to use variables. I'm not very good with Jass but it probably won't kill me as I've managed to make a save/load system before X.X
 
Level 3
Joined
Sep 13, 2008
Messages
63
This should change terrain from one type to another. For changing more then one terrain type you'll need to call this a few times.

Terrain types are stored as integers, but are inputted as 'Fdrt' (see example below). To find the terrain codes make a GUI variable for terrain type, in a trigger get the variable to whatever terrain, then convert the trigger to JASS (Edit > Convert to Custom Text).

BTW, do you have vJASS?
Oh, and as always, this is untested, so I don't know if it works.

JASS:
function ConvertTerrain takes integer old, integer new returns nothing
    local rect r = GetWorldBounds()
    local real minX = GetRectMinX(r)
    local real maxX = GetRectMaxX(r)
    local real minY = GetRectMinY(r)
    local real maxY = GetRectMaxY(r)
    local real x = minX
    local real y = minY
    loop
        loop
            if GetTerrainType(x,y) == old then
                call SetTerrainType(x, y, new, GetTerrainVariance(x, y), 1, 1)
            endif
            set y = y + 128.00
            exitwhen y >= maxY
        endloop
        set y = minY
        set x = x + 128.00
        exitwhen x >= maxX
    endloop
    //Cleanup
    call RemoveRect(r)
    set r = null
    set minX = 0
    set maxX = 0
    set minY = 0
    set maxY = 0
    set x = 0
    set y = 0
endfunction

Example of usage:
JASS:
//Put this inside a function
call ConvertTerrain('Ldrt', 'Fdrt')
 
Last edited:
Level 3
Joined
Sep 13, 2008
Messages
63
There is no need to "null" all those reals.
I know I probably don't need to set all the reals to 0, but I have a habit of it.

Out of curiosity, if you leave a real with a large number does it takes up more memory then leaving it as a zero?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Out of curiosity, if you leave a real with a large number does it takes up more memory then leaving it as a zero?

No. A variable allocates all the memory it may take at the maximum. A float (real in warcraft) is 4 bytes, doesn't matter if the value it holds is 0, 0.01, or 394485.495842.

And setting them to zero is just making the computer work more for no reason.
 
Status
Not open for further replies.
Top