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

[Trigger] Making a missile unit change height

Status
Not open for further replies.
Level 30
Joined
Jul 23, 2009
Messages
1,029
So I'm trying to make a fire bomb spell that works like Tiny's toss in dota.

When you finish channeling the ability, a fire bomb should be thrown from the caster toward the target location, flying higher into the air the closer it gets to the target location until it is halfway there. Then it is supposed to start falling to the ground so that it hits the ground at the target location.

I have tried as good as I can on my own but it usually just flies up to a random height, or starts falling too early and some times it won't even fly.

Please help, rep shall be given

  • Fire Bomb Channel Ended
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Spellbinder: Fire Bomb
    • Actions
      • Unit - Remove Unit_CastBar[(Player number of (Owner of (Triggering unit)))] from the game
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • AB_TempCastTimer[(Player number of (Owner of (Triggering unit)))] Less than or equal to (<=) 0.00
          • Then - Actions
            • Set AB_TempCasterPoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
            • Unit - Create 1 Spellbinder: Missile Fire Bomb for (Owner of (Triggering unit)) at AB_TempCasterPoint[(Player number of (Owner of (Triggering unit)))] facing AB_TempPoint[(Player number of (Owner of (Triggering unit)))]
            • Unit Group - Add (Last created unit) to AB_FireBombMissiles
            • Unit Group - Add (Last created unit) to AB_FireBombRisingMissiles
            • Set AB_FireBombMissile[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
            • Unit - Order AB_FireBombMissile[(Player number of (Owner of (Triggering unit)))] to Move To AB_TempPoint[(Player number of (Owner of (Triggering unit)))]
            • Set AB_FireBombDist[(Player number of (Owner of (Triggering unit)))] = (Distance between AB_TempCasterPoint[(Player number of (Owner of (Triggering unit)))] and AB_TempPoint[(Player number of (Owner of (Triggering unit)))])
            • Set AB_FireBombTravelTimer[(Player number of (Owner of (Triggering unit)))] = (1.00 / (500.00 / AB_FireBombDist[(Player number of (Owner of (Triggering unit)))]))
            • Animation - Change AB_FireBombMissile[(Player number of (Owner of (Triggering unit)))] flying height to 100000.00 at (200.00 x (500.00 / AB_FireBombDist[(Player number of (Owner of (Triggering unit)))]))
            • Trigger - Turn on Fire Bomb Travel <gen>
            • Trigger - Turn on Fire Bomb Gravity <gen>
          • Else - Actions
      • Unit Group - Remove (Triggering unit) from AB_TempCasters
  • Fire Bomb Travel
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String(AB_FireBombTravelTimer[1], 0, 0))
      • Unit Group - Pick every unit in AB_FireBombMissiles and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AB_FireBombTravelTimer[(Player number of (Owner of (Picked unit)))] Greater than (>) 0.00
            • Then - Actions
              • Set AB_FireBombTravelTimer[(Player number of (Owner of (Picked unit)))] = (AB_FireBombTravelTimer[(Player number of (Owner of (Picked unit)))] - 0.50)
            • Else - Actions
              • Unit - Remove (Picked unit) from the game
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (AB_FireBombMissiles is empty) Equal to (==) True
          • Then - Actions
            • Trigger - Turn off (This trigger)
          • Else - Actions
  • Fire Bomb Gravity
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in AB_FireBombRisingMissiles and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AB_FireBombTravelTimer[(Player number of (Owner of (Picked unit)))] Less than or equal to (<=) (AB_FireBombDist[(Player number of (Owner of (Picked unit)))] / 2.00)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from AB_FireBombRisingMissiles
              • Animation - Change AB_FireBombMissile[(Player number of (Owner of (Picked unit)))] flying height to 0.00 at (200.00 x (500.00 / AB_FireBombDist[(Player number of (Owner of (Triggering unit)))]))
            • Else - Actions
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
Use a parabola function or vector math( in GUI you should take the parabola) to calculate the arc.
I think there also is a thread here somewhere, similar like this one: http://www.wc3c.net/showthread.php?t=102077

There are also many threads about this already
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/parabola-arc-equation-220288/
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/need-help-parabola-equation-222080/

And you can always look in the spellsection for GUI spells with similar effects:
http://www.hiveworkshop.com/forums/spells.php?status=a&search=jump&d=list&r=20
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I'd go with the vector method, since your target is a location.

The missile unit should have several real variables associated with it:
velocity_x
velocity_y
velocity_z
acceleration_z

When the spell is cast, you calculate velocity_x and velocity_y using the cos and sin functions. (velocity_x = (desired speed) * cos(angle between caster and target) ; velocity_y = (desired speed) * sin(angle between caster and target)

velocity_z you can make whatever you want for your arc (this is the rate at which the unit will change height), the important part is acceleration_z, which will decrease velocity_z by a small amount many times a second to give the perception of a curve.
Calculate how long the missile will be in flight (based on the distance and desired speed), and set acceleration_z (or velocity_z instead if you want a set acceleration) based on that number.

The loop should be a periodic 0.03.
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
Vector stuff in GUI is ugly.

velocity_z you can make whatever you want for your arc (this is the rate at which the unit will change height), the important part is acceleration_z, which will decrease velocity_z by a small amount many times a second to give the perception of a curve.
Calculate how long the missile will be in flight (based on the distance and desired speed), and set acceleration_z (or velocity_z instead if you want a set acceleration) based on that number.
.

Also this is total crapshit.
He probably wants it to hit a certain point and not just somewhere random.
Even if you do an approximation, terrainheights would throw it off.
This would be the correct formula for z_Vel
JASS:
((-gravity.z * t) / 2 - position.z/t + e/t)

I still recommend you to just use the parabola func.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Vector stuff in GUI is ugly.

Also this is total crapshit.
He probably wants it to hit a certain point and not just somewhere random.
Even if you do an approximation, terrainheights would throw it off.\

Sure it's "total crapshit"... except that it works. I have no idea why you think it would be "somewhere random", the apex is perfectly at the center as with a parabola.


  • Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm (Neutral Hostile)
    • Actions
      • Unit - Add Crow Form to (Triggering unit)
      • Unit - Remove Crow Form from (Triggering unit)
      • Set leapSpeed = 500.00
      • Set leapUnit = (Triggering unit)
      • Set tempLoc1 = (Position of (Triggering unit))
      • Set tempLoc2 = (Target point of ability being cast)
      • Set leapDx = ((leapSpeed x 0.03) x (Cos((Angle from tempLoc1 to tempLoc2))))
      • Set leapDy = ((leapSpeed x 0.03) x (Sin((Angle from tempLoc1 to tempLoc2))))
      • Set leapDuration = ((Distance between tempLoc1 and tempLoc2) / leapSpeed)
      • Set leapDuration = (leapDuration / 0.03)
      • Set leapDDz = -3.00
      • Set leapDz = ((leapDuration x leapDDz) / -2.00)
      • Set leapExitCondition = (leapDz x -1.00)
      • Custom script: call RemoveLocation(udg_tempLoc1)
      • Custom script: call RemoveLocation(udg_tempLoc2)
      • Unit - Pause leapUnit
      • Trigger - Turn on Loop <gen>
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Animation - Change leapUnit flying height to ((Current flying height of leapUnit) + leapDz) at 0.00
      • Set leapDz = (leapDz + leapDDz)
      • Custom script: call SetUnitX(udg_leapUnit, GetUnitX(udg_leapUnit) + udg_leapDx)
      • Custom script: call SetUnitY(udg_leapUnit, GetUnitY(udg_leapUnit) + udg_leapDy)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • leapDz Less than leapExitCondition
        • Then - Actions
          • Unit - Unpause leapUnit
          • Animation - Change leapUnit flying height to 0.00 at 0.00
          • Trigger - Turn off (This trigger)
        • Else - Actions

@ OP there's a testmap attached, it's currently for a unit to leap, but I'm sure you can figure out how to adjust it for a dummy missile unit.
 

Attachments

  • curvedleap.w3x
    17.8 KB · Views: 38
Level 25
Joined
Jul 10, 2006
Messages
3,315
I realise I probably worded my first post badly; what I mean to say is that OP can either:
- Have a fixed acceleration and calculate the velocity; or
- Have a fixed velocity and calculate the acceleration.

The reason for using the latter would be to reduce the "height" of the arc. In my testmap if you cast the leap far enough, it goes well above viewing height.
 
Status
Not open for further replies.
Top