library SpawnTable initializer init
//System by Dr Super Good
globals
public integer array SpawnType
public integer array SpawnNumber
public real array WaveDuration
public sound array WaveNoise
public string array WaveInfo
public real array SpawnX
public real array SpawnY
public real array SpawnDirection
public integer array ActiveSpawns
public integer ActiveSpawnNumber = 8
public constant integer FinalWave = 36
endglobals
private function LimateAS_forplayer takes nothing returns nothing
set ActiveSpawns[ActiveSpawnNumber] = GetPlayerId(GetEnumPlayer())
set ActiveSpawnNumber = ActiveSpawnNumber+1
endfunction
public function LimateAS takes nothing returns nothing
set ActiveSpawnNumber = 0
call ForForce(udg_ConnectedPlayers,function LimateAS_forplayer)
endfunction
private function init takes nothing returns nothing
local integer i = 0
set SpawnX[0]=-5376
set SpawnY[0]=5376
set SpawnDirection[0]=-90
set SpawnX[1]=-768
set SpawnY[1]=768
set SpawnDirection[1]=180
set SpawnX[2]=768
set SpawnY[2]=768
set SpawnDirection[2]=90
set SpawnX[3]=5376
set SpawnY[3]=5376
set SpawnDirection[3]=180
set SpawnX[4]=-5376
set SpawnY[4]=-5376
set SpawnDirection[4]=0
set SpawnX[5]=-768
set SpawnY[5]=-768
set SpawnDirection[5]=-90
set SpawnX[6]=768
set SpawnY[6]=-768
set SpawnDirection[6]=0
set SpawnX[7]=5376
set SpawnY[7]=-5376
set SpawnDirection[7]=90
set ActiveSpawns[0]=0
set ActiveSpawns[1]=1
set ActiveSpawns[2]=2
set ActiveSpawns[3]=3
set ActiveSpawns[4]=4
set ActiveSpawns[5]=5
set ActiveSpawns[6]=6
set ActiveSpawns[7]=7
//wave 1
set i = i+1
set SpawnType[i] = 'hfoo'
set SpawnNumber[i] = 528
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 2
set i = i+1
set SpawnType[i] = 'hrif'
set SpawnNumber[i] = 1288
set WaveDuration[i] = 60
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 3
set i = i+1
set SpawnType[i] = 'hsor'
set SpawnNumber[i] = 1568
set WaveDuration[i] = 65
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
//wave 4
set i = i+1
set SpawnType[i] = 'hspt'
set SpawnNumber[i] = 360
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFArmored|r"
//wave 5
set i = i+1
set SpawnType[i] = 'hmpr'
set SpawnNumber[i] = 720
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Immune
set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFDivine|r"
//wave 6
set i = i+1
set SpawnType[i] = 'hkni'
set SpawnNumber[i] = 1144
set WaveDuration[i] = 71.5
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 7
set i = i+1
set SpawnType[i] = 'hgyr'
set SpawnNumber[i] = 1000
set WaveDuration[i] = 50
set WaveNoise[i] = gg_snd_Wave_Air
set WaveInfo[i] = "|CFFFF00FFAir|r"
//wave 8
set i = i+1
set SpawnType[i] = 'hmtm'
set SpawnNumber[i] = 1704
set WaveDuration[i] = 71
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
//wave 9
set i = i+1
set SpawnType[i] = 'hmtt'
set SpawnNumber[i] = 120
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFExtra Tough|r and |CFFFF00FFExtra Fast|r"
//wave 10
set i = i+1
set SpawnType[i] = 'ogru'
set SpawnNumber[i] = 480
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Immune
set WaveInfo[i] = "|CFFFF00FFImmune|r"
//wave 11
set i = i+1
set SpawnType[i] = 'ohun'
set SpawnNumber[i] = 808
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 12
set i = i+1
set SpawnType[i] = 'odoc'
set SpawnNumber[i] = 944
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 13
set i = i+1
set SpawnType[i] = 'oshm'
set SpawnNumber[i] = 1152
set WaveDuration[i] = 55
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 14
set i = i+1
set SpawnType[i] = 'orai'
set SpawnNumber[i] = 1272
set WaveDuration[i] = 55
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
//wave 15
set i = i+1
set SpawnType[i] = 'otau'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 60
set WaveNoise[i] = gg_snd_Wave_Immune
set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFLarge Volume|r"
//wave 16
set i = i+1
set SpawnType[i] = 'okod'
set SpawnNumber[i] = 800
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
//wave 17
set i = i+1
set SpawnType[i] = 'otbr'
set SpawnNumber[i] = 240
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Air
set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFArmored|r"
//wave 18
set i = i+1
set SpawnType[i] = 'ospw'
set SpawnNumber[i] = 360
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFDivine|r"
//wave 19
set i = i+1
set SpawnType[i] = 'ugho'
set SpawnNumber[i] = 240
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 20
set i = i+1
set SpawnType[i] = 'ucry'
set SpawnNumber[i] = 120
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Immune
set WaveInfo[i] = "|CFFFF00FFImmune|r"
//wave 21
set i = i+1
set SpawnType[i] = 'uban'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 59
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
//wave 22
set i = i+1
set SpawnType[i] = 'unec'
set SpawnNumber[i] = 960
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 23
set i = i+1
set SpawnType[i] = 'ugar'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 58
set WaveNoise[i] = gg_snd_Wave_Air
set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
//wave 24
set i = i+1
set SpawnType[i] = 'uabo'
set SpawnNumber[i] = 1040
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 25
set i = i+1
set SpawnType[i] = 'umtw'
set SpawnNumber[i] = 800
set WaveDuration[i] = 44
set WaveNoise[i] = gg_snd_Wave_Immune
set WaveInfo[i] = "|CFFFF00FFImmune|r"
//wave 26
set i = i+1
set SpawnType[i] = 'uobs'
set SpawnNumber[i] = 280
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Normal
set WaveInfo[i] = ""
//wave 27
set i = i+1
set SpawnType[i] = 'ufro'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 57
set WaveNoise[i] = gg_snd_Wave_Air
set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
//wave 28
set i = i+1
set SpawnType[i] = 'Obla'
set SpawnNumber[i] = 960
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFExtra Fast|r"
//wave 29
set i = i+1
set SpawnType[i] = 'Edem'
set SpawnNumber[i] = 1200
set WaveDuration[i] = 50
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r"
//wave 30
set i = i+1
set SpawnType[i] = 'Hmkg'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 60
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r, |CFFFF00FFLarge Volume|r and |CFFFF00FFImmune|r"
//wave 31
set i = i+1
set SpawnType[i] = 'ninf'
set SpawnNumber[i] = 360
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Boss
set WaveInfo[i] = "|CFFFF00FFBoss|r"
//wave 32
set i = i+1
set SpawnType[i] = 'Nngs'
set SpawnNumber[i] = 640
set WaveDuration[i] = 45
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r"
//wave 33
set i = i+1
set SpawnType[i] = 'Ucrl'
set SpawnNumber[i] = 120
set WaveDuration[i] = 40
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFArmored|r"
//wave 34
set i = i+1
set SpawnType[i] = 'Udea'
set SpawnNumber[i] = 1800
set WaveDuration[i] = 60
set WaveNoise[i] = gg_snd_Wave_Hero
set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFLarge Volume|r"
//wave 35
set i = i+1
set SpawnType[i] = 'nrwm'
set SpawnNumber[i] = 1160
set WaveDuration[i] = 50
set WaveNoise[i] = gg_snd_Wave_Air
set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFImmune|r"
//wave 36
set i = i+1
set SpawnType[i] = 'nsgh'
set SpawnNumber[i] = 120
set WaveDuration[i] = 60
set WaveNoise[i] = gg_snd_Wave_Boss
set WaveInfo[i] = "|CFFFF00FFBoss|r"
endfunction
endlibrary
library SpawnSystem initializer init
globals
public real WaveDelay
private timer Timer = CreateTimer()
public integer Wave = 0
private integer Number = 0
private integer Type
private sound Noise = null
private constant player Evil = Player(11)
endglobals
private function win_forallplayers takes nothing returns nothing
local player p = GetEnumPlayer()
call RemovePlayer(p, PLAYER_GAME_RESULT_VICTORY )
call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
if (GetPlayerController(p) == MAP_CONTROL_USER) then
set bj_changeLevelShowScores = true
call CustomVictoryDialogBJ(p)
endif
set p = null
endfunction
private function win takes nothing returns nothing
call ForForce(udg_ConnectedPlayers,function win_forallplayers)
call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
endfunction
private function lose_forallplayers takes nothing returns nothing
local player p = GetEnumPlayer()
call RemovePlayer(p,PLAYER_GAME_RESULT_DEFEAT )
call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
if (GetPlayerController(p) == MAP_CONTROL_USER) then
call CustomDefeatDialogBJ(p,"TRIGSTR_1460")
endif
set p = null
endfunction
private function lose takes nothing returns nothing
call ForForce(udg_ConnectedPlayers, function lose_forallplayers)
call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
endfunction
private function endwave_delay takes nothing returns nothing
call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),-1)
call LeaderboardSortItemsByValue(udg_LEADERBOARD,false)
call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
call ExecuteFunc("SpawnSystem_endwave")
endfunction
private function batch takes nothing returns nothing
local integer i = 0
local integer s
loop
exitwhen i == SpawnTable_ActiveSpawnNumber
set s = SpawnTable_ActiveSpawns[i]
call CreateUnit(Evil,Type,SpawnTable_SpawnX[s],SpawnTable_SpawnY[s],SpawnTable_SpawnDirection[s])
set i = i+1
endloop
set udg_CurrentlyOnMap = udg_CurrentlyOnMap+SpawnTable_ActiveSpawnNumber
set Number = Number-SpawnTable_ActiveSpawnNumber
call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
if Number<=0 then
call TimerStart(Timer,WaveDelay,false,function endwave_delay)
endif
endfunction
private function winning takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Congratulations, you have survived the invasion and the valley will be safe for ages to come!")
call DestroyTrigger(gg_trg_PlayerQuit)
set gg_trg_PlayerQuit = null
call TimerStart(Timer,40,false,function win)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, thank you for playing and remember to play again when ever you like.")
endfunction
private function losing_forallunits takes nothing returns nothing
local unit u = GetEnumUnit()
call PauseUnit(u,true)
call SetUnitTimeScale(u,0)
set u = null
endfunction
private function losing takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
call ForGroup(g,function losing_forallunits)
call DestroyGroup(g)
set g = null
call DestroyTrigger(gg_trg_PlayerQuit)
set gg_trg_PlayerQuit = null
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"TRIGSTR_1458" )
call LeaderboardSetItemValueColor(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),255,0,0,255)
call TimerStart(Timer,40,false,function lose)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, I advise trying again or playing at a lower difficulty.")
endfunction
private function UpdateFood takes nothing returns nothing
call SetPlayerState(GetEnumPlayer(),PLAYER_STATE_RESOURCE_FOOD_USED,Wave)
endfunction
public function endwave takes nothing returns nothing
if udg_CurrentlyOnMap>=700 then
call losing()
return
elseif udg_CurrentlyOnMap>=350 then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|cffFF0000[WARNING]|r - You lose if more than 700 invaders are out at the same time at the end of a wave!")
endif
set Wave = Wave+1
if Wave > SpawnTable_FinalWave then
call winning()
return
endif
set Type = SpawnTable_SpawnType[Wave]
set Number = Number+SpawnTable_SpawnNumber[Wave]
call ForForce(udg_ConnectedPlayers, function UpdateFood)
if Noise != null then
call StopSound(Noise,false,true)
endif
set Noise = SpawnTable_WaveNoise[Wave]
call StartSound(Noise)
call TimerStart(Timer,SpawnTable_WaveDuration[Wave]*SpawnTable_ActiveSpawnNumber/Number,true,function batch)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Here comes wave "+I2S(Wave)+" consisting of "+I2S(Number)+" "+GetObjectName(Type)+" units attacking over the course of "+I2S(R2I(SpawnTable_WaveDuration[Wave]))+" seconds.")
if SpawnTable_WaveInfo[Wave] != "" then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"This wave is "+SpawnTable_WaveInfo[Wave]+".")
endif
endfunction
private function init takes nothing returns nothing
call TimerStart(Timer,35,false,function endwave)
endfunction
endlibrary