globals
player user = Player(0)
player Byron = Player(2)
integer Warlock = 'nw2w'
integer Drake = 'nbzk'
integer target = 0
endglobals
// ATTACK SYSTEM
function AttackTarget takes nothing returns nothing
//This is all encased in a loop so after hitting last wave, the cycle restarts
loop
if target == 1 then
call DisplayTextToPlayer(user, 0, 0, "Target = 1, cycle start")
// Wave 1
call InitAssaultGroup()
call CampaignAttackerEx(2, 2, 2, 'ogru')
call CampaignAttackerEx(1, 1, 1, 'ohun')
call CampaignAttackerEx(2, 2, 2, 'orai')
call CampaignAttackerEx(1, 1, 1, Warlock)
call SuicideOnPlayer(15, Byron)
// Wave 2 — only if target still 1
if target == 1 then
call InitAssaultGroup()
call CampaignAttackerEx(2, 2, 2, 'ogru')
call CampaignAttackerEx(2, 2, 2, 'ohun')
call CampaignAttackerEx(1, 1, 1, 'orai')
call CampaignAttackerEx(2, 2, 2, Warlock)
call SuicideOnPlayer(45, Byron)
endif
if target == 1 then
// Wave 3
call InitAssaultGroup()
call CampaignAttackerEx(1, 1, 1, 'ogru')
call CampaignAttackerEx(2, 2, 2, 'ohun')
call CampaignAttackerEx(2, 2, 2, 'orai')
call CampaignAttackerEx(1, 1, 1, Warlock)
call SuicideOnPlayer(45, Byron)
endif
if target == 1 then
// Wave 4
call InitAssaultGroup()
call CampaignAttackerEx(3, 3, 3, 'ogru')
call CampaignAttackerEx(3, 3, 3, 'ohun')
call CampaignAttackerEx(1, 1, 1, Warlock)
call SuicideOnPlayer(45, Byron)
endif
if target == 1 then
// Wave 5
call InitAssaultGroup()
call CampaignAttackerEx(2, 2, 2, 'ogru')
call CampaignAttackerEx(1, 1, 1, 'ohun')
call CampaignAttackerEx(2, 2, 2, 'orai')
call CampaignAttackerEx(1, 1, 1, Warlock)
call SuicideOnPlayer(45, Byron)
endif
elseif target == 2 then
//Waves to Player
call DisplayTextToPlayer(user, 0, 0, "Target = 2")
call InitAssaultGroup()
call CampaignAttackerEx(2, 2, 2, 'owyv')
call CampaignAttackerEx(1, 1, 1, Drake)
call SuicideOnPlayer(M3, user)
loop
call DisplayTextToPlayer(user, 0, 0, "Target = 2 Loop")
call InitAssaultGroup()
call CampaignAttackerEx(2, 2, 2, 'ogru')
call CampaignAttackerEx(2, 2, 2, 'ohun')
call CampaignAttackerEx(1, 1, 1, 'orai')
call CampaignAttackerEx(2, 2, 2, Warlock)
call CampaignAttackerEx(1, 1, 1, Drake)
call SuicideOnPlayer(M3, user)
call InitAssaultGroup()
call CampaignAttackerEx(3, 3, 3, 'owyv')
call CampaignAttackerEx(2, 2, 2, 'orai')
call CampaignAttackerEx(2, 2, 2, 'ohun')
call SuicideOnPlayer(M4, user)
call InitAssaultGroup()
call CampaignAttackerEx(1, 1, 1, 'owyv')
call CampaignAttackerEx(3, 3, 3, Drake)
call SuicideOnPlayer(M3, user)
call InitAssaultGroup()
call CampaignAttackerEx(3, 3, 3, 'ogru')
call CampaignAttackerEx(1, 1, 1, 'ohun')
call CampaignAttackerEx(2, 2, 2, Warlock)
call CampaignAttackerEx(2, 2, 2, 'owyv')
call SuicideOnPlayer(M4, user)
endloop
//For fringe cases where the new command hasn't been registered at the very start of the map loading
else
call Sleep(2)
endif
call DisplayTextToPlayer(user, 0, 0, "Restart Loop")
endloop
endfunction
function ConditionState takes nothing returns nothing
if CommandsWaiting() > 0 then
call DisplayTextToPlayer(user, 0, 0, "Command received!")
set target = GetLastCommand()
call DisplayTextToPlayer(user, 0, 0, "Target =" + I2S(target))
call PopLastCommand()
endif
endfunction
// CONDITION LOOP
function ConditionLoop takes nothing returns nothing
call ConditionState()
call StaggerSleep(1,5)
loop
call ConditionState()
call Sleep(2)
endloop
endfunction
// MAIN FUNCTION
function main takes nothing returns nothing
call CampaignAI('otrb', null)
call SetReplacements(100, 100, 100)
call SetPeonsRepair(true)
call SetHeroesFlee(false)
call SetGroupsFlee(false)
//Buildings
call SetBuildUnit(3, 'opeo') //Peon
call SetBuildUnit(1, 'ogre') //Great Hall
call SetBuildUnit(1, 'obar') //Barracks
call SetBuildUnit(5, 'otrb') //Burrow
call SetBuildUnit(5, 'owtw') //Watch Tower
call SetBuildUnit(1, 'ostr') //Stronghold
call SetBuildUnit(1, 'osld') //Spirit Lodge
call SetBuildUnit(1, 'obea') //Beastiary
call SetBuildUnit(2, 'nzep') //Zeppelins
call StartThread(function ConditionLoop)
call StartThread(function AttackTarget)
endfunction