• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Thunder spell ... Remove ability problem !

Status
Not open for further replies.
HI guys, i was making a map to compete with ciebron, but unfortunatly i found a bug with no solution (or so I think).
The problem is that I add an ability to an unit, but then i can not remove it.
This code uses vJASS and ABC (i know it is old, but is is easy as well) and so i really would like to know what it wrong =S

JASS:
struct Mystruct
    unit caster = GetTriggerUnit()
    timer repeator = CreateTimer()
    timer picker = CreateTimer()
    timer remover = CreateTimer()
    group buffer = CreateGroup()
    trigger end = CreateTrigger()
    triggeraction endAction
    triggercondition endCondition
endstruct
//==========================================================================
function End_Conds takes nothing returns boolean
   return GetSpellAbilityId() == 'A000' 
endfunction
//==========================================================================
function End_Acts takes nothing returns nothing
    //catches the trigger and runs this function
    local Mystruct data = GetTriggerStructB(GetTriggeringTrigger())
    local unit targ
    
    //Cleans all units from data.buffer and destroys it
    loop
        set targ = FirstOfGroup(data.buffer)
        exitwhen(targ == null)
        call UnitRemoveAbility(targ, 'A00A')
        call UnitRemoveAbility(targ, 'A00B')
        call UnitRemoveAbility(targ, 'A003')
        call GroupRemoveUnit(data.buffer, targ)
    endloop
    call DestroyGroup(data.buffer)
    
    //removes the created trigger in the Code_acts function
    call TriggerRemoveCondition(data.end,data.endCondition)
    call TriggerRemoveAction(data.end,data.endAction)
    call DestroyTrigger(data.end)
    call ClearTriggerStructB(data.end)

    //stops the repeator timer and ends the spell once and for all
    call PauseTimer(data.repeator)
    call DestroyTimer(data.repeator)
    call PauseTimer(data.picker)
    call DestroyTimer(data.picker)
    call PauseTimer(data.remover)
    call DestroyTimer(data.remover)
    call ClearTimerStructA(data.repeator)
    call ClearTimerStructB(data.picker)
    call ClearTimerStructC(data.remover)
endfunction
//==========================================================================
function Remover takes nothing returns nothing
    local Mystruct data = GetTimerStructC(GetExpiredTimer())
    local unit targ
    //THE BUG IS HERE !! THE UNITS DO NOT DIE !! HELP PLEASE !! WHYYYYY!!!
    
    //here I check all units in data.buffer to see if they are inside range
    loop
        set targ = FirstOfGroup(data.buffer)
        exitwhen(targ == null)
//        call BJDebugMsg("loop")
        call KillUnit(targ)
//        if (IsUnitInRange(data.caster, targ, 900) == false) then
//            call UnitRemoveAbility(targ, 'A003')
//            call UnitRemoveAbility(targ, 'A00A')            
//            call UnitRemoveAbility(targ, 'A00B')
//            call GroupRemoveUnit(data.buffer, targ)
//        endif
    endloop
endfunction
//==========================================================================
function Picker takes nothing returns nothing
    local Mystruct data = GetTimerStructB(GetExpiredTimer())
    local group g = CreateGroup()
    local unit targ
    local player p = GetOwningPlayer(data.caster)
    local integer level = GetUnitAbilityLevel(data.caster, 'A000')
    
    //here i select friendly units, give them new ability, and add them to data.buffer
    call GroupEnumUnitsInRange( g, GetUnitX( data.caster ), GetUnitY( data.caster ), 900, Filter(null))
    loop  
        set targ = FirstOfGroup( g )  
        exitwhen (targ == null)  
        if IsUnitAlly(targ, p) then 
            if IsUnitType(targ, UNIT_TYPE_HERO) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) and ((targ == data.caster)== false) then
                //spell book for hero atatckers
                call UnitAddAbility(targ, 'A003')  //add book
                call SetUnitAbilityLevel(targ, 'A003', level)  // set lv of book to the level of the current hero ability
                call SetUnitAbilityLevel(targ,'A001', level)//sets lv of Ability to the level of the current hero ability
                call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A003', false )
                call GroupAddUnit(data.buffer, targ)
            elseif IsUnitType(targ, UNIT_TYPE_MELEE_ATTACKER) and (IsUnitType(targ, UNIT_TYPE_HERO) == false) and (IsUnitType(targ, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(targ, UNIT_TYPE_STRUCTURE) == false) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) then
                //spell book for melee atatcker units
                call UnitAddAbility(targ, 'A00B')  //add book
                call SetUnitAbilityLevel(targ, 'A00B', level)  // set lv of book to the level of the current hero ability
                call SetUnitAbilityLevel(targ,'A005', level)//sets lv of Melee to the level of the current hero ability
                call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A00B', false )
                call GroupAddUnit(data.buffer, targ)
            elseif IsUnitType(targ, UNIT_TYPE_RANGED_ATTACKER) and (IsUnitType(targ, UNIT_TYPE_HERO) == false) and (IsUnitType(targ, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(targ, UNIT_TYPE_STRUCTURE) == false) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) then
                //spell book for ranged atatckers
                call UnitAddAbility(targ, 'A00A')  //add book
                call SetUnitAbilityLevel(targ, 'A00A', level)  // set lv of book to the level of the current hero ability
                call SetUnitAbilityLevel(targ,'A006', level)//sets lv of ranged to the level of the current hero ability
                call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A00A', false )
                call GroupAddUnit(data.buffer, targ)
            endif
        endif  
            call GroupRemoveUnit(g,targ)
    endloop
    
    call DestroyGroup(g)    
    set g = null 
endfunction
//==========================================================================
function LightningInvocation takes nothing returns nothing
    //catches the expired timer and runs this function
    local Mystruct data = GetTimerStructA(GetExpiredTimer())
    
    //This uses polar projection. Formula: Center + r * trigfunction(angle teta); 
    //where Center is the center coordinate X or Y
    //r is the distance (in the case rabdom between 300 and 600)
    //trigfunction is Sin if using Y and Cos if using X
    //angle teta is the angle formed between r and the axis (in this case random, can be all circle)
    
    local real randomX 
    local real randomY 
    local unit dummy
    local integer exit = GetUnitAbilityLevel(data.caster, 'A000')
    local integer counter = 0
    
    loop
        exitwhen(counter >= exit)
        set randomX =  GetUnitX(data.caster) + GetRandomReal(100.00, 900.00) * Cos(GetRandomReal(0.0, 360.0) * bj_DEGTORAD)
        set randomY =  GetUnitY(data.caster) + GetRandomReal(100.00, 900.00) * Sin(GetRandomReal(0.0, 360.0) * bj_DEGTORAD)
        set dummy = CreateUnit(GetOwningPlayer(data.caster), 'h000', randomX, randomY, 0)
        call UnitAddAbility(dummy, 'A002')
        call IssueImmediateOrder( dummy, "thunderclap" )
        call UnitApplyTimedLife(dummy, 'BTLF', 2.00)
        set counter = counter + 1
    endloop
    
    set dummy = null
    
endfunction
//==========================================================================
function LightningInvocation_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//==========================================================================
function LightningInvocation_Acts takes nothing returns nothing
    local Mystruct data = Mystruct.create()
    
    //starts the effect of the spell, thunders start falling from sky
    call SetTimerStructA(data.repeator, data)
    call TimerStart(data.repeator, 3 / GetUnitAbilityLevel(data.caster, 'A000'), true, function LightningInvocation)
    
    //creates the timer that picks units arround the hero to give them abilities
    call SetTimerStructB(data.picker, data)
    call TimerStart(data.picker, 1, true, function Picker)
    
    //This timer checks every 0.2 secs if a unit is outside range, to remove the buffs
    call SetTimerStructC(data.remover, data)
    call TimerStart(data.remover, 0.2, true, function Remover)

    //creates the trigger that will end the spell when the hero stops channeling
    call SetTriggerStructB(data.end, data)
    call TriggerRegisterAnyUnitEventBJ( data.end, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    set data.endCondition = TriggerAddCondition( data.end, Condition( function End_Conds ) )
    set data.endAction = TriggerAddAction( data.end, function End_Acts )
endfunction
//===========================================================================
function InitTrig_Lightning_Invocation takes nothing returns nothing
    set gg_trg_Lightning_Invocation = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Invocation, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_Lightning_Invocation, Condition( function LightningInvocation_Conds ) )
    call TriggerAddAction( gg_trg_Lightning_Invocation, function LightningInvocation_Acts )
endfunction

The code looks complex but it is very simple actually.
It is a channeling spell. When i start casting it i use 3 timers and a unit group(among other things).
1 timer is to create thunders, 2 timer is to pick allied units around the caster according to a condition and then it adds them to buffer group, finally the 3 timer ... well, it should kill unit is group buffer, but that does not happen !! whyy !!!

When the spell ends, i kill all timers and remove all units from group buffer, I also destroy the group. At least this part works perfectly...

Can some1 please help me out here ?? Why isn't the 3rd timer working ?? Is the problem on the timer ??
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I guess call BJDebugMsg("loop") does not appear(when without '//')?
But you have units in the group(they get buffs)?
call GroupRemoveUnit(data.buffer, targ)
You need to keep that line for the debugging or else you would kill only one unit.
Only thing that comes to my mind (sleeping atm) is that the first unit in the group is null.
(no idea what i am blabering about)
try using in the struct group buffer = null
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
A null unit can't be in a group spiwn.

I kinda thought so. But if the loop never runs( Flame_Phoenix should say) then that would be the only reason.
So again I ask does the "loop" message appear?
(yes, when there are no "//")
 
AHh, spell books can be added and removed with no problem. This is the second spell i make with them, and that is not the problem.
ABout the bugged loop, well you got it right at the first time: The loop only runs 1 time. It only kills 1 unit, and I dunno why ....

Also, the loop message appears many time =S
I can post the spell map here if you guys want.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Did you do waht I said in my first post?
remove the "//" before call GroupRemoveUnit(data.buffer, targ) ?
Hmm, first remove it from the group than kill it.
 
LOL; you are a genious ... i can't believe i was so stupid to the point of forgetting that detail .... So dead units still remain in groups ? I didn't know that .. anyway, thx !!
+rep for you all !

EDIT EDIT EDIT

DAMN, well sorry about this guys, nut now i have another bug =S
Well, When i make the remove buff thing, the spell book will only be removed if the units exiting the area are in an order "hero, melee, ranged".
This is bad, because i want it to work for all cases and not just this one =s
I dunno what else i can do...Please help !

[jass=Code]struct Mystruct
unit caster = GetTriggerUnit()
timer repeator = CreateTimer()
timer picker = CreateTimer()
timer remover = CreateTimer()
group buffer = CreateGroup()
trigger end = CreateTrigger()
triggeraction endAction
triggercondition endCondition
endstruct
//==========================================================================
function End_Conds takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
//==========================================================================
function End_Acts takes nothing returns nothing
//catches the trigger and runs this function
local Mystruct data = GetTriggerStructB(GetTriggeringTrigger())
local unit targ

//Cleans all units from data.buffer and destroys it
loop
set targ = FirstOfGroup(data.buffer)
exitwhen(targ == null)
call UnitRemoveAbility(targ, 'A00A')
call UnitRemoveAbility(targ, 'A00B')
call UnitRemoveAbility(targ, 'A003')
call GroupRemoveUnit(data.buffer, targ)
endloop
call DestroyGroup(data.buffer)

//removes the created trigger in the Code_acts function
call TriggerRemoveCondition(data.end,data.endCondition)
call TriggerRemoveAction(data.end,data.endAction)
call DestroyTrigger(data.end)
call ClearTriggerStructB(data.end)

//stops the repeator timer and ends the spell once and for all
call PauseTimer(data.repeator)
call DestroyTimer(data.repeator)
call PauseTimer(data.picker)
call DestroyTimer(data.picker)
call PauseTimer(data.remover)
call DestroyTimer(data.remover)
call ClearTimerStructA(data.repeator)
call ClearTimerStructB(data.picker)
call ClearTimerStructC(data.remover)
endfunction
//==========================================================================
function Killer takes nothing returns nothing
//IGNORE THIS FUNCTION, THIS IS FOR TESTING PURPOSES ONLY
local unit targ = GetEnumUnit()
local Mystruct data = GetTriggerStructC(GetTriggeringTrigger())
// call KillUnit(targ)
if (IsUnitInRange(data.caster, targ, 900) == false) then
call UnitRemoveAbility(targ, 'A003')
call UnitRemoveAbility(targ, 'A00A')
call UnitRemoveAbility(targ, 'A00B')
endif
endfunction
//==========================================================================
function Remover takes nothing returns nothing
local Mystruct data = GetTimerStructC(GetExpiredTimer())
local unit targ

call ForGroup(data.buffer, function Killer)
//here I check all units in data.buffer to see if they are inside range
loop
set targ = FirstOfGroup(data.buffer)
exitwhen(targ == null)
// call BJDebugMsg("loop")
// call KillUnit(targ)
if (IsUnitInRange(data.caster, targ, 900) == false) then
call GroupRemoveUnit(data.buffer, targ)
// call KillUnit(targ)
call UnitRemoveAbility(targ, 'A003')
call UnitRemoveAbility(targ, 'A00A')
call UnitRemoveAbility(targ, 'A00B')
endif
endloop
endfunction
//==========================================================================
function Picker takes nothing returns nothing
local Mystruct data = GetTimerStructB(GetExpiredTimer())
local group g = CreateGroup()
local unit targ
local player p = GetOwningPlayer(data.caster)
local integer level = GetUnitAbilityLevel(data.caster, 'A000')

//here i select friendly units, give them new ability, and add them to data.buffer
call GroupEnumUnitsInRange( g, GetUnitX( data.caster ), GetUnitY( data.caster ), 900, Filter(null))
loop
set targ = FirstOfGroup( g )
exitwhen (targ == null)
if IsUnitAlly(targ, p) then
if IsUnitType(targ, UNIT_TYPE_HERO) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) and ((targ == data.caster)== false) then
//spell book for hero atatckers
call UnitAddAbility(targ, 'A003') //add book
call SetUnitAbilityLevel(targ, 'A003', level) // set lv of book to the level of the current hero ability
call SetUnitAbilityLevel(targ,'A001', level)//sets lv of Ability to the level of the current hero ability
call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A003', false )
call GroupAddUnit(data.buffer, targ)
elseif IsUnitType(targ, UNIT_TYPE_MELEE_ATTACKER) and (IsUnitType(targ, UNIT_TYPE_HERO) == false) and (IsUnitType(targ, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(targ, UNIT_TYPE_STRUCTURE) == false) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) then
//spell book for melee atatcker units
call UnitAddAbility(targ, 'A00B') //add book
call SetUnitAbilityLevel(targ, 'A00B', level) // set lv of book to the level of the current hero ability
call SetUnitAbilityLevel(targ,'A005', level)//sets lv of Melee to the level of the current hero ability
call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A00B', false )
call GroupAddUnit(data.buffer, targ)
elseif IsUnitType(targ, UNIT_TYPE_RANGED_ATTACKER) and (IsUnitType(targ, UNIT_TYPE_HERO) == false) and (IsUnitType(targ, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(targ, UNIT_TYPE_STRUCTURE) == false) and (GetUnitState(targ, UNIT_STATE_LIFE) > 0) then
//spell book for ranged atatckers
call UnitAddAbility(targ, 'A00A') //add book
call SetUnitAbilityLevel(targ, 'A00A', level) // set lv of book to the level of the current hero ability
call SetUnitAbilityLevel(targ,'A006', level)//sets lv of ranged to the level of the current hero ability
call SetPlayerAbilityAvailable( GetOwningPlayer(targ), 'A00A', false )
call GroupAddUnit(data.buffer, targ)
endif
endif
call GroupRemoveUnit(g,targ)
endloop

call DestroyGroup(g)
set g = null
endfunction
//==========================================================================
function LightningInvocation takes nothing returns nothing
//catches the expired timer and runs this function
local Mystruct data = GetTimerStructA(GetExpiredTimer())

//This uses polar projection. Formula: Center + r * trigfunction(angle teta);
//where Center is the center coordinate X or Y
//r is the distance (in the case rabdom between 300 and 600)
//trigfunction is Sin if using Y and Cos if using X
//angle teta is the angle formed between r and the axis (in this case random, can be all circle)

local real randomX
local real randomY
local unit dummy
local integer exit = GetUnitAbilityLevel(data.caster, 'A000')
local integer counter = 0

loop
exitwhen(counter >= exit)
set randomX = GetUnitX(data.caster) + GetRandomReal(100.00, 900.00) * Cos(GetRandomReal(0.0, 360.0) * bj_DEGTORAD)
set randomY = GetUnitY(data.caster) + GetRandomReal(100.00, 900.00) * Sin(GetRandomReal(0.0, 360.0) * bj_DEGTORAD)
set dummy = CreateUnit(GetOwningPlayer(data.caster), 'h000', randomX, randomY, 0)
call UnitAddAbility(dummy, 'A002')
call IssueImmediateOrder( dummy, "thunderclap" )
call UnitApplyTimedLife(dummy, 'BTLF', 2.00)
set counter = counter + 1
endloop

set dummy = null

endfunction
//==========================================================================
function LightningInvocation_Conds takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
//==========================================================================
function LightningInvocation_Acts takes nothing returns nothing
local Mystruct data = Mystruct.create()

//starts the effect of the spell, thunders start falling from sky
call SetTimerStructA(data.repeator, data)
call TimerStart(data.repeator, 3 / GetUnitAbilityLevel(data.caster, 'A000'), true, function LightningInvocation)

//creates the timer that picks units arround the hero to give them abilities
call SetTimerStructB(data.picker, data)
call TimerStart(data.picker, 1, true, function Picker)

//This timer checks every 0.2 secs if a unit is outside range, to remove the buffs
call SetTimerStructC(data.remover, data)
call TimerStart(data.remover, 1.2, true, function Remover)

//creates the trigger that will end the spell when the hero stops channeling
call SetTriggerStructB(data.end, data)
call TriggerRegisterAnyUnitEventBJ( data.end, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
set data.endCondition = TriggerAddCondition( data.end, Condition( function End_Conds ) )
set data.endAction = TriggerAddAction( data.end, function End_Acts )
endfunction
//===========================================================================
function InitTrig_Lightning_Invocation takes nothing returns nothing
set gg_trg_Lightning_Invocation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Invocation, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_Lightning_Invocation, Condition( function LightningInvocation_Conds ) )
call TriggerAddAction( gg_trg_Lightning_Invocation, function LightningInvocation_Acts )
endfunction[/code]

any suggestions ?
Sry for double post, i fix it now
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
The problem is actually the same again :D
I will just explain how the loop part(the substitution of ForGroup) works:
You set a variable to the first unit in a group.
Basically that is your picked up unit.
You do your actions and then you remove the unit from the group(You absolutely must remove it from the group or else on the next hop of the loop the first of group would be the same).
As I see you need the data.buffer group and cannot remove all the units from it, you need to declare a local variable... oh here is the code:
JASS:
function Remover takes nothing returns nothing
    local Mystruct data = GetTimerStructC(GetExpiredTimer())
    local unit targ
    local group qwer=data.buffer
    //call ForGroup(data.buffer, function Killer)
    //here I check all units in data.buffer to see if they are inside range
    loop
        set targ = FirstOfGroup(qwer)
        exitwhen(targ == null)
// call BJDebugMsg("loop")
// call KillUnit(targ)
        if (IsUnitInRange(data.caster, targ, 900) == false) then
            call GroupRemoveUnit(data.buffer, targ)
// call KillUnit(targ)
            call UnitRemoveAbility(targ, 'A003')
            call UnitRemoveAbility(targ, 'A00A')
            call UnitRemoveAbility(targ, 'A00B')
        endif
        call GroupRemoveUnit(qwer,targ)
    endloop
set qwer=null
endfunction
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Oh crap, another one slipped :D (well that is my way of coding - not a first hit perfect job, but at the end... )
But you got what I meant?
 
Sorry it still doesn't work =S
I think the problem is in the way you set group qwer.
Well, thing is that I believe setting a group that way will only make qwer point to the memory address of the other group and will not copy its content as we want. To do that we may need another loop, which will add each unit of buffer to qwer.

This is what i think but i am not sure ... suggestions ?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Not sure.
But if so use GroupAddGroup to add data.buffer to qwer(which should be initialized( i mean add CreateGroup() )).
 
Mmm you mean :
JASS:
function Remover takes nothing returns nothing
    local Mystruct data = GetTimerStructC(GetExpiredTimer())
    local unit targ
    local group qwer
    call GroupAddGroup(data.buffer, qwer)
    
    //here I check all units in data.buffer to see if they are inside range
    loop
        set targ = FirstOfGroup(qwer)
        exitwhen(targ == null)
        if (IsUnitInRange(data.caster, targ, 900) == false) then
            call GroupRemoveUnit(data.buffer, targ)
            call UnitRemoveAbility(targ, 'A003')
            call UnitRemoveAbility(targ, 'A00A')
            call UnitRemoveAbility(targ, 'A00B')
        endif
        call GroupRemoveUnit(qwer,targ)
    endloop
    call DestroyGroup(qwer)
    set qwer=null
endfunction

??????
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
To quote KaTTaNa:
Be careful that removed units removed using RemoveUnit() will still appear as null entries in a group until removed, so be sure to use GroupRemoveUnit even if you kill or remove the unit from the game.
 
Well, RemovedUnit() and KillUnit() do not remove a unit from a unit group.

Hey I was reading a tutorial from Blade something (can't remember the whole nickname)
and i found a copy group function that was just what i needed !
Now it works !

[jass=Yupi!]function CopyGroup takes group g returns group
set bj_groupAddGroupDest = CreateGroup()
call ForGroup(g, function GroupAddGroupEnum)
return bj_groupAddGroupDest
endfunction
//==========================================================================
function Remover takes nothing returns nothing
local Mystruct data = GetTimerStructC(GetExpiredTimer())
local unit targ
local group qwer = CopyGroup(data.buffer)

//here I check all units in data.buffer to see if they are inside range
loop
set targ = FirstOfGroup(qwer)
exitwhen(targ == null)

if (IsUnitInRange(data.caster, targ, 900) == false) then
call GroupRemoveUnit(data.buffer, targ)
call UnitRemoveAbility(targ, 'A003')
call UnitRemoveAbility(targ, 'A00A')
call UnitRemoveAbility(targ, 'A00B')
endif
call GroupRemoveUnit(qwer,targ)
endloop
call DestroyGroup(qwer)
set qwer=null
endfunction[/code]

Here is the link to the tutorial
JASS:
//================================================================================
// [url]http://www.wc3campaigns.net/showthread.php?t=83337[/url]
//================================================================================

Now i can finally go On !! Thx !!
You will get credit when i post spell on the spells section, for being the only guy that helped all the way to the end (well, it's not done yet, but it is almost there xD )
Thx for letting me know that qwer group thing !!
+rep !
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Great that you got it working. But that is exactly what GroupAddGroup does :grin:

JASS:
function GroupAddGroup takes group sourceGroup, group destGroup returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupAddGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupAddGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction
JASS:
function GroupAddGroupEnum takes nothing returns nothing
    call GroupAddUnit(bj_groupAddGroupDest, GetEnumUnit())
endfunction

Ok, almost exactly :p
 
Status
Not open for further replies.
Top