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

Make a region unpathable.

Status
Not open for further replies.
Level 14
Joined
Jul 12, 2011
Messages
1,371
Hello once again everyone.
I got a problem.
How can I make a region totally unpathabe?
I have already done this:
  • Environment - Set terrain pathing at (Center of Region 004 <gen>) of type Any to Off
But obviously it works only for the center of this region.
How can I replace the "Center of Region 004" so it can cover the hole Region 004??

Region characteristics:
Left: -640
Right: 288
Bottom: -4736
Top: -3744

Thank you.
 
Level 18
Joined
Jun 15, 2012
Messages
498
Well, I think it would be easier just placing pathing blockers (air and ground) around the region, so you don't even need to cover the region of pathing blockers, a trigger is not needed in my opinion
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Coders ask themselves the reversed question. Why place stuff manually when you can do it via trigger? The region might change position/size, the mapmaker may place other doodads at this position that also requires pathing (which would get in conflict with blockers in the editor). However, wanted to respond because just covering the border can be troublesome when you have blink spells, triggered movement or units nudge each other like when being summoned for example.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
JASS:
native GetRectMinX takes rect whichRect returns real
native GetRectMaxX takes rect whichRect returns real
native GetRectMinY takes rect whichRect returns real
native GetRectMaxY takes rect whichRect returns real

Now itterate through X and Y with an offset of 32 untill every position within the rect has been covered with for example 32x32 pathing blockers. You can set them to variables and destroy the pathing blockers whenever you need afterwards.

A simple loop (itteration) that goes through all the positions within the region (rect) should work just fine.
 
I made this:

JASS:
function RegionUnpathable takes rect r returns nothing
    local real Xmin = GetRectMinX(r)
    local real Xmax = GetRectMaxX(r)
    local real Ymin = GetRectMinY(r)
    local real Ymax = GetRectMaxY(r)
    local real x = Xmin
    local real y = Ymin
    loop
        if ( x < Xmax ) and ( y == Ymin ) then
            call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )
            set x = x + 1
        elseif ( x == Xmax ) and ( y < Ymax ) then
            call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )
            set y = y + 1
        elseif ( x > Xmin ) and ( y == Ymax ) then
            call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )
            set x = x - 1
        elseif ( y > Ymin ) then
            call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )
            set y = y - 1
            exitwhen (y == Ymin )
        endif
    endloop
endfunction

It works, but im really tired so if someone see something wrong or it can be optimized, go ahead.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
function RegionUnpathable takes rect r returns nothing
    local real Xmin = GetRectMinX(r)+16
    local real Xmax = GetRectMaxX(r)
    local real Ymin = GetRectMinY(r)+16
    local real Ymax = GetRectMaxY(r)
    local real x = Xmin
    local real y = Ymin

    loop
        exitwhen (y>yEnd)

        set x = Xmin

        loop
            exitwhen (x>xEnd)

            call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )

            set x=x+32
        endloop

        set y=y+32
    endloop
endfunction

A pathing cell is of the size 32*32. So you only need iterations worth of 32 x/y. Pathing cells originate in the left-lower corner each, so you should not include the cells of xMax/yMax, because this would add another row/column. This is why I made the offset of +16.

To be considered is that this should not be used on big regions as the 2d loop would easily accumulate enough operations to break the operation limit. Would require recursion or separation with thread instanciation then. Anyway, it is not performant anyway. Of course placing destructables with huge pathing maps is faster.
 
You can use a destructable as a pathing blocker and if you change the region size just change the destructable type with a different pathing type... As a suggestion. Of course I don't think that this way could be more efficient than blocking the maps pathing by code. It's an alternative from using pathing blockers as
 
I think that this one is the biggest square pathing texture blocker.
PathTextures\12x12Default.tga
although there are others.
PathTextures\8x8Default.tga
PathTextures\6x6Default.tga
PathTextures\4x4Default.tga
PathTextures\2x2Default.tga
These are the basic strings.

This value is placed in the field of Pathing - Pathing Texture of the destructible that you want to edit. go through the others values if you want a different one or just ask me.
I would suggest using a pathing blocker as your base destructible.
 
Status
Not open for further replies.
Top