- Reaction score
- 534
Hi!
I've got a problem with a code... It's been like 3 days I'm finding to find a way around it but I just can't... it must be MUI!
Here it is...
What it does ? it is a mass attack command. When your wisp enter ''Attack Yellow'' region, all your units attack Yellow. Really, this code works in GUI. It worked well with Integer A. But since Integer A was used everytime a player wanted to mass attack another one, it bugged, there was only one solution : make it MUI.
There is a huge background history to this trigger : First I used Unit Groups. I got insane Unit Congestion. Next I deleted it from the map and when Darthfett told me with Integer Loops and waits the units stopped Congestion, I tried again. It worked !
But only with Integer A. I tried with a global integer variable and it didn't work either. So I decided to switch to JASS and use a local integer variable.
It doesn't work either.
What is the problem exactly ? It doesn't move all the units! With Integer A all the units are moved ! As soon as I use an integer variable, global or not, half of the units are moved. I think the problem is somewhere close to this line :
exitwhen ivar > CountUnitsInGroup(Units_of_Player)
But I can't be sure
Any ideas why it doesn't send all the units?
I've got a problem with a code... It's been like 3 days I'm finding to find a way around it but I just can't... it must be MUI!
Here it is...
Code:
function Trig_Attack_Yellow_Copy_Func003002002 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) != 'e00E' )
endfunction
function Trig_Attack_Yellow_Copy_Actions takes nothing returns nothing
local integer i = GetConvertedPlayerId(GetOwningPlayer(GetEnteringUnit()))
local integer ivar
local group Units_of_Player
local unit u
local location sy
local location p
set Units_of_Player = GetUnitsOfPlayerMatching(GetOwningPlayer(GetEnteringUnit()), Condition(function Trig_Attack_Yellow_Copy_Func003002002))
set p = GetRectCenter(udg_AttackerSpawn[i])
call SetUnitPositionLoc( GetEnteringUnit(), p )
set ivar = 1
loop
exitwhen ivar > CountUnitsInGroup(Units_of_Player)
call TriggerSleepAction( 0.02 )
set u = GroupPickRandomUnit(Units_of_Player)
set sy = GetRandomLocInRect(gg_rct_Spawn_Yellow)
call IssuePointOrderLocBJ( u, "attack", sy )
call GroupRemoveUnitSimple( u, Units_of_Player )
call RemoveLocation(sy)
set ivar = ivar + 1
endloop
call RemoveLocation(p)
call DestroyGroup(Units_of_Player)
endfunction
//===========================================================================
function InitTrig_Attack_Yellow takes nothing returns nothing
set gg_trg_Attack_Yellow = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Attack_Yellow, gg_rct_Attack_Yellow )
call TriggerAddAction( gg_trg_Attack_Yellow, function Trig_Attack_Yellow_Copy_Actions )
endfunction
What it does ? it is a mass attack command. When your wisp enter ''Attack Yellow'' region, all your units attack Yellow. Really, this code works in GUI. It worked well with Integer A. But since Integer A was used everytime a player wanted to mass attack another one, it bugged, there was only one solution : make it MUI.
There is a huge background history to this trigger : First I used Unit Groups. I got insane Unit Congestion. Next I deleted it from the map and when Darthfett told me with Integer Loops and waits the units stopped Congestion, I tried again. It worked !
But only with Integer A. I tried with a global integer variable and it didn't work either. So I decided to switch to JASS and use a local integer variable.
It doesn't work either.
What is the problem exactly ? It doesn't move all the units! With Integer A all the units are moved ! As soon as I use an integer variable, global or not, half of the units are moved. I think the problem is somewhere close to this line :
exitwhen ivar > CountUnitsInGroup(Units_of_Player)
But I can't be sure
Any ideas why it doesn't send all the units?