//==================================================================
// Spawn system by Vestras
// I tried to make it as balanced as I could,
// and here are the results.
// NOTE: I have edited the code a little bit
// to make it more balanced. - Vestras.
//
//
// Requirements:
// Not really anyone, just two things: You have to
// Store every zombie into the variable called
// "S_I", and change the integer called "sti" from 4 (basic) to 5
// of course more, if you have added more zombies.
// Also, ALL monsters that should be spawned needs to have a food
// requirement, nevermind how big it is. Else it wont work.
//
//
// How this works:
// minhi is the minimum high in the i random integer.
// minli is the minimum low in the i random integer.
// i adds minhi to minli, and times them by 2. After that,
// it divides the number by 3, which makes it more balanced.
//
//
// How to edit:
// If you think the system is imbalanced and you want to edit
// the system, just edit the minhi and minli integers to the
// desired number. This will also edit the i integer, and by
// that, also the number of units spawned per spawn region.
//==================================================================
function SpawnCond takes nothing returns boolean
if ( not ( udg_waveint >= 3 ) ) then
set udg_minhi = ( udg_minhi + 1 )
set udg_minli = ( udg_minli + 1 )
call DisplayTextToForce(GetPlayersAll(), ( "Level" + ( " " + I2S(udg_waveint) ) ) ) // Just for testing, just delete or edit if you want to.
return false
endif
set udg_minhi = ( udg_minhi + 3 )
set udg_minli = ( udg_minli + 3 )
call DisplayTextToForce(GetPlayersAll(), ( "Level" + ( " " + I2S(udg_waveint) ) ) ) // Just for testing, just delete or edit if you want to.
return true
endfunction
function Main_Actions takes nothing returns nothing
local integer sloop = 1
set udg_stp[1] = GetRandomLocInRect(gg_rct_MonstersSpawn1)
set udg_stp[2] = GetRandomLocInRect(gg_rct_MonstersSpawn2)
set udg_stp[3] = GetRandomLocInRect(gg_rct_MonstersSpawn3)
set udg_stp[4] = GetRandomLocInRect(gg_rct_MonstersSpawn4)
set udg_stp[5] = GetRandomLocInRect(gg_rct_MonstersSpawn5)
set udg_stp[6] = GetRandomLocInRect(gg_rct_MonstersSpawn6)
set udg_stap = GetRandomLocInRect(gg_rct_MonstersSpawn7AIRSPANWSONLY)
set udg_S_I[1] = 'n001'
set udg_S_I[2] = 'n000'
set udg_S_I[3] = 'n002'
set udg_S_I[4] = 'u001'
set udg_minhi = ( udg_minhi + 8 )
set udg_minli = ( udg_minli + 4 )
set udg_i = ( udg_minhi + ( udg_minli * ( 2 / 3 ) ) )
set udg_waveint = ( udg_waveint + 1 )
loop
exitwhen sloop > udg_i
set udg_sti = GetRandomInt(1, 4)
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[1], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[2], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[3], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[4], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[5], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, udg_S_I[udg_sti], Player(1), udg_stp[6], bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
call CreateNUnitsAtLoc( 1, 'u001', Player(1), udg_stap, bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call IssuePointOrder(udg_u,"attack",0,0)
set udg_u = null
set udg_sti = 0
set sloop = sloop + 1
call PolledWait(0.20)
endloop
call ExecuteFunc("SpawnCond")
set udg_S_I[1] = 0
set udg_S_I[2] = 0
set udg_S_I[3] = 0
set udg_S_I[4] = 0
call RemoveLocation(udg_stap)
call RemoveLocation(udg_stp[1])
call RemoveLocation(udg_stp[2])
call RemoveLocation(udg_stp[3])
call RemoveLocation(udg_stp[4])
call RemoveLocation(udg_stp[5])
call RemoveLocation(udg_stp[6])
endfunction
//===========================================================================
function InitTrig_Spawn takes nothing returns nothing
set gg_trg_Spawn = CreateTrigger( )
call TriggerRegisterPlayerStateEvent( gg_trg_Spawn, Player(1), PLAYER_STATE_RESOURCE_FOOD_USED, LESS_THAN_OR_EQUAL, 0.00 )
call TriggerAddAction( gg_trg_Spawn, function Main_Actions )
endfunction