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

[Trigger] GetLocationZ works wrong

Status
Not open for further replies.
may you know the (old) version of my MissileSystem (NoParabola).
i'm still working on it but i have some problems with the GetLocationZ
i use:
  • MS Loop
    • Ereignisse
      • Zeit - Every 0.03 seconds of game time
    • Bedingungen
    • Aktionen
      • Einheitengruppe - Pick every unit in MS_Missles and do (Actions)
        • Schleifen - Aktionen
          • Set MS_TempUnit[0] = (Picked unit)
          • Set MS_TempUnit[1] = (Load (Key Caster) of (Key (Picked unit)) in MS_Hash)
          • -------- ================================ --------
          • Einheit - Turn collision for MS_TempUnit[0] Aus
          • -------- ================================ --------
          • Set MS_TempReal[0] = (Load (Key Damage) of (Key (Picked unit)) from MS_Hash)
          • Set MS_TempReal[1] = (Load (Key CollisionsRad) of (Key (Picked unit)) from MS_Hash)
          • Set MS_TempReal[2] = ((Load (Key ZAngle) of (Key (Picked unit)) from MS_Hash) + 90.00)
          • Set MS_TempReal[3] = ((Cos((Load (Key ZAngle) of (Key (Picked unit)) from MS_Hash))) x (Load (Key Speed) of (Key (Picked unit)) from MS_Hash))
          • Set MS_TempReal[7] = (Load (Key DamageRad) of (Key (Picked unit)) from MS_Hash)
          • -------- ================================ --------
          • Set MS_LeakPoint[0] = (Position of (Picked unit))
          • Set MS_LeakPoint[1] = (MS_LeakPoint[0] offset by MS_TempReal[3] towards (Load (Key Angle) of (Key (Picked unit)) from MS_Hash) degrees)
          • -------- ================================ --------
          • Einheit - Move (Picked unit) instantly to MS_LeakPoint[1]
          • Einheit - Make (Picked unit) face (Load (Key Angle) of (Key (Picked unit)) from MS_Hash) over 0.00 seconds
          • -------- ================================ --------
          • -------- ================================ --------
          • Set MS_TempReal[6] = ((Load (Key NormalHeight) of (Key (Picked unit)) from MS_Hash) + ((Sin((Load (Key ZAngle) of (Key (Picked unit)) from MS_Hash))) x (Load (Key Speed) of (Key (Picked unit)) from MS_Hash)))
          • Hashtabelle - Save MS_TempReal[6] as (Key NormalHeight) of (Key (Picked unit)) in MS_Hash
          • Custom script: set udg_MS_TempReal[8]=GetLocationZ(udg_MS_LeakPoint[1])
          • Set MS_TempReal[9] = (MS_TempReal[6] + ((Load (Key StartZ) of (Key (Picked unit)) from MS_Hash) - MS_TempReal[8]))
          • Hashtabelle - Save MS_TempReal[8] as (Key StartZ) of (Key (Picked unit)) in MS_Hash
          • -------- ================================ --------
          • Animation - Change MS_TempUnit[0] flying height to MS_TempReal[9] at 0.00
          • -------- ================================ --------
          • -------- ================================ --------
          • Custom script: call SetUnitAnimationByIndex(udg_MS_TempUnit[0], R2I(udg_MS_TempReal[2]))
          • -------- ================================ --------
          • Hashtabelle - Save ((Load (Key Distance) of (Key (Picked unit)) from MS_Hash) - (Load (Key Speed) of (Key (Picked unit)) from MS_Hash)) as (Key Distance) of (Key (Picked unit)) in MS_Hash
          • Hashtabelle - Save ((Load (Key Speed) of (Key (Picked unit)) from MS_Hash) + (Load (Key SpeedIncraise) of (Key (Picked unit)) from MS_Hash)) as (Key Speed) of (Key (Picked unit)) in MS_Hash
          • -------- ================================ --------
          • Custom script: set udg_MS_KillMissle= CheckForCollision(GetLocationX(udg_MS_LeakPoint[1]),GetLocationY(udg_MS_LeakPoint[1]),GetUnitFlyHeight(udg_MS_TempUnit[0]),udg_MS_TempReal[1], GetOwningPlayer(udg_MS_TempUnit[0]))
          • -------- =========================================================================== --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • Or - Any (Conditions) are true
                • Bedingungen
                  • MS_KillMissle Gleich True
                  • (MS_PlayableMapArena contains MS_TempUnit[0]) Gleich False
                  • (Current flying height of MS_TempUnit[0]) Größer gleich MS_MaxHeight
                  • (Current flying height of MS_TempUnit[0]) Kleiner gleich 1.00
                  • (Load (Key Distance) of (Key (Picked unit)) from MS_Hash) Kleiner gleich 0.00
            • 'THEN'-Aktionen
              • Custom script: call DamageUnitInRange(GetLocationX(udg_MS_LeakPoint[1]),GetLocationY(udg_MS_LeakPoint[1]),GetUnitFlyHeight(udg_MS_TempUnit[0]),udg_MS_TempReal[0],udg_MS_TempReal[7],udg_MS_TempUnit[1])
              • Set MS_KillMissle = False
              • Einheitengruppe - Remove MS_TempUnit[0] from MS_Missles
              • Spezialeffekt - Destroy (Load (Key UnitSFX) of (Key (Picked unit)) in MS_Hash)
              • Custom script: call SetUnitAnimationByIndex(udg_MS_TempUnit[0], 90)
              • Spezialeffekt - Create a special effect attached to the origin of MS_TempUnit[0] using (Load (Key DeadSFX) of (Key (Picked unit)) from MS_Hash)
              • Spezialeffekt - Destroy (Last created special effect)
              • Hashtabelle - Clear all child hashtables of child (Key (Picked unit)) in MS_Hash
              • Einheit - Add a 2.00 second Standard expiration timer to MS_TempUnit[0]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • (Number of units in MS_Missles) Gleich 0
                • 'THEN'-Aktionen
                  • Auslöser - Turn off (This trigger)
                • 'ELSE'-Aktionen
            • 'ELSE'-Aktionen
          • -------- ================================ --------
          • Custom script: call RemoveLocation (udg_MS_LeakPoint[0])
          • Custom script: call RemoveLocation (udg_MS_LeakPoint[1])
but it look like this:

-----------------
--x------xx-----
-x--x--x----xx--
x----x----------x
--_-----__------
-/--\--/----\_--
/----\/--------\_

x = missile
_ / \ = ground


i also tryed some other ways but all doesn't work :(
plz can somebody help me
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Ehm, can you explain the spell a bit, please? ^^
If I'm correct, it should create an arc, right? (And you use Trigonometry, although not correct if I understand what you're doing).

So I'd like you to explain the values and what they're supposed to do (not really extended, just the basics so I don't have to figure everything out xD).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
what he meant was that he want his missile to go completly straight but when the hegight changes it falls like into a pit and then up again
Ohh, wait (I don't know if you meant this), he wants the missile to go straight, no matter what the terrain height is :p
Since the normal flying units' height changes when flying over lower/higher terrain, he tries to undo that =D

Time for some highly advanced ASCII art:


-----------------
---xxxxxxx------
-xx--------xx----
x------------x---
--_-----__----x-
-/--\--/----\_--x
/----\/--------\_

This is how he wants it to go?

Does the missile need to go straight for a while? (Like in my "Drawing"), or does it make a regular arc?
 
Level 8
Joined
Apr 30, 2009
Messages
338
it looks like he wants to set the absolute Z parameter of the missle, but his trigger is setting the Z parameter relative to the terrain
 
Level 5
Joined
Feb 6, 2008
Messages
134
You must make Ground Unit (not flying), add Raven Form and then set Z height... Z0 = Old Z loc Z1 = New Z loc Zc = Unit height what you need.

Z = Zc + (Z0 - Z1)
 
Ohh, wait (I don't know if you meant this), he wants the missile to go straight, no matter what the terrain height is :p
Since the normal flying units' height changes when flying over lower/higher terrain, he tries to undo that =D

Time for some highly advanced ASCII art:


-----------------
---xxxxxxx------
-xx--------xx----
x------------x---
--_-----__----x-
-/--\--/----\_--x
/----\/--------\_

This is how he wants it to go?

Does the missile need to go straight for a while? (Like in my "Drawing"), or does it make a regular arc?

no it should work like this:

-----------------
xxxxxxxxxxxxxxxx
-----------------
-----------------
--_-----__------
-/--\--/----\_---
/----\/--------\_


EDIT: here ist the system View attachment MissleSystem(NoParabola).w3x
 
You are most likely having problems with warcraft's flying unit handling. Make the unit have the "Float" movement type and move them with SetUnitX and SetUnitY. Don't forget that you will need to use the fly trick to adjust their height.

done but now the unit doesn't move (it move but you always see the sfx at the start point) but it doesn't work :(

Don't forget that you will need to use the fly trick to adjust their height.

you mean this with 'arav' or something like this? if yes i already done this

can plz somebody do this and post the final system?
 
Level 10
Joined
May 26, 2005
Messages
194
Ehm...

Thats the problem with posting such long codes, nobody reads them...

Theres no call to SetUnitFlyHeight in the whole code, is there?
You get the right LocationZ, but you have to set the fly height of course.

in Jass it would be:

call SetUnitFlyHeight(unit,z-GetLocationZ(loc),0)

GetLocationZ(loc) is already saved in a variable in your example, z would be the "real" height


By the way, its right that you need to use floating instead of flying to make it work correctly near cliffs.
Floating, disabled collision and when you create the dummy, add the ability 'Amrf' (Crow form) to the dummy, then set the fly height to some value (except for 0), then remove the ability again
 
Level 10
Joined
May 26, 2005
Messages
194
oh sorry, thought it was an "Einheit"-action

ehm, then, i dont know what your variables mean...

if TempReal[6] should be the absolute height, then the SetUnitFlyHeight would only be TempReal[6] - LocationZ

(dont want to look up your confusing temp variable.... its actually important to have a clear code... well...)

so remove that Load key bla from it....

i mean you dont have a technical problem here... its just because you even dont know what the code does... what the variables mean and so on... its crucial to find fitting names


SetFlyHeight(u, desired height - location z, 0)

where desired height would be constant for a straight movement as you showed it in your picture... (i dont know what that sin is for there... sin isnt a flight path, if you thought so?)

flight path:

maxheight - diffbetweenheights*(t-(time at which the bullet is at its heighest pos)) ^2

(or something like that, i personally like it more to save a speed in z direction and accelerate the bullet towards the ground permanently)



EDIT: ah by the way, and never expect anyone to download your map.... maybe some people download it, but its not the way to ask a question...
you can still upload it when someone wants to see it

its your turn to explain the problem good enough, so others can understand it and help you.... (should i upload something like flightsim and ask someone here to fix the problem? nope, no chance, but if i ask a good question, maybe someone can help)
 
ok here comes a good description fro the Flying Height problem:

what i use:

i move the unit whit Cos(Zangle)*speed (works corect :p)

then i set TempReal[6] to using NormalHeight (ignore the LocationZ)+Sin(Zangle)*speed
and store this number in the hash.
so i will get the height if the locationZ is always the same. (works also corect)
then i set the flying height of the missile to the TempReal[6] + the LocationZ of the last point (the point of the missile befor i move it) -the LocationZ of the point i move the missile

may a little bit confusing.... :/

  • Set MS_TempReal[3] = ((Cos((Load (Key ZAngle) of (Key (Picked unit)) from MS_Hash))) x (Load (Key Speed) of (Key (Picked unit)) from MS_Hash))
  • Set MS_LeakPoint[0] = (Position of (Picked unit))
  • Set MS_LeakPoint[1] = (MS_LeakPoint[0] offset by MS_TempReal[3] towards (Load (Key Angle) of (Key (Picked unit)) from MS_Hash) degrees)
  • ----- Set x and y....-----
  • Set MS_TempReal[6] = ((Load (Key NormalHeight) of (Key (Picked unit)) from MS_Hash) + ((Sin((Load (Key ZAngle) of (Key (Picked unit)) from MS_Hash))) x (Load (Key Speed) of (Key (Picked unit)) from MS_Hash)))
  • Hashtabelle - Save MS_TempReal[6] as (Key NormalHeight) of (Key (Picked unit)) in MS_Hash
  • Custom script: set udg_MS_TempReal[8]=GetLocationZ(udg_MS_LeakPoint[1])
  • Set MS_TempReal[9] = (MS_TempReal[6] + ((Load (Key StartZ) of (Key (Picked unit)) from MS_Hash) - MS_TempReal[8]))
  • Hashtabelle - Save MS_TempReal[8] as (Key StartZ) of (Key (Picked unit)) in MS_Hash
  • Animation - Change MS_TempUnit[0] flying height to MS_TempReal[9] at 0.00
 
Level 10
Joined
May 26, 2005
Messages
194
nope, really, its no good description, i dont understand the code, but i CAN explain GetLocationZ() to you: the height of the terrain

to place a unit in an absolute height:

SetUnitFlyHeight(U,desired height - locationZ,0)

make sure the unit does change its fly height at all, try GetRandomReal(0,1000) for example, it should flicker around, then everything is okay, otherwise the bug is that the unit doesnt change its height at all

in any other case:
you have a mistake in calculating the "desired height", but i dont know what you desire, so i cant help you there... i cant see what you want from the code

tell me what the variables mean and i may be able to help you (as ive already said, precise names of variables are important)
 
Status
Not open for further replies.
Top