• 🏆 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!

height condition

Status
Not open for further replies.
Level 9
Joined
Apr 7, 2010
Messages
480
how do i detect if unit height is lower than terrain height without any regions?

for example, point A height is 10 and point B height is 20, then the unit height is 15

when unit is in point A nothing will happen but when unit is in point B the unit will explode.

but the main idea here is the condition that always check when the terrain is higher than the unit then if true, unit dies.

one of the main problems here is that when flying unit goes to a higher terrain it automatically changes to a higher height. that will make the condition always false..
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Detecting unit fly height:
JASS:
native          GetUnitFlyHeight        takes unit whichUnit returns real
Detecting location height:
JASS:
native GetLocationZ             takes location whichLocation returns real
Now, just use comparison to check which value is greater.
If you are using GUI, make sure you start with periodic event (every 0.05 seconds of game time) and refer to unit you want height to be checked.

Lets say you always check fly heigh value of unitX.
  • Actions
    • Set p = (Position of unitX)
    • Custom script: if GetUnitFlyHeight(udg_unitX) <= GetLocationZ(udg_p) then
    • Unit - Kill unitX
    • Custom script: endif
    • Custom script: call RemoveLocation(udg_p)
 
Level 9
Joined
Apr 7, 2010
Messages
480
  • Actions
    • Set p = (Position of unitX)
    • Custom script: if GetUnitFlyHeight(udg_unitX) <= GetLocationZ(udg_p) then
    • Unit - Kill unitX
    • Custom script: endif
    • Custom script: call RemoveLocation(udg_p)

do i just have to copy this triggers?
for unit variable set p = position of unitX
how do i set it to all units, unit group?
what part here checks the terrain height?
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
do i just have to copy this triggers?
for unit variable set p = position of unitX
how do i set it to all units, unit group? #1
what part here checks the terrain height? #2

1. If you use temporary group:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units (...)) and do Actions
      • Loop - Actions
        • Set p = (Position of (Picked unit))
        • Custom script: if GetUnitFlyHeight(GetEnumUnit()) <= GetLocationZ(udg_p) then
        • Unit - Kill (Picked unit)
        • Custom script: endif
        • Custom script: call RemoveLocation(udg_p)
If you want to use global group (set ealier) just skip 'bj_want..' part and refer to your group instead.

2. GetLocationZ is the function which checks the height of given location (terrain) as I've mentioned already.
 
Level 9
Joined
Apr 7, 2010
Messages
480
i see. thanks. ill try it now to my map

didnt work. i guess its because of this
one of the main problems here is that when flying unit goes to a higher terrain it automatically changes to a higher height. that will make the condition always false..
 
Level 9
Joined
Apr 7, 2010
Messages
480
the first thread was incomplete (my bad). this is the full version ^^

if unit height is 0.00 meaning its no longer flying, and it would be below water

and it would not be constant since players can change the unit height when pressing up and down arrow key
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Oh. Then why don't you refer to that constant instead (mentioned by Garfield)? If those players set height by using arrays you probably use: Animation - Set unit fly height and for sure it's constant value untill player changes height again.

Compasiron becomes freaking easy.
if <declared height value here> <= 0.00 then
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Here's all you need:
  • Trigger 1 tho
    • event
      • A player presses up arrow
    • actions
      • Set HeightChange[GetPlayerNumber(Triggering Player)] = 3.00 //or some other number idk
  • ------------
  • Trigger 2 tho
    • event
      • A player releases up arrow
      • A player releases down arrow
    • actions
      • Set HeightChange[GetPlayerNumber(Triggering Player)] = 0.00
  • -------------
  • Trigger 3 tho
    • event
      • A player presses down arrow
    • actions
      • Set HeightChange[GetPlayerNumber(Triggering Player)] = -3.00
  • ------------
  • Trigger 4 tho
    • event
      • Each 0.03 seconds
    • actions
      • Pick every jet in map
        • loc1 = position of picked unit
        • loc2 = loc1 offset by speed
        • Move picked unit to loc2
        • Custom script: set udg_Z = GetLocationZ(udg_loc2)
        • Animation - SetUnitFlyHeight(picked unit,Height[GetPlayerNumber(Owner of picked unit)] - Z + HeightChange[GetPlayerNumber(Owner of picked unit)],0.00)
        • Set Height[GetPlayerNumber(Owner of picked unit)] = [GetPlayerNumber(Owner of picked unit)] + HeightChange[GetPlayerNumber(Owner of picked unit)]
You need variables: real array Height, real array HeightChange, real Z.
 
Level 9
Joined
Apr 7, 2010
Messages
480
what does loc2 = loc1 offset by speed
Move picked unit to loc2 mean?

srry. i cant edit right now. but ill be online.
 
Status
Not open for further replies.
Top