BuffaloChipper: How does one defeat the megadragon??
(Your topic tile should be more specific.)
I haven't actually killed the Mega Dragon myself, but here are some strategies:
During the late game, I recommend giving most of the late game level bonuses to a fighter or barbarian, and getting items to allow them to use their high level to cast Day of Protection and either Day of Sorcery or Power Shield. Many shops will stock spell casting items, and they restock random items at the start of each (10-day) week. So, save on the last day of the week, enter the shop twice (each time takes a day), and the second time the shop will have new stock; if it doesn't have anything you want, either check other shops or reload and try again.
Before the fight, take advantage of the various fountains found throughout Xeen. In particular, the +50 level fountain is useful, as is the energy resistance fountain. You should wait until after using the level fountain to cast Day of Protection/Sorcery. Also, if possible, have your highest level character use items to cast those spells (you can replace Day of Sorcery with Levitate, and Day of Protection with Heroism + Holy Bonus); this lets you use the spells at a higher level (exception: having a level 256 or higher character cast those spells might not work so well due to integer overflow).
The dragon's attack is energy-based. When choosing equipment, you should favor energy resistance. Remember, since, like many enemies, the dragon's attack is not physical, AC is useless. Protection from Elements isn't useful, but Power Shield can still help (in fact, with enough energy resistance, there's a chance of reducing the damage to 0, which also means you can't be eradicated this turn.)
The best weapon to use, believe it or not, is the Xeen Slayer Sword. It has the property of ignoring the enemy's resistance, which is nice because the dragon has 90 physical resistance. If you are at a decent level and have Holy Bonus (from Day of Protection) active. Also, this weapon also has the nice property that it never breaks, even if the character gets eradicated. You can trade this weapon between characters without using up a turn, or you can use the "i lost it" cheat at the Clouds mirror to get more (but be aware that you can't drop or sell this weapon).
Early in the fight, anybody who knows Mass Distortion should use it; on a successful save, it cuts the dragon's HP in half (which could be over 30,000 damage). (On a failed save, it only does 5 damage.) Also, my understanding is that the Dragon Sleep spell can work on this dragon, though not nearly as well as it does on other Darkside dragons.
If your main attacker (most likely a fighter or barbarian) dies or gets eradicated, you can resurrect them or (especially if it happens early) just Mr. Wizard out and reload (why isn't reloading allowed during combat anyway?).