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

Terrain Hight Detection: ___---___

Status
Not open for further replies.
Level 10
Joined
Jan 21, 2007
Messages
576
Alright when using the WE I run into this problem quite often: The terrain has only one level of hight, meaning if a flying-unit is on a cliff over-looking a valley with 300 Defualt flying-height, he will have the same height as a unit in the valley below who has 300 default flying-height. I wan't to know if it is possible to detect how high the terrain makes the unit rise, how high the unit is actualy off the "base-ground" of the map. I beleive this has to be done in jass but I'm not sure so I didn't prefix this. Now I'll tell you why I need it, should make my question easier to understand.

Right now when my unit casts an ability he shoots out a dummy-unit as a projectile, this projectiles height is changed every time it is moved as to make it look like it's arcing in the air. Now this works fine on flat terrain but if my unit is going down on his arc (or is supposed to be) but goes over higher terrain/a hill it will look odd.

So if anyone could find a way around this I would be extremely grateful.
 
Level 10
Joined
Jan 21, 2007
Messages
576
Sorry for late response - I am currently testing it now with your suggestions in mind.
Alright it works now - but do you guys have any suggestions on how to make it arc better? Right now it is somewhat.. buggy.
 
Last edited:
Level 10
Joined
Jan 21, 2007
Messages
576
Here you go, lol@the trigger name just realized.

Snowballs Starting crap before edited:
Height: 50
Aquistion range: 20
Mana: 100000
Hp: 100000

  • Timer
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a Repeating timer that will expire in 0.03 seconds
  • Create Balls
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Throw Snowball
    • Actions
      • Set P = (Position of (Triggering unit))
      • Set P2 = (Target point of ability being cast)
      • Unit - Create 1 Snowball for (Owner of (Triggering unit)) at P facing (Angle from P to P2) degrees
      • Unit - Set mana of (Last created unit) to (Distance between P and P2)
      • Unit - Set life of (Last created unit) to 50.00
      • Unit - Set the custom value of (Last created unit) to 0
      • Wait 0.05 seconds
      • Unit - Reset ability cooldowns for Peasant 0001 <gen>
      • Unit - Order Peasant 0001 <gen> to Stop
      • Unit Group - Add (Last created unit) to SnowBalls
      • Custom script: call RemoveLocation(udg_P)
      • Custom script: call RemoveLocation(udg_P2)
  • Move Balls
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SnowBalls and do (Actions)
        • Loop - Actions
          • Set SnowBall = (Picked unit)
          • Set P = (Position of (Picked unit))
          • Set MS = (Current acquisition range of (Picked unit))
          • Set T = (Real((Custom value of (Picked unit))))
          • Set TT = (Mana of (Picked unit))
          • Set H = (Life of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • T Less than or equal to TT
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of SnowBall) Less than or equal to 5.00
                • Then - Actions
                  • Unit - Explode SnowBall
                  • Unit Group - Remove SnowBall from SnowBalls
                • Else - Actions
                  • Set UnitsInRange = (Units within (Current movement speed of (Picked unit)) of P)
                  • Unit Group - Pick every unit in UnitsInRange and do (Actions)
                    • Loop - Actions
                      • -------- Peasant --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to Peasant
                          • ((Owner of (Picked unit)) is an enemy of (Owner of SnowBall)) Equal to True
                          • (Current flying height of SnowBall) Less than or equal to 90.00
                        • Then - Actions
                          • Unit - Explode SnowBall
                          • Unit Group - Remove SnowBall from SnowBalls
                        • Else - Actions
                          • Unit Group - Remove (Picked unit) from UnitsInRange
                      • -------- Snowball --------
                  • Unit - Move SnowBall instantly to (P offset by MS towards (Facing of (Picked unit)) degrees)
                  • Unit - Set the custom value of SnowBall to ((Custom value of SnowBall) + (Integer(MS)))
                  • -------- Height --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • T Less than or equal to (TT / 2.00)
                    • Then - Actions
                      • Animation - Change (Picked unit) flying height to (H x ((T / (TT / 2.00)) + 1.00)) at 1000.00
                      • Custom script: set udg_TH = GetLocationZ(udg_P)
                      • Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
                    • Else - Actions
                      • Animation - Change (Picked unit) flying height to ((((TT - T) / TT) + 0.50) x (H x 2.00)) at 1000.00
                      • Custom script: set udg_TH = GetLocationZ(udg_P)
                      • Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of SnowBall) Less than or equal to 5.00
                • Then - Actions
                  • Unit - Explode SnowBall
                  • Unit Group - Remove SnowBall from SnowBalls
                • Else - Actions
                  • Unit - Move SnowBall instantly to (P offset by MS towards (Facing of (Picked unit)) degrees)
                  • Unit - Set the custom value of SnowBall to ((Custom value of SnowBall) + (Integer(MS)))
                  • -------- Height --------
                  • Animation - Change (Picked unit) flying height to ((((TT - T) / TT) + 0.50) x (H x 2.00)) at 1000.00
                  • Custom script: set udg_TH = GetLocationZ(udg_P)
                  • Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
          • Game - Display to (All players) the text: (String((Current flying height of SnowBall)))
          • Custom script: call RemoveLocation(udg_P)
 
Level 10
Joined
Jan 21, 2007
Messages
576
Move Balls
Events
Time - Timer expires
Conditions
Actions
Unit Group - Pick every unit in SnowBalls and do (Actions)
Loop - Actions
Set SnowBall = (Picked unit)
Set P = (Position of (Picked unit))
Set MS = (Current acquisition range of (Picked unit))
Set T = (Real((Custom value of (Picked unit))))
Set TT = (Mana of (Picked unit))
Set H = (Life of (Picked unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
T Less than or equal to TT
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current flying height of SnowBall) Less than or equal to 5.00
Then - Actions
Unit - Explode SnowBall
Unit Group - Remove SnowBall from SnowBalls
Else - Actions
Set UnitsInRange = (Units within (Current movement speed of (Picked unit)) of P)
Unit Group - Pick every unit in UnitsInRange and do (Actions)
Loop - Actions
-------- Peasant --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Peasant
((Owner of (Picked unit)) is an enemy of (Owner of SnowBall)) Equal to True
(Current flying height of SnowBall) Less than or equal to 90.00
Then - Actions
Unit - Explode SnowBall
Unit Group - Remove SnowBall from SnowBalls
Else - Actions
Unit Group - Remove (Picked unit) from UnitsInRange
-------- Snowball --------
Unit - Move SnowBall instantly to (P offset by MS towards (Facing of (Picked unit)) degrees)
Unit - Set the custom value of SnowBall to ((Custom value of SnowBall) + (Integer(MS)))
-------- Height --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)

If - Conditions
T Less than or equal to (TT / 2.00)
Then - Actions
Animation - Change (Picked unit) flying height to (H x ((T / (TT / 2.00)) + 1.00)) at 1000.00
Custom script: set udg_TH = GetLocationZ(udg_P)
Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
Else - Actions
Animation - Change (Picked unit) flying height to ((((TT - T) / TT) + 0.50) x (H x 2.00)) at 1000.00
Custom script: set udg_TH = GetLocationZ(udg_P)
Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current flying height of SnowBall) Less than or equal to 5.00
Then - Actions
Unit - Explode SnowBall
Unit Group - Remove SnowBall from SnowBalls
Else - Actions
Unit - Move SnowBall instantly to (P offset by MS towards (Facing of (Picked unit)) degrees)
Unit - Set the custom value of SnowBall to ((Custom value of SnowBall) + (Integer(MS)))
-------- Height --------
Animation - Change (Picked unit) flying height to ((((TT - T) / TT) + 0.50) x (H x 2.00)) at 1000.00
Custom script: set udg_TH = GetLocationZ(udg_P)
Animation - Change SnowBall flying height to ((Current flying height of SnowBall) - TH) at 1000.00
Game - Display to (All players) the text: (String((Current flying height of SnowBall)))
Custom script: call RemoveLocation(udg_P)]


Animation - Change (Picked unit) flying height to (H x ((T / (TT / 2.00)) + 1.00)) at 1000.00

H is a variable set to the snowballs life, T is how long the unit has already traveled which is the units custom value, TT is the distance between the snowball when it is first created and the target point of the ability.

First red text: If T is less then TT / 2 (if the snowball hasen't traveled more then half the distance of it total trip). Then:
  • Animation - Change (Picked unit) flying height to (H x ((T / (TT / 2.00)) + 1.00)) at 1000.00
Sets the units hight to a percentage that relies on how far the unit has traveled, so basicaly it sets the units height to H(its hp, which is 50, its starting hight) x (1 + (% of distance traveled by the ball from where it was created to the halfway point.)). So basicaly every .03 seconds the units hight gets set a little bit higher until it reaches halfway, at which point it will be at its crest (of 100, twice as much as the starting hight). From there on out the process is backwards, causing it to sink.

I want to know a better formula because mine doesn't look smooth atm. I want the crest-height to incorporate how far the snowball is being thrown aswell but I am unaware how to do this =/.
 
Status
Not open for further replies.
Top