• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Z of point {how to get it using (GUI) triggers?}

Status
Not open for further replies.
Level 18
Joined
Aug 3, 2008
Messages
1,935
i dont get it.

the Z is the height of something.

Are you saying that that custom script determines the height of something ?

So if i were to set Temp Z to Position of Unit, wouldn't Z only equal the Xand Y of the units position ? not the Z which is the height, which is what we are looking for ?

Or does that know it means the height of something.
 
Level 8
Joined
Jun 20, 2004
Messages
229
temp z is the number variable most preferably a real not an integer for precision. you may name this whatever you want I just name it tempZ, the locationPoint variable is the point variable. this is where you would put the name of your point variable named whatever. by doing this, it will find the z height of the point variable you put in the parameter and it will send that value to tempZ. then you can just use tempZ in any calculation you needed but make sure tempZ or whatever you want to call it exists first in your map.

the function to find the z height of a point alone is just
Code:
GetLocationZ(point)
but you need to have a variable = that function call since it returns a value. if you dont have xx variable = getlocationz(parameter) then it would have no variable to return the value to.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
It would not only be usefull, it would (is) already be used ;)
with GetLocationZ(<YourPoint>) you can get the Z of the point
with GetUnitFlyingHeight(<Unit>)you can get the Z between ground and unit
with GetLocationZ(GetUnitLoc(u)) + GetUnitFlyingHeight(u) you get the unit's absolute Z height,,

Usefull for some peoplez ;)

(Of course you need to clean the point leak made in this, but that is no big deal i think)
 
Level 8
Joined
Jun 20, 2004
Messages
229
indeed, it is useful for both camera and flying height values. i would like to point out however, if you plan to use it for a camera you will need to use something like this due to the way terrain works with the camera.

it is much simpler than it looks, just use this in a script in your trigger and paste the function in you custom scripts section in mapname.w3x where player is going to be the player such as getenumplayer() which is picked player, and then zvalue which would be something like tempZ as used when finding the z height of the current camera position.

Code:
call SetCameraZ(player, zvalue)

Code:
function SetCameraZ takes player whichPlayer, real z returns nothing
    if ( GetLocalPlayer() == whichPlayer ) then
    set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+z-GetCameraTargetPositionZ()
    call SetCameraField(CAMERA_FIELD_ZOFFSET,z,- 0.01)
    call SetCameraField(CAMERA_FIELD_ZOFFSET,z,0.01)
    endif
endfunction
 
Status
Not open for further replies.
Top