Snippet IsPositionPathable

Andrewgosu

The Silent Pandaren Helper
Reaction score
716

Cohadar

master of fugue
Reaction score
209
Will this return false if there is some unit on a normally pathable location?
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Perhaps group all units in a certain radius around the x,y coordinates and set off their collision? And then set it on after for sure. Since there are no waits it shouldn't be a problem at all or?
 

emjlr3

Change can be a good thing
Reaction score
395
looks neat, but i do think it could bug if there is a unit there already, but then, i guess it would not be pathable then either :p
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
So far it works as designed (please, prove me wrong. I know it can be done).

A tree, doodad or a unit, not to mention a cliff, is in the way - BOOM!

False.
 

emjlr3

Change can be a good thing
Reaction score
395
what unit is 'hfoo'?
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Just a regular footman, though, I can be replaced with anything.

The check is instant, so the "dummy" unit is never seen.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
So far it works as designed (please, prove me wrong. I know it can be done).

A tree, doodad or a unit, not to mention a cliff, is in the way - BOOM!

False.

Hmmm but still... most spells or whatever don't care if a UNIT is blocking the way, therefore people must add some stuff to avoid it. Idea behind is fine though and since it seems to work (did you test?) why not :s
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Why not make a test map that proved everything that is stucking in the way return false?
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
The test maps shows that the function will return false, if a unit, destructible or a cliff is on the way.

It worked...
 

Attachments

  • IsPositionPathable_Andrewgosu_2008.w3x
    10.2 KB · Views: 317

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
http://www.wc3jass.com/viewtopic.php?t=2374

Read the comments on that system.

If a unit is created in a region that is unpathable due to doodads, it will stil be created there as a stuck unit. Creating a second unit on top of the first and checking whether the X and Y are the same as unit 1 fixes this. (Since then it would indeed be a "stuck" loacation since one unit got created ontop of another one, which normally can't happen)


Vexorian uses items with an enum, here's why:
If the reason the test item wasn't in the right spot is because there's an item already there, then the terrain is pathable.

This will solve the "pathable, but another unit was in the way..." issue
 

emjlr3

Change can be a good thing
Reaction score
395
if a unit is in the way its not pathable is it?, in which case, you could check to see if its a unit in that loc, and return a boolean
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
What if you want to use a custom blink, surely you'd want the unit to actually blink, but instead of landing ontop of the other unit, you'd be landing next to it...
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
On top of the unit sounds worse than next to it.

I am sure this snippet(*) works 99 times out of 100, when used on a normal map, not some kind of monstrosity with no pathable places at all.


(*)Yes, a snippet.

Not an overly complicated system.
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
JASS:
library PathingFuncs initializer init
    globals
        private constant real ItemSafeX = 0. //This is the X coordinate of a point that nobody can get to on your map.
        private constant real ItemSafeY = 0. //This is the Y coordinate of the same point. It's to keep from having hidden
        private item I                       //item errors, such as comps picking them up, etc.
        private unit U
    endglobals

    function IsPointPathable takes real x, real y, boolean evalunits returns boolean
        local boolean b
        if(evalunits)then
            call ShowUnit(U,true)
            call SetUnitPosition(U,x,y)
            set b=GetUnitX(U)==x and GetUnitY(U)==y
            call ShowUnit(U,false)
        else
            call SetItemVisible(I,true)
            call SetItemPosition(I,x,y)
            set b=GetItemX(I)==x and GetItemY(I)==y
            call SetItemPosition(I,ItemSafeX,ItemSafeY)
            call SetItemVisible(I,false)
        endif
        return b
    endfunction
    
    private function init takes nothing returns nothing
        set I=CreateItem('ward',ItemSafeX,ItemSafeY)
        call SetItemInvulnerable(I,true)
        call SetItemVisible(I,false)
        set U=CreateUnit(Player(15),'hfoo',ItemSafeX,ItemSafeY,0.)
        call SetUnitInvulnerable(U,true)
        call ShowUnit(U,false)
    endfunction
endlibrary
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
I've made my own stuff yesterday because I needed something that doesn't count orgranic units [btw, how is the unit state orgranic/living (no structure^^) called in JASS? I didn't figure it out and took mechanic == false :O].

So I groupenum units in a certain range of the targeted point and turn off their collision and afterwards turn it on again.
An other problem was that the reals were always slightly different so that the function returned false always. Hence I converted the reals to integers and back again, which worked.
Dunno if i needn't do this with items though :S

This is what fit my purposes ;S
JASS:
library Pathability

function FiltLiving takes nothing returns boolean
    return IsUnitType(GetFilterUnit(),UNIT_TYPE_MECHANICAL) == false
endfunction

function PathOff takes nothing returns nothing
    call SetUnitPathing(GetEnumUnit(),false)
endfunction

function PathOn takes nothing returns nothing
    call SetUnitPathing(GetEnumUnit(),true)
endfunction

function IsPositionPathable takes real x, real y, integer radius returns boolean // radius to define the AOE around the location
local boolean flag                                                               // in which the units collision shall be turned off
local real xnew  = I2R(R2I(x))
local real ynew = I2R(R2I(y))
local group g = CreateGroup()
local unit tester
    call GroupEnumUnitsInRange(g,x,y,radius,Filter(function FiltLiving))
    call ForGroup(g, function PathOff)
    set tester = CreateUnit(Player(15), 'hmtm', xnew, ynew, 0)
    set flag = (GetUnitX(tester) == xnew) and (GetUnitY(tester) == ynew)
    call RemoveUnit(tester)
    call ForGroup(g, function PathOn)
    call DestroyGroup(g)
    set g = null
    set tester = null
    return flag
endfunction

endlibrary
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top