 |
WC3Jass.com "The Jass Vault"
|
Affiliates
|
 |
|
 |
| Script code |
function CheckPathabilityTrickGet takes nothing returns nothing
set bj_rescueChangeColorUnit = bj_rescueChangeColorUnit or (GetEnumItem()!=bj_itemRandomCurrentPick)
endfunction
function CheckPathabilityTrick takes item p, real x, real y returns boolean
local integer i=30
local rect r
call SetItemPosition(p,x,y)
if ((Pow(GetItemX(p)-x,2)+Pow(GetItemY(p)-y,2))<=100) then
return true
endif
set r=Rect(x-i,y-i,x+i,y+i)
set bj_itemRandomCurrentPick=p
set bj_rescueChangeColorUnit=false
call EnumItemsInRect(r,null,function CheckPathabilityTrickGet)
call RemoveRect(r)
set r=null
return bj_rescueChangeColorUnit
endfunction
function CheckPathability takes real x, real y returns boolean
local item it = CreateItem('ciri',x,y)
local boolean b = CheckPathabilityTrick(it,x,y)
call SetItemVisible(it,false)
call RemoveItem(it)
set it=null
return b
endfunction
|
|
 |
|
| Script info |
| Name: |
CheckPathability (By Vexorian) |
| Author: |
vile |
| Submitted: |
Mon Aug 29, 2005 3:36 pm |
| Lines: |
28 |
| Functions: |
|
|
|
| Description |
I'd like to say THANKS HEAPS to Vexorian for this function! It's SOOOO useful!
It's from his latest Raging Charge ability.
It helped me GREATLY in my knockback spells on my map, and I couldn't perfect it without him. So thanks alot.
This detects if an x/y point is pathable, that includes any destructables/doodads/cliff levels
Example:
if CheckPathability(x, y) == false then
xxxxx
endif
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Sun May 07, 2006 3:23 pm Post subject:
|
|
|
I don't really get why to call a enum function. Plx tell me, if you can. Thx. _________________ ► BertTheJasser |
|
|
|
 |
|
|
|
| Message |
Posted:
Sun May 07, 2006 9:11 pm Post subject:
|
|
|
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. _________________ jass.vim |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Mon Jul 02, 2007 7:38 pm Post subject:
|
|
|
this does not work 100%
if you have a platform which is completely filled with doodads, spots in this area will be classified as pathable...
create another item just on top of the first one, and if its the same position, if the 2 items are on the same position, then its not pathable... because both of them got stuck inside an unpathable region...
I use this function to get a nearby pathable location, not the same, but you may see what i mean:
| Code: |
function GetPathableLoc takes location P, real Collision, real MaxRange returns boolean
local unit PathingDummy
local unit PathingDummy2
local boolean PathableLocFound = true
local real X
local real Y
local real DistX
local real DistY
if Collision < 32 then
set PathingDummy = CreateUnitAtLoc(Player(15),'h016',P,0) // Collision: 12
else
set PathingDummy = CreateUnitAtLoc(Player(15),'h00Z',P,0) // Collision: 32
endif
set X = GetUnitX(PathingDummy)
set Y = GetUnitY(PathingDummy)
set DistX = X - GetLocationX(P)
set DistY = Y - GetLocationY(P)
if DistX*DistX+DistY*DistY > MaxRange*MaxRange then
set PathableLocFound = false
else
call MoveLocation(P, X, Y)
set PathingDummy2 = CreateUnitAtLoc(Player(15),'h016',P,0) // Collision: 12
if X==GetUnitX(PathingDummy2) and Y==GetUnitY(PathingDummy2) then
set PathableLocFound = false
endif
call RemoveUnit(PathingDummy2)
set PathingDummy2 = null
endif
call RemoveUnit(PathingDummy)
set PathingDummy = null
return PathableLocFound
endfunction
|
_________________ Projects:
SupCom | WC3 FlightSim | JASS Benchmark |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Sun Jul 22, 2007 11:15 pm Post subject:
|
|
|
I'm using this function:
| Code: |
function CheckCollisionXY takes real x, real y returns boolean
call SetUnitPosition(udg_CollisionUnit, x, y)
return GetUnitX(udg_CollisionUnit) == x and GetUnitY(udg_CollisionUnit) == y
endfunction
|
Where CollisionUnit is a unit that is created at map initialization and has windwalk always active. |
|
|
|
 |
|
|
|
| Message |
Posted:
Fri Aug 03, 2007 1:36 pm Post subject:
Hiding |
|
|
| Sagan wrote: |
Where CollisionUnit is a unit that is created at map initialization and has windwalk always active. |
Even though I don't agree with using a global variable, it actual would be much easier and faster than what has been said before....
However, I think you should hide the unit instead of just using windwalk... Its much safer, maybe a combination of the two... _________________
 |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Fri Aug 03, 2007 2:04 pm Post subject:
|
|
|
ive already said, that it does not work...
if the unit has no space left on the terrain level it currently is on, then it will get stuck there
my way to find that out was to create a second unit and then check if its on the same pos, as it wouldnt, if there were enough space...
and dont point at me and say "you use locations" i used them because i wanted the location to be moved to the right position, as i cant return 2 reals (well, except for using globals.... but this was easier)
nontheless it returns a boolean, if you just want to check if the location is pathable
i dont know how items act, but i believe it isnt different... and for my purpose items wouldnt help, as i need to check for place for a unit with some collision size _________________ Projects:
SupCom | WC3 FlightSim | JASS Benchmark |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Fri Aug 03, 2007 2:58 pm Post subject:
|
|
|
I guess it isn't 100% accurate, but for some purposes the function will probably suffice.
An advantage of using items rather than units is that you don't get the "Unit entered rect" event (and others) fired by accident when using it. I don't know of any such events that might be triggered when using items. It is possible that hiding the unit prevents the event from being fired, though, I don't know.
I never needed a function like this myself, but I once suggested that you use orders to detect it. Order a witch doctor to cast Evil Eye at the point, and see if the order succeeded (using the boolean it returns). Don't know if it actually works, and of course, like with the other solution, this method fires bogus events.
(And Bob666 uses locations ) |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Fri Aug 03, 2007 3:21 pm Post subject:
|
|
|
it does not work, ive tested that... if you are on such a terrain level, you can create the wards on a very very small area between cliffs and pathing blockers which leave no space between the cliff and themselves... well, blink worked, but it somehow returned the wrong boolean, or i was too stupid to get it.. (or a ==true was needed, like some other functions have that problem)
and the unit enters region events: i never thought about them, but i dont think i have those in my map... or only for waypoints, and then nothing happens with the neutral unit, but yes, that could be a problem
but the idea of creating 2 objects at the same place should also work with items _________________ Projects:
SupCom | WC3 FlightSim | JASS Benchmark |
|
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Tue Sep 08, 2009 7:03 pm Post subject:
D4RK_G4ND4LF |
|
|
2 problems:
-if you are using this with a knockback system there might be a case where a hero (32 collision size) will fit threw some 16 space
-the unit which is being knocked back might block the items/pathing checker units
Offtopic:
and it seems like items block invisible units  |
|
|
|
 |
|
|
You can submit new scripts in this section You can comment on scripts in this section You cannot edit your scripts in this section You cannot delete your scripts in this forum
|
|