HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

jass - why isnt this looping through the map (changing terrain + buildability on map)

01-26-2007, 04:01 AM#1
Mythic Fr0st
Ok, vertically this works

the map is like this

| |
| |

The terrain shows as

|: |
|: |

: being the terrain, vertically it goes up 100%, and covers the terrain
but horizontally it doesnt

its suppost to change entire map to grass! and unbuildable

Collapse JASS:
function Trig_Test_Actions takes nothing returns nothing
local real x_start = -1247.3
local real y_start = -1505.8
local real x = x_start
local real y = y_start
local real x_end = 1230.3
local real y_end = 1029.2
local integer i = 0
local boolean enable = true
local integer y_i = 0
local boolean covered = false

    loop
    exitwhen covered == true
    call SetTerrainPathableBJ(Location(x, y), PATHING_TYPE_BUILDABILITY, false )
    call SetTerrainTypeBJ(Location(x, y), 'Fgrd', -1, 1, 1 )
    if enable == true then
        if y >= y_end then
            set x = x + 1
            set y = y_start
            set y_i = y_i + 1
            call DisplayTextToForce( GetPlayersAll(), "loop"+I2S(y_i))
            call DisplayTextToForce( GetPlayersAll(), "x"+R2S(x))
            call DisplayTextToForce( GetPlayersAll(), "y"+R2S(y))
        endif
        set y = y + 1
    endif
    endloop
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction

It just stops, and y_i shows as 1 -.-, it should continue the loop?
01-26-2007, 04:29 AM#2
rain9441
You hit the 300,000 opcode execution limit, so warcraft killed your script.

I did something very similar and had the same problem. I ended up making a timer that did a small section of terrain changes but at a very very fast interval (0.05 or 0.10 or something) and it worked fine.

In your code: You are looping through ~2500x2500 locations (offsets of 1). Thats 6250000 points in which you are setting terrain values.

I recommend changing the offsets from (+1) to (+128). Each pathing tile is 128x128 anyway, so it'll change all the tiles. As far as buildability goes though, you'll have to use offsets of 32. By changing the loop to increment by 32 instead of 1 you are making it 1000 times faster, and by incrementing it by 128 you'll make it 16000 times faster.
01-26-2007, 04:37 AM#3
Mythic Fr0st
Ok, Thanks alot

it only runs twice like this though

Collapse JASS:
function Trig_Test_Actions takes nothing returns nothing
local real x_start = -1247
local real y_start = -1505
local real x = x_start
local real y = y_start
local real x_end = 1230
local real y_end = 1029
local integer i = 0
local integer end = 32 * 2500
local boolean covered = false
loop
    exitwhen x == end
    set y = y + 32
    call SetTerrainPathableBJ(Location(x, y), PATHING_TYPE_BUILDABILITY, false )
    //call SetTerrainTypeBJ(Location(x, y), 'Fgrd', -1, 1, 1 )
    if y >= y_end then
        set x = x + 32
        set y = y_start
        call DisplayTextToForce( GetPlayersAll(), "X = ["+R2S(x)+"]")
    endif
endloop
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction

OKAY I realized you meant y + 32 and x + 32, not just x, lol

thanks, it works now thanks (how do I know when to exit loop though)


how do I detect whether the entire map is covered? so I can exit the loop

IE
Collapse JASS:
exitwhen complete == true

if x == 32 * 2500?
set complete = true
endif

I thought something like what you said was happening

///////FIXED thanks
jass - why isnt this looping through the map (changing terrain + buildability on map) - Wc3C.net