Check Walkability Setup

Events


Map initialization

Conditions

Actions


Set CP_Rect = (Region(0.00, 0.00, 128.00, 128.00))


Custom script: set udg_CP_Item = CreateItem('wtlg', 0, 0)


Item - Hide CP_Item


-------- Variables For Copy and Paste --------


Set CP_HiddenItemsIndex = 0


Set CP_HiddenItems[0] = No item


Set CP_Point = (Target point of ability being cast)


Set CP_PointIsWalkable = False
Check Walkability

Events

Conditions

Actions


Custom script: local real x = GetLocationX(udg_CP_Point)


Custom script: local real y = GetLocationY(udg_CP_Point)


Custom script: local real x2 = 0


Custom script: local real y2 = 0


Custom script: call MoveRectTo(udg_CP_Rect, x, y)


Item - Pick every item in CP_Rect and do (Actions)



Loop - Actions




Custom script: if IsItemVisible(GetEnumItem()) then




Set CP_HiddenItems[CP_HiddenItemsIndex] = (Picked item)




Custom script: call SetItemVisible(udg_CP_HiddenItems[udg_CP_HiddenItemsIndex], false)




Set CP_HiddenItemsIndex = (CP_HiddenItemsIndex + 1)




Custom script: endif


Custom script: call SetItemPosition(udg_CP_Item, x, y)


Custom script: set x2 = GetItemX(udg_CP_Item)


Custom script: set y2 = GetItemY(udg_CP_Item)


Custom script: call SetItemVisible(udg_CP_Item, false)


Custom script: loop


Custom script: exitwhen udg_CP_HiddenItemsIndex <= 0


Custom script: set udg_CP_HiddenItemsIndex = udg_CP_HiddenItemsIndex - 1


Custom script: call SetItemVisible(udg_CP_HiddenItems[udg_CP_HiddenItemsIndex], true)


Custom script: set udg_CP_HiddenItems[udg_CP_HiddenItemsIndex] = null


Custom script: endloop


Custom script: set udg_CP_PointIsWalkable = ((x2-x)*(x2-x) + (y2-y)*(y2-y) <= 100) and (not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY))
Example

Events


Unit - A unit Is issued an order targeting a point

Conditions

Actions


-------- Set CP_Point to the point you want to check for walkability --------


Set CP_Point = (Target point of issued order)


-------- Run "Check Walkability" --------


Trigger - Run Check Walkability <gen> (ignoring conditions)


-------- If CP_PointIsWalkable is true, then the point is walkable --------


-------- If it is false, then it isn't pathable. --------


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




CP_PointIsWalkable Equal to True



Then - Actions




Game - Display to (All players) the text: Pathable!



Else - Actions




Game - Display to (All players) the text: Not Pathable!


Custom script: call RemoveLocation(udg_CP_Point)