• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] Is Pathable

Level 31
Joined
Jul 10, 2007
Messages
6,306
Uh huh, but it can check for different types of pathability and it avoids a wc3 bug that the item movement check method fails to catch.

read the comments >.>

JASS:
                //if the point was found as pathable, it may not be pathable
                //units are placed at the original coordinates if the closest pathable point is
                //at least 1024 units out
                //loop through to see if the coordinates move *away* from the original position


Also keep in mind that an item wouldn't be able to tell if something like water had ship a ship at a point or floating buildings at a point =P.


But yea, due to the wc3 bug, you have to do the loop or you could get invalid results ;\.
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
To know which integer to use, you can spoof GetHandleId as the array indices here. pathingtype only goes 0-7 so fits into an array perfectly.

JASS:
    constant pathingtype        PATHING_TYPE_ANY                = ConvertPathingType(0)
    constant pathingtype        PATHING_TYPE_WALKABILITY        = ConvertPathingType(1)
    constant pathingtype        PATHING_TYPE_FLYABILITY         = ConvertPathingType(2)
    constant pathingtype        PATHING_TYPE_BUILDABILITY       = ConvertPathingType(3)
    constant pathingtype        PATHING_TYPE_PEONHARVESTPATHING = ConvertPathingType(4)
    constant pathingtype        PATHING_TYPE_BLIGHTPATHING      = ConvertPathingType(5)
    constant pathingtype        PATHING_TYPE_FLOATABILITY       = ConvertPathingType(6)
    constant pathingtype        PATHING_TYPE_AMPHIBIOUSPATHING  = ConvertPathingType(7)

This is more intuitive and allows the user to pass in the pathingtype directly instead of some integer.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Let's see some benchmarks just what a "ton of overhead" GetHandleId is.

Here's what I know about it:

1. It was benchmarked faster than H2I.
2. Some natives are almost as fast as array lookups. This is probably one of them.
3. There's no way it has a "ton of overhead".

At most it'd be a 0.5% speed difference with what you have now.

However, it will preserve intuivity with maintaining the same names as already-existing variables, and those variables are even highlighted with syntax.

Reducing the learning curve on a lot of your libraries is definitely a good thing.

This is not a function you want to be calling on high-speed timers anyway. I can't think of a reason to use it.

Nice work on the documentation though.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Final update. This is now the best IsPathable library and the only one that fully works.

edit
60 fps vs 30 fps
JASS:
globals
    constant boolean F=true
endglobals
function r takes nothing returns nothing
    local integer x=5000
    local integer i
    loop
        static if F then
            set i=GetHandleId(PATHING_TYPE_ANY)
        else
            set i=0
        endif
        set x=x-1
        exitwhen 0==x
    endloop
endfunction
struct tester extends array
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),.015625000,true,function r)
    endmethod
endstruct

This is the last time I'm benchmarking your bs claims for you. From now on, you bench it yourself before you make them.


You need to get with the program Bribe.

edit
Oh yea, and to give you an idea of how slow GetHandleId is, it tied with the SubString and LoadInteger natives on speed.

GetHandleId is among the slowest of all of the natives... you really don't believe me, but you forget that I've been coding JASS for many years and I know these things..

when GetHandleId was done and benched against H2I, it was barely faster, and H2I was an extremely slow and heavy operation... that just automatically says that GetHandleId is among the slowest of all of the natives.

Again, before you make these suggestions of yours, you need to investigate them yourself and prove that your suggestion is better. I'm only going to investigate them if there is room for doubt.

Because you really don't seem to know any of the native speeds, you keep throwing out these absurd suggestions. You need to do your own research Bribe.

I'm just getting tired of these claims of yours Bribe... and it's especially irritating when you throw these claims that I already know are totally asinine without even testing them and then claim that I'm the dude who doesn't know anything while on your high cloud of air -.-.

Next time you make one of these really stupid claims without any backing expecting me to test it for you even though I already know the outcome, I swear I'm going to 100% ignore you.
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Nestharus, you fully missed the entire point.

I don't know how you got the idea to compare GetHandleId
to "set i = 0".

I said when compared to this whole IsPathable function, it
would add at most a 0.5% speed increase.

Now that you got rid of the loop in that function, I wouldn't
hold the same claim. I'd say maybe 15-20% speed increase
now (because it also involves creating a local), so it'd now
be worth it.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Maybe there is a failure in this benchmark but i don't see which one :

JASS:
library Test initializer init



globals

    private boolean GetHandleIdTest = false

    integer array I

endglobals



function F takes nothing returns nothing

    local integer i

    local integer j = 0

    

    loop

    exitwhen j == 6500

    set j = j+1

    

        static if GetHandleIdTest then

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

            set i = GetHandleId(PATHING_TYPE_WALKABILITY)

        else

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

            set i = I[1]

        endif

        

    endloop

    

    //call BJDebugMsg("limit op not reached")

endfunction



private function init takes nothing returns nothing

    local trigger trig = CreateTrigger()

    call TriggerSleepAction(2.)

    call BJDebugMsg("test")

    

    set I[1] = 1

    call TimerStart(CreateTimer(),0.03,true,function F)

endfunction



endlibrary

Result : about 40 fps for both tests. (without the timer i have 60 fps)

PS : Not revelant but the code i pasted is the "inputwar3map.j" created by Jasshelper, i didn't put so much new lines myself.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I changed to array and still got same results as what I had before

JASS:
globals
    constant boolean F=true
    integer array p
endglobals
function r takes nothing returns nothing
    local integer x=5000
    local integer i
    loop
        static if F then
            set i=GetHandleId(PATHING_TYPE_ANY)
        else
            set i=p[1]
        endif
        set x=x-1
        exitwhen 0==x
    endloop
endfunction
struct tester extends array
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),.015625000,true,function r)
    endmethod
endstruct
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
When i test your last code i got both 60 fps, when i set the value of x to 9000 i got 45 fps for GetHandleId et 60 fps for the array.

Correct me if i miss something but i consider my last test (i tested again and the result was still about 45 for both) as more accurate because :

- i made sure i nearly reached the limit op in the timer callback to reduce the matter of the timer callback by itself.
- i use 10 tests in the loop to reduce the matter of the loop iteration by itself.
- the timer period was higher than yours, so again it should reduce the matter of the timer callback by itself.

(i made sure i didn't reached the limit op in each tests)

So what, can we conclude these kind of tests are pretty innacurate ?

PS : Just to be sure i've removed the BJDebugMsg and the TriggerSleepAction before test it again.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Still 60
JASS:
globals
    constant boolean F=false
    integer array p
endglobals
function r takes nothing returns nothing
    local integer x=5000
    local integer i
    loop
        static if F then
            set i=GetHandleId(PATHING_TYPE_ANY)
        else
            set i=p[1]
        endif
        set x=x-1
        exitwhen 0==x
    endloop
endfunction
struct tester extends array
    private static method onInit takes nothing returns nothing
        set p[1]=1
        call TimerStart(CreateTimer(),.015625000,true,function r)
    endmethod
endstruct
 
if Warcraft 3's handle class contains, say, an integer or some similar member variable named say, myHandleID. and GetHandleID() only tried to look up that value then it should be one of the fastest natives.

However, that doesn't seem to be the case, if it's stored in a vector or array, or any other container class then it could result in slower times. If it's stored in the hashtable class then it possibly could be even slower.

Knowing Blizzard and how they coded the natives and BJ's my bet is they put it into a hashtable of sorts.

Now; regarding your system i realize that an item is faster and that a unit can check for other pathing types. Well; if the requested check for pathing is against the ground then use an item as a special case, since that'll be the most frequent check. For other cases use the unit?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
if Warcraft 3's handle class contains, say, an integer or some similar member variable named say, myHandleID. and GetHandleID() only tried to look up that value then it should be one of the fastest natives.

However, that doesn't seem to be the case, if it's stored in a vector or array, or any other container class then it could result in slower times. If it's stored in the hashtable class then it possibly could be even slower.

Knowing Blizzard and how they coded the natives and BJ's my bet is they put it into a hashtable of sorts.

I've benchmarked it and posted the script ...
 
Items are 'faster' than units in part because they use less bytes because they contain less data compared to a movable, controllable unit.

Edit: To give an actual review to make me want to use this and give it a 6/5 (yes over 100%) i ask that two things be done (well 3 if you could using items)
  1. Make the checked point, if the point checked is occupied by a building's pathing map, to 'collide' with it as otherwise that building can't be hit. (for referance use blizz AoEs buildings turn green with the AoE barly touching their col maps)
  2. Convert to JASS as an option, because using vJASS limits who can use it.
 
Last edited:
I realize this, in my opinion though either using a demo map or you LUA scripts [which are extensive] The end user is required to the same amount of work in each case. Why not give them familiar work and have a demo map?

Personally fer me, i'd rather have the demo map [even if it's vJASS] because i have problems changing my warcraft 3 from the standard stuff to using any 3rd party tool that runs with war3.
 
Level 10
Joined
May 27, 2009
Messages
494
what does pt~="blighted" means?
the ~= part o.o

i'm just creating the units one by one since I'm having problems with the LUA


oh wait, why you're using integers for X and Y? o.o it should be real right? o.o

hmm
how to check if a unit is able to walk on a point? it seems it can pass through trees O.O with the WALKABILITY pathing

EDIT:
ahh okay so this thing is different from TerrainPathability, perhaps i'll stick with TerrainPathability D:
This thing seems to work just like the natives eh?
anyways, pretty nice stuff
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
ok, terrain pathability just checks if the terrain type is pathable. This one checks if the point is pathable.

The reason it takes an integer is because it checks a 32x32 square ; P.


For trees, it shouldn't show that the path is walkable... it sounds like you probably did something wrong here. It works flawlessly for me ;o.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
hmm perhaps with the units?
can you provide a test map where I can copy the units?

don't suggest the LUA, i'm not gonna use it D:

seems like its always returning false

Sry, in cases with more than 2 objects, I don't provide a map for cnping them :\.


My suggestion is, if you ran the Lua, to look at your units and see if the towers are there (it's like neutral special or something). If they are there, then you are set. If not, then you installed it wrong.

Now, the reason why it would always be returning false (not pathable) is because it wasn't able to create the unit, meaning that it is getting coordinates of 0,0, which obviously doesn't match target coordinates, hence false =).
 
Level 10
Joined
May 27, 2009
Messages
494
well, i can't use the lua
keeps on giving jasshelper error:

unable to find ..\grimext\luadir\FILE_NAME_dir\JassGlobals.luajass.j
following this procedure:
http://www.hiveworkshop.com/forums/...art-guide-installing-lua-scripts-easy-195612/
Note: i'm not yet changing FILE_NAME to other names
O.O

even though i follow the setup of the LUA script, it will still return false, something wrong with the units aye?

edit:
please fix the integer x, integer y on the function

Edit
ok true is now working
but i'm still able to pass through a group of trees and through the pathing blocker doodad o.o
 
Last edited:
Level 7
Joined
Oct 11, 2008
Messages
304
@Jim7777

If you're not generating the object editor things (basically running the Lua right), so this is the reason why you're having issue, the system is getting the path of a null id unit :).

PS: I have the same issue with UnitIndexer, I just generate the ability, then all the issues are fixed.
 
Level 10
Joined
May 27, 2009
Messages
494
no it's not
the model of the unit is being shown (which in this case, a scout tower) swaying around each point (if safe_pathing is set to true)

anyways, its just easy to create your own object by just following the lua setup,
and for my case, i'm doing it since installing lua in my map just gives jasshelper error which is JassGlobals blah blah can't be found or doesn't exist

EDIT:

okay okay
units works now but i'm having a problem
Sometimes the snippet won't work, it will just stop randomly even though the point is pathable (like WALKABILITY) especially if it is near Pathing Blocker doodads
it randomly stops even though the tower could be built there
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
The thing is Bribe... I'm still going to have to move the unit around...


It's comparing SetUnitPosition with a x,y comparison to SetUnitX, SetUnitY, IssuePointOrder, and I don't even know if the latter will work properly. Also, IssuePointOrder has to compute the path between (a rather hefty operation) whereas SetUnitPosition only needs to do an enumeration on probably a QuadTree (just get closest neighbor searches).
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Well if you look at Knockback 2D, for example:

There's just a dummy unit, and it has a custom inferno ability with 4 levels (different collision sizes for each summon). I order him to cast to a certain point, and if the IssuePointOrder returns false that means that that point is not pathable for that specific collision size. And it works. The only thing is that it ignores trees, but you could most likely get the same result with a Pocket Factory which would not ignore trees.
 
Top