• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Enterable buildings with walk-on roofs

Status
Not open for further replies.
Level 4
Joined
Jan 7, 2011
Messages
72
I've read through some of the existing threads on creating buildings that units can enter (like this one: http://www.hiveworkshop.com/forums/...279/creating-enterable-exitable-houses-62141/)

However, I don't just want to create a building that units can enter, I also want one with a roof that units can walk on. The problem that I am encountering is this: the region for the interior of the building overlaps that for the roof. So I can't simply use regions to trigger whether the roof is shown or hidden, otherwise the roof will be hidden when units try to walk on top of it (since the roof region overlaps the ground level region, and the ground level region triggers the roof being hidden).

Could I use region triggers, but with an additional condition based on the triggering unit's vertical position relative to ground level? In other words, if the unit is inside the region and positioned at ground level, then the roof is hidden. But if the unit moves beyond a certain vertical position threshold (by virtue of climbing a set of stairs), then the roof is shown.

Are there any easier / more elegant solutions than the region + vertical position trigger that I described that DON'T involve setting camera bounds?
 
You can't have 2 or more stages of Z layer in wc3. Engine can't support that.
There is maybe way to code system that will set units Z offset to some value, but it will be pain in the ass to code so many coordinates, because like ground Z will change from time to time.

House with 2 floors won't be problem if you have default and for example 150 z offset value, but again you need to work with enter/leave floor triggers, with transparency and so on, disabling units on lower floors and so on.
 
Level 4
Joined
Jan 7, 2011
Messages
72
You can't have 2 or more stages of Z layer in wc3. Engine can't support that.
There is maybe way to code system that will set units Z offset to some value, but it will be pain in the ass to code so many coordinates, because like ground Z will change from time to time.

House with 2 floors won't be problem if you have default and for example 150 z offset value, but again you need to work with enter/leave floor triggers, with transparency and so on, disabling units on lower floors and so on.

There will be a constant z level for the entire ground floor of the building as well as a constant z level for the entire roof of the building (i.e. the entire walkable region of the roof is perfectly flat).

Disabling units and hiding destructibles is not a problem. I just need to know whether there is a way to check a unit's position relative to the z level or not (or whether there is a more elegant / easier way to achieve what I want).
 
Level 4
Joined
Jan 7, 2011
Messages
72
you can use a roof model and then hide/show it when entering a stair

This won't work for the reason that I mentioned in my original post. The moment the unit climbs up the stairs and walks onto the roof, the roof will be hidden because the roof overlaps the ground level of the building and the ground level region triggers the roof being hidden.
 
Level 2
Joined
Dec 7, 2012
Messages
16
I haven't seen many conditions that allow you to detect a unit's Z. Only 'X and Y Of Point' exist. Math - Distance Between Points will ignore heights. You could potentially use Unit Flying Height (Current) of an invisible dummy unit created on top of the unit you want, but I'm not sure even that would work because the unit being created might only be passed the X and Y of the triggering unit. You could make the triggering unit fly at 0 but that makes all sorts of new problems.
 
Level 4
Joined
Jan 7, 2011
Messages
72
Thanks for the suggestions, xn85d.

I think there may be a more elegant solution to this: create two small regions near the top of the stairs, with one of them (region A) "above" the other (region B). If a unit enters region A and leaves region B, then display the roof for that unit. If a unit enters region B and leaves region A, then hide the roof for that unit.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I haven't seen many conditions that allow you to detect a unit's Z. Only 'X and Y Of Point' exist. Math - Distance Between Points will ignore heights. You could potentially use Unit Flying Height (Current) of an invisible dummy unit created on top of the unit you want, but I'm not sure even that would work because the unit being created might only be passed the X and Y of the triggering unit. You could make the triggering unit fly at 0 but that makes all sorts of new problems.

to get a unit's Z, just place a location at the unit's loc, get its Z, remove the location, return the Z
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
to get a unit's Z, just place a location at the unit's loc, get its Z, remove the location, return the Z

It's nice to give him/her the native too, but I guess it's not hard to let him/her find out ;)
JASS:
native GetLocationZ takes location whichLocation returns real
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
It's nice to give him/her the native too, but I guess it's not hard to let him/her find out ;)
JASS:
native GetLocationZ takes location whichLocation returns real


do you really have to do research for the name of the function to "get a location's Z" ? :D
 
Level 4
Joined
Jan 7, 2011
Messages
72
Thanks Arhowk and Hash!

Could either (or both) of you guys explain what you mean by placing a location, getting its Z, removing the location, and returning the Z?

I understand what you mean in theory, but I don't understand the practical application (i.e. the JASS code). I am a total JASS noob, so I don't know whether you guys are referring to basic-level JASS stuff that I will learn as I develop my JASS skills, or high-level stuff that requires specialist experience.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Thanks Arhowk and Hash!

Could either (or both) of you guys explain what you mean by placing a location, getting its Z, removing the location, and returning the Z?

I understand what you mean in theory, but I don't understand the practical application (i.e. the JASS code). I am a total JASS noob, so I don't know whether you guys are referring to basic-level JASS stuff that I will learn as I develop my JASS skills, or high-level stuff that requires specialist experience.

JASS:
call GetLocationZ(udg_myLocation)
is a basic Jass function call. Every action you create in GUI will eventually use function calls in Jass.

This one doesn't exist in GUI however and you can use it to determine the Z height of the terrain at the location send to the "parameter" of the function.

To do this you could do something like:
  • Custom script: set udg_myRealGUIVariable = GetLocationZ(udg_myLocation)
GUI variables in Jass are refference by udg_
so myRealGUIVariable is a real variable in GUI and myLocation is a point variable in GUI.
(make sure to remove leaks when working with locations).
Since GetLocationZ returns a real it will then be saved inside the real variable.

So in other words: myRealGUIVariable will contain the height of the terrain at the location you've passed to the function.
 
Level 2
Joined
Dec 7, 2012
Messages
16
do you really have to do research for the name of the function to "get a location's Z" ? :D

Yes you do, actually, because I have only ever learnt JASS by converting GUI triggers, and it doesn't exist at all in GUI. ;)

Galatius said:
Could either (or both) of you guys explain what you mean by placing a location, getting its Z, removing the location, and returning the Z?
Just use a Point variable, then set it to the location of the unit normally using Set Variable, then have a Real variable ready to store the Z of the unit in question. So you'd have something like:

UnitLoc - Variable of type Point
UnitHeight - Variable of type Real

  • Set Variable UnitLoc = (Unit - Position of Unit (Triggering Unit))
  • Custom script: set udg_UnitHeight = GetLocationZ(udg_UnitLoc)
  • Custom script: call RemoveLocation(udg_UnitLoc)
Don't forget the udg_ prefix for your variable names when using JASS as they tell it you are not using a local variable.

Edit: Hashjie basically said the same thing, but hopefully the example actions above are still useful.
 
Status
Not open for further replies.
Top