removing the comment should help.
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="2"/>
<players>
<player control="human" faction="egypt" team="1"/>
<player control="cpu" faction="egypt" team="1"/>
<player control="cpu" faction="egypt" team="2"/>
<player control="cpu" faction="egypt" team="2"/>
</players>
<map value="conflict"/>
<tileset value="forest"/>
<tech-tree value="megapack"/>
<default-resources value="false"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<startup>
human_player = 0
human_ally = 1
ally_unit_name = 'pyramid'
spammer_player = 2
spam_unit_name = 'mummy'
spam_unit_count_total = 1050
spam_unit_count_add = 1
spam_unit_count_already = 0
spam_unit_growth_ratio = 2
spam_wave_max_sec_per_unit = 60
spam_unit_count_max_per_second = 5
spam_unit_food = 1 --it dies after a while (avoid ignoring wave)
human_units = { 'pyramid', 1, 'slave', 4, 'chicken', 2, 'farm', 1,
'desert_camp', 1, 'obelisk', 1, 'temple', 1, 'priest', 1 }
ally_unit = -1
timer_spam = -1
human_resources = { 'food', 1000, 'gold', 2000, 'stone', 1000, 'wood', 1000 }
debugging = false
for i=0,3 do
if i ~= human_player then
disableAi(i)
end
end
disableConsume(spammer_player)
function logLine(msg)
if debugging then
--addConsoleText(msg)
print(msg)
end
end
createUnit(ally_unit_name, human_ally, startLocation(human_player))
ally_unit=lastCreatedUnit()
function giveResources(resources_with_counts, player_number)
for i=1,#resources_with_counts,2 do
giveResource(resources_with_counts[i], player_number, resources_with_counts[i+1])
end
end
function createUnits(units_with_counts, player_number, location)
for i=1,#units_with_counts,2 do
for j=1,units_with_counts[i+1] do
createUnit(units_with_counts[i], player_number, location)
end
end
end
function spamUnit()
createUnit(spam_unit_name, spammer_player, startLocation(spammer_player))
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(human_player))
spam_unit_count_already = spam_unit_count_already + 1
giveResource('food', spammer_player, spam_unit_food);
end
function spamUnits()
timerSpam(false)
spam_unit_count_already = 0
displayFormattedText('%s', spam_unit_count_add .. 'x ' .. spam_unit_name)
logLine('spamUnits: ' .. spam_unit_name .. ' ' .. spam_unit_count_add)
timerSpam(true)
end
function spamNextUnits()
spam_unit_count_add = spam_unit_count_add * spam_unit_growth_ratio
spamUnits()
end
timer_spam_enabled = false
function timerSpam(enabled)
if enabled ~= timer_spam_enabled then
timer_spam_enabled = enabled
if enabled then
timer_spam = startTimerEvent()
else
stopTimerEvent(timer_spam)
end
end
end
logLine('starting game')
createUnits(human_units, human_player, startLocation(human_player))
giveResources(human_resources, human_player)
spamUnits()
timer_avoid_avoiding_wave = startTimerEvent()
timer_avoiding_elapsed_last_time = 0
timer_spam_elapsed_last_time = 0
</startup>
<timerTriggerEvent>
if triggeredTimerEventId() == timer_spam then
timer_elapsed = timerEventSecondsElapsed(triggeredTimerEventId())
timer_diff = timer_elapsed - timer_spam_elapsed_last_time
timer_diff_spam = timer_diff * spam_unit_count_max_per_second
remaining = spam_unit_count_add - spam_unit_count_already
timer_spam_elapsed_last_time = timer_elapsed
if remaining > 0 then
spam_how_many = math.min(remaining, timer_diff_spam)
if spam_how_many > 0 then
logLine('trigger event ' .. timer_elapsed .. 'sec: '
.. 'spamming ' .. spam_how_many .. ' units'
.. ', ' .. remaining .. ' units remains')
for i=1,spam_how_many do
spamUnit()
end
end
else
timerSpam(false)
end
elseif triggeredTimerEventId() == timer_avoid_avoiding_wave then
timer_elapsed = timerEventSecondsElapsed(triggeredTimerEventId())
timer_elapsed_diff = timer_elapsed - timer_avoiding_elapsed_last_time
max_allowed_time = spam_wave_max_sec_per_unit * spam_unit_count_add
if timer_elapsed_diff > max_allowed_time then
timer_avoiding_elapsed_last_time = timer_avoiding_elapsed_last_time + max_allowed_time
logLine('wave takes too long (' .. timer_elapsed_diff .. ' seconds), starting next wave')
spamNextUnits()
end
end
</timerTriggerEvent>
<unitCreated>
</unitCreated>
<unitDied>
if lastDeadUnit() == ally_unit then
clearDisplayText()
setPlayerAsWinner(spammer_player)
endGame()
else
spammer_player_unitCount = unitCount(spammer_player)
logLine('spammer has ' .. spammer_player_unitCount .. ' units left')
if spammer_player_unitCount == 0 then
logLine('spammer has no units')
if spam_unit_count_add * spam_unit_growth_ratio >= spam_unit_count_total then
logLine('victory')
clearDisplayText()
setPlayerAsWinner(human_player)
endGame()
else
spamNextUnits()
end
end
end
</unitDied>
</scripts>
</scenario>