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: 319

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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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