Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,239
Straight up converted from: TerrainPathability - Wc3C.net
Should save people some time though.
Wurstbin
Should save people some time though.
Wurstbin
Wurst:
package pathable
constant real MAX_RANGE = 10.
constant integer DUMMY_ITEM_ID = 'wolg'
item pathChecker = null
rect find = null
item array hid
integer hidMax = 0
function moveBackItems()
while(hidMax > 0)
hidMax = hidMax - 1
SetItemVisible(hid[hidMax], true)
hid[hidMax] = null
function hideItem()
if IsItemVisible(GetEnumItem())
hid[hidMax] = GetEnumItem()
hid[hidMax].setVisible(false)
hidMax = hidMax + 1
function hideNearbyItems(real x, real y)
MoveRectTo(find, x, y)
EnumItemsInRect(find ,null, function hideItem)
function isTerrainWalkable(real x, real y) returns boolean
hideNearbyItems(x, y)
pathChecker.setPos(vec2(x, y))
real itemPosX = pathChecker.getX()
real itemPosY = pathChecker.getY()
pathChecker.setVisible(false)
return (itemPosX-x)*(itemPosX-x)+(itemPosY-y)*(itemPosY-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
public function vec2.isTerrainWalkable() returns boolean
return isTerrainWalkable(this.x, this.y)
public function isTerrainWalkable(vec2 pos) returns boolean
return isTerrainWalkable(pos.x, pos.y)
init
find = Rect(0., 0., 128., 128.)
pathChecker = CreateItem(DUMMY_ITEM_ID, 0, 0)
..setVisible(false)