HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

FirstOfGroup() Issues

02-11-2007, 10:36 PM#1
Rising_Dusk
Collapse JASS:
function Seedlings_BeBorn takes nothing returns nothing
    local unit u = udg_u_Arke
    local unit s
    local unit d
    local integer id = 'n00D'
    local integer lvl = GetUnitAbilityLevel(u, 'A08F')
    local group g = I2G(bj_meleeTwinkedHeroes[360])
    
    if lvl == 3 or lvl == 4 then
        set id = 'n00A'
    elseif lvl == 5 then
        set id = 'n00E'
    endif
    call GroupAddUnit(g, null)  //Prevents Ghosting
    loop
        set s = FirstOfGroup(g)
        exitwhen s == null
        if GetWidgetLife(s) > 0.405 then
            set d = CreateUnit(GetOwningPlayer(u), id, GetUnitX(s), GetUnitY(s), GetUnitFacing(s))
            call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl", GetUnitX(d), GetUnitY(d)))
            call UnitApplyTimedLife(d, 'BTLF', 45.)
            call KillUnit(s)
        endif
        call GroupRemoveUnit(g, s)
    endloop
    call PauseTimer(GetExpiredTimer())
    call ReleaseTimer(GetExpiredTimer())
    
    call GroupClear(g)
    call DestroyGroup(g)
    set g = null
    set u = null
    set s = null
    set d = null
endfunction
Collapse JASS:
function Seedlings_Actions takes nothing returns nothing
    local unit u = udg_u_Arke
    local unit s
    local integer lvl = GetUnitAbilityLevel(u, 'A08F')
    local integer i = 1
    local group g = CreateGroup()
    local real x1 = GetUnitX(u)
    local real y1 = GetUnitY(u)
    local real angle
    local real dist
    local real x2
    local real y2
    
    call SetUnitAnimationByIndex(u, 3)
    loop
        exitwhen i > 2+(2*lvl)
        set dist = GetRandomReal(50, 200)
        set angle = GetRandomReal(0, 360)
        set x2 = ProjectX(x1, dist, angle)
        set y2 = ProjectY(y1, dist, angle)
        set s = CreateUnit(GetOwningPlayer(u), 'n009', x2, y2, GetRandomReal(0, 360))
        call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", x2, y2))
        call UnitApplyTimedLife(s, 'BTLF', 11.25)
        call GroupAddUnit(g, s)
        set i = i + 1
    endloop
    
    set bj_meleeTwinkedHeroes[360] = H2I(g)
    call TimerStart(NewTimer(), 10.50, false, function Seedlings_BeBorn)
    
    set g = null
    set u = null
    set s = null
endfunction

The spell groups all of the units spawned at first, then loops through them in the timer callback.
This is a pretty standard procedure, but offers some unexpected results in a specific case.

If one of the initial units dies, then for some reason the entire loop seems to die.
It returns, doesn't even get to the timer cleanup part.

It's bizarre, and I really need someone else to give it a go over.
'Cuz my staring at it hasn't helped yet.

Thanks in advance.
02-12-2007, 12:03 AM#2
PipeDream
Maybe you need to do the ghost prevention thing inside the loop, or remove the unit from the group before killing it.
02-12-2007, 03:09 PM#3
MrSmiLe
or your unit have a death time less then 1 sec (for example) and it removes self before you can make your "For Group" action ... (some flying units removed from game in about 5 seconds.) there are many other possibilitys.
02-12-2007, 03:16 PM#4
masda70
call GroupAddUnit(g, null) has never worked for me :(.

Try using a unit array if possible :p.
02-12-2007, 03:19 PM#5
Rising_Dusk
Quote:
call GroupAddUnit(g, null) has never worked for me :(.
Try using a unit array if possible :p.
Blame Vex for telling me to do that. -_-
I really can't figure this out though.

It'll probably get remade to another method that I'm sure will work.
But it still irkes me that this doesn't work.
It should.
02-12-2007, 03:28 PM#6
Vexorian
I told you because it works.

If it doesn't work anymore blame blizzard.

Latelly I see no sense in using groups on things that are not enuming.

Collapse JASS:
 type dummygroup extends unit array [20] // Look I made the perfect group replacement in one line!

You just made one of the word snipeds I've ever seen : What's up with meleeTwinkedHeroes[360]? And then all the typecast and all that stuff, man if your solution is static just use a global variable , no need to do that stuff.
02-12-2007, 03:28 PM#7
MrSmiLe
Dynamic Groups here (on array) http://xgm.ru/forum/attachment.php?attachmentid=11743 maybe will be some inspiration for you...
Attached Images
File type: pngBeastmaster.png (15.7 KB)
02-12-2007, 03:31 PM#8
Vexorian
That's terrible
02-12-2007, 03:38 PM#9
masda70
You can always use ForGroup, just store any of the locals needed in some bj constants --'.
02-12-2007, 05:48 PM#10
Rising_Dusk
Quote:
You can always use ForGroup, just store any of the locals needed in some bj constants --'.
That was what I was planning on doing.

Quote:
You just made one of the word snipeds I've ever seen
I'd respond to that if it made sense. >_<