I wrote this guide to help people add in basic damaging spells. It is not meant to be a guide for advanced spells or any other type of spell. It is written, tested, and works on stock tbaMUD. It may or may not work if your game is heavily modified or from an older version.
Code:
// In spells.h scroll down to the bottom of the spell list and define a new one. Make sure it is +1 from the previous spell.
#define SPELL_INFRAVISION 50 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_WATERWALK 51 /* Reserved Skill[] DO NOT CHANGE */
+ #define SPELL_METEOR 52 /* Meteor of DOOM! */
// In spells.h, right under that, there should be #define NUM_SPELLS. Make sure you add one to that since you have defined a new one.
+ #define NUM_SPELLS 52
// In magic.c search mag_damage and scroll past the spellnum. The spells here should be damaging spells like Fireball, Magic Missile, and Chill Touch. Add in the new spell beneath it. Note: If the spell affects the character casting in any way it must be added to man_damage (with spells like Armor and Blindness) but in this example the spell does not.
case SPELL_FIREBALL:
if (IS_MAGIC_USER(ch))
dam = dice(11, 8) + 11;
else
dam = dice(11, 6) + 11;
break;
+ case SPELL_METEOR:
+ dam = dice(25, 15) + 15;
+ break;
// In spell_parser.c search for another damaging spell. I used Fireball as my template. These spells should be listed a few lines below mag_assign_spells.
spello(SPELL_FIREBALL, "fireball", 40, 30, 2, POS_FIGHTING,
TAR_CHAR_ROOM | TAR_FIGHT_VICT, TRUE, MAG_DAMAGE,
NULL);
+ spello(SPELL_METEOR, "meteor", 40, 30, 2, POS_FIGHTING,
+ TAR_CHAR_ROOM | TAR_FIGHT_VICT, TRUE, MAG_DAMAGE,
+ NULL);
// In class.c search for init_spell_levels and add in your new spell into that list. CLASS_MAGIC_USER can be any of the classes that are built into your game, but since Mages are the unpredictable spell casters I chose to assign it to them. "30" is the level of which the Mage will learn that spell.
spell_level(SPELL_FIREBALL, CLASS_MAGIC_USER, 15);
+ spell_level(SPELL_METEOR, CLASS_MAGIC_USER, 30);
spell_level(SPELL_CHARM, CLASS_MAGIC_USER, 16);
// Back out of the src directory, and enter the lib director, then misc. Open the file messages, search for the damaging spells, and add in the messages for your new spell. Be sure the number above the messages match the spell number from spells.h. Note: Don't forget the "M" on the line just above the spell number!!!
+ * Meteor
+ M
+ 52
+ Your meteor hits $N with full force, causing an immediate death!
+ A meteor summoned by $n hits you with full force. What a way to go...
+ $N summons a meteor on $n's head, causing instant death. Booyah!
+ The meteor you summoned seems to have...disintegrated.
+ The meteor $n summoned seems to have disintegrated. Whew!
+ The meteor $n summoned upon $N's head seems to have disintegrated. Oops!
+ You summon a meteor from the sky and reign it down upon the doomed head of $N!
+ $n has summoned a flaming meteor down upon your head. Ping!
+ $N has summoned a flaming meteor from the sky upon the doomed head of $N!
+ Hah, the Gods -made- the meteors!
+ Laugh, $n has tried summoning a meteor to hit you!
+ $N gracefully disintegrates the meteor that $n has tried to summon.