1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  5. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  6. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  7. The results are out! Check them out.
    Dismiss Notice
  8. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  9. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

PathingLib v1.6

Submitted by Quilnez
This bundle is marked as approved. It works and satisfies the submission rules.
Code (vJASS):

library PathingLib
   
    // Object generator
    //! external ObjectMerger w3u hgry hPLF unsf "(PathingLib) FlyChecker"   unam "" umdl ".mdl" ubdg 0 uabi "Aloc" uble 0 ulum 0 upoi 0 uico "" umxp 0 umxr 0 ussc 0 ushu "" ugol 0 uaen "" udea "" umvt "fly" usnd "" ufle 0 ufoo 0 uspe 1 uhom 1 urac "unknown" usid 0 usin 0 upgr "" uhot "" utip "" utub ""
    //! external ObjectMerger w3u hfoo hPLW unsf "(PathingLib) WalkChecker"  unam "" umdl ".mdl" ubdg 0 uabi "Aloc" uble 0 ulum 0 upoi 0 uico "" umxp 0 umxr 0 ussc 0 ushu "" ugol 0 uaen "" udea "" umvt "foot" ucol 0 usnd "" ufle 0 ufoo 0 uspe 1 uhom 1 urac "unknown" usid 0 usin 0 upgr "" uhot "" utip "" utub ""
    //! external ObjectMerger w3u hhou hPLB unsf "(PathingLib) BuildChecker" unam "" umdl ".mdl" ubdg 1 uabi "Aloc" upat "" ulum 0 upoi 0 uubs "" uble 0 ushb "" uico "" ugol 0 ufma 0 umxp 0 ubsl "" umxr 0 ussc 0 ushu "" uaen "" udea "" umvt "" ucol 0 usnd "" ufle 0 ufoo 0 uspe 1 uhom 1 urac "unknown" usid 0 usin 0 upgr "" uhot "" utip "" utub ""
    //! external ObjectMerger w3u hpea hPLP unsf "(PathingLib) PathChecker"  unam "" umdl ".mdl" ubdg 0 uabi "Aloc" uble 0 ubui "hPLF,hPLW,hPLB" ulum 0 upoi 0 uico "" umxp 0 umxr 0 ussc 0 ushu "" ugol 0 uaen "" udea "" umvt "foot" ucol 0 usnd "" ufle 0 ufoo 0 uspe 1 uhom 1 urac "unknown" usid 0 usin 0 upgr "" uhot "" utip "" utub ""
   
    // Configuration
        globals
            private constant integer PATH_CHECKER  = 'hPLP'
            private constant integer FLY_CHECKER   = 'hPLF'
            private constant integer WALK_CHECKER  = 'hPLW'
            private constant integer BUILD_CHECKER = 'hPLB'
            private constant player  DUMMY_PLAYER  = Player(15)
        endglobals
    /*
                    Pathing Library v1.6
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        Description
        ¯¯¯¯¯¯¯¯¯¯¯
            Allows you to detect all pathability types:
            walkablility, flyability, and buildability.
           
            Warning!
            Please keep informed that this system is more sensitive than
            any other walkability checker systems out there, as it also
            detects pathing map generated by normal units as well.
           
        API
        ¯¯¯
            | function IsTerrainFlyable takes real x, real y returns boolean
            | function IsTerrainWalkable takes real x, real y returns boolean
            | function IsTerrainBuildable takes real x, real y returns boolean
                   
        How to import
        ¯¯¯¯¯¯¯¯¯¯¯¯¯
            - Copy Fly, Walk, Build, and Path Checker at object editor (Unit).
            - Make sure Path Checker is able to build Fly, Walk, and Build Checker
              (at object editor>unit>Path Checker>"Techtree - Structures built")
            - Configure this system correctly.
                   
        Link: hiveworkshop.com/forums/spells-569/pathing-type-v1-2-a-263230/
    */

   
    globals
        private unit PathChecker
    endglobals
   
    function IsTerrainFlyable takes real x, real y returns boolean
        return IssueBuildOrderById(PathChecker, FLY_CHECKER, x, y)
    endfunction
   
    function IsTerrainWalkable takes real x, real y returns boolean
        return IssueBuildOrderById(PathChecker, WALK_CHECKER, x, y)
    endfunction
   
    function IsTerrainBuildable takes real x, real y returns boolean
        return IssueBuildOrderById(PathChecker, BUILD_CHECKER, x, y)
    endfunction
   
    private module Init
        private static method onInit takes nothing returns nothing
            call init()
        endmethod
    endmodule
   
    private struct InitStruct extends array
        private static method init takes nothing returns nothing
            set PathChecker = CreateUnit(DUMMY_PLAYER, PATH_CHECKER, 0, 0, 0)
            call UnitRemoveAbility(PathChecker, 'Amov')
            call ShowUnit(PathChecker, false)
            if GetLocalPlayer() == DUMMY_PLAYER then
                call FogEnable(false)
            endif
        endmethod
        implement Init
    endstruct
   
endlibrary
 


Last update:
- Added object generator

Credits:
- Special thanks to PurgeandFire for his pathability checking method!
- TheHelper.net for a complete pathing color tutorial.

Keywords:
check, terrain, pathing, pathability, walkability, flyability, buildability, color
Contents

PathingLib (Map)

Reviews
Moderator
11:40, 10th Mar 2015 IcemanBo: The system works very nicely and can be very useful. Good job.
  1. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,738
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    How sensitive is IsTerrainWalkable? For better understanding the word sensitive is used
    to describe a true positive result.

    In other words, what is the closest point to an unwalkable point returning IsWalkable?
    If I remember correctly the minimum collision size was something like 8.
    Let's say (0,0) is not walkable. Will IsTerrainWalkable(1, 0) return true or false?
    Or is the closest point (9, 0)?
     
  2. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    I'd drop

    function GetTerrainPathingColor takes real x, real y returns integer


    and all of your coloring stuff. That stuff isn't necessary ; ). The same can be accomplished with an external lib at no extra cost with more specificity to the problem.


    To support vexorian's JassHelper, you should be using a module initializer instead of the regular initializer. By using the regular initializer, a general public resource (at least one I write) can't use this.

    I have taken the opportunity to edit the script and give some more specific comments within the script itself.

    Code (vJASS):

    library PathingLib
       
        // Configuration
       
            globals
           
                private constant integer PATH_CHECKER  = 'h000'
                private constant integer FLY_CHECKER   = 'h001'
                private constant integer WALK_CHECKER  = 'h002'
                private constant integer BUILD_CHECKER = 'h003'
               
                private constant player  DUMMY_PLAYER  = Player(15)
               
            endglobals
       
        /*
       
                    Pathing Library v1.4
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                            by: Quilnez aka Dalvengyr
           
           
            Description
            ¯¯¯¯¯¯¯¯¯¯¯
                This library allows you to detect all pathability types:
                walkablility, flyability, and buildability.
               
                Warning!
                Please keep informed that this system is more sensitive than
                any other walkability checker systems out there, as it also
                detects pathing map generated by normal units as well.
               
                (You can check your pathing map by pressing 'p' at terrain editor.)
               
               
            API
            ¯¯¯

                // this is difficult to read with the description coming before the function
                // normally the functions are listed with tabbed descriptions. This is common in
                // all forms of professional documentation.
                1. Used for checking certain point's flyability
               
                    | function IsTerrainFlyable takes real x, real y returns boolean
                   
                   
                2. Used for checking certain point's walkability.
               
                    | function IsTerrainWalkable takes real x, real y returns boolean
                   
                   
                3. Used for checking certain point's buildability.
               
                    | function IsTerrainBuildable takes real x, real y returns boolean
                       
                       
            How to import
            ¯¯¯¯¯¯¯¯¯¯¯¯¯
                - Copy Fly, Walk, Build, and Path Checker (units) at object editor.
                - Make sure Path Checker is able to build Fly, Walk, and Build Checker
                  (at object editor>unit>Path Checker>"Techtree - Structures built")
                - Configure this system (available above).
                       
                       
            Credits
            ¯¯¯¯¯¯¯
                - PurgeandFire for pathability checking method.
                - TheHelper.net for complete pathing types tutorial.
                       
                       
            Link
            ¯¯¯¯
                hiveworkshop.com/forums/spells-569/pathing-type-v1-2-a-263230/
       
        */

       
        globals

            // should be pathChecker
            private unit PathChecker

        endglobals
       
        function IsTerrainFlyable takes real x, real y returns boolean
            return IssueBuildOrderById(PathChecker, FLY_CHECKER, x, y)
        endfunction
       
        function IsTerrainWalkable takes real x, real y returns boolean
            return IssueBuildOrderById(PathChecker, WALK_CHECKER, x, y)
        endfunction
       
        function IsTerrainBuildable takes real x, real y returns boolean
            return IssueBuildOrderById(PathChecker, BUILD_CHECKER, x, y)
        endfunction

        // Init library here if this is ugly -> github.com/nestharus/JASS/blob/master/jass/Systems/Init/script.j
        private module Init
            private static method onInit takes nothing returns nothing
                call init()
            endmethod
        endmodule

        private struct InitStruct extends array
            private static method init takes nothing returns nothing
       
                // should disable whatever Unit Indexing library before creating this unit

                set PathChecker = CreateUnit(DUMMY_PLAYER, PATH_CHECKER, 0, 0, 0)
                call UnitRemoveAbility(PathChecker, 'Amov')
                call ShowUnit(PathChecker, false)

                // is this line necessary? I really don't know.
                if GetLocalPlayer() == DUMMY_PLAYER then
                    call FogEnable(false)
                endif
           
            endmethod

            implement Init
        endstruct
       
    endlibrary
     


    I also recommend that, if there is a unit indexing library involved, you disable the unit indexer when creating your unit : ).

    You might also want to do 3 methods of installation.

    Method 1: Copy objects
    Method 2: Run object merger script
    Method 3: Run installation script (dynamic, see my Lua stuff on github under JASS)



    Also, having "cool" bonus functionality is not a good thing : P.


    I'm only critiquing this harshly because I think it should be used as the standard pathing library. It's better than mine too : ).

    https://github.com/nestharus/JASS/blob/master/jass/Systems/IsPathable/script.j


    In order to really be used as a core standard, it needs to have very tight code (minimal features), it needs to work with as many resources as possible (things like module initializers), and it needs to have as many methods of installation as possible for compatibility (by Lua, by inline, by copy).



    For now, I personally rate this a 4/5. Let's bring it to a perfect score ^)^.
     
  3. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,852
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    while I dont take your opinion out, you are almost like Nazi. "Making it the standard"
    a.) You are not really in position to call things standards, we are not coding for you, but for the comunity
    b.) nowhere did he say he wants this to become clear standard smashing everything to ground from now on.

    Forms of instalation, I dont think copy pasting 2 things from one map to another is really an issue, dont forget LUA doesnt work for everyone

    Also on the color, while it is extra stuff, it is still strongly related, therefore I see why it could be in the core of this system instead of new independant resource, mainly because having 50 lines resources that can be inlined into the original thing are just plain annoying and retarded(look at your shitty tables you had here). Modularity is nice thing, but having 10 line resources is just, as I said, plain retarded, mainly because there is no good way to pull scripts from internet into JassHelper, yet
     
  4. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,738
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Quite inappropriate.

    I agree on covering a disable call for a possible unit indexer tool.
    Module initializers is (sadly) a must have in every resource, which should be accessible from other resources.

    You can do the LUA thing, it's not a must have for only few objects (my opinion).
     
  5. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    I think this is perfectly precise, theoritically. Since I'm using 0 collision size for every checker unit, but thanks God they are still able to check pathability.

    @Nestharus:
    Your post is so long to quote.

    But I would like to ask you, why you love to separate every little thing? Alright the color feature is just useful in some rare cases but still, it's just some lines of codes, how terrible can it be?

    I could fix the initializer thing tho, I never knew the issue behind that method before.

    And sorry for the late response, I didn't really check my resources lately.
     
  6. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,738
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Last time I tried this together with my missile library, it was too sensitive.
    For example I the terrain was not pathable when firing a missile, because it detected the
    shooters collision. :(

    Apart from that this is really useful
     
  7. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    Yeah, it detects pathing map generated by normal units as well, unlike PnF's. That's why I call it "sensitive". I couldn't use this in my spell either because of that. :(
     
  8. Pinzu

    Pinzu

    Joined:
    Nov 30, 2007
    Messages:
    1,177
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    Suggestion: Maybe removing the collisions of all units in the search area and then setting it back would work?
     
  9. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    Sorry for late reply. No it won't work. Disabling unit collision doesn't remove the pathing map.
     
  10. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Someone else uses the Blink ability.
     
  11. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    That approach could be better :p Maybe it will ignore pathing map by units, haven't tested it tho.
     
  12. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    Update:
    - Fixed initialization issue
    - Library is now separated into PathingLib and PathingColor
    - Minimized code size
     
  13. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Excellent update.

    You still have an initializer thing in your first line of code.


    The only things left would be to generate objects specific to this resource and account for unit indexing systems.
     
  14. ZiBitheWand3r3r

    ZiBitheWand3r3r

    Joined:
    Nov 21, 2012
    Messages:
    899
    Resources:
    15
    Maps:
    7
    Spells:
    8
    Resources:
    15
    Maybe add 3 walk-checker units instead of 1.
    Base them on peon, grunt and tauren.
    This will allow you to improve this library by adding abilities to check 3 diffrent walkability sizes: 16/32/48
     
  15. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    Silly me. Forgot to update minor mistake as Nestharus pointed out.
     
  16. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,791
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Code (vJASS):

    private module Init
             private static method onInit takes nothing returns nothing
                 call init()
             endmethod
         endmodule
         
         private struct InitStruct extends array
             private static method init takes nothing returns nothing
                 set PathChecker = CreateUnit(DUMMY_PLAYER, PATH_CHECKER, 0, 0, 0)
                 call UnitRemoveAbility(PathChecker, 'Amov')
                 call ShowUnit(PathChecker, false)
                 if GetLocalPlayer() == DUMMY_PLAYER then
                     call FogEnable(false)
                 endif
             endmethod
             implement Init
         endstruct

    What exactly was the issue with the library initializer btw? The new solution seems super convoluted and I don't see the point in it.

    Also, any ideas on how to fix the unit sensitivity problem? You lib is the only one I've seen so far that takes destructables into account, but this thing also reacting to units makes it kinda unusable for missile or knockback systems.
     
  17. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    It is an issue with Vexorian's jasshelper. Picture libraries as a tree where "requires" indicates that the library is a parent. The "root" node in a tree is the one that is all the way at the top (all the children require the root, or they require a library which requires the root).

    i.e. if you have a library B that requires A, and library C that requires A, then you'll have a tree that will look something like this:

    .. A .
    ./...\.
    B....C

    Vexorian's jasshelper evaluates initializers as follows:
    • First execute the root module initializer, and then all its children's module initializers.
    • Second, execute the root struct initializers (
      private static method onInit
      ) and then all its children's struct initializers.
    • Third, execute the library initializers and all its children's library initializers.
    • Finally, execute the scope initializers and all its children's scope initializers, and then its regular Trig_Init methods (I don't remember the details for this step).

    This leads to weird problems when you try to use a library within an initialization function. If the library you require uses a library initializer whereas your child library uses a struct initializer, then your child library's init will run first.

    That's why a lot of libraries just use module initializers. They are implemented first, so you're guaranteed to have functionality when someone calls it within their initialization function. It is a minor cost of readability, but eh there isn't any way of knowing how an individual user writes his code, so it is kinda a necessary evil if you wan't your code to work in those cases. :\

    The easiest way to fix this would be to update jasshelper. Cohadar did that but he switched the parser and that gave a slew of other issues--so it never really caught on.
     
  18. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,251
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    I kinda forgot to reply. Maybe there is. But perhaps it's not a neat solution:
    Before you check a pathing just move all units around the point within.. largest unit collision size in your map, to another point. Using SetUnitX/Y will move normal unit's pathing to the new spot immediately, but not with structure unit's, it will stay. If you do so, I suppose it will work like PnF's pathing checker then. I haven't tested it tho but I'm pretty much sure bout the result ^^

    @PnF:
    Thanks man for the explanation!
     
  19. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,305
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7


    Now that the number of players has increased from 12 to 24, modifying the DUMMY_PLAYER to refer to the new slot of Neutral Passive would be recommended instead of just a hardcoded 15.
     
  20. Pinzu

    Pinzu

    Joined:
    Nov 30, 2007
    Messages:
    1,177
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    This hasn't been replaced by new natives right?