- Joined
- Jul 28, 2008
- Messages
- 211
Can someone tell me what's wrong with my script? Here's the script :
I made the spell part just for testing. When i cast the spell, the dummy unit is created, but doesn't move.
I tried removing the
part but then the effect would move, while the dummy wouldnt.
Can someone help me pls?
I attached the map.
JASS:
scope Lightning initializer Init
globals
constant integer DUMMY_ID = 'h000'
constant integer SPELL_ID = 'A000'
constant string EFFECT = "Abilities\\Weapons\\ChimaeraLightningMissile\\ChimaeraLightningMissile.mdl"
timer T = CreateTimer()
integer Total = 0
integer array Ar
endglobals
private struct Data
unit d
group damaged
real cos
real sin
real fx
real fy
static method create takes unit u, real angle returns Data
local Data dat = Data.allocate()
set dat.d = CreateUnitAtLoc( GetOwningPlayer(u), DUMMY_ID, GetUnitLoc(u), angle )
set dat.cos = Cos(angle)
set dat.sin = Sin(angle)
set dat.fx = GetUnitX(dat.d) + 800 * dat.cos
set dat.fy = GetUnitY(dat.d) + 800 * dat.sin
call TimerStart(T, 0.035, true, function Data.Execute )
if Total == 4000 then
set Total = 0
endif
set Total = Total + 1
set Ar[Total - 1] = dat
return dat
endmethod
static method Execute takes nothing returns nothing
local Data dat
local integer i = 0
local real x
local real y
loop
exitwhen i >= Total
set dat = Ar[i]
if dat.fx != x and dat.fy != y then
set x = GetUnitX(dat.d) + 8 * dat.cos
set y = GetUnitY(dat.d) + 8 * dat.sin
call DestroyEffect( AddSpecialEffect( EFFECT, x, y) )
call SetUnitX(dat.d, x)
call SetUnitY(dat.d, y)
endif
set i = i + 1
endloop
endmethod
endstruct
private function Wave takes unit u, real angle returns nothing
call Data.create(u,angle)
endfunction
//==================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real ang = GetUnitFacing(caster)
call Wave(caster,ang)
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 )
endfunction
endscope
I made the spell part just for testing. When i cast the spell, the dummy unit is created, but doesn't move.
I tried removing the
JASS:
if dat.fx != x and dat.fy != y then
Can someone help me pls?
I attached the map.