• 🏆 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] Formula Parabola "oblique"

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
Hi Everyone

currently iv been making a spell e-z :The hero go at height "500" than he throw a missile.... This missile should not jump or do arc since the hero is already in the air!!


for this use i have work on Engine to make it for me But there is a problem Its alway jumps!!!


I guess there a special formula for this its should do an oblique From up to down & Down to up : we could call it like a Kind of Bullet system

my code is pretty crappy i guess ..... i would like to not use other people stuff and use mine becuz i made it and i know all code so i know how to modify it. I think this problem require more than only reading and spaming answer : i would like to get feedback after answer from people


p.s. : there is a bug at the end It wont go fully to ground like it should maybe its the formula or condition ?

here is my code so far




  • JumpX Engine
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JPX_Index_Size Equal to 0
        • Then - Actions
          • Trigger - Turn on JumpX Loop <gen>
        • Else - Actions
      • -------- Increase the index size --------
      • Set JPX_Index_Size = (JPX_Index_Size + 1)
      • -------- Dynamic Index --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JPX_Index_Size Greater than JPX_Index_maxSize
        • Then - Actions
          • Set JPX_Index[JPX_Index_Size] = JPX_Index_Size
          • Set JPX_Index_maxSize = JPX_Index_Size
        • Else - Actions
      • -------- Dynamic Index End --------
      • Set JPXInt = JPX_Index[JPX_Index_Size]
      • -------- Setup those arrays --------
      • -------- --------------------------------------------------------- --------
      • Set JPX_CASTER[JPXInt] = JumpXCaster
      • -------- ################ --------
      • Set TempLoc = (Position of JPX_CASTER[JPXInt])
      • Set TempLoc2 = JumpXPoint2
      • -------- ################ --------
      • -------- --------------------------------------------------------- --------
      • Set JPX_ANGLE[JPXInt] = JumpXAngle
      • Set JPX_MaxDistance[JPXInt] = JumpXMaxDistance
      • -------- --------------------------------------------------------- --------
      • -------- ################ --------
      • -------- --------------------------------------------------------- --------
      • Set JPX_CurDistance[JPXInt] = 0.00
      • Set JPX_FHEIGHT[JPXInt] = 0.00
      • Set JPX_Formula[JPXInt] = 0.00
      • -------- --------------------------------------------------------- --------
      • Set JPX_COUNTER[JPXInt] = 0
      • Set JPX_XCOUNTER[JPXInt] = 0
      • -------- --------------------------------------------------------- --------
      • -------- ################ --------
      • -------- --------------------------------------------------------- --------
      • -------- if true than set arc if false set max height --------
      • Set JPX_SPEED[JPXInt] = JumpXSpeed
      • Set JPX_ARC[JPXInt] = JumpXArc
      • Set JPX_MAXHEIGHT[JPXInt] = JumpXMaxHeight
      • -------- --------------------------------------------------------- --------
      • -------- --------------------------------------------------------- --------
      • Set JPX_ARCYesNo[JPXInt] = JumpXArcOrHeight
      • Set JPX_MissileOrUnit[JPXInt] = JumpX_MissileOrUnit
      • -------- --------------------------------------------------------- --------
      • Set JPX_String[JPXInt] = JumpXString
      • Set JPX_String2[JPXInt] = JumpXString2
      • -------- --------------------------------------------------------- --------
      • Set JPX_TIME_COUNTER1[JPXInt] = JumpXTIME_COUNTER1
      • Set JPX_TIME_COUNTER2[JPXInt] = JumpXTIME_COUNTER2
      • -------- --------------------------------------------------------- --------
      • Set JPX_DMG[JPXInt] = JumpXDMG
      • Set JPX_DMG_AOE[JPXInt] = JumpXDMG_AOE
      • Set JPX_DUMMY_ANIMATION_SPEED[JPXInt] = JumpXDUMMY_ANIMATION_SPEED
      • Set JPX_DUMMY_BLUE[JPXInt] = JumpXDUMMY_BLUE
      • Set JPX_DUMMY_GREEN[JPXInt] = JumpXDUMMY_GREEN
      • Set JPX_DUMMY_RED[JPXInt] = JumpXDUMMY_RED
      • Set JPX_DUMMY_SIZE[JPXInt] = JumpXDUMMY_SIZE
      • -------- --------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JPX_ARCYesNo[JPXInt] Equal to True
        • Then - Actions
          • Custom script: set udg_JPX_Formula2[udg_JPXInt] = ( 4 * udg_JPX_ARC[udg_JPXInt])
        • Else - Actions
          • Custom script: set udg_JPX_Formula2[udg_JPXInt] = ( 4 * udg_JPX_MAXHEIGHT[udg_JPXInt] / udg_JPX_MaxDistance[udg_JPXInt])
      • -------- --------------------------------------------------------- --------
      • -------- ################ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JPX_MissileOrUnit[JPXInt] Equal to True
        • Then - Actions
          • Unit - Create 1 Dummy DUMMY for (Owner of JPX_CASTER[JPXInt]) at TempLoc facing (Angle from TempLoc to TempLoc2) degrees
          • Set JPX_MISSILE[JPXInt] = (Last created unit)
          • Set TempLoc3 = (Position of JPX_MISSILE[JPXInt])
          • Unit - Move JPX_MISSILE[JPXInt] instantly to TempLoc, facing JPX_ANGLE[JPXInt] degrees
          • -------- ################ --------
          • Special Effect - Create a special effect attached to the origin of JPX_MISSILE[JPXInt] using JPX_String[JPXInt]
          • Set JPX_SFX[JPXInt] = (Last created special effect)
        • Else - Actions
          • Set JPX_MISSILE[JPXInt] = JPX_CASTER[JPXInt]
          • Set TempLoc3 = (Position of JPX_MISSILE[JPXInt])
          • Unit - Move JPX_MISSILE[JPXInt] instantly to TempLoc, facing JPX_ANGLE[JPXInt] degrees
      • -------- ################ --------
      • -------- --------------------------------------------------------- --------
      • Set JPX_INITIALHEIGHT[JPXInt] = (Current flying height of JPX_MISSILE[JPXInt])
      • -------- some stuff to make it good mui --------
      • Set JPX_BOOLEAN[JPXInt] = True
      • Set JPX_BOOLEANBomb[JPXInt] = True
      • -------- --------------------------------------------------------- --------
      • -------- basic stuff to make the missile take height when need :) --------
      • Unit - Add Storm Crow Form to JPX_MISSILE[JPXInt]
      • Unit - Remove Storm Crow Form from JPX_MISSILE[JPXInt]
      • Unit - Turn collision for JPX_MISSILE[JPXInt] Off
      • Custom script: set udg_JPX_FHEIGHT[udg_JPXInt] = GetUnitFlyHeight(udg_JPX_MISSILE[udg_JPXInt])
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
      • Custom script: call RemoveLocation(udg_TempLoc3)
  • JumpX Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer JPX_LOOP) from 1 to JPX_Index_Size, do (Actions)
        • Loop - Actions
          • -------- This let look everything cleaner. --------
          • Set JPXInt = JPX_Index[JPX_LOOP]
          • Set TempLoc = (Position of JPX_MISSILE[JPXInt])
          • Set TempLoc2 = (TempLoc offset by JPX_SPEED[JPXInt] towards JPX_ANGLE[JPXInt] degrees)
          • Set JPX_CURRENTHEIGHT[JPXInt] = (Current flying height of JPX_MISSILE[JPXInt])
          • Set JPX_CurDistance[JPXInt] = (JPX_CurDistance[JPXInt] + JPX_SPEED[JPXInt])
          • Custom script: set udg_JPX_Formula3[udg_JPXInt] = (udg_JPX_MaxDistance[udg_JPXInt] - udg_JPX_CurDistance[udg_JPXInt])
          • Custom script: set udg_JPX_Formula4 [udg_JPXInt] =(udg_JPX_CurDistance[udg_JPXInt] / udg_JPX_MaxDistance[udg_JPXInt])
          • Custom script: set udg_JPX_Formula[udg_JPXInt] = udg_JPX_Formula2[udg_JPXInt] * udg_JPX_Formula3[udg_JPXInt] * udg_JPX_Formula4[udg_JPXInt]
          • Custom script: call SetUnitFlyHeight(udg_JPX_MISSILE[udg_JPXInt],GetLocationZ(udg_TempLoc) + udg_JPX_FHEIGHT[udg_JPXInt]+ udg_JPX_Formula[udg_JPXInt],0.)
          • -------- Condition... --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • JPX_Formula[JPXInt] Greater than 0.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • JPX_CurDistance[JPXInt] Less than JPX_MaxDistance[JPXInt]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Playable map area) contains TempLoc2) Equal to True
                    • Then - Actions
                      • Unit - Move JPX_MISSILE[JPXInt] instantly to TempLoc2, facing JPX_ANGLE[JPXInt] degrees
                    • Else - Actions
                      • Set JPX_MaxDistance[JPXInt] = 0.00
                      • Custom script: set udg_JPX_Formula[udg_JPXInt] = 0.
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • JPX_MissileOrUnit[JPXInt] Equal to True
                        • Then - Actions
                          • Unit - Remove JPX_MISSILE[JPXInt] from the game
                        • Else - Actions
                • Else - Actions
              • -------- Actions --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • JPX_BOOLEANBomb[JPXInt] Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • JPX_CurDistance[JPXInt] Greater than (JPX_MaxDistance[JPXInt] - 35.00)
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • JPX_Formula[JPXInt] Less than or equal to 0.00
                        • Then - Actions
                          • Set JPX_BOOLEANBomb[JPXInt] = False
                          • Game - Display to (All players) the text: KILL THE MISSILE
                          • Animation - Change JPX_MISSILE[JPXInt] flying height to JPX_INITIALHEIGHT[JPXInt] at 0.00
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • JPX_MissileOrUnit[JPXInt] Equal to True
                            • Then - Actions
                              • Unit - Remove JPX_MISSILE[JPXInt] from the game
                            • Else - Actions
                              • Unit - Turn collision for JPX_MISSILE[JPXInt] On
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • JPX_CASTER[JPXInt] Equal to JPX_MISSILE[JPXInt]
                                • Then - Actions
                                • Else - Actions
                          • Special Effect - Destroy JPX_SFX[JPXInt]
                          • Unit - Create 1 Dummy DUMMY for (Owner of JPX_CASTER[JPXInt]) at TempLoc facing Default building facing degrees
                          • Set JPX_DUMMY[JPXInt] = (Last created unit)
                          • Unit - Add a 2.00 second Generic expiration timer to JPX_DUMMY[JPXInt]
                          • Animation - Change JPX_DUMMY[JPXInt]'s size to (JPX_DUMMY_SIZE[JPXInt]%, JPX_DUMMY_SIZE[JPXInt]%, JPX_DUMMY_SIZE[JPXInt]%) of its original size
                          • Animation - Change JPX_DUMMY[JPXInt]'s vertex coloring to (JPX_DUMMY_RED[JPXInt]%, JPX_DUMMY_GREEN[JPXInt]%, JPX_DUMMY_GREEN[JPXInt]%) with 0.00% transparency
                          • Animation - Change JPX_DUMMY[JPXInt]'s animation speed to JPX_DUMMY_ANIMATION_SPEED[JPXInt]% of its original speed
                          • Special Effect - Create a special effect at TempLoc using JPX_String2[JPXInt]
                          • Special Effect - Destroy (Last created special effect)
                          • Game - Display to (All players) the text: END
                          • Set JPX_GROUP[JPXInt] = (Units within JPX_DMG_AOE[JPXInt] of TempLoc matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of JPX_CASTER[JPXInt])) Equal to False)))
                          • Unit Group - Pick every unit in JPX_GROUP[JPXInt] and do (Actions)
                            • Loop - Actions
                              • Unit - Cause JPX_CASTER[JPXInt] to damage (Picked unit), dealing JPX_DMG[JPXInt] damage of attack type Magic and damage type Demolition
                          • -------- Destroy handles --------
                          • Custom script: call DestroyGroup(udg_JPX_GROUP[udg_JPXInt])
                          • -------- RecycleIndex --------
                          • Set JPX_Index[JPX_LOOP] = JPX_Index[JPX_Index_Size]
                          • Set JPX_Index[JPX_Index_Size] = JPXInt
                          • Set JPX_Index_Size = (JPX_Index_Size - 1)
                          • Set JPX_LOOP = (JPX_LOOP - 1)
                        • Else - Actions
                    • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_TempLoc)
      • -------- Turn the trigger again off if the index_size is below 0... --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JPX_Index_Size Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc2)

 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
If you want just a straight linear projectile, use simple line maths.

lets say your hero is 500 units higher than the target and is 250 units away from the target. You simply decrease the projectile height by 2 units per target (500/250). For a formula you just use a simple line formula y = mx+c where y is the height above ground.

This is the most simple way to get a line but the line will not take into account the distance the projectile travels only the distance from point to point on the ground. For a more realistic version you use 2D trigonometry to work out the hypotonuse of the RAT triangle formed and from that divide by the velocity the thing is moving at to get the time for it to cover that distance. You have a time so you can simply divide its delta height by that to get the average velocty directly downwards. This would mean even a directly virticle shot downwards will still behave properly and have travel time.

Well if you want a curvy fall down, that is also simple and it involves simlar maths although you can no longer rely on an average velocity. You will have to decide how you want it to look.

The easiest is a cos shape, where you simply multiply it by the delta of heights and then add an offset onto its height. The angle inputed you are after is 0 to pi/2 where pi/2 is only obtained at the end. For proper velocity of it it becomes trickier as you have to use the differential of your formula which is -sin instead of cos. That then gives you the gradient, the ratio of height over horozontal movement. You can then inverse tan and use sin and cos to get the multiplyer for its velocity at any point so you can displace it correctly. Ofcourse there is an even better but more complicated way of this to factor in the distance traveled during the time but im tired.

For a parabola you use a quadratic with -(x*factor)^2 and an offset. Then repeate the above with differentiation and stuff.

For a division (x^-1) graph you will probably also have to do some offseting and the incriment into the formula is different, I do not think this is what you are after.
 
Level 10
Joined
Feb 20, 2008
Messages
448
hmm, i see how the first could work but, i would like to try the parabola Could you show me an parabola exemple in gui(base on my code if possible) ? becuz im a lil bit lost atm.....

does it exist a Vector Engine in gui ? becuz im very lost now lol... i ask 1 of my friend that were good vjass Call Wizardum and he didnt succed and have time to help me do it

Thanks for your helps... But you should have link me this http://www.hiveworkshop.com/forums/spells-569/gui-bullet-arc-missile-system-v1-00-a-157856/ O_O if u change the height its do what i want it to do O_O i will learn about it since i need image to get it

Thanks :D
 
Last edited:
Status
Not open for further replies.
Top