HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

SetUnitZ, GetUnitZ?

08-22-2007, 10:09 PM#1
cohadar
Collapse JASS:
//==============================================================================
function GetUnitZ takes unit u returns real
    call MoveLocation( LocationZ ,GetUnitX(u),GetUnitY(u) )
    return GetLocationZ(LocationZ) + GetUnitFlyHeight(u)
endfunction

//==============================================================================
function SetUnitZ takes unit u,real z returns nothing
    call MoveLocation( LocationZ ,GetUnitX(u),GetUnitY(u) )
    call SetUnitFlyHeight(u,z-GetLocationZ(LocationZ),0)
endfunction

Is there any better way to do this stuff?
08-22-2007, 10:18 PM#2
Toadcop
inline it...
// + omg such function i use allready for a long time. thats the effect of "i will do my stuff self..."
+ syntax error
NOT return GetLocationZ( LocationZ + GetUnitFlyHeight(u) )
SO return GetLocationZ(LocationZ)+GetUnitFlyHeight(u)
08-22-2007, 10:20 PM#3
iNfraNe
Hey, here's an idea. Put them in globals, easier and faster, wow. Here it is:

function SetUnitZ takes structedunit u, real z returns nothing
call MoveLocation(loc, u.x, u.y)
set u.z = z
call SetUnitFlyHeight(u.u,u.z+GetLocationZ(u.u),0)
endfunction

function GetUnitZ takes structedunit u returns real
return u.z
endfunction

That way, you could even do without these function, saves alot of cpu again.
08-22-2007, 10:27 PM#4
cohadar
How did I make that syntax error while copying ???

nwm, Anyways I will not use X/Y globals because the engine would not be flexible enough then.
(It will not be able to handle multiple move vectors at once)


May I ask again, is there any other way to do this or not?
(besides of optimizations)

EDIT:
Ah I can't use global X and Y, but that global Z would come in handy.
Thank you.

EDIT2:
I have seen some people use SetUnitX, SetUnitY instead of SetUnitPosition
is there some good reason for this or is it just their preference
08-22-2007, 10:34 PM#5
Toadcop
Quote:
It will not be able to handle multiple move vectors at once
ha lol you are stupid but well it's your right.

INLINE IT ! no call this functions just do that calcs in needed function!?

Quote:
function SetUnitZ takes structedunit u, real z returns nothing
call MoveLocation(loc, u.x, u.y)
set u.z = z
call SetUnitFlyHeight(u.u,u.z+GetLocationZ(u.u),0)
endfunction

function GetUnitZ takes structedunit u returns real
return u.z
endfunction
suck... you need only set it's height + position using this function. but on the other hand it's more optimal (and i do it so 2)
+ GetUnitZ aka new DoNothing() (in your case)
08-22-2007, 10:43 PM#6
cohadar
I will inline it AFTER I am sure it is working properly.
08-22-2007, 10:59 PM#7
Toadcop
O_O you are not sure what it works perfectly...
NOTHING IS PERFECT ! you will see ^^ (what is made by humans hands etc...)
08-22-2007, 11:07 PM#8
cohadar
Collapse JASS:
//==============================================================================
function GetUnitZ takes unit u returns real
    call MoveLocation( LocationZ ,GetUnitX(u),GetUnitY(u) )
    return GetLocationZ(LocationZ) + GetUnitFlyHeight(u)
endfunction

//==============================================================================
function SetUnitZ takes unit u,real z returns nothing
    call MoveLocation( LocationZ ,GetUnitX(u),GetUnitY(u) )
    call SetUnitFlyHeight(u,z-GetLocationZ(LocationZ),0)
endfunction

OK THIS IS NOT WORKING.

When I go over edges it bumps up and down just like when I use flyingHeight only, if it is going to do the same shit as flyingHeight then why do I need GetLocationZ after all?

And that optimizations with global Z was moving even worse.
08-22-2007, 11:12 PM#9
Toadcop
what kind of units are you using ? are they... flying units ?
08-22-2007, 11:16 PM#10
cohadar
I am using ground units in combination with 'Amrf'

EDIT:

My mistake I was testing on too high ground.

This is working:
Collapse JASS:
//==============================================================================
function SetUnitZ takes unit u,real z returns nothing
    call MoveLocation( LocationZ ,GetUnitX(u),GetUnitY(u) )
    call SetUnitFlyHeight(u,z-GetLocationZ(LocationZ),0)
endfunction

//==============================================================================
set  data.z = data.z + data.dz
call SetUnitZ(data.hero, data.z)

Interesting thing.. you cannot set FlyHeight to negative value.
Is there any way to do this? (to burrow units below ground)
08-22-2007, 11:24 PM#11
Anitarf
There could be a number of things. Did you set art-elevation-sample radius to 0? Did you try to move it over water?
08-22-2007, 11:32 PM#12
cohadar
Art-Elevator-Sample-Radius ???

WTF is that now?
08-23-2007, 07:44 AM#13
MaD[Lion]
tell me tat too ani
08-23-2007, 07:55 AM#14
Tide-Arc Ephemera
Just wondering... is there a SetLocationZ() sort of function? To set the height without physically manipulating the terrain...
08-23-2007, 08:15 AM#15
Anitarf
Quote:
Originally Posted by cohadar
Art-Elevator-Sample-Radius ???

WTF is that now?
Elevation, not elevator. It's an object editor field. I don't actualy know what it does, but I usualy set it to 0 just in case it might have something to do with height smoothing.

Anyway, you figured it out already. And no, you can not burrow units below ground unless you displace their whole model and change the z value accordingly.