Acquiring Immunity to Death from Massive Damage Is Weirdly Difficult
Immunity to precision damage or critical hits doesn't make one immune to death from massive damage. Having the elemental, ooze, or plant type doesn't make one immune to death from massive damage. A creature under the effect of the spell gaseous form [trans] (PH 234) isn't immune to death from massive damage. Even becoming incorporeal doesn't render one immune to death from massive damage. Apparently, massive damage is supposed to kill living things, and the way to become immune to massive damage is not to live.
That means immunity to death from massive damage can be gained only from the 7th-level Sor/Wiz spell body of war [trans] (SpC 35), the 7th-level Sor/Wiz spell undead mask [necro] (SS 71), and the 8th-level Sor/Wiz spell veil of undeath [necro] (SpC 229).
The mask and veil leave the target's type unchanged but grant many undead features, including immunity to death from massive damage. The body grants the caster, by turning him into a warforged titan, the construct type, hence immunity to death from massive damage; the caster can't cast--even via magic items--while affected by the spell.
So, um, yeah. That's it. That's all of 'em.
You can go sideways. Use the spell magic jar [necro] (PH 250-1) to move your mind into a body that's immune to death from massive damage or the spell polymorph any object [trans] (PH 263) to change form into a creature (or sandwich) that's immune to death from massive damage, for instance, but of the thousands of Wizards of the Coast spells published for D&D 3.X no spell exists that simply says, "You're immune to death from massive damage."
What You Can Do
- Lug around a talisman of undying fortitude (MIC 188) (8,000 gp; 0 lbs.). As a swift action twice per day for 3 rounds gain immunity to death from massive damage.
- Use the 2nd-level Sor/Wiz spell heroics [trans] (SpC 113) to gain the feat Martial Study (ToB 31-2) and pick the maneuver mind over body (ToB 64). Spend an immediate action to make a Concentration skill check that replaces a Fortitude saving throw.
- Use a wand of conviction [abjur] (SpC 52) (1st-level spell at caster level 18) (or just cast the spell if you're level 18 or higher) and the spells superior resistance [abjur] (SpC 174) and recitation [conj] (SpC 170). In other words, just have a +14 bonus to all saving throws. Then get a golf bag of luck blades with zero wishes (DMG 227) (22,060 gp; 2 lbs.) or a mantle of second chances (MIC 115) (12,000 gp; 0 lbs.) or access to the granted power of the pride domain (SpC 278-9) or whatever to reroll failed saving throws.
If the Moonbeam spell required the actual moon to be shining down, and somehow focused its light (or similar), you would assume that its text would reflect that. No mention is made of this, nor of the restrictions that it would naturally apply to use of the spell.
This wouldn't just be a problem indoors - consider phases of the moon, daytime, cloudy nights, or even eclipses. In fact, it would be an extremely limited usage spell.
Contrast the Call Lightning spell (Thanks Tashio for providing the text):
PHB Pg.220 Call Lightning
A storm cloud appears in the shape of a cylinder that is 10 feet tall with a 60-foot radius, centered on a point you can see 100 feet directly above you. The spell fails if you can't see a point in the air where the storm cloud could appear (for example, if you are in a room that can't accommodate the cloud).
If you are outdoors in stormy condition when you cast this spell, the spell gives you control over the existing storm instead of creating a new one.
This specifically says that it creates a cloud, includes limitations requiring you to be outdoors or have an incredibly high ceiling, and includes an additional effect if there is a pre-existing storm. Based on this, it seems clear that Moonbeam has no particular source or restriction whatsoever.
Obviously, you are the DM, and you are free to add fluff or requirements as you choose. But I would urge you to consider how limited this spell would become before you do.
Best Answer
The rules differentiate between dealing and taking damage.
The Damage and Resistance section of the Basic Rules (emphasis mine) gives an example of such wording:
Example:
The spell description says:
Failing the save means the guardian deals 20 damage, while succeeding means the guardian only deals 10 damage.
You factor in the outgoing damage towards 60, regardless of the damage the creature actually receives. The last creature failing the save on your example also takes 20 damage; after that, the guardian vanishes.
Total damage accumulated: 70 damage.