Effect changes its direction when unit's direction changed

Edw

New Member
Reaction score
0
Here my code:
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
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?
 

jonas

You can change this now in User CP.
Reaction score
64
store the facing of the unit in a real variable at the beginning of the loop, then use the stored value instead of the current one
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top