View Single Post
Old 10-01-2007, 02:25 PM   #7
Malf
I LIKE PIZZA! | >
 
Malf's Avatar
 
Join Date: Sep 2007
Posts: 625

Submissions (2)

Malf has a spectacular aura about (92)Malf has a spectacular aura about (92)Malf has a spectacular aura about (92)Malf has a spectacular aura about (92)

Send a message via AIM to Malf
Default

SetCSData and GetCSData are the "UserDatas" for handles. They are exactly like SetUnitUserData and GetUnitUserData

You should also really use just one global timer. When you want to knockback a unit, add that unit to an array of some sort. Then whenever the global timer expires, it loops through all the units in the array.

Collapse JASS:
globals
    private integer INDEX = 0
endglobals

function callback takes nothing returns nothing
local struct d
local struct D
local integer i = 0
    loop
        set i = i+1
        exitwhen  > INDEX
        set d = struct(i)
        if d.currentdist > d.maxdist then
          call struct.destroy(d) //Destroys the struct, but it leaves an empty "space" later on when the timer iterates again
          //So you'd have to find out how to reorganize the structs' indexing
          set INDEX = INDEX - 1
        else
          set d.x = d.x + d.distance * Cos(d.a*0.01745)
          set d.y = d.y + d.distance * Sin(d.a*0.01745)
          call SetUnitPosition(d.u, d.x, d.y)
          set d.currentdist = d.currentdist + d.distance
        endif
    endloop
endfunction

function knockback unit takes unit u, blah blah nothing
local struct d = struct.create()
    set d.u = u
    etc,.
    set INDEX = INDEX + 1
endfunction

NOTE: I just wrote this within 10 minutes, it may be crappy :p
Malf is offline   Reply With Quote