• 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.

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..
 
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?
 
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 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