HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Two Groups... Looping... other stuff... what's wrong?

04-18-2008, 05:14 AM#1
Burning Rose
Sorry for the vague Title, but I didn't know what to put besides "HAY MY TRIGGER WONT WERK!". Anyways -

The Trigger is supposed to find units with a buff and if they're enemies, deal them damage, and if they're friendly, heal them for an amount proportionate to the total damage dealt. It was working back in GUI, but It was also filled with leaks, so I tried to update it. Unfortunetly, somewhere inbetween looping through groups and creating boolexprs and... everything else, it stopped working. Through Testing, and DisplayTextToPlayer, I've found that for some reason, it's only picking one unit in each loop each time. Does anyone know why? I'm getting similar problems in other triggers.
Collapse JASS:
function Trig_Chaos_Aura_1_Func003001002002 takes nothing returns boolean
    if ( UnitHasBuffBJ(GetFilterUnit(), 'B017') == true ) then
        return true
    endif
    if ( UnitHasBuffBJ(GetFilterUnit(), 'B01C') == true ) then
        return true
    endif
    if ( UnitHasBuffBJ(GetFilterUnit(), 'B01B') == true ) then
        return true
    endif
    if ( UnitHasBuffBJ(GetFilterUnit(), 'B01A') == true ) then
        return true
    endif
    return false
endfunction

function Trig_Chaos_Aura_1_Actions takes nothing returns nothing
    local group friend = CreateGroup()
    local group enemy = CreateGroup()
    local unit f
    local real healing
    local real health
    call GroupEnumUnitsInRect(friend, bj_mapInitialPlayableArea, Condition(function Trig_Chaos_Aura_1_Func003001002002))
    call GroupEnumUnitsInRect(enemy, bj_mapInitialPlayableArea, Condition(function Trig_Chaos_Aura_1_Func003001002002))
    loop
        set f = FirstOfGroup(enemy)
        exitwhen f == null
        if ( IsUnitEnemy(f, GetOwningPlayer(udg_Chaotic)) == true ) then
            if ( UnitHasBuffBJ(f, 'B017') == true ) then
                call UnitDamageTarget( udg_Chaotic, f, 6.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
                set healing = healing + 2
            endif
            if ( UnitHasBuffBJ(f, 'B01C') == true ) then
                call UnitDamageTarget( udg_Chaotic, f, 9.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
                set healing = healing + 3
            endif
            if ( UnitHasBuffBJ(f, 'B01B') == true ) then
                call UnitDamageTarget( udg_Chaotic, f, 12.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
                set healing = healing + 4
            endif
            if ( UnitHasBuffBJ(f, 'B01A') == true ) then
                call UnitDamageTarget( udg_Chaotic, f, 15.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
                set healing = healing + 5
            endif
        endif
        call GroupRemoveUnit(enemy, f)
    endloop
    loop
        set f = FirstOfGroup(friend)
        exitwhen f == null
        if ( IsUnitAlly(f, GetOwningPlayer(udg_Chaotic)) == true ) then
            set health = GetUnitState(f, UNIT_STATE_LIFE)
            call SetUnitState(f,UNIT_STATE_LIFE, health + healing)
            if (healing > 0) then
                call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl", f,"origin" ))
            endif
        endif
        call GroupRemoveUnit(friend, f)
    endloop
    call DestroyGroup(friend)
    call DestroyGroup(enemy)
    set enemy = null
    set friend = null
    set f = null
endfunction
04-18-2008, 05:28 AM#2
midiway
variable healing isn't initializated, so local real healing = 0
04-18-2008, 06:39 AM#3
ADOLF
Collapse JASS:
function Trig_Chaos_Aura_1_Func003001002002 takes nothing returns boolean
 return GetUnitAbilityLevel(GetFilterUnit(), 'B017')!=0 or GetUnitAbilityLevel(GetFilterUnit(), 'B01A')!=0 or GetUnitAbilityLevel(GetFilterUnit(), 'B01B')!=0 or GetUnitAbilityLevel(GetFilterUnit(), 'B01C')!=0
endfunction

why not so?)
04-18-2008, 10:06 AM#4
Toadcop
GetUnitAbilityLevel(GetFilterUnit(), 'B017') returns int =) so it must be

GetUnitAbilityLevel(GetFilterUnit(), 'B017')>0
// or have i missed something for all this years !? O_o
04-18-2008, 11:19 AM#5
ADOLF
fixed)
04-18-2008, 09:57 PM#6
Burning Rose
Oh yeah, the buff thing. That's just me being lazy. I'll change it when the rest of the spell works right.

No, I think it has something to do when the Exitwhen. It does select a unit each time, just only one instead of the whole group.

EDIT: my mistake, tried initializing the Integers like you said, it works perfectly now. Thanks!