• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] How do I use TT

Status
Not open for further replies.
Level 8
Joined
Dec 16, 2007
Messages
252
I have been using HandleVars but I heard that.. it's not good.

Can someone teach me how to use the TT by Cohadar?


Here's a spell that uses the HandleVars, how can I make it use the TT instead?
I think I saw a spell that uses TT, I looked through a code but I can't figure where you configure the interval time nor how to use it.

Yes the spell is converted from GUI.

JASS:
function Trig_Nuke_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00E'
endfunction

function Nuke_Effect takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local unit dummy = H2U(GetHandleHandle(t, "dummy"))
  local unit bomb
  local real ang = GetHandleReal(t, "ang")
  local real i = GetHandleReal(t, "i")
  local location o= GetUnitLoc(dummy)
  call SetUnitPosition(dummy,GetUnitX(dummy) + 20 * Cos(ang * bj_DEGTORAD),GetUnitY(dummy) + 20 * Sin(ang * bj_DEGTORAD))
  set i = i + 1
  call SetHandleReal (t, "i", i)

  if i == 100 then
    set bomb = CreateUnitAtLoc(GetOwningPlayer(dummy) , 'u004', o, ang )
    call SetUnitUserData( bomb, GetUnitUserData(dummy) )   
    call UnitAddAbilityBJ( 'Arav', bomb )
    call SetUnitPathing(bomb, false)
    call SetUnitFlyHeightBJ( bomb, 1.00, 400.00 )
    set bomb = null
  endif

  if i == 200 then
    call RemoveUnit(dummy)
    call PauseTimer(t)
call FlushHandleLocals(t)
    call PauseTimer(t)
    call DestroyTimer(t)
  else
  endif

  call RemoveLocation(o)

  set t=null
  set dummy=null
  set o=null
endfunction

function Trig_Nuke_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local unit dummy
  local location l = GetSpellTargetLoc()
  local real x = GetUnitX(u)
  local real y = GetUnitY(u)
  local real xtarg = GetLocationX(l)
  local real ytarg = GetLocationY(l)
  local real ang = bj_RADTODEG * Atan2(ytarg - y, xtarg - x)
  local timer t = CreateTimer()
  local location s = PolarProjectionBJ(Location(xtarg, ytarg), 2000., ang - 180)

  set dummy = CreateUnitAtLoc(GetOwningPlayer(u) , 'u003', s, ang )
  call SetUnitUserData( dummy, GetUnitAbilityLevelSwapped('A00E', u ))  
  call SetUnitPathing(dummy, false)

  call SetHandleHandle(t, "dummy", dummy)
  call SetHandleHandle(t, "u", u)
  call SetHandleReal(t, "ang", ang)
  call TimerStart(t, 0.03, true, function Nuke_Effect)

  call RemoveLocation(l)
  call RemoveLocation(s)
  
  set s=null
  set l=null
  set t=null
endfunction

//===========================================================================
function InitTrig_Nuke takes nothing returns nothing
    set gg_trg_Nuke = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Nuke, EVENT_PLAYER_UNIT_SUMMON )
    call TriggerAddCondition( gg_trg_Nuke, Condition( function Trig_Nuke_Conditions ) )
    call TriggerAddAction( gg_trg_Nuke, function Trig_Nuke_Actions )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Because I've seen many spells using it, and don't really know the difference between them.
Just use TimerUtils.

JASS:
struct ThisIsSomeData
//...
endstruct

function Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local ThisIsSomeData dat = GetTimerData(t)
    //...
    //if you're done
    call ReleaseTimer(t)
    //...
endfunction

function Parent takes nothing returns nothing
    local ThisIsSomeData dat = ThisIsSomeData.create()
    local timer t = NewTimer()
    call SetTimerData(t,dat)
    //...
    call TimerStart(t,...,function Child)
    //...
endfunction
 
Status
Not open for further replies.
Top