- Joined
- Dec 29, 2006
- Messages
- 994
I have a TD (4 player solo TD) and i converted the spawn triggers into JASS and i have a problem. Ive gone through the entire code for each player, but for somereason it spawns 2 extra creeps per round for red. Heres the code:
Red:
Blue:
Teal:
Purple:
Also if there are any leakes, or anyway the code could be compacted, improved please let me know.
And if your wondering i have the loop so i can spawn creeps at 1 second intervals, yet have less code and easier control over the conditions.
Red:
JASS:
function Trig_RedSpawn_Conditions takes nothing returns boolean
if ( not ( udg_Defeat == false ) ) then
return false
endif
return true
endfunction
function Trig_RedSpawn_Func004Func002001 takes nothing returns boolean
return ( udg_Level_Number != 10 )
endfunction
function Trig_RedSpawn_Func004Func002002001 takes nothing returns boolean
return ( udg_Level_Number != 20 )
endfunction
function Trig_RedSpawn_Func004Func002002002 takes nothing returns boolean
return ( udg_Level_Number != 30 )
endfunction
function Trig_RedSpawn_Func004Func002002 takes nothing returns boolean
return GetBooleanAnd( Trig_RedSpawn_Func004Func002002001(), Trig_RedSpawn_Func004Func002002002() )
endfunction
function Trig_RedSpawn_Func004C takes nothing returns boolean
if ( not GetBooleanAnd( Trig_RedSpawn_Func004Func002001(), Trig_RedSpawn_Func004Func002002() ) ) then
return false
endif
return true
endfunction
function Trig_RedSpawn_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Red_Spawn), bj_UNIT_FACING )
call DisplayTextToForce( bj_FORCE_PLAYER[0], ( ( "Level " + I2S(udg_Level_Number) ) + ( " - " + ( GetUnitName(GetLastCreatedUnit()) + "s" ) ) ) )
if ( Trig_RedSpawn_Func004C() ) then
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
call TriggerSleepAction( 1.00 )
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Red_Spawn), bj_UNIT_FACING )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
endloop
else
endif
endfunction
//===========================================================================
function InitTrig_RedSpawn takes nothing returns nothing
set gg_trg_RedSpawn = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_RedSpawn, udg_Next_Level )
call TriggerAddCondition( gg_trg_RedSpawn, Condition( function Trig_RedSpawn_Conditions ) )
call TriggerAddAction( gg_trg_RedSpawn, function Trig_RedSpawn_Actions )
endfunction
Blue:
JASS:
function Trig_BlueSpawn_Conditions takes nothing returns boolean
if ( not ( udg_Defeat == false ) ) then
return false
endif
return true
endfunction
function Trig_BlueSpawn_Func004Func001001 takes nothing returns boolean
return ( udg_Level_Number != 10 )
endfunction
function Trig_BlueSpawn_Func004Func001002001 takes nothing returns boolean
return ( udg_Level_Number != 20 )
endfunction
function Trig_BlueSpawn_Func004Func001002002 takes nothing returns boolean
return ( udg_Level_Number != 30 )
endfunction
function Trig_BlueSpawn_Func004Func001002 takes nothing returns boolean
return GetBooleanAnd( Trig_BlueSpawn_Func004Func001002001(), Trig_BlueSpawn_Func004Func001002002() )
endfunction
function Trig_BlueSpawn_Func004C takes nothing returns boolean
if ( not GetBooleanAnd( Trig_BlueSpawn_Func004Func001001(), Trig_BlueSpawn_Func004Func001002() ) ) then
return false
endif
return true
endfunction
function Trig_BlueSpawn_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Blue_Spawn), bj_UNIT_FACING )
call DisplayTextToForce( bj_FORCE_PLAYER[1], ( ( "Level " + I2S(udg_Level_Number) ) + ( " - " + ( GetUnitName(GetLastCreatedUnit()) + "s" ) ) ) )
if ( Trig_BlueSpawn_Func004C() ) then
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
call TriggerSleepAction( 1.00 )
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Blue_Spawn), bj_UNIT_FACING )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
endloop
else
endif
endfunction
//===========================================================================
function InitTrig_BlueSpawn takes nothing returns nothing
set gg_trg_BlueSpawn = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_BlueSpawn, udg_Next_Level )
call TriggerAddCondition( gg_trg_BlueSpawn, Condition( function Trig_BlueSpawn_Conditions ) )
call TriggerAddAction( gg_trg_BlueSpawn, function Trig_BlueSpawn_Actions )
endfunction
Teal:
JASS:
function Trig_TealSpawn_Conditions takes nothing returns boolean
if ( not ( udg_Defeat == false ) ) then
return false
endif
return true
endfunction
function Trig_TealSpawn_Func004Func002001 takes nothing returns boolean
return ( udg_Level_Number != 10 )
endfunction
function Trig_TealSpawn_Func004Func002002001 takes nothing returns boolean
return ( udg_Level_Number != 20 )
endfunction
function Trig_TealSpawn_Func004Func002002002 takes nothing returns boolean
return ( udg_Level_Number != 30 )
endfunction
function Trig_TealSpawn_Func004Func002002 takes nothing returns boolean
return GetBooleanAnd( Trig_TealSpawn_Func004Func002002001(), Trig_TealSpawn_Func004Func002002002() )
endfunction
function Trig_TealSpawn_Func004C takes nothing returns boolean
if ( not GetBooleanAnd( Trig_TealSpawn_Func004Func002001(), Trig_TealSpawn_Func004Func002002() ) ) then
return false
endif
return true
endfunction
function Trig_TealSpawn_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Teal_Spawn), bj_UNIT_FACING )
call DisplayTextToForce( bj_FORCE_PLAYER[2], ( ( "Level " + I2S(udg_Level_Number) ) + ( " - " + ( GetUnitName(GetLastCreatedUnit()) + "s" ) ) ) )
if ( Trig_TealSpawn_Func004C() ) then
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call TriggerSleepAction( 1.00 )
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Teal_Spawn), bj_UNIT_FACING )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
else
endif
endfunction
//===========================================================================
function InitTrig_TealSpawn takes nothing returns nothing
set gg_trg_TealSpawn = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_TealSpawn, udg_Next_Level )
call TriggerAddCondition( gg_trg_TealSpawn, Condition( function Trig_TealSpawn_Conditions ) )
call TriggerAddAction( gg_trg_TealSpawn, function Trig_TealSpawn_Actions )
endfunction
Purple:
JASS:
function Trig_PurpleSpawn_Conditions takes nothing returns boolean
if ( not ( udg_Defeat == false ) ) then
return false
endif
return true
endfunction
function Trig_PurpleSpawn_Func004Func002001 takes nothing returns boolean
return ( udg_Level_Number != 10 )
endfunction
function Trig_PurpleSpawn_Func004Func002002001 takes nothing returns boolean
return ( udg_Level_Number != 20 )
endfunction
function Trig_PurpleSpawn_Func004Func002002002 takes nothing returns boolean
return ( udg_Level_Number != 30 )
endfunction
function Trig_PurpleSpawn_Func004Func002002 takes nothing returns boolean
return GetBooleanAnd( Trig_PurpleSpawn_Func004Func002002001(), Trig_PurpleSpawn_Func004Func002002002() )
endfunction
function Trig_PurpleSpawn_Func004C takes nothing returns boolean
if ( not GetBooleanAnd( Trig_PurpleSpawn_Func004Func002001(), Trig_PurpleSpawn_Func004Func002002() ) ) then
return false
endif
return true
endfunction
function Trig_PurpleSpawn_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Purple_Spawn), bj_UNIT_FACING )
call DisplayTextToForce( bj_FORCE_PLAYER[3], ( ( "Level " + I2S(udg_Level_Number) ) + ( " - " + ( GetUnitName(GetLastCreatedUnit()) + "s" ) ) ) )
if ( Trig_PurpleSpawn_Func004C() ) then
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call TriggerSleepAction( 1.00 )
call CreateNUnitsAtLoc( udg_Monster_Amount, udg_Monster_Type, Player(11), GetRectCenter(gg_rct_Purple_Spawn), bj_UNIT_FACING )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
else
endif
endfunction
//===========================================================================
function InitTrig_PurpleSpawn takes nothing returns nothing
set gg_trg_PurpleSpawn = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_PurpleSpawn, udg_Next_Level )
call TriggerAddCondition( gg_trg_PurpleSpawn, Condition( function Trig_PurpleSpawn_Conditions ) )
call TriggerAddAction( gg_trg_PurpleSpawn, function Trig_PurpleSpawn_Actions )
endfunction
Also if there are any leakes, or anyway the code could be compacted, improved please let me know.
And if your wondering i have the loop so i can spawn creeps at 1 second intervals, yet have less code and easier control over the conditions.