HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Possible thread limit on a loop

08-15-2006, 12:44 PM#1
The)TideHunter(
Ok, i wasent allowed to use a effect for the spell making competetion, so i need to change it.
I decided to use brillance aura model, but in 6 directions around the caster, each spaced 100 units every 60 degrees.
Although, not 1 effect is appearing, and i dont know why.
So my guess is its the thread limit, but i need some other opinions.
I might even be making a silly mistake again.

The loop i do, is very optimized, i started off as around 30 lines, then i broke it down to 1 in a loop.

So here it is:

Collapse JASS:
    loop
        exitwhen i == 6
        call CF_AttachHandle(CF_CreateGroundEffect(X+S*Cos(i*60. * bj_DEGTORAD), Y+S*Sin(i*60. * bj_DEGTORAD), 5., F, 1., E, 255, 255, 255, 255), "Spell_Rapids_CasterEffect"+I2S(i), t)
        set i = i + 1
    endloop

Its attaching 6 effects to timer t, creating them, and attaching more stuff to the effect through the CF_CreateGroundEffect function.

Heres all the locals i use:

Collapse JASS:
    local timer t = CreateTimer()
    local real X = GetUnitX(Caster)
    local real Y = GetUnitY(Caster)
    local real S = Spell_Rapids_ChannelEffectSpacing() // == 100.
    local real F = GetUnitFacing(Caster)
    local string E = Spell_Rapids_ChannelEffect() // == "Abilities\\Spells\\Human\\Brilliance\\Brilliance.mdl"
    local integer i = 1

And all the functions:

Collapse JASS:
function CF_AttachHandle takes handle whichHandle, string label, handle KeyHandle returns nothing
    local integer h = CF_H2I(whichHandle)
    local integer i = CF_H2I(KeyHandle)
    if(i+h != 0) then
        call StoreInteger(CF_GC(), label, I2S(i), h)
    else
        call FlushStoredMission(CF_GC(), label)
    endif
endfunction

function CF_GC takes nothing returns gamecache
    if(udg_GC == null) then
        call FlushGameCache(InitGameCache("GC"))
        set udg_GC = InitGameCache("GC")
    endif
    return udg_GC
endfunction

function CF_CreateGroundEffect takes real X, real Y, real Z, real facing, real sizeFactor, string modelPath, integer red, integer green, integer blue, integer alpha returns effect
    local effect NewEffect
    local unit CarryingUnit
    if(CF_IsLocSafe(X, Y)) then
        set CarryingUnit = CF_GetADummy(X, Y)
        set NewEffect = AddSpecialEffectTarget(modelPath, CarryingUnit, "origin")
        call SetUnitFlyHeight(CarryingUnit, Z, 0.)
        call SetUnitFacing(CarryingUnit, facing)
        call SetUnitScalePercent(CarryingUnit, sizeFactor, sizeFactor, sizeFactor) // This uses scaling factor.
                                                                                   // 1. would be the same size.
                                                                                   // 1.1 would be 10% bigger than
                                                                                   // usual.
                                                                                   // 2. would be 100% bigger than
                                                                                   // usual.
        call SetUnitVertexColor(CarryingUnit, red, green, blue, alpha)
        call CF_AttachHandle(CarryingUnit, "Effect_CarryingUnit", NewEffect)
        call CF_AttachReal(X, "Effect_XCoord", NewEffect)
        call CF_AttachReal(Y, "Effect_YCoord", NewEffect)
        call CF_AttachReal(Z, "Effect_ZCoord", NewEffect)
        call CF_AttachReal(facing, "Effect_FacingDegrees", NewEffect)
        call CF_AttachReal(sizeFactor, "Effect_Size", NewEffect)
        call CF_AttachInteger(red, "Effect_RedColour", NewEffect)
        call CF_AttachInteger(green, "Effect_GreenColour", NewEffect)
        call CF_AttachInteger(blue, "Effect_BlueColour", NewEffect)
        call CF_AttachInteger(alpha, "Effect_AlphaColour", NewEffect)
        call CF_AttachString(modelPath, "Effect_ModelPath", NewEffect)
        call CF_StoreHandle(NewEffect, "CF_MEMORY_LASTCREATED_EFFECT", "Effect")
        return NewEffect
    endif
    set NewEffect = null
    set CarryingUnit = null
    return null
endfunction

// Thats the function im worried about, i use it often with no problems, but it uses a shitload of functions.


Thanks in advance.
08-15-2006, 02:40 PM#2
blu_da_noob
That is nowhere near the thread limit. In your local decleration change it to local integer i = 0. Your loop is currently setup to only run 5 times.
08-15-2006, 03:08 PM#3
The)TideHunter(
Ok, il change that, thanks for pointing that out.