• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Timer-Related Loop Help

Status
Not open for further replies.
Level 2
Joined
May 25, 2006
Messages
13
Im newish to jass, iv been using for some time now and have a basic grasp of it, but i can't for the life of me get this trigger to work. It's supposed to create a unit at the point of the caster and be moved instantly to his position for 10 seconds. All it's doing at the moment is lagging slightly then creating the unit. Can anyone please point out what im doing wrong


function heal_Actions takes nothing returns nothing
local timer t=CreateTimer()
local unit u=GetTriggerUnit()
local unit d
local real x=GetUnitX(u)
local real y=GetUnitY(u)
set d=CreateUnit(GetOwningPlayer(GetTriggerUnit( )),'h00F',x,y,I2R(0))
call TimerStart(t,I2R(10),FALSE,null)
loop
exitwhen R2I(TimerGetRemaining(t))==0
set x=GetUnitX(u)
set y=GetUnitY(u)
call SetUnitPosition(d,x,y)
endloop
endfunction


//==================================================================
function InitTrig_heal takes nothing returns nothing
set gg_trg_heal = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_heal, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddAction( gg_trg_heal, function heal_Actions )
endfunction


i haven cleaned up leaks or anything yet*
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Use
JASS:
 tags.
You don't need those I2R() things.
You should use a wait in your loop. The loop you have now runs extremely many times, so warcraft stops it to prevent crash. Using the wait will heavily reduce how many times it runs.
The best would be to use another function for the moving, but that is more advanced.
 
Status
Not open for further replies.
Top