wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-30-2008, 04:57 AM   #1
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default TerrainPathability

TerrainPathability Library

Background:
This is a library of code that allows users to detect whether a given point of terrain is land, shallow water, deep water, or walkable with great simplicity.

Requirements:
  • (None)
Credits:Code:
Expand Library:

Function List:
This library provides the following functions to the user.
  • function IsTerrainDeepWater takes real x, real y returns boolean
  • function IsTerrainShallowWater takes real x, real y returns boolean
  • function IsTerrainLand takes real x, real y returns boolean
  • function IsTerrainPlatform takes real x, real y returns boolean
  • function IsTerrainWalkable takes real x, real y returns boolean
I also attached a testmap that shows my method in action. Originally, this library used a windwalk'd unit to detect walkability of terrain, but after some benchmarks, the item method proved to be reliably and significantly faster. Anitarf then agreed that I should use that version of the walkability check in this library, as originally used in his resource, so here it is. If you used the older version of this library, you can go ahead and delete the windwalk dummy ability, it's no longer necessary. Fly the Gryphon around and you can see what the system returns for wherever it is at any given time.

Backwards Compatibility:
In the event that you used IsTerrainWalkable in your map, the following backwards compatibility library has been provided for your convenience. Simply replace the old library with the library below and it will work fine.
Expand IsTerrainWalkable:

Enjoy!
Attached Files
File Type: w3x TerrainPathabilityTestMap.w3x (35.2 KB, 162 views)
__________________

Last edited by Rising_Dusk : 12-07-2009 at 01:51 AM. Reason: Updated
Rising_Dusk is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-30-2008, 10:51 AM   #2
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Nice resource.
Few points :

- You should add a constant dummy player.
- What about move the unit outside the playable map area if it was moved ?
I mean she is insivible, with no collision and all, but the unit still can be enumed.
__________________
Cool != Useful

Last edited by Troll-Brain : 12-30-2008 at 10:52 AM.
Troll-Brain is offline   Reply With Quote
Old 12-30-2008, 12:58 PM   #3
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

Collapse JASS:
not (not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)

huh...don't they cancel out, like a double negative?
__________________
emjlr3 is offline   Reply With Quote
Old 12-30-2008, 01:05 PM   #4
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

emjlr3 double check that expression ...
--
I think the bunch of other things to detect are a little useless. All that was needed was walkable, the rest we already had natives for, I think it is simpler to just call IsTerrainPathable in cases when we want to detect land or water. Just saying this so it could just remain 'IsTerrainWalkable' but using the new method so that migration would be easy, both things do the same and detecting true on deep water was just a bug so, it is natural to "fix it" by using this new method. Though I think that having to use a dummy ability is a little too much, aren't there passive abilities that do the same windwalk does? Or you could add the IsTerrainWalkable function to what you have now and also a library library IsTerrainWalkable that requires this new one that has all these constants.

Quote:
I mean she is insivible, with no collision and all, but the unit still can be enumed.
Should probably hide the unit.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 12-30-2008, 01:58 PM   #5
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

yea I figured I had missed the other )

Quote:
Should probably hide the unit.

or 'Aloc' it (not sure what 'Avul' does - i assume its for invulnerability)
__________________

Last edited by emjlr3 : 12-30-2008 at 01:59 PM.
emjlr3 is offline   Reply With Quote
Old 12-30-2008, 03:49 PM   #6
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Use 'Aloc' will not work since an unit witch have this ability can be on every pathing, that would be a nice function witch always return true, but hide/unhide the unit is the way to go i think.
Hmm but for some reasons if a player use a group for filter hidden units in a range R on X/Y, then the hidden unit would be enumed so.
And if you place the unit outside the playable map area, i don't see any problem, but correct me if i'm wrong.
__________________
Cool != Useful

Last edited by Troll-Brain : 12-30-2008 at 03:50 PM.
Troll-Brain is offline   Reply With Quote
Old 12-30-2008, 04:59 PM   #7
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

doesn't that crash maps online? - thus the needed for map border checks when using SetUnitX/Y
__________________
emjlr3 is offline   Reply With Quote
Old 12-30-2008, 05:01 PM   #8
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Troll-Brain
- You should add a constant dummy player.
It is unnecessary, but I will do it anyways for completeness of constants.
Quote:
Originally Posted by Vexorian
I think the bunch of other things to detect are a little useless.
If you look at my knockback system in the database, being able to differentiate between shallow water and land is incredibly useful. It is also useful if you want spells to do different things on shallow water as opposed to land, which can be practical for different map types. I only included deep water because I had shallow water and land and wanted the complete spectrum.
Quote:
Originally Posted by Vexorian
the rest we already had natives for
I am aware that we can check the tile, but I was not aware that we could check shallow water/land/etc. What native is it?
Quote:
Originally Posted by Vexorian
Should probably hide the unit.
Generally, most mapmakers exclude their dummy units from enumeration, but I can hide it.
Quote:
Originally Posted by Vexorian
I think it is simpler to just call IsTerrainPathable in cases when we want to detect land or water
If WALKABILITY and FLOATABILITY and AMPHIBIOUS returned reliably for shallow water/deep water/land, this wouldn't be a problem. The issue is that the native is incredibly counterintuitive and most people would never guess that FLOATABILITY is the only reliable way to detect land and vice versa.
Quote:
Originally Posted by Vexorian
aren't there passive abilities that do the same windwalk does?
I wish. It is the passing through units behavior of Windwalk that makes it so necessary. It is the only spell or manner to properly do it without walking through trees and so forth.

Vex, it seems you want an IsTerrainWalkable function, but I thought we didn't want to have function name conflicts in the database? I was originally going to separate walkable from the rest, but I remember once you got angry for me using a function name already in the database. I am not sure.
Quote:
Originally Posted by Troll-Brain
And if you place the unit outside the playable map area, i don't see any problem, but correct me if i'm wrong.
SetUnitPosition won't go out of map area, and SetUnitX/Y crashes if you tell it to go out of map bounds. I think hiding the unit will suffice.
__________________

Last edited by Rising_Dusk : 12-30-2008 at 05:01 PM.
Rising_Dusk is offline   Reply With Quote
Old 12-30-2008, 05:33 PM   #9
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

No you don't get it i said outside the playable map area not the entire map

Collapse JASS:
library GetWorldBoundsMin initializer init

globals
    private real Xmin
    private real Ymin
endglobals

    
public function init takes nothing returns nothing
    local rect r= GetWorldBounds()
    
    set Xmin= GetRectMinX(r)
    set Ymin= GetRectMinY(r)
    
    call RemoveRect(r)
    set r=null
endfunction
    
    
endlibrary

And with the function SetUnitX/Y the unit will be outside the playable map area with no crash, i already used it for other stuff.
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Old 12-30-2008, 06:20 PM   #10
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

That does not fix the enumeration issue, though, it only makes it less likely. Hiding it will fix the enumeration problem, I believe.
__________________
Rising_Dusk is offline   Reply With Quote
Old 12-30-2008, 06:25 PM   #11
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

With only adding and removing 'Aloc' you can enumerate units...
moyack is offline   Reply With Quote
Old 12-30-2008, 06:27 PM   #12
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Aloc interferes with the collisional properties of the dummy unit, though.
__________________
Rising_Dusk is offline   Reply With Quote
Old 12-30-2008, 06:52 PM   #13
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Rising_Dusk
That does not fix the enumeration issue, though, it only makes it less likely. Hiding it will fix the enumeration problem, I believe.
Or do both :p
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Old 12-30-2008, 06:56 PM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

I want to avoid as much unnecessary unit handling as possible. I think I will hide the unit only.
__________________
Rising_Dusk is offline   Reply With Quote
Old 12-30-2008, 07:01 PM   #15
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Just a question, is it possible to know with a native fuction if an unit is hidden by an ability or by the action ShowUnit ?
Yes i know we could link a boolean to the unit, or add it in a group when we hide it with ShowUnit, and after check if the unit is in or not, and so one, that's not the question.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-13-2009 at 08:51 PM.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 08:38 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services