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

[Trigger] Parabolic equations.

Status
Not open for further replies.
Level 4
Joined
Feb 22, 2006
Messages
31
Actually i managed to manipulate terrain height very easily with GUI. i made a linear ammo-movement system almost identiqual to Elim Tourny's. the ammo folows a line independantly of the terrain height and dies when it hit a wall. i already have a parabola system but its not as accurate as i would like it to be. it uses y=A(x-h)^2+k and sets "h" to 1/2 of the distance between my target and my nade-thrower, wich isnt very accurate when my thrower and my target point are on very different terrain heights


Purple: I would like to tell you it helped me, but unfortunatly i cant. i really dont understand jass AT ALL. im more used to concrete event-action-condition than to locals(<-really have no clue wut that is), vectors and takes/returns. from what i understood of shadow1500's drawing and formulas, his equations doesnt modify the parabola depending on the height of starting and arrival points, so it wouldnt be much better than what i already have.

i tried looking into Elim's tourny grenade script but bleeeehhh...i would basically need a translator:

function Trig_Grenade_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A001'
endfunction
function Trig_Grenade_Actions takes nothing returns nothing
local unit h=GetSpellAbilityUnit()
local location l=GetSpellTargetLoc()
local real x=GetLocationX(l)-GetUnitX(h)
local real y=GetLocationY(l)-GetUnitY(h)
local real a=Atan2BJ(y,x)
local real aoa
local unit u=CreateParticle(GetOwningPlayer(h),'e000',GetUnitX(h),GetUnitY(h),a)
local real array r
set r[2]=750
set r[0]=RMinBJ(r[2],SquareRoot(x*x+y*y))
set r[1]=SquareRoot(r[2]*VectorGetLength(G()))
set aoa=(bj_PI/2)-(Asin((r[0]*VectorGetLength(G()))/(r[1]*r[1]))/2)
call SetUnitTimeScalePercent(u,10.00)
call SetParticleSpeed(u,Cos(aoa)*CosBJ(a)*r[1],Cos(aoa)*SinBJ(a)*r[1],r[1]*Sin(aoa))
call SetParticleGravityFactor(u,1)
call SetGroundHitFunction(u,"GroundHit_Bounce")
call SetDeathFunction(u,"Death_Explode256")
call UnitApplyTimedLife(u,'BTLF',2.)
set l=null
set h=null
set u=null
endfunction

a parabolla with no equations other than trigonometry....there isnt even the SetUnitFlyingHeight function to change the grenade height....kinda wierd coding but if it works....=/

what are locals anyway? Variables stored and used on a unit like its life/mana/customvalue/movespeed/etc.?

i just need the equations to find my parabolla equation given my 3 values. the rest i can do by my own. no need jass functions or anything. just the equations to find my parabola.


i have been coding in gui for 4 years and i always managed to do what i wanted to do even if people told me i should use Jass. GUI have the same Jass posibilities. its just longer to do. With all the map-making pros on this website, i am sure one of them have a way for me to suceed.

Thanks for (upcoming maybe?) help =)
 
Last edited:
Level 4
Joined
Feb 22, 2006
Messages
31
Hmm, I know what you mean, but I'm not sure how to solve that.

You'd be using Custom Script actions, which are JASS.

nope. i set the "constant height" as the unit's mana+500
then it sets the unit flying height to its mana-500-Terrainheight of itsposition
If (Flying height)= or elss 5.00, Kill unit and create a "die effect" at same height/position.

no jass in that =)

the only jass i used was Call RemoveLocation and Call DestroyGroup
 
Level 15
Joined
Feb 15, 2006
Messages
851
Let's do a customizable parabolic equation, so you can develop a function to do that.

a parabolic function can be written in this way: y = ax^2+bx+c

so we need to know the values of a, b and c. How can we do that?? easy, let's see the initial conditions:

d = horizontal distance that the projectile should move.
h = maximum parabola height

x = 0; ax^2+bx+c = 0
x = d/2; ax^2+bx+c = h
x = d; ax^2+bx+c = 0

replacing in the equations the x value, we will obtain this:

a*0 + b*0 + c = 0 => c = 0
a*(d^2/4)+b*d/2 = h
a*d^2+b*d= 0


With the last two equations we can get a and b in terms of h and d, which are the known values. I did the calculations and the result are:

  • a = (-4*h)/(3*d^2)
  • b = (4*h)/(3*d)

now with that, we can do a function in JASS which calculates the height of the projectile in function of the maximum height and distance advanced in this way:

JASS:
function ParabolicMovement takes real h, real d, real x returns real
    // h, d, and x are in the same units of distance in WC3, which is more comfortable to use :)
    local real a = -4*h/(3*d*d)
    local real b = 4*h/(3*d)
    return a*x*x + b*x
endfunction

I hope this can help you with your spell. God bless math!!!
 
Last edited:
Level 4
Joined
Feb 22, 2006
Messages
31
its allright i fixed my parabolic equations.

Just incase you were curious i decided i would share with you my GUI triggers

Nade Creation:
  • Nade
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Nade
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current lumber) Greater than 0
        • Then - Actions
          • Set TempPoint1 = (Position of (Triggering unit))
          • Set TempPoint2 = (Target point of ability being cast)
          • Unit - Create 1 Nade for (Owner of (Triggering unit)) at TempPoint1 facing ((Angle from TempPoint1 to TempPoint2) + 0.00) degrees
          • Unit - Turn collision for (Last created unit) Off
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between TempPoint1 and TempPoint2) Less than or equal to 850.00
            • Then - Actions
              • Set HorizontalDistance = ((Distance between TempPoint1 and TempPoint2) + 0.00)
            • Else - Actions
              • Set TempPoint3 = (TempPoint1 offset by 850.00 towards (Angle from TempPoint1 to TempPoint2) degrees)
              • Set HorizontalDistance = 850.00
              • Custom script: call RemoveLocation (udg_TempPoint3)
          • Set Nade[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
          • Set VerticalDistance = ((Z height of TempPoint2) - (Z height of TempPoint1))
          • Set Dist[(Player number of (Owner of (Triggering unit)))] = ((HorizontalDistance / 100.00) x (1.00 + (VerticalDistance / 1500.00)))
          • Set K[(Player number of (Owner of (Triggering unit)))] = (3.00 / (Dist[(Player number of (Owner of (Triggering unit)))] / 3.60))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • K[(Player number of (Owner of (Triggering unit)))] Greater than 3.00
            • Then - Actions
              • Set K[(Player number of (Owner of (Triggering unit)))] = 3.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • K[(Player number of (Owner of (Triggering unit)))] Less than 1.00
                • Then - Actions
                  • Set K[(Player number of (Owner of (Triggering unit)))] = 1.00
                • Else - Actions
          • Set X[(Player number of (Owner of (Triggering unit)))] = 0.00
          • Set Speed[(Player number of (Owner of (Triggering unit)))] = 1.20
          • Set Facing[(Player number of (Owner of (Triggering unit)))] = (Angle from TempPoint1 to TempPoint2)
          • Set BaseHeight[(Player number of (Owner of (Triggering unit)))] = ((Z height of TempPoint1) + 50.00)
          • Set A[(Player number of (Owner of (Triggering unit)))] = (K[(Player number of (Owner of (Triggering unit)))] / (Power(((1.00 / 2.00) x Dist[(Player number of (Owner of (Triggering unit)))]), 2.00)))
          • Animation - Change (Last created unit) flying height to 60.00 at 0.00
          • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
          • Custom script: call RemoveLocation (udg_TempPoint1)
          • Custom script: call RemoveLocation (udg_TempPoint2)
          • Player - Add -1 to (Owner of (Triggering unit)) Current lumber
        • Else - Actions

Nade movement and collision detection
  • Nade move
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Nade[(Integer A)] Not equal to No unit
            • Then - Actions
              • Set TempPoint1 = (Position of Nade[(Integer A)])
              • Set TempPoint2 = (TempPoint1 offset by (Dist[(Integer A)] x Speed[(Integer A)]) towards Facing[(Integer A)] degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Z height of TempPoint2) Greater than ((Current flying height of Nade[(Integer A)]) + (Z height of TempPoint1))
                • Then - Actions
                  • Set TempPoint7 = (TempPoint2 offset by (Dist[(Integer A)] x (2.00 x Speed[(Integer A)])) towards (Facing[(Integer A)] + 180.00) degrees)
                  • Set TempPoint3 = (TempPoint7 offset by (Dist[(Integer A)] x (2.00 x Speed[(Integer A)])) towards 90.00 degrees)
                  • Set TempPoint4 = (TempPoint7 offset by (Dist[(Integer A)] x (2.00 x Speed[(Integer A)])) towards 270.00 degrees)
                  • Set TempPoint5 = (TempPoint7 offset by (Dist[(Integer A)] x (2.00 x Speed[(Integer A)])) towards 180.00 degrees)
                  • Set TempPoint6 = (TempPoint7 offset by (Dist[(Integer A)] x (2.00 x Speed[(Integer A)])) towards 0.00 degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Z height of TempPoint3) Greater than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 5.00))
                          • (Z height of TempPoint4) Greater than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 5.00))
                      • (Z height of TempPoint5) Less than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 1.00))
                      • (Z height of TempPoint6) Less than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 1.00))
                    • Then - Actions
                      • Custom script: call RemoveLocation (udg_TempPoint2)
                      • Set Facing[(Integer A)] = (Facing[(Integer A)] - (2.00 x Facing[(Integer A)]))
                      • Set TempPoint2 = (TempPoint1 offset by (Dist[(Integer A)] x 8.00) towards Facing[(Integer A)] degrees)
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Z height of TempPoint5) Greater than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 5.00))
                          • (Z height of TempPoint6) Greater than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 5.00))
                      • (Z height of TempPoint3) Less than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 1.00))
                      • (Z height of TempPoint4) Less than ((Current flying height of Nade[(Integer A)]) + ((Z height of TempPoint1) + 1.00))
                    • Then - Actions
                      • Custom script: call RemoveLocation (udg_TempPoint2)
                      • Set Facing[(Integer A)] = (Facing[(Integer A)] + (180.00 - (2.00 x Facing[(Integer A)])))
                      • Set TempPoint2 = (TempPoint1 offset by (Dist[(Integer A)] x (1.50 x Speed[(Integer A)])) towards Facing[(Integer A)] degrees)
                    • Else - Actions
                  • Custom script: call RemoveLocation (udg_TempPoint3)
                  • Custom script: call RemoveLocation (udg_TempPoint4)
                  • Custom script: call RemoveLocation (udg_TempPoint5)
                  • Custom script: call RemoveLocation (udg_TempPoint6)
                  • Custom script: call RemoveLocation (udg_TempPoint7)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of Nade[(Integer A)]) Less than or equal to 5.00
                  • (Z height of TempPoint1) Less than ((Z height of TempPoint2) + 5.00)
                  • (Z height of TempPoint1) Greater than ((Z height of TempPoint2) - 5.00)
                • Then - Actions
                  • Set K[(Integer A)] = ((K[(Integer A)] + ((BaseHeight[(Integer A)] - (Z height of TempPoint2)) / 150.00)) / 2.00)
                  • Set X[(Integer A)] = 0.00
                  • Set Dist[(Integer A)] = (Dist[(Integer A)] - (((Z height of TempPoint2) - (Z height of TempPoint1)) x ((K[(Integer A)] x Dist[(Integer A)]) x 0.60)))
                  • Set Dist[(Integer A)] = (Dist[(Integer A)] / 2.00)
                  • Set Speed[(Integer A)] = (Speed[(Integer A)] x 1.50)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Dist[(Integer A)] Less than 0.00
                    • Then - Actions
                      • Set Facing[(Integer A)] = (Facing[(Integer A)] + 180.00)
                      • Set Dist[(Integer A)] = (Dist[(Integer A)] x -1.00)
                    • Else - Actions
                  • Set BaseHeight[(Integer A)] = ((Z height of TempPoint2) + 6.00)
                  • Set A[(Integer A)] = (K[(Integer A)] / (Power(((1.00 / 2.00) x Dist[(Integer A)]), 2.00)))
                  • Unit - Set the custom value of Nade[(Integer A)] to 1
                • Else - Actions
              • Unit - Move Nade[(Integer A)] instantly to TempPoint2
              • Animation - Change Nade[(Integer A)] flying height to ((-100.00 x (A[(Integer A)] x (Power((X[(Integer A)] - ((1.00 / 2.00) x Dist[(Integer A)])), 2.00)))) - ((Z height of TempPoint2) + ((K[(Integer A)] x -100.00) - BaseHeight[(Integer A)]))) at 0.00
              • Set X[(Integer A)] = (X[(Integer A)] + ((Dist[(Integer A)] / 100.00) x Speed[(Integer A)]))
              • Custom script: call RemoveLocation (udg_TempPoint1)
              • Custom script: call RemoveLocation (udg_TempPoint2)
            • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top