Can the KS3D2 test as suggested by Fasano and Franceschini (1987) be used when one of the three variables take discrete values between 0-40? The other two variables are continuous.
Kolmogorov-Smirnov 3d test is when you have the sample of 3d vectors. The idea is to compare the sample distribution to a model distribution. So the main question is how does model distribution looks like.
Now KS-test compares the cumulative distributions of sample distribution and the model distribution. The 3d test does the same. If you worry about discrete-values look at the bottom of page 6 of your reference. The authors test the behaviour of their statistic when the model distribution (they call it parent distribution) is constant in certain cubes. This means that the the testable distribution is discrete. So the answer to your question seems to be yes, discreteness is not a problem.
To make sure you can always do some Monte-Carlo simulations where you control the model distribution and choose it to be similar to the one you want to test, and see how the statistic performs.
I don't have the reputation to comment @mpiktas answer, but I think he is wrong: the parent distributions have "constant density" (to quote the paper) on the cubes and thus are uniform on these cubes. Thus the parent distributions are not discrete.
To answer the original question, the Wikipedia page of the KS test states that "In the two-sample case (see Section 3), the distribution considered under the null hypothesis is a continuous distribution but is otherwise unrestricted." so according to Wikipedia (sorry I don't have a better reference) it doesn't work.