--       _________ __                 __                               
--      /   _____//  |_____________ _/  |______     ____  __ __  ______
--      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
--      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \ 
--     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
--             \/                  \/          \//_____/            \/ 
--  ______________________                           ______________________
--                        T H E   W A R   B E G I N S
--         Stratagus - A free fantasy real time strategy game engine
--
--      ai.lua - Define the AI.
--
--      (c) Copyright 2000-2004 by Lutz Sammer and Jimmy Salmon
--
--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation; either version 2 of the License, or
--      (at your option) any later version.
--  
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--  
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--
--      $Id: ai.lua,v 1.9 2004/03/18 05:30:52 mohydine Exp $


--(define (ai:sleep) () #t)
-- List of special units used for adaptive AI
 UnitsAI = {}
 BuildingList = {}

race1 = "red-ants"
-- race2 = "orc"

--=============================================================================
--
--  AI helper table, the AI must know where to build units,
--  where to research spells, where to upgrade units.
--  If this is allowed and which dependencies exists, isn't
--  handled here. (see upgrade.ccl)
--
--  NOTE: perhaps this could later be used to build the buttons?
--
--  DefineAiHelper(list)
--

--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--  * Race human.
--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DefineAiHelper(
  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  -- Unit can build which buildings.
  --
  {"build", "unit-worker",
  "unit-egg-collector", "unit-barracks", "unit-queen", "unit-wood-house",
  "unit-blacksmith", "unit-watch-tower", "unit-human-wall",
  "unit-dock", "unit-foundry", "unit-plancton-house",
  "unit-alchemist", "unit-insect-house", "unit-witch-tower", "unit-temple",
  "unit-flying-house", "unit-tunnel", "unit-runestone"},
  {"build", "unit-worker1",
  "unit-egg-collector", "unit-barracks", "unit-queen", "unit-wood-house",
  "unit-blacksmith", "unit-watch-tower", "unit-human-wall",
  "unit-dock", "unit-foundry", "unit-plancton-house",
  "unit-alchemist", "unit-insect-house", "unit-witch-tower", "unit-temple",
  "unit-flying-house", "unit-tunnel", "unit-runestone"},
  {"build", "unit-plancton-collector", "unit-plancton-platform"},
  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  -- Building can train which units.
  --
  {"train", "unit-egg-collector", "unit-ladybug"},
  {"train", "unit-queen", "unit-worker", "unit-worker1"},
  {"train", "unit-queen-castle", "unit-worker", "unit-worker1"},
  {"train", "unit-queen-fortress", "unit-worker", "unit-worker1"},
  {"train", "unit-barracks", "unit-warrior", "unit-archer", "unit-advanced-archer"},
  {"train", "unit-insect-house","unit-tank", "unit-knight", "unit-advanced-knight"},
  {"train", "unit-alchemist",  "unit-dynamite-ant"},
  {"train", "unit-witch-tower", "unit-witch"},
  {"train", "unit-flying-house", "unit-flying-ant"},
  {"train", "unit-dock", "unit-plancton-collector", "unit-gunboat", "unit-shuttle",
  "unit-submarine", "unit-gallion"},
  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  --
  -- Building can upgrade which upgrades.
  --
  {"upgrade", "unit-queen", "unit-queen-castle"},
  {"upgrade", "unit-queen-castle", "unit-queen-fortress"},
  {"upgrade", "unit-watch-tower", "unit-arrow-tower", "unit-cannon-tower"},

  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  --
  -- Building can research which spells or upgrades.
  --
  --- BLACKSMITH
  {"research", "unit-blacksmith",
  "upgrade-sword1", "upgrade-sword2", "upgrade-arrow1", "upgrade-arrow2",
  "upgrade-human-shield1", "upgrade-human-shield2"},
  --- INSECTHOUSE
  {"research", "unit-insect-house",
   "upgrade-ballista1", "upgrade-ballista2"},
  --- STOREHOUSE
  {"research", "unit-wood-house", "upgrade-worker1"},
  ---WITCH TOWER
  {"research", "unit-witch-tower",
  ---"upgrade-slow", "upgrade-flame-shield", "upgrade-invisibility", "upgrade-blizzard",
  "upgrade-polymorph"},
  --- FOUNDRY
  {"research", "unit-foundry",
  "upgrade-human-ship-cannon1", "upgrade-human-ship-cannon2",
  "upgrade-human-ship-armor1", "upgrade-human-ship-armor2"},
 
 
  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  -- Unit can repair which units.
  --
  {"repair", "unit-worker",
  "unit-egg-collector", "unit-barracks", "unit-queen", "unit-queen-castle", "unit-queen-fortress",
  "unit-wood-house", "unit-blacksmith", "unit-watch-tower",
  "unit-arrow-tower", "unit-cannon-tower", "unit-human-wall",
  "unit-dock", "unit-foundry", "unit-plancton-house",
  "unit-alchemist", "unit-insect-house", "unit-witch-tower", "unit-temple",
  "unit-flying-house", "unit-tunnel", "unit-runestone",
  "unit-shuttle"},
   
  {"repair", "unit-worker1",
  "unit-egg-collector", "unit-barracks", "unit-queen", "unit-queen-castle", "unit-queen-fortress",
  "unit-wood-house", "unit-blacksmith", "unit-watch-tower",
  "unit-arrow-tower", "unit-cannon-tower", "unit-human-wall",
  "unit-dock", "unit-foundry", "unit-plancton-house",
  "unit-alchemist", "unit-insect-house", "unit-witch-tower", "unit-temple",
  "unit-flying-house", "unit-tunnel", "unit-runestone",
  "unit-shuttle"},

  --
  -- Reduce unit limits.
  --
  {"unit-limit", "unit-queen", "food"},
  --
  -- Equivalence of units for the resource manager.
  --
  {"unit-equiv", "unit-queen", "unit-queen-castle", "unit-queen-fortress"},
  {"unit-equiv", "unit-queen-castle", "unit-queen-fortress"},
  {"unit-equiv", "unit-archer",  "unit-advanced-archer"},
  {"unit-equiv", "unit-knight",  "unit-advanced-knight"},
  {"unit-equiv", "unit-worker", "unit-worker1"},
  {"unit-equiv", "unit-plancton-collector"} )


--ADD basic units into UnitList

unit = { 
UnitName = "unit-warrior",
UnitPriority = 90,
UnitAIType = "AiSoldier",
UnitType = "unit",
Level = 3,
Dependency = {"unit-barracks"},
ShouldRushToThisUnit= "false"
}
table.insert(UnitsAI,unit)






--
--  City-center of the current race.
--
function AiCityCenter()
  if (AiGetRace() == race1) then
    return "unit-queen"
  else
    return "unit-great-hall"
  end
end

--
--  Better city-center of the current race.
--
function AiBetterCityCenter()
  if (AiGetRace() == race1) then
    return "unit-queen-castle"
  else
    return "unit-stronghold"
  end
end

--
--  Best city-center of the current race.
--
function AiBestCityCenter()
  if (AiGetRace() == race1) then
    return "unit-queen-fortress"
  else
    return "unit-fortress"
  end
end

--
--  Worker of the current race.
--
function AiWorker()
  if (AiGetRace() == race1) then
    return "unit-worker"
  else
    return "unit-peon"
  end
end

--
--  Advanced Worker of the current race.
--
function AiWorker1()
  if (AiGetRace() == race1) then
    return "unit-worker1"
  else
    return "unit-peon1"
  end
end



--
--  Lumber mill of the current race.
--
function AiLumberMill()
  if (AiGetRace() == race1) then
    return "unit-wood-house"
  else
    return "unit-troll-lumber-mill"
  end
end

--
--  Upgrade worker 1 of the current race.
--
function AiUpgradeWorker1()
  if (AiGetRace() == race1) then
    return "upgrade-worker1"
  else
    return "upgrade-peon1"
  end
end


--
--  Blacksmith of the current race.
--
function AiBlacksmith()
  if (AiGetRace() == race1) then
    return "unit-blacksmith"
  else
    return "unit-mythical-blacksmith"
  end
end

--
--  Upgrade armor 1 of the current race.
--
function AiUpgradeArmor1()
  if (AiGetRace() == race1) then
    return "upgrade-human-shield1"
  else
    return "upgrade-orc-shield1"
  end
end

--
--  Upgrade armor 2 of the current race.
--
function AiUpgradeArmor2()
  if (AiGetRace() == race1) then
    return "upgrade-human-shield2"
  else
    return "upgrade-orc-shield2"
  end
end

--
--  Upgrade weapon 1 of the current race.
--
function AiUpgradeWeapon1()
  if (AiGetRace() == race1) then
    return "upgrade-sword1"
  else
    return "upgrade-battle-axe1"
  end
end

--
--  Upgrade weapon 2 of the current race.
--
function AiUpgradeWeapon2()
  if (AiGetRace() == race1) then
    return "upgrade-sword2"
  else
    return "upgrade-battle-axe2"
  end
end

--
--  Upgrade missile 1 of the current race.
--
function AiUpgradeMissile1()
  if (AiGetRace() == race1) then
    return "upgrade-arrow1"
  else
    return "upgrade-throwing-axe1"
  end
end

--
--  Upgrade missile 2 of the current race.
--
function AiUpgradeMissile2()
  if (AiGetRace() == race1) then
    return "upgrade-arrow2"
  else
    return "upgrade-throwing-axe2"
  end
end

--
--  Upgrade catapult 1 of the current race.
--
function AiUpgradeCatapult1()
  if (AiGetRace() == race1) then
    return "upgrade-ballista1"
  else
    return "upgrade-catapult1"
  end
end

--
--  Upgrade catapult 2 of the current race.
--
function AiUpgradeCatapult2()
  if (AiGetRace() == race1) then
    return "upgrade-ballista2"
  else
    return "upgrade-catapult2"
  end
end

--
--  Research of the current race.
--
function AiScientific()
  if (AiGetRace() == race1) then
    return "unit-alchemist"
  else
    return "unit-alchemist"
  end
end

--
--  Stables of the current race.
--
function AiStables()
  if (AiGetRace() == race1) then
    return "unit-insect-house"
  else
    return "unit-ogre-mound"
  end
end

--
--  Temple of the current race.
--
function AiTemple()
  if (AiGetRace() == race1) then
    return "unit-temple"
  else
    return "unit-altar-of-storms"
  end
end

--
--  Mage tower of the current race.
--
function AiMageTower()
  if (AiGetRace() == race1) then
    return "unit-witch-tower"
  else
    return "unit-temple-of-the-damned"
  end
end

--
--  Airport of the current race.
--
function AiAirport()
  if (AiGetRace() == race1) then
    return "unit-flying-house" 
  else
    return "unit-dragon-roost"
  end
end

--
--  Barracks of the current race.
--
function AiBarracks()
  if (AiGetRace() == race1) then
    return "unit-barracks"
  else
    return "unit-mythical-barracks"
  end
end
-----------------------------------------------------------------------------------
---
-- Chooses the best unit in the chosen class type
---
function AiChoose(aitype)

	--table.sort(UnitsAI)
	print( "Number of Special Units (Table Size)= " .. table.getn(UnitsAI))
	AiTypeTable = {} -- clears the table
	print ("table size = ".. table.getn(AiTypeTable))
	for i = 1,table.getn(UnitsAI) do 
			
		print("UnitName = " .. UnitsAI[i].UnitName)
		print("UnitAIType = ".. UnitsAI[i].UnitAIType)

            --Create a local table with all the units tables that have the same AiType
	    --AiTypeTable
		if aitype == UnitsAI[i].UnitAIType then
		
		table.insert(AiTypeTable,UnitsAI[i])
			print (UnitsAI[i].UnitName .. " is a " .. aitype)  
		end			
	end

	--Check Dependency
	
	i=1
	while i <= table.getn(AiTypeTable) do 
	print ("table size = ".. table.getn(AiTypeTable))
	print ("i = " .. i)
		if AiTypeTable[i].ShouldRushToThisUnit== "true" then 
			for j = 1,table.getn(AiTypeTable[i].Dependency) do

				if IfUnit("this", "<", 1, AiTypeTable[i].Dependency[j]) then 
					AiNeedUnit(AiTypeTable[i].Dependency[j])
					print(" Asked to build " .. AiTypeTable[i].Dependency[j])
				end
			end
			print(" Rush to " .. AiTypeTable[i].UnitName)
		else 
			BuildingNotThere= false
			for j = 1,table.getn(AiTypeTable[i].Dependency) do

				if IfUnit("this", "<", 1, AiTypeTable[i].Dependency[j]) then 
					BuildingNotThere = true		
				end
			end
			if BuildingNotThere == true then
					print (" unit " .. AiTypeTable[i].UnitName .. " removed") 
					table.remove(AiTypeTable,i)	
					
			else
					i=i+1
			end	
				
		end 
		AiTypeTableSize=table.getn(AiTypeTable)
		
	
	end

print ("table size before switching= ".. table.getn(AiTypeTable))

	if aitype == "AiShooter" then 
	  	print ("Found an AiShooter")

		if table.getn(AiTypeTable)>=1 then
			print (" Returned " .. ReturnHighestPriority(AiTypeTable)  .. " instead of unit-archer") 	
			return ReturnHighestPriority(AiTypeTable)
			
		else
			return "unit-archer"
	
		end
	end
	if aitype == "AiSoldier" then 
	  	print ("Found an AiSoldier")
		if table.getn(AiTypeTable) >= 1 then
			print (" Returned " .. ReturnHighestPriority(AiTypeTable)  .. " instead of unit-warrior") 	
			return ReturnHighestPriority(AiTypeTable)	
		else
			

			return "unit-warrior"
		end
	end
	if aitype == "AiCavalry" then 
	  	print ("Found an AiCavalry")
		if table.getn(AiTypeTable) >= 1 then
			print (" Returned " .. ReturnHighestPriority(AiTypeTable)  .. " instead of unit-knight") 	
			return ReturnHighestPriority(AiTypeTable)	
		else
			return "unit-knight"
		end
	end
	if aitype == "AiCatapult" then 
	  	print ("Found an AiCatapult")
		if table.getn(AiTypeTable) >= 1 then
			print (" Returned " .. ReturnHighestPriority(AiTypeTable)  .. " instead of unit-tank") 	
			return ReturnHighestPriority(AiTypeTable)	
		else
			return "unit-tank"
		end
	end
	if aitype == "AiFlyer" then 
	  	print ("Found an AiFlyer")
		if table.getn(AiTypeTable) >= 1 then
			print (" Returned " .. ReturnHighestPriority(AiTypeTable)  .. " instead of unit-helicopter") 	
			return ReturnHighestPriority(AiTypeTable)	
		else
			return "unit-helicopter"
		end
	end

end
-----------------------------------------------------------------------------------
--
-- Sort a table, based on the UnitProperty value, and return the highest value. 
-- A random value would be nice.
--
function ReturnHighestPriority(myTable)
	
	HighestPriorityIndex = 1
	for i = 1,table.getn(myTable) do

		if myTable[i].UnitPriority > myTable[HighestPriorityIndex].UnitPriority then
			-- Add a randomization here. This makes the AI behave like an human :)
			RandomNumber = math.random(1,10)
			if RandomNumber >5 then
			HighestPriorityIndex = i
			end
		end
	end
	return myTable[HighestPriorityIndex].UnitName
end

--
-- Check if a building is into the dependency table
--
function IsBuildingNotBuilt(DependencyTable)
	Found = {}
	for i = 1,table.getn(DependencyTable) do 

		for j = 1,table.getn(BuildingList) do 
			if BuildingList[j] == DependencyTable[i] then
				table.insert(Found,DependencyTable[i])
			end		
	 	end
	end
	if table.getn(Found) ==  table.getn(DependencyTable) then
		return false
	else
		return true
	end
end

--
-- Ask Ai to build a building
--
function AiNeedUnit(unit)
	AddBuildingToList(unit)
	AiNeed(unit)
end


--
-- Add a building to the BuildingList
--
function AddBuildingToList(Building)
	Found = false
	for i = 1,table.getn(BuildingList) do 
		if Building == BuildingList[i] then
			Found = true
		end		
	end
	if Found == false then 
		table.insert(BuildingList,Building)
	end
end

----------------------------------------------------------------------------------
--
--  Soldier of the current race.
--
function AiSoldier()
  if (AiGetRace() == race1) then
    return AiChoose("AiSoldier")
  else
    return "unit-grunt"
  end
end

--
--  Flyer of the current race.
--
function AiFlyer()
  if (AiGetRace() == race1) then
    return AiChoose("AiFlyer")
  else
    return "unit-dragon"
  end
end

--
--  Shooter of the current race.
--
function AiShooter()
  if (AiGetRace() == race1) then
    return AiChoose("AiShooter")
  else
    return "unit-axethrower"
  end
end

--
--  Elite Shooter of the current race.
--
function AiEliteShooter()
  if (AiGetRace() == race1) then
  	return AiChoose("AiShooter")
  else
    return "unit-berserker"
  end
end

--
--  Cavalry of the current race.
--
function AiCavalry()
  if (AiGetRace() == race1) then
    return AiChoose("AiCavalry")
  else
    return "unit-ogre"
  end
end

--
--  Cavalry mages of the current race.
--
function AiCavalryMage()
  if (AiGetRace() == race1) then
    return "unit-advanced-knight"
  else
    return "unit-ogre-mage"
  end
end

--
--  Mage of the current race.
--
function AiMage()
  if (AiGetRace() == race1) then
    return "unit-witch"
  else
    return "unit-death-knight"
  end
end

--
--  Catapult of the current race.
--
function AiCatapult()
  if (AiGetRace() == race1) then
    return AiChoose("AiCatapult")
  else
    return "unit-catapult"
  end
end

--
--  Scout of the current race.
--
function AiScout()
  if (AiGetRace() == race1) then
    return "unit-flying-ant"
  else
    return "unit-zeppelin"
  end
end


--
--  Tower of the current race.
--
function AiTower()
  if (AiGetRace() == race1) then
    return "unit-watch-tower"
  else
    return "unit-mythical-watch-tower"
  end
end

--
--  Guard-Tower of the current race.
--
function AiGuardTower()
  if (AiGetRace() == race1) then
    return "unit-arrow-tower"
  else
    return "unit-mythical-guard-tower"
  end
end

--
--  Cannon-Tower of the current race.
--
function AiCannonTower()
  if (AiGetRace() == race1) then
    return "unit-cannon-tower"
  else
    return "unit-mythical-cannon-tower"
  end
end

--
--  Harbor of the current race.
--
function AiHarbor()
  if (AiGetRace() == race1) then
    return "unit-dock"
  else
    return "unit-mythical-shipyard"
  end
end

--
--  Refinery of the current race.
--
function AiRefinery()
  if (AiGetRace() == race1) then
    return "unit-plancton-house"
  else
    return "unit-orc-refinery"
  end
end

--
--  Foundry of the current race.
--
function AiFoundry()
  if (AiGetRace() == race1) then
    return "unit-foundry"
  else
    return "unit-mythical-foundry"
  end
end

--
--  Ship armor 1 of the current race.
--
function AiUpgradeShipArmor1()
  if (AiGetRace() == race1) then
    return "upgrade-human-ship-armor1"
  else
    return "upgrade-orc-ship-armor1"
  end
end

--
--  Ship armor 2 of the current race.
--
function AiUpgradeShipArmor2()
  if (AiGetRace() == race1) then
    return "upgrade-human-ship-armor2"
  else
    return "upgrade-orc-ship-armor2"
  end
end

--
--  Ship weapon 1 of the current race.
--
function AiUpgradeShipCannon1()
  if (AiGetRace() == race1) then
    return "upgrade-human-ship-cannon1"
  else
    return "upgrade-orc-ship-cannon1"
  end
end

--
--  Ship weapon 2 of the current race.
--
function AiUpgradeShipCannon2()
  if (AiGetRace() == race1) then
    return "upgrade-human-ship-cannon2"
  else
    return "upgrade-orc-ship-cannon2"
  end
end

--
--  Platform of the current race.
--
function AiPlatform()
  if (AiGetRace() == race1) then
    return "unit-plancton-platform"
  else
    return "unit-mythical-oil-platform"
  end
end

--
--  Tanker of the current race.
--
function AiTanker()
  if (AiGetRace() == race1) then
    return "unit-plancton-collector"
  else
    return "unit-orc-oil-tanker"
  end
end

--
--  Submarine of the current race.
--
function AiSubmarine()
  if (AiGetRace() == race1) then
    return "unit-submarine"
  else
    return "unit-mythical-submarine"
  end
end

--
--  Destroyer of the current race.
--
function AiDestroyer()
  if (AiGetRace() == race1) then
    return "unit-gunboat"
  else
    return "unit-mythical-destroyer"
  end
end

--
--  Battleship of the current race.
--
function AiBattleship()
  if (AiGetRace() == race1) then
    return "unit-gallion"
  else
    return "unit-ogre-juggernaught"
  end
end

--
--  Transporter of the current race.
--
function AiTransporter()
  if (AiGetRace() == race1) then
    return "unit-shuttle"
  else
    return "unit-mythical-transport"
  end
end

--
--  1st Elite Shooter of the current race.
--
function AiUpgradeEliteShooter()
  if (AiGetRace() == race1) then
    return "upgrade-ranger"
  else
    return "upgrade-berserker"
  end
end

--
--  1st Upgrade of elite Shooter of the current race.
--
function AiUpgradeEliteShooter1()
  if (AiGetRace() == race1) then
    return "upgrade-ranger-scouting"
  else
    return "upgrade-berserker-scouting"
  end
end

--
--  2nd Upgrade of elite Shooter of the current race.
--
function AiUpgradeEliteShooter2()
  if (AiGetRace() == race1) then
    return "upgrade-longbow"
  else
    return "upgrade-light-axes"
  end
end

--
--  3th Upgrade of elite Shooter of the current race.
--
function AiUpgradeEliteShooter3()
  if (AiGetRace() == race1) then
    return "upgrade-ranger-marksmanship"
  else
    return "upgrade-berserker-regeneration"
  end
end

--
--  Upgrade cavalry to cavalry mages of the current race.
--
function AiUpgradeCavalryMage()
  if (AiGetRace() == race1) then
    return "upgrade-paladin"
  else
    return "upgrade-ogre-mage"
  end
end

--
--  1st spell of the cavalry mages of the current race.
--
function AiCavalryMageSpell1()
  if (AiGetRace() == race1) then
    return "upgrade-healing"
  else
    return "upgrade-bloodlust"
  end
end

--
--  2nd spell of the cavalry mages of the current race.
--
function AiCavalryMageSpell2()
  if (AiGetRace() == race1) then
    return "upgrade-exorcism"
  else
    return "upgrade-runes"
  end
end

--
--  1st spell of the mages of the current race.
--
function AiMageSpell1()
  if (AiGetRace() == race1) then
    return "upgrade-slow"
  else
    return "upgrade-haste"
  end
end

--
--  2nd spell of the mages of the current race.
--
function AiMageSpell2()
  if (AiGetRace() == race1) then
    return "upgrade-flame-shield"
  else
    return "upgrade-raise-dead"
  end
end

--
--  3th spell of the mages of the current race.
--
function AiMageSpell3()
  if (AiGetRace() == race1) then
    return "upgrade-invisibility"
  else
    return "upgrade-whirlwind"
  end
end

--
--  4th spell of the mages of the current race.
--
function AiMageSpell4()
  if (AiGetRace() == race1) then
    return "upgrade-polymorph"
  else
    return "upgrade-unholy-armor"
  end
end

--
--  5th spell of the mages of the current race.
--
function AiMageSpell5()
  if (AiGetRace() == race1) then
    return "upgrade-blizzard"
  else
    return "upgrade-death-and-decay"
  end
end



Load("scripts/ai/passive.lua")
Load("scripts/ai/air_attack.lua")
Load("scripts/ai/land_attack.lua")
Load("scripts/ai/sea_attack.lua")
--Load("scripts/ai/sea_attack_1.lua")
--Load("scripts/ai/land_attack2.lua")
Load("scripts/ai/campaign.lua")
