Egres said:Can we say then that the Elf is "affected"?
For purposes of determining which creatures are affected (read: targeted) by Sleep, only unconscious, undead, and constructs are ignored. Thus, any creature immune to the spell and is targeted essentially takes away the number of hit dice the spell can affect.
If the elf were not actually targeted in the example I gave above (because it's immune to sleep), then the spell would also target the ape.
1 hit die for human warrior
1 hit die for human warrior
2 hit dice for ape
Instead, the spell targets....
1 hit die for human warrior
1 hit die for human warrior
1 hit die for elven archer
And the one remaining hit-die in insufficient to target the ape.
If there were also eight half hit-die elf children in the area, then all eight of them would be targeted, and the sleep spell would be rendered useless (although the caster can choose a different point of origin so that some of those 8 babies are not in the area.)