HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger hits Op Limit but i dunno why

04-04-2007, 01:56 PM#1
anXieTy
Hello again,

i have another problem now. I am creating a spell with frost balls rotating around the lich, if they contact with enemys the enemys get hit by a frost nova and the ball disappers. So for now, rotating them and the stuff works, but in the end of the trigger grimiore tells me i hit the OP limit. Dunno why. I think i used many loops :D and i hope somebody can help me and maybe explain what i made wrong or what to look at mire precisely.

So far, anX

Here is my triggeR:

Collapse JASS:
constant function IceShards_Dummy takes nothing returns integer
    return 'h01A' // Rawcode of the dummyunit swirling around the caster
endfunction

constant function IceShards_SpellId takes nothing returns integer
    return 'A003' // SpellId
endfunction

constant function IceShards_Duration takes nothing returns integer
    return 20 // Duration you would like to have in seconds
endfunction

constant function IceShards_DetectionRadius takes nothing returns integer
    return 100 // radius to recognize enemy units
endfunction

constant function IceShards_Novadummycaster takes nothing returns integer
    return 'h00C' // dummy to cast frost nova on several targets
endfunction

constant function IceShards_Dummynova takes nothing returns integer
    return 'A01Z' // nova added to the dummy
endfunction

function IceShards_Novacast takes unit u, unit caster returns nothing
local real x = GetUnitX (u)
local real y = GetUnitY (u)
local unit dummy


if IsPlayerAlly (GetOwningPlayer (caster), GetOwningPlayer (u)) ==false then
   set dummy = CreateUnit (GetOwningPlayer(caster),IceShards_Novadummycaster(),x,y,270)
   call UnitApplyTimedLifeBJ( 1, 'BTLF', dummy )
   call UnitAddAbility (dummy, IceShards_Dummynova())
   call SetUnitAbilityLevel (dummy,IceShards_Dummynova(),GetUnitAbilityLevel(caster,IceShards_SpellId())) 
   call IssueTargetOrder ( dummy, "frostnova",u )   

endif
set caster = null                   
endfunction



 
function Trig_Ice_Shards_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == IceShards_SpellId()
endfunction

function Ice_Shards_expire takes nothing returns nothing
local timer t = GetExpiredTimer ()
local unit caster = GetHandleUnit (t, "caster")
local unit array dummys
local real array angle
local real offset = GetHandleReal (t, "offset")
local integer i = 1
local real x
local real y
local real dur = GetHandleReal (t, "dur")    
local unit u
local boolean alive = false

call DisplayTextToForce (GetPlayersAll (), "timer epxired")


loop
    exitwhen i >=9
     set dummys[i]= GetHandleUnit (t, "dummys"+I2S(i))
     set angle[i]= GetHandleReal (t, "angle"+I2S(i))
     set i = i +1
endloop

set i = 1

loop
    exitwhen i >= 9
   
   if GetWidgetLife(dummys[i]) > 0.405  then   
        set alive = true
        set angle[i] = angle[i] + 5.00
        set x = GetUnitX (caster) + offset * Cos (angle[i]*bj_DEGTORAD)
        set y = GetUnitY (caster) + offset * Sin (angle[i]* bj_DEGTORAD) 
        call SetUnitPosition (dummys[i],x, y)
        call GroupClear (udg_TempGroup)
        call GroupEnumUnitsInRange (udg_TempGroup,x,y,IceShards_DetectionRadius(),null)
      //  set udg_TempUnit = dummys[i]
      //  set udg_TempUnit2 = caster
        
        
     if IsUnitGroupEmptyBJ (udg_TempGroup)==false and IsPlayerAlly (GetOwningPlayer(caster), GetOwningPlayer (FirstOfGroup (udg_TempGroup))) == false and GetUnitState(dummys[i], UNIT_STATE_LIFE) > 0 then  
         set u = FirstOfGroup (udg_TempGroup)
         call IceShards_Novacast ( u , caster)
         call KillUnit (dummys[i])
         set dummys[i] = null
     endif
        call SetHandleReal (t, "angle"+I2S(i), angle[i])
                call DisplayTextToForce (GetPlayersAll (), GetUnitName (dummys[i]))
    endif             
    
      set i = i +1
       

endloop


if dur<=0 or alive == false then
    
    call PauseTimer (t)
    call DestroyTimer (t)
    set t = null
    set i = 1
        
        loop
        exitwhen i >= 9
        if GetWidgetLife(dummys[i]) > 0.405  then   
        call KillUnit (dummys[i])
        set dummys [i] = null
        set i = i +1
        endif
        endloop
    call FlushHandleLocals( t )



else
set dur = dur -1
call SetHandleReal (t, "dur", dur)
endif
set caster = null
    


endfunction

function Trig_Ice_Shards_Actions takes nothing returns nothing
local unit caster       = GetSpellAbilityUnit ()
local unit array dummys 
local real array angle  
local real offset       = 200
local integer i = 1
local real r = 0.00
local timer t = CreateTimer ()
local real casterX = GetUnitX (caster)
local real casterY = GetUnitY (caster)
local real dur = IceShards_Duration() * 20
local real x
local real y

    loop
    exitwhen i>=9
        set angle[i] = 0.00
        set i = i + 1
    endloop
    
set i = 1                                  
    
    loop
        exitwhen i >= 9
        set r = ( r + ( 360.00 / 8.00 ) )
        set angle[i] = ( ( 360.00 / 8.00 ) + r )
        set x = casterX + offset * Cos (angle[i]*bj_DEGTORAD)
        set y = casterY + offset * Sin (angle[i]* bj_DEGTORAD) 
        
        set dummys[i] = CreateUnit (GetOwningPlayer (caster), IceShards_Dummy(), x,y,  bj_UNIT_FACING )
        call SetHandleHandle (t, "dummys"+I2S(i), dummys[i])
        call SetHandleReal (t, "angle"+I2S(i), angle[i]  )
        set i = i  + 1
    endloop
    call SetHandleReal (t, "offset", offset)
    call SetHandleHandle (t, "caster", caster)
    call SetHandleReal (t, "dur", dur)
    call TimerStart (t,0.05, true,function Ice_Shards_expire )
    

endfunction

//===========================================================================
function InitTrig_Ice_Shards takes nothing returns nothing
    set gg_trg_Ice_Shards = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ice_Shards, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ice_Shards, Condition( function Trig_Ice_Shards_Conditions ) )
    call TriggerAddAction( gg_trg_Ice_Shards, function Trig_Ice_Shards_Actions )
endfunction



EDIT: got the problem with the op limit solved, but now there is a new prob: the trigger leaks and laggs like hell and i dunno why... pls help.. :(


Edit2: Solved it now, didnt use a pick unit part and added a local trigger detecting if an enemy unit comes in range of the dummyballs.