Jass Vault WC3Jass.com
"The Jass Vault"
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in  
 Forum   Scripts   Files   Chat   Pastebin   Function finder  
Affiliates
The HIVE Workshop Games Modding
The Hubb Wc3Campaigns
WC3-Mapping.net

CheckPathability (By Vexorian)

 
Post new topic   Reply to topic    Jass Vault -> Geometry
View previous script :: View next script  

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

Author
BertTheJasser


Joined: 28 Apr 2005
Comments: 68
Back to top
Message
CommentPosted: Sun May 07, 2006 3:23 pm    Post subject: Reply with quote

I don't really get why to call a enum function. Plx tell me, if you can. Thx.
_________________
► BertTheJasser
View user's profile Send private message Send e-mail

Author
PipeDream


Joined: 20 Nov 2005
Comments: 294
Back to top
Message
CommentPosted: Sun May 07, 2006 9:11 pm    Post subject: Reply with quote

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
View user's profile Send private message

Author
Bob666


Joined: 29 Jun 2007
Comments: 192
Back to top
Message
CommentPosted: Mon Jul 02, 2007 7:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website

Author
Sagan


Joined: 15 Apr 2007
Comments: 4
Back to top
Message
CommentPosted: Sun Jul 22, 2007 11:15 pm    Post subject: Reply with quote

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.
View user's profile Send private message ICQ Number

Author
kixer


Joined: 13 Feb 2007
Comments: 11
Back to top
Message
CommentPosted: Fri Aug 03, 2007 1:36 pm    Post subject: Hiding Reply with quote

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...
_________________
View user's profile Send private message Send e-mail

Author
Bob666


Joined: 29 Jun 2007
Comments: 192
Back to top
Message
CommentPosted: Fri Aug 03, 2007 2:04 pm    Post subject: Reply with quote

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" Razz 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
View user's profile Send private message Visit poster's website

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Comments: 655
Back to top
Message
CommentPosted: Fri Aug 03, 2007 2:58 pm    Post subject: Reply with quote

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 Razz)
View user's profile Send private message Send e-mail Visit poster's website

Author
Bob666


Joined: 29 Jun 2007
Comments: 192
Back to top
Message
CommentPosted: Fri Aug 03, 2007 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website

Author
D4RK_G4ND4LF
Guest



Back to top
Message
CommentPosted: Tue Sep 08, 2009 7:03 pm    Post subject: D4RK_G4ND4LF Reply with quote

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 Shocked

Display posts from previous:   
Post new topic   Reply to topic    Jass Vault -> Geometry All times are GMT
Page 1 of 1

 
Jump to:  
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



FSDark by SkaidonDesigns
Powered by phpBB © 2001, 2002 phpBB Group