AdamGriffith
You can change this now in User CP.
- Reaction score
- 69
This is just a piece of code that I made for my map and I found it quite useful.
It basically just moves a unit to a point with a uniform deceleration.
You specify the displacement, final velocity, time, which unit and the angle.
REQUIRES:
-NewGen
The code:
View attachment 23734
It basically just moves a unit to a point with a uniform deceleration.
You specify the displacement, final velocity, time, which unit and the angle.
REQUIRES:
-NewGen
The code:
JASS:
library Slide
//######################################################################################################################################\\
// Slide System \\
// By: \\
// AdamGriffith @ <a href="http://www.thehelper.net/" class="link link--internal">http://www.thehelper.net/</a> \\
// Adamdagr8@Northrend \\
// \\
// Key: \\
// S = Displacement \\
// U = Intial_Velocity \\
// V = Final_Velocity \\
// A = Acceleration \\
// T = Time \\
// \\
// Function list: \\
// call Slide_SVT(Displacement, Final_Velocity, Time, whatAngle, whichUnit) \\
// \\
//######################################################################################################################################\\
struct SlideData
real S = 0.00
real U = 0.00
real V = 0.00
real A = 0.00
real T = 0.00
real angle = 0.00
real time = 0.00
real x = 0.00
real y = 0.00
unit slider = null
endstruct
globals
private integer C = 0
private real timeout = 0.035 // This is the timeout of the SlideTimer. This value should be good for eyecandy and lag.
private timer SlideTimer = CreateTimer()
private SlideData array data
endglobals
private function Slide takes nothing returns nothing
local SlideData a
local integer i = C
local real displacement
local real newx
local real newy
loop
exitwhen i <= 0
set a = data<i>
set displacement = (a.U * a.time) + (0.50 * a.A * Pow(a.time, 2.00))
set newx = a.x + displacement * Cos(a.angle * bj_DEGTORAD)
set newy = a.y + displacement * Sin(a.angle * bj_DEGTORAD)
call SetUnitPosition(a.slider, newx, newy)
set a.time = a.time + timeout
if a.time >= a.T then
call a.destroy()
set data<i> = data[C]
set C = C - 1
if C == 0 then
call PauseTimer(SlideTimer)
else
endif
else
endif
set i = i - 1
endloop
endfunction
public function SVT takes real Displacement, real Final_Velocity, real Time, real whatAngle, unit whichUnit returns nothing
local SlideData a
set C = C + 1
set data[C] = SlideData.create()
set a = data[C]
set a.S = Displacement
set a.V = Final_Velocity
set a.T = Time
set a.U = (a.S / (0.5 * a.T)) - a.V
set a.A = (a.S - (a.V * a.T)) / (-0.50 * Pow(a.T, 2.00))
set a.angle = whatAngle
set a.slider = whichUnit
set a.x = GetUnitX(a.slider)
set a.y = GetUnitY(a.slider)
if C == 1 then
call TimerStart(SlideTimer, 0.035, true, function Slide)
else
endif
endfunction
//===========================================================================
function InitTrig_Slide takes nothing returns nothing
set gg_trg_Slide = CreateTrigger( )
endfunction
endlibrary</i></i>
View attachment 23734