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

[JASS] Math Formula

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
( the quotes are for unknown or of someway of explaining )

Ok you all know the spell Impale( wc3 ). And the Impale buff, the one that hits the units and sends them up into the sky.

I need a formula to calculate something( i dont really know )

It's like a Jump, just with no arch and no movement, just the height change. Starts fast( because of the thrust ) and with higher velocities you get higher "thrusts". The unit slows down when going up due to the gravity and when the "speed( or sum ) is at 0 it starts to drop. The "loop" will end( it will stop moving ) when it has landed on the ground.

For all of you Jass and vJass users i think you would understand better if i would show you some calls and variables

JASS:
function Thrust takes unit u, real v, real t returns nothing

u = Unit
v = Velocity
t = Time it takes

So it is some sort of formula that calculates height after how many / what it has done.

Gravity variable is in this, " G ". So the real ' v ' is affected by the gravity.

The unit's height is changed every interval " I ".
 
Level 9
Joined
Nov 28, 2008
Messages
704
I dont think its a parabola. Parabolas involve archs.

Why not just make a knockback function and replace changing X and Y with height? And you would have to cancel it not when it reaches 0, but when its lower then the * -1 of your original velocity, no?
 
You´ve never seen that function haven´t you?^^
Check this, it uses that.
800px-Simple_sine_wave.svg.png
 
Level 7
Joined
Jul 20, 2008
Messages
377
What GhostWolf means is that you just set an initial velocity for the unit, then:

1) add velocity to height
2) subtract a gravity constant from your velocity
3) stop when height is at most 0 (I use "at most" because I like to play it safe).

Note, of course, this means you must initially change the height -before- checking if height is at most 0, otherwise it won't even make the jump.

EDIT: Or, of course, you could use the sine function to change the unit's height as the post above says. That would work too, just take the maximum height you want the unit to jump up to and then multiply that by sin (t*constant) where

t = time (seconds, perhaps?)
constant = adjusts the rate at which height changes.

Stop when t*constant hits 180.

>.<
Sine(0)=0
Sine(180)=1
Got it?

No, Sin(90)=1.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Sinus(sin) is a mathematical function like cosinus(cos) and tangens(tan) and it gives you numbers from -1 to 1, just like cosinus. Tangens works different. Cosinus and Sinus is useful when dealing with coordinates (I'm not so good with tangens). Example use of Sin and Cos:
JASS:
function example takes unit u, real velocity, real angle returns nothing
    local vx = velocity * Cos(angle)
    local vy = velocity * Sin(angle)
    local real x1 = GetUnitX(u)
    local real y1 = GetUnitY(u)
    local real x2
    local real y2
    loop
        set x2 = x1 + vx
        set y2 = y1 + vy
        call SetUnitX(u, x2)
        call SetUnitY(u, y2)
        set x1 = x2
        set y1 = y2
    endloop
endfunction
This is not a great example, but I think it helps explain. Remember: Sinus and Cosinus uses radians instead of degrees.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
a = m/s2
a = speed increase every s timeinterval,,
on earth, the speed increase is 9,81 m/s2

Wait a sec, im looking for my fysics book now ^^

EDIT:
Found it!
s = distance
a = speed increase (dunno how to say in english)
t = time

s = 0,5 * v * t
When you are falling, your speed increases every 't' in secs by 'a'
So, sec 1, you fall out of a plane, your speed is 50 m/s
sec 2 = 59,81 m/s
sec 3 = 69,62 m/s
(i thought so)

Hope i helped you ^^

P.S. If i read it wrong, and you dont mean falling down, then dont even think about what i said^^ xD
 
Status
Not open for further replies.
Top