--	Stratagus Map - Single player campaign

Load("campaigns/human/level09h_c2.sms")

Briefing(
  title,
  objectives,
  "../campaigns/human/interface/introscreen3.png",
  "campaigns/human/level09h.txt",
  {"campaigns/human/level09h-intro1.wav"}
)

AddTrigger(
  function() return IfNearUnit("this", "==", 1, "unit-man-of-light", "unit-circle-of-power") end,
  function() return ActionVictory() end)

AddTrigger(
  function() return GetPlayerData(GetThisPlayer(), "UnitTypesCount", "unit-man-of-light") == 0 and
    GetPlayerData(3, "UnitTypesCount", "unit-man-of-light") == 0 end,
  function() return ActionDefeat() end)
AddTrigger(
  function() return GetPlayerData(GetThisPlayer(), "TotalNumUnits") == 0 end,
  function() return ActionDefeat() end)

--Units
local allowedOrcUnits = {"unit-pig-farm",
	"unit-great-hall", "unit-stronghold", "unit-fortress", "unit-peon",
	"unit-orc-barracks", "unit-grunt", "unit-axethrower", "unit-berserker", "unit-catapult",
	"unit-troll-lumber-mill", "upgrade-throwing-axe1", "upgrade-throwing-axe2",
	"upgrade-berserker", "upgrade-light-axes", "upgrade-berserker-scouting", "upgrade-berserker-regeneration",
	"unit-orc-blacksmith", "upgrade-battle-axe1", "upgrade-orc-shield1", "upgrade-catapult1",
	"upgrade-battle-axe2", "upgrade-orc-shield2", "upgrade-catapult2",
	"unit-orc-watch-tower", "unit-orc-guard-tower", "unit-orc-cannon-tower",
	"unit-orc-shipyard", "unit-orc-oil-tanker", "unit-orc-destroyer", "unit-orc-transport",
	"unit-ogre-juggernaught",
	"unit-orc-oil-platform", "unit-orc-refinery",
	"unit-orc-foundry", "upgrade-orc-ship-cannon1", "upgrade-orc-ship-armor1",
	"upgrade-orc-ship-cannon2", "upgrade-orc-ship-armor2",
	"unit-alchemist", "unit-zeppelin",
	"unit-ogre-mound", "unit-ogre", "unit-ogre-mage",
	"unit-altar-of-storms", "upgrade-ogre-mage", "upgrade-eye-of-kilrogg", "upgrade-bloodlust"
}
local function DefineAllowTable(table, flags)
	for i, unitName in ipairs(table) do
		DefineAllow(unitName, flags)
	end
end

DefineAllowNormalHumanUnits("FFFFFFFFFFFFFFFF")
DefineAllowExtraHumanUnits("FFFFFFFFFFFFFFFF")
DefineAllowNormalOrcUnits("FFFFFFFFFFFFFFFF")
DefineAllowExtraOrcUnits("FFFFFFFFFFFFFFFF")
DefineAllowSpecialUnits("FFFFFFFFFFFFFFFF")
DefineAllowHumanAlways()
DefineAllowOrcAlways()
DefineAllowTable(allowedOrcUnits, "AAAAAAAAAAAAAAAA")

-- AI

--=============================================================================
--	This AI script builds only worker and tanker.
--

local hum_09_funcs = {
	function() return AiSet(AiWorker(), 2) end,
	function() return AiSet(AiTanker(), 1) end,
	function() return AiSleep(10000) end,
	function() stratagus.gameData.AIState.index[1 + AiPlayer()] = 1; return false end,
}

function AiHuman09() return AiLoop(hum_09_funcs, stratagus.gameData.AIState.index) end
DefineAi("hum-09", "*", "hum-09", AiHuman09)

-- Map

Load("campaigns/human/level09h.sms")
