Here my code:
Whenever I cast this spell, effect would be created in a line, but when caster unit changes its direction, the effect's direction changes also (facing unit direction). How to fix that?
Code:
globals
constant integer SPELLID = 'A001'
constant string SFX = "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl"
endglobals
function cond takes nothing returns boolean
return GetSpellAbilityId() == SPELLID
endfunction
function PolarX takes real x, real dist, real angle returns real
return x + dist*Cos(angle*bj_DEGTORAD)
endfunction
function PolarY takes real y, real dist, real angle returns real
return y + dist*Sin(angle*bj_DEGTORAD)
endfunction
function act takes nothing returns nothing
local real x
local real y
local integer i
local unit u
set u = GetTriggerUnit()
set x = GetWidgetX(u)
set y = GetWidgetY(u)
set i = 0
loop
exitwhen i > 10
call DestroyEffect(AddSpecialEffect(SFX,PolarX(x,100*i,GetUnitFacing(u)),PolarY(y,100*i,GetUnitFacing(u))))
call TriggerSleepAction(0.1)
set i = i + 1
endloop
set u = null
endfunction
function InitTrig_Spell2 takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t,Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
call TriggerAddCondition(t, function cond)
call TriggerAddAction(t, function act)
set t = null
endfunction