- Joined
- Jul 28, 2008
- Messages
- 211
I said i would post my code when I get to my computer, but I couldn't wait so I made a new one. Here's the code:
Earlier I sad that i tried creating an effect at x and y and that it did move, but now, like the dummy unit, it doesn't. What's the problem here?
Thanks in advance!
JASS:
scope Missle initializer Init
globals
constant integer SPELL_ID = 'A000'
constant integer UNIT_ID = 'h000'
timer Tim
endglobals
struct Data
unit u
real cos
real sin
real angle
static Data array Index
static integer Total
static method Move takes nothing returns nothing
local Data dat
local integer i = 0
local real x
local real y
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
set y = GetUnitY(dat.u) + 5 * dat.sin
set x = GetUnitX(dat.u) + 5 * dat.cos
call SetUnitX(dat.u, x)
call SetUnitY(dat.u, y)
call DestroyEffect( AddSpecialEffect( "Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl", x, y) )
call dat.destroy()
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 Data dat = Data.allocate()
set dat.angle = bj_RADTODEG * Atan2(targetY - GetUnitY(caster), targetX - GetUnitX(caster))
set dat.u = CreateUnit(GetOwningPlayer(caster), UNIT_ID, GetUnitX(caster), GetUnitY(caster), dat.angle)
set dat.cos = Cos(dat.angle)
set dat.sin = Sin(dat.angle)
if dat.Total == 0 then
call TimerStart(Tim, 0.035, true, function Data.Move )
endif
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local real x = GetLocationX(l)
local real y = GetLocationY(l)
call Data.Start(c, x, y)
call RemoveLocation(l)
set c = null
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 Conditions ) )
call TriggerAddAction(t, function Actions )
set Tim = CreateTimer()
endfunction
endscope
Earlier I sad that i tried creating an effect at x and y and that it did move, but now, like the dummy unit, it doesn't. What's the problem here?
Thanks in advance!