- Joined
- Jul 28, 2008
- Messages
- 211
As usual, i have a problem 
VERY IMPORTANT READ:I know i DON'T destroy the struct. I'll put that in later. Don't say "You don't destroy the struct" and stuff like that!
So as usual, the dummy won't move. I set its speed to 1, but it still doesn't work.

JASS:
scope Slide initializer Init
globals
constant integer SPELL_ID = 'A000'
constant integer DUMMY_ID = 'h000'
constant real SPEED = 600
constant real INTERVAL = 0.035
timer Tim
endglobals
struct Slide
unit u
real x
real y
real dx
real dy
static Slide array Index
static integer Total
static method Loop takes nothing returns nothing
local Slide dat
local integer i = 0
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
set dat.x = dat.x + dat.dx
set dat.y = dat.y + dat.dy
call SetUnitPosition(dat.u, dat.x, dat.y)
set dat.Total = dat.Total - 1
set dat.Index[i] = dat.Index[dat.Total]
endloop
if dat.Total == 0 then
call PauseTimer(Tim)
endif
endmethod
static method Start takes unit caster, real targetX, real targetY returns nothing
local Slide dat = Slide.allocate()
local real distanceX
local real distanceY
local real distance
local real angle
set dat.x = GetUnitX(caster)
set dat.y = GetUnitY(caster)
set distanceX = targetX - dat.x
set distanceY = targetY - dat.y
set distance = SquareRoot(distanceX * distanceX + distanceY * distanceY)
set dat.dx = distanceX/distance*SPEED*INTERVAL
set dat.dy = distanceY/distance*SPEED*INTERVAL
set angle = bj_DEGTORAD * Atan2(distanceY, distanceX)
set dat.u = CreateUnit(GetOwningPlayer(caster), DUMMY_ID, dat.x, dat.y, angle)
if dat.Total == 0 then
call TimerStart(Tim, INTERVAL, true, function Slide.Loop)
endif
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
private function Act takes nothing returns nothing
local location l = GetSpellTargetLoc()
call Slide.Start( GetTriggerUnit(), GetLocationX(l), GetLocationY(l) )
call RemoveLocation(l)
set l = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition( function Cond ) )
call TriggerAddAction(t, function Act )
set Tim = CreateTimer()
endfunction
endscope
VERY IMPORTANT READ:I know i DON'T destroy the struct. I'll put that in later. Don't say "You don't destroy the struct" and stuff like that!
So as usual, the dummy won't move. I set its speed to 1, but it still doesn't work.