includefilename = "asset\\composition\\AIScript\\LordAICommon.lua"
includefilename = SYSTEM.RelativeToAbsolutePath( includefilename )
dofile( includefilename )
includefilename = "asset\\composition\\AIScript\\test_helper.lua"
includefilename = SYSTEM.RelativeToAbsolutePath( includefilename )
dofile( includefilename )
--******************************************************************
-- Normal                                                           
--******************************************************************



function cowardly_Wander( AILUATable )
	--AILUATable.Check = "wander"
	local x, y = MAP.GetRandomPosition( )
	WalkTo( x, y, AILUATable )
end

function cowardly_Update_Normal( AILUATable )
	--AILUATable.Check = "cowardly"
	local EnemyID = ARMY.GetInRangeID( AILUATable.myArmyID, "VISIBLE_ENEMY_ARMY", 4000 )
	if EnemyID == -1 then
		cowardly_Wander( AILUATable )
		return 1
	end
	local EnemyDif = GetEnemyDif( EnemyID, AILUATable )
	if EnemyDif < 2000 then
		local x, y = MAP.GetOppositePositionApproachingEnemy( AILUATable.myArmyID, EnemyID )
		WalkTo( x, y, AILUATable )
		if EnemyDif < 500 and ARMY.IsCanUseSpell( AILUATable.myArmyID ) then
			ARMY.UseSpecialAbility( AILUATable.myArmyID )
		end
	else
		cowardly_Wander( AILUATable )
	end
end
	
--
--******************************************************************
-- General                                                          
--******************************************************************
function cowardly_AI_Init( AILUATable )
	--AILUATable.RandomTowerIndex = 0
	AILUATable.State = "normal"
	AILUATable.Check = "init"
	--AILUATable.g_EnemyShape = 0
	--
AILUATable.g_MyShape = 0
end

function cowardly_AI_Update( AILUATable )
	DEBUG.ShowMessage( AILUATable.myArmyID, AILUATable.Check )
	if AILUATable.State == "normal" then
		cowardly_Update_Normal( AILUATable )
	end
end
