- Joined
- Jun 20, 2005
- Messages
- 108
Hello everyone.
I'm having a problem with a new trigger I'm doing. It's supposed to spawm two units from a preset array and make them fight each other. When one of them wins, the trigger must spawn other 2 units (there are not the same as before) and repeat itself until there's no unit to spawn in the preset group, then it resets.
The problem is that when I use a unit on this trigger, I add it to another group (udg_GROUP_Duel[2]), but for some reason when the trigger runs again, that group is empty! I don't use this group in any other function and I'm totally lost with this bug. Could you guys help me?
Thanks in advance.
Here's the code (Full of debug messages trying to track the bug):
I'm having a problem with a new trigger I'm doing. It's supposed to spawm two units from a preset array and make them fight each other. When one of them wins, the trigger must spawn other 2 units (there are not the same as before) and repeat itself until there's no unit to spawn in the preset group, then it resets.
The problem is that when I use a unit on this trigger, I add it to another group (udg_GROUP_Duel[2]), but for some reason when the trigger runs again, that group is empty! I don't use this group in any other function and I'm totally lost with this bug. Could you guys help me?
Thanks in advance.
Here's the code (Full of debug messages trying to track the bug):
JASS:
function Trig_Spawn_Duelists_Actions takes nothing returns nothing
local unit u1
local unit u2
local unit u
local location loc
call DisplayTextToForce(udg_GROUP_Debug, "start")
if ( CountUnitsInGroup(udg_GROUP_Duel[1]) > 1 ) then
//unit on the left
call DisplayTextToForce(udg_GROUP_Debug, "Before all: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
set loc = GetRectCenter(gg_rct_Duel_Arena_1)
set u = GroupPickRandomUnit(udg_GROUP_Duel[1])
set u1 = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), GetUnitTypeId(u), loc, 0.00)
call DisplayTextToForce(udg_GROUP_Debug, "u1 picked: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
call GroupAddUnit( udg_GROUP_Duel[2], u1 )
call GroupRemoveUnit( udg_GROUP_Duel[1], u )
call DisplayTextToForce(udg_GROUP_Debug, "After Removing u1: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
call Leak_SFX(loc,"Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl")
call SetUnitAnimation( u1, "stand victory" )
//unit on the right
set loc = GetRectCenter(gg_rct_Duel_Arena_2)
set u = GroupPickRandomUnit(udg_GROUP_Duel[1])
set u2 = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), GetUnitTypeId(u), loc, 180.00)
call DisplayTextToForce(udg_GROUP_Debug, "u2 Picked: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
call GroupAddUnit( udg_GROUP_Duel[2], u2 )
call GroupRemoveUnit( udg_GROUP_Duel[1], u )
call Leak_SFX(loc,"Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl")
call SetUnitAnimation( u2, "stand victory" )
call TriggerSleepAction( 3.00 )
call IssueTargetOrderBJ( u1, "attack", u2 )
call IssueTargetOrderBJ( u2, "attack", u1 )
call DisplayTextToForce(udg_GROUP_Debug, "After all: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
else
call DisplayTextToForce(udg_GROUP_Debug, "Else: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
call GroupAddGroup( udg_GROUP_Duel[2], udg_GROUP_Duel[1] )
call DisplayTextToForce(udg_GROUP_Debug, "Group Added")
call GroupClear( udg_GROUP_Duel[2] )
call DisplayTextToForce(udg_GROUP_Debug, "Group Cleared")
call DisplayTextToForce(udg_GROUP_Debug, "Else Checking: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
// call TriggerExecute( gg_trg_Spawn_Duelists )
endif
//set u = null
//set u1 = null
//set u2 = null
//call RemoveLocation(loc)
//set loc = null
call DisplayTextToForce(udg_GROUP_Debug, "Last Check: [1]:" + I2S(CountUnitsInGroup(udg_GROUP_Duel[1])) + "[2]: " + I2S(CountUnitsInGroup(udg_GROUP_Duel[2])))
endfunction