1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Check Walkability

Submitted by PurgeandFire
This bundle is marked as approved. It works and satisfies the submission rules.
  • A GUI version of:
    http://www.wc3c.net/showthread.php?t=103862

    No credits are needed. If you do give credits, then give credits to Rising_Dusk or Vexorian for the original implementation of the pathing check.

    This is to help spells when checking for pathing. I noticed that some knockbacks and such have poor checking, as they only check if the terrain walkability is off. That only checks the default pathing (cliffs and such), but the unit will slide through buildings and destructables. I know people won't use the vJASS version, so I made a GUI implementation.

  • There are two common methods for checking pathing:

    (1) Move an item there. (Vexorian/Rising_Dusk) Check if the item's position is close to the destination point. If it isn't close, then that means that the wc3 engine repositioned it because that point isn't pathable. Seems simple, right? Well, there are some issues:
    - Items are similar to unit pathing is most ways... except units can walk through items. Items can't be positioned near other items, however. This is why the enumeration is necessary--it hides items so that it accurately determines whether the point is walkable for a unit.
    - There may be some issues in really crowded areas (a.k.a. when the wc3 engine desperately has to find the nearest pathable point).
    The pros is that this method is clean, fast, and handles most cases quite nicely. And one thing is for sure, it is definitely more accurate than checking if the walkability is off (it actually combines that check + the item check).

    (2) Set a unit's position there. (Bob666 [N-a-z-g-u-l]/Nestharus) Then you perform similar checks based on that. That fixes the problem mentioned in the second point above (in really crowded areas). However, the reason why I chose the first implementation is that SetUnitPosition() fires a "stop" order and moving the unit may fire region enter events. In the end, it may be more problematic for GUI users than it is worth.

  • Initialization/Setup
    • 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

    Core
    • 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))
  • Demonstration
    • 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)

    • Go to File -> Preferences and check Automatically create unknown variables while pasting trigger data
    • Copy and paste the category "CheckWalkability"
    • (Optional) Delete the code after "Variables for Copy and Paste"
    • Use it as shown in the demo. You just set CP_Point to the point you want to check for pathability. Then you run the trigger. CP_IsPointWalkable will return whether the point is walkable.
    • Note: You may want to remove the location after using it if you no longer need it, just to prevent leaking.
Contents

Walkability Check (Map)

Reviews
Moderator
Check Walkability | Reviewed by Maker | 9th Jul 2013 APPROVED [tr] [IMG] This is a very useful system, I can seet it being used widely. There could be a variable for the tolerance.
  1. Check Walkability | Reviewed by Maker | 9th Jul 2013
    APPROVED

    [​IMG]

    • This is a very useful system, I can seet it being used widely.
      There could be a variable for the tolerance.

     
  2. jonhysone

    jonhysone

    Joined:
    Oct 29, 2012
    Messages:
    1,240
    Resources:
    1
    Maps:
    1
    Resources:
    1
    This is epic . +rep !
     
  3. Daffa the Mage

    Daffa the Mage

    Map Moderator

    Joined:
    Jan 30, 2013
    Messages:
    7,531
    Resources:
    26
    Packs:
    1
    Maps:
    8
    Spells:
    16
    Tutorials:
    1
    Resources:
    26
    I really like it, why? It's useful + No more this kind of shits : "WTF? My Hero got stuck after use my KB!! Plz Help!! I use Pathing Check!!!"
    +Rep
     
  4. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    mckill description? XD

    How about cacheing first GetEnumUnit then index it?
     
  5. Daffa the Mage

    Daffa the Mage

    Map Moderator

    Joined:
    Jan 30, 2013
    Messages:
    7,531
    Resources:
    26
    Packs:
    1
    Maps:
    8
    Spells:
    16
    Tutorials:
    1
    Resources:
    26
    Also, splitting the unused variables as a different trigger then make an unused trigger to store them is good enough I think :)
     
  6. T. D. W.

    T. D. W.

    Joined:
    Jul 31, 2012
    Messages:
    1,505
    Resources:
    5
    Spells:
    5
    Resources:
    5
    Yay, checked it, so cool it's a 5/+rep :p
     
  7. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    You mean GetEnumItem()? Eh, I thought of that, it *could* be a minor speed increase but it won't be anything in an actual scenario.

    Anyway, most of the time that part won't even fire. It is just for the odd scenarios when there happens to be an item laying on the ground. :)

    Thanks for the comments guys.
     
  8. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Ah sorry for dat typo XD
    Yup, it is just minor
     
  9. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
    That's a very misleading screenshot. :p

    Everything about the code and test-map is nice, of course.

    Not really about your system, but I just find it somewhat lame to have to emulate function calls using triggers and global variables just so that GUIers minimize their use of custom scripts.
     
  10. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Haha, I had to make it look epic. It reels you in, thinking that I made an awesome test map featuring a crazy duel between a tauren and a blood elf mage. Nope. muahaha

    I agree. It isn't really that efficient, either (TriggerExecute() calls). But ah well. GUI'ers find custom scripts scary. I can't really blame them either, since the default syntax checker for regular WE will slap you left and right for any mistake you make in the code (it'll throw 5-6 errors and disable the trigger, pretty annoying stuff).

    But I agree, it is a pretty weird method and only promotes GUI even more. However, it is better than having them code things poorly (a lot of GUI spells have poor pathing checks). So in the end I decided to make this for them :[

    P.S. Nice to see you back :D
     
  11. Daffa the Mage

    Daffa the Mage

    Map Moderator

    Joined:
    Jan 30, 2013
    Messages:
    7,531
    Resources:
    26
    Packs:
    1
    Maps:
    8
    Spells:
    16
    Tutorials:
    1
    Resources:
    26
    This + Knockback Spells = Total Awesomeness :D (for maps :D)
     
  12. Mythic

    Mythic

    Joined:
    Apr 24, 2012
    Messages:
    7,647
    Resources:
    47
    Models:
    32
    Icons:
    4
    Maps:
    3
    Spells:
    6
    Tutorials:
    2
    Resources:
    47
    I just made a knockback spell, just what I needed. It's perfect for checking pathing. Definitely a must-have for GUI users.
     
  13. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Uhh, I think I shall update my Knockback 2D
     
  14. zv27

    zv27

    Joined:
    Aug 21, 2010
    Messages:
    296
    Resources:
    0
    Resources:
    0
    Maybe I'm wrong but this only supports location [udg_CP_Point] (missing coordinates)

    With this, it is only possible to use this

    Code (vJASS):
    set udg_CP_Point = GetOrderPointLoc()

    Code (vJASS):
    set udg_CP_Point = GetSpellTargetLoc()

    and so on...
    [Very limited possibilities]

    What if someone wants to use something like this
    Example:

    Code (vJASS):
    set udg_CP_X = GetOrderPointX()

    Code (vJASS):
    set udg_CP_Y = GetOrderPointY()

    Code (vJASS):
    set udg_CP_X = GetSpellTargetX()

    Code (vJASS):
    set udg_CP_Y = GetSpellTargetY()

    Code (vJASS):
    set udg_CP_X = GetUnitX(whichUnit)

    Code (vJASS):
    set udg_CP_Y = GetUnitY(whichUnit)

    Code (vJASS):
    set udg_CP_X = GetItemX(whichItem)

    Code (vJASS):
    set udg_CP_Y = GetItemY(whichItem)

    and so on...


    Definitely, the system should support both options
    This would make the system much more complete
     
  15. T. D. W.

    T. D. W.

    Joined:
    Jul 31, 2012
    Messages:
    1,505
    Resources:
    5
    Spells:
    5
    Resources:
    5
    1. It's a system for GUIers... So they won't use the X and Y
    2. There is something that is:
    • Set CP_Point = Point(X, Y)
     
  16. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    @zv27: I'll add support for coordinates when I get back to my modding comp (probably won't get back until around Tuesday/Wednesday). I didn't really accommodate for coordinates since there aren't any GUI functions that really use them (or not much, aside from Point()). But I suppose it wouldn't hurt.

    P.S. If you have any knowledge of JASS, I highly recommend using Rising_Dusk's version. It is far better for all intents and purposes since my method relies on a TriggerExecute per function call (to support easy usage with GUI). In most cases, the performance shouldn't matter since it is still a lightweight function, but it is still wiser to use the vJASS version if you know how.
     
  17. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,218
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    • and (not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY))

    is not required to do :) EDIT: or may be I'm wrong
     
    Last edited: Mar 2, 2015
  18. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,784
    Resources:
    11
    Models:
    4
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    11
    Btw, does your method detect pathing set by
    call SetTerrainPathable( x, y, PATHING_TYPE_WALKABILITY, false )
    ?
     
  19. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    I can't be certain but hopefully that is covered by this:
    Code (vJASS):
     (not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)


    Otherwise blizzard is dumb. This is a direct port of this:
    http://www.wc3c.net/showthread.php?t=103862
    To GUI, so it inherits all the same mistakes and issues (whatever they may be).