Making this mui/mpi

AdamGriffith

You can change this now in User CP.
Reaction score
69
JASS:
function Slide_SVT_01 takes real displacement, real final_velocity, real time, unit u returns nothing
    local timer t1 = CreateTimer()
    set udg_S = displacement
    set udg_V = final_velocity
    set udg_T = time
    set udg_U = (udg_S / (0.5 * udg_T)) - udg_V
    set udg_A = (udg_S - (udg_V * udg_T)) / (-0.5 * Pow(udg_T, 2))
    set udg_Unit = u
    set udg_Point = GetUnitLoc(udg_Unit)
    call TimerStart(t1, 0.035, true, function Slide_SVT_02)
endfunction

JASS:
function Slide_SVT_02 takes nothing returns nothing
    local real distance = (udg_U * udg_Real) + (0.5 * udg_A * Pow(udg_Real, 2))
    local location point = PolarProjectionBJ(udg_Point, distance, GetUnitFacing(udg_Unit))
    local timer t1 = GetExpiredTimer()
    call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, R2S(distance))
    call SetUnitPositionLoc(udg_Unit, point)
    if udg_Real >= udg_T then
        call DestroyTimer(t1)
        set udg_Real = 0
    else
    set udg_Real = udg_Real + 0.035
    endif
    call RemoveLocation(point)
endfunction


JASS:
call Slide_SVT_01(displacement, final_velocity, time, u)
 

Flare

Stops copies me!
Reaction score
662
Loop array method

You'll need a global integer var which will count current instances (by default, it'll be 0) and all your variables will need an array

You'll need to make this the timer callback function
JASS:
function ArrayLooper takes nothing returns nothing
local integer i = udg_Counter
local real distance
local point P
//Any other locals you may need, such as x1, y1, etc
loop
exitwhen i <= 0
   set distance = (udg_U<i> * udg_Real<i>) + (0.5 * udg_A<i> * Pow(udg_Real<i>, 2))
   set P = PolarProjectionBJ (udg_Point<i>, distance, GetUnitFacing (udg_Unit<i>))
   call SetUnitPositionLoc (udg_Unit<i>, P)
   call RemoveLocation (P)
   set udg_Real<i> = udg_Real<i> + 0.035
   if udg_Real<i> &gt;= (your intended value) then
       call RemoveLocation (udg_Point<i>)
       set udg_Point<i> = udg_Point[udg_Counter]
//And the same with the rest of your global variable arrays
//This moves all the data from the last, current slide instance to the &#039;slot&#039; we just freed up, to reduce the stuff being looped through by the timer
       set udg_Counter = udg_Counter - 1
   endif
   set i = i - 1
endloop
endfunction
</i></i></i></i></i></i></i></i></i></i></i></i>


Then, in your initiating function
JASS:
function Start takes ... returns nothing
//Locals that you may need
set udg_Counter = udg_Counter + 1
set udg_Unit[udg_Counter] = whichUnit
//Set the rest of your variables
endfunction


function InitTrig_SomeName takes nothing returns nothing
call TimerStart (udg_Timer, 0.035, true, function ArrayLooper) //0.03125 is probably a better timer period choice, since it&#039;ll reach 1 second exactly (0.035 will overshoot the 1 second mark) and it allows for greater precision with your displacement.
endfunction
//Single timer is better than numerous timers IMO



OR!!!

Use NewGen/vJASS and structs. It'd be easier than that since you can just declare a struct array via global blocks (alongside any other globals you may need)
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Or globalize a struct array.
JASS:
library MySystem

globals
    private timer T = CreateTimer()
    private integer Count = 0
endglobals

private struct SystemData
    unit u
    real displacement
    real finalvelocity
    real time
    static method create takes unit u, real displacement, real finalvelocity, real time returns SystemData
        local SystemData data = SystemData.allocate()
        set data.u = u
        set data.displacement = displacement
        set data.finalvelocity = finalvelocity
        set data.time = time
        return data
    endmethod
endstruct

globals
    private SystemData array Data
endglobals

function Slide_SVT_02 takes nothing returns nothing
    local SystemData data
    local integer i = Count
    loop
        exitwhen i &lt;= 0
            set data = Data<i>
            //Do actions
            if &lt;YourTimeCounter&gt; &gt;= data.time then
                call data.destroy()
                set Data<i> = Data[Count]
                set Data[Count] = 0
                set Count = Count - 1
            endif
        set i = i - 1
    endloop

    if Count == 0 then
        call PauseTimer(T)
    endif
endfunction

function Slide_SVT_01 takes real displacement, real final_velocity, real time, unit u returns nothing
    local SystemData data

    set Count = Count + 1
    set Data[Count] = data.create(u, displacement, final_velocity, time)

    if Count == 1 then
        call TimerStart(T, 0.035, true, function Slide_SVT_02)
    endif
endfunction

endlibrary</i></i>


Freehand written but you get the point.
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
I have no idea how to use vJass but i'll give it ago.
Will post here in a second.

What does a scope mean?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Scopes and libraries allows you to make variables, structs functions etc private or public members of the scope/library, giving them names dependant on the scope/libraryname.

Example:

JASS:
scope Thing

globals
    public integer Count = 1
endglobals

endscope


You would be able to access the variable Count by refering to <Scopename>_<Variablename>, in this case Thing_Count.

Private members of a scope/library are only accessible within the scope/library they are declared in.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Libraries are moved to the map header, which makes them awesome for systems.
 

Flare

Stops copies me!
Reaction score
662
I don't really know what the word scope means, but they're awesome :D

Normally, JASS functions will clash if their names are the same e.g.
JASS:
function Test takes nothing returns nothing
endfunction

function Test takes nothing returns nothing
endfunction


However, if these functions are declared in separate scopes, with a private/public prefix (private and public prefixes are only usable in scopes and libraries) like so
JASS:
scope FirstScope
private function Test takes nothing returns nothing
endfunction

endscope


scope SecondScope
private function Test takes nothing returns nothing
endfunction

endscope

//Functions of the same name within the same scope/library, regardless of being private/public, will have name conflicts I think


The private prefix generates a random number which is placed before your function's name (IIRC, it would look like this: <scopename>_10234456 (just a random number I made up ^^)_<function name> ). And, private members can't be used anywhere other than the scope/library they were declared in whereas public members can be used like so:
<scope/library name>_<function name>

There's a tutorial on scopes and libraries somewhere, it might explain it better than I have :p

It's very useful for making spells, where you want to use fairly general function names e.g. function SpellCondition, function SpellActions, function TimerCallback, function GroupCallback, and so on
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Okay but other than moved to the map header, is that the only difference?
Like the public and private thing works in the same way.

Also, thanks for that little mini tut flare! :thup:

And, do globals in a global block need to have a udg_ prefix?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
vJASS globals does not require udg_, which makes them more awesome than user defined crapglobals.
 

Flare

Stops copies me!
Reaction score
662
They don't need the udg_ prefix, but you can use it (if, say, you wanted to port a non-vJASS system to vJASS, and wanted to make the old stuff compatible)

If you don't know how to declare global blocks
JASS:
globals
unit myUnit
real myReal
integer array myIntArray
endglobals


EDIT: Couldn't find that tutorial on scopes and libraries, but here's one in relation to vJASS, which should explain their purpose, where to use them, and how to use them
Link
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Hmmmm....
Any idea why this doesn't work?

JASS:
library SlideSVT

globals
    private location Point
    private real S
    private real U
    private real V
    private real A
    private real T
    private real Time
    private unit Unit
endglobals

function Slide_SVT_02 takes nothing returns nothing
    local real distance = (U * Time) + (0.5 * A * Pow(Time, 2))
    local location point = PolarProjectionBJ(Point, distance, GetUnitFacing(Unit))
    local timer t1 = GetExpiredTimer()
    call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, R2S(distance))
    call SetUnitPositionLoc(Unit, point)
    if Time &gt;= T then
        call DestroyTimer(t1)
        set Time = 0
    else
    set Time = Time + 0.035
    endif
    call RemoveLocation(point)
endfunction

function Slide_SVT_01 takes real displacement, real final_velocity, real time, unit u returns nothing
    local timer t1 = CreateTimer()
    set S = displacement
    set V = final_velocity
    set T = time
    set U = (S / (0.5 * T)) - V
    set A = (S - (V * T)) / (-0.5 * Pow(T, 2))
    set Unit = u
    set Point = GetUnitLoc(Unit)
    call TimerStart(t1, 0.035, true, function Slide_SVT_02)
endfunction

endlibrary
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
It just goes to the warcraft 3 game screen.
And yes, I know you have to save NewGen before you can test.
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Nope still not working.
Could you maybe look over the trigger and see if anything is wrong:
JASS:
library slide

globals
    private location Point
    private real S
    private real U
    private real V
    private real A
    private real T
    private real Time
    private timer Timer
    private unit Unit
endglobals

function Slide_SVT_02 takes nothing returns nothing
    local real distance = (U * Time) + (0.5 * A * Pow(Time, 2))
    local location point = PolarProjectionBJ(Point, distance, GetUnitFacing(Unit))
    local timer t1 = GetExpiredTimer()
    call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, R2S(distance))
    call SetUnitPositionLoc(Unit, point)
    if Time &gt;= T then
        call DestroyTimer(t1)
        set Time = 0
    else
    set Time = Time + 0.035
    endif
    call RemoveLocation(point)
endfunction

function Slide_SVT_01 takes real displacement, real final_velocity, real time, unit u returns nothing
    set S = displacement
    set V = final_velocity
    set T = time
    set U = (S / (0.5 * T)) - V
    set A = (S - (V * T)) / (-0.5 * Pow(T, 2))
    set Unit = u
    set Point = GetUnitLoc(Unit)
    call TimerStart(Timer, 0.035, true, function Slide_SVT_02)
endfunction

endlibrary

Also, the JassHelper checker thing gives no errors. =S
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top